pub trait WriteMessage {
    // Required methods
    fn poll_ready(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>
    ) -> Poll<Result<()>>;
    fn start_send<M: Serialize + Debug>(
        self: Pin<&mut Self>,
        object_id: u32,
        msg: M
    );
    fn poll_flush(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>
    ) -> Poll<Result<()>>;

    // Provided methods
    fn send<'a, 'b, 'c, M: Serialize + Unpin + Debug + 'b>(
        &'a mut self,
        object_id: u32,
        msg: M
    ) -> Send<'c, Self, M> 
       where Self: Unpin,
             'a: 'c,
             'b: 'c { ... }
    fn flush(&mut self) -> Flush<'_, Self> 
       where Self: Unpin { ... }
}
Expand description

A trait for objects that can accept messages to be sent.

This is similar to Sink, but instead of accepting only one type of Items, it accepts any type that implements Serialize.

Required Methods§

source

fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Reserve space for a message

source

fn start_send<M: Serialize + Debug>( self: Pin<&mut Self>, object_id: u32, msg: M )

Queue a message to be sent.

Panics

if there is not enough space in the queue, this function panics. Before calling this, you should call poll_reserve to ensure there is enough space.

source

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Flush connection

Provided Methods§

source

fn send<'a, 'b, 'c, M: Serialize + Unpin + Debug + 'b>( &'a mut self, object_id: u32, msg: M ) -> Send<'c, Self, M> where Self: Unpin, 'a: 'c, 'b: 'c,

source

fn flush(&mut self) -> Flush<'_, Self> where Self: Unpin,

Implementors§