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

    // Provided methods
    fn send<'a, 'b, 'c, M>(
        &'a mut self,
        object_id: u32,
        msg: M
    ) -> Send<'c, Self, M> 
       where 'a: 'c,
             'b: 'c,
             M: Serialize + Unpin + Debug + 'b,
             Self: Unpin { ... }
    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§

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

Reserve space for a message

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

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.

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

Flush connection

Provided Methods§

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

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

Implementors§