//! WebSocket transport trait for platform-agnostic WebSocket operations.

use super::messages::StatusUpdate;
use crate::error::WebSocketError;

/// Platform-agnostic WebSocket transport trait.
#[allow(async_fn_in_trait)]
pub trait WebSocketTransport {
    /// Connect to the WebSocket server.
    async fn connect(&mut self) -> Result<(), WebSocketError>;

    /// Disconnect from the WebSocket server.
    async fn disconnect(&mut self) -> Result<(), WebSocketError>;

    /// Check if currently connected.
    fn is_connected(&self) -> bool;

    /// Send a message to the server.
    async fn send(&mut self, message: &str) -> Result<(), WebSocketError>;

    /// Receive the next status update.
    async fn receive(&mut self) -> Result<StatusUpdate, WebSocketError>;
}
