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§
Sourcefn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_ready( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Reserve space for a message
Sourcefn start_send<M>(self: Pin<&mut Self>, object_id: u32, msg: M)
fn start_send<M>(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.
Provided Methods§
fn send<'a, 'b, 'c, M>( &'a mut self, object_id: u32, msg: M, ) -> Send<'c, Self, M> ⓘ
fn flush(&mut self) -> Flush<'_, Self> ⓘwhere
Self: Unpin,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.