Skip to main content

MediaSocket

Trait MediaSocket 

Source
pub trait MediaSocket: Send {
    // Required methods
    fn recv<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Option<WsIn>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn send_text<'life0, 'async_trait>(
        &'life0 mut self,
        s: String,
    ) -> Pin<Box<dyn Future<Output = Result<(), FlowcatError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn send_binary<'life0, 'async_trait>(
        &'life0 mut self,
        b: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<(), FlowcatError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A bidirectional media socket carrying text/binary WebSocket frames.

Implementations are driven (via MediaTransport) by the S2S pipeline: recv yields inbound frames; send_text/send_binary push outbound frames.

Required Methods§

Source

fn recv<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Option<WsIn>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive the next inbound frame, or None once the socket is exhausted.

Source

fn send_text<'life0, 'async_trait>( &'life0 mut self, s: String, ) -> Pin<Box<dyn Future<Output = Result<(), FlowcatError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a UTF-8 text frame.

Source

fn send_binary<'life0, 'async_trait>( &'life0 mut self, b: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), FlowcatError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send a binary frame.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S, E> MediaSocket for WsMediaTransport<S>
where S: Stream<Item = Result<Message, E>> + Sink<Message, Error = E> + Unpin + Send, E: Display + Send,