pub struct ReliableBincodeChannel { /* private fields */ }
Expand description
Wraps a ReliableChannel
together with an internal buffer to allow easily sending message types
serialized with bincode
.
Messages are guaranteed to arrive, and are guaranteed to be in order. Messages have a maximum length, but this maximum size can be larger than the size of an individual packet.
Implementations
sourceimpl ReliableBincodeChannel
impl ReliableBincodeChannel
sourcepub fn new(channel: ReliableChannel, max_message_len: u16) -> Self
pub fn new(channel: ReliableChannel, max_message_len: u16) -> Self
Create a new ReliableBincodeChannel
with a maximum message size of max_message_len
.
sourcepub async fn send<T: Serialize>(&mut self, msg: &T) -> Result<(), Error>
pub async fn send<T: Serialize>(&mut self, msg: &T) -> Result<(), Error>
Write the given message to the reliable channel.
In order to ensure that messages are sent in a timely manner, flush
must be called after
calling this method. Without calling flush
, any pending writes will not be sent until the
next automatic sender task wakeup.
This method is cancel safe, it will never partially send a message, though canceling it may or may not buffer a message to be sent.
sourcepub async fn flush(&mut self) -> Result<(), Error>
pub async fn flush(&mut self) -> Result<(), Error>
Ensure that any previously sent messages are sent as soon as possible.
This method is cancel safe.
sourcepub async fn recv<'a, T: Deserialize<'a>>(&'a mut self) -> Result<T, Error>
pub async fn recv<'a, T: Deserialize<'a>>(&'a mut self) -> Result<T, Error>
Read the next available incoming message.
This method is cancel safe, it will never partially read a message or drop received messages.
Auto Trait Implementations
impl !RefUnwindSafe for ReliableBincodeChannel
impl Send for ReliableBincodeChannel
impl Sync for ReliableBincodeChannel
impl Unpin for ReliableBincodeChannel
impl !UnwindSafe for ReliableBincodeChannel
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more