pub struct CompressedBincodeChannel { /* private fields */ }
Expand description
Wraps a ReliableMessageChannel
and reliably sends a single message type serialized with
bincode
and compressed with snap
.
Messages are written in large blocks to aid compression. Messages are serialized end to end,
and when a block reaches the maximum configured size (or flush
is called), the block is
compressed and sent as a single message.
This saves space from the compression and also from the reduced message header overhead per individual message.
Implementations
sourceimpl CompressedBincodeChannel
impl CompressedBincodeChannel
sourcepub fn new(channel: ReliableChannel, max_chunk_len: u16) -> Self
pub fn new(channel: ReliableChannel, max_chunk_len: u16) -> Self
The max_chunk_len
parameter describes the maximum buffer size of a combined message block
before it is automatically sent.
An individual message may be no more than max_chunk_len
in length.
sourcepub async fn send<T: Serialize>(&mut self, msg: &T) -> Result<(), Error>
pub async fn send<T: Serialize>(&mut self, msg: &T) -> Result<(), Error>
Send the given message.
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>
Finish sending the current block of messages, compressing them and sending them over the reliable channel.
This method is cancel safe.
sourcepub async fn recv<T: DeserializeOwned>(&mut self) -> Result<T, Error>
pub async fn recv<T: DeserializeOwned>(&mut self) -> Result<T, Error>
Receive a message.
This method is cancel safe, it will never partially receive a message and will never drop a received message.
Auto Trait Implementations
impl !RefUnwindSafe for CompressedBincodeChannel
impl Send for CompressedBincodeChannel
impl Sync for CompressedBincodeChannel
impl Unpin for CompressedBincodeChannel
impl !UnwindSafe for CompressedBincodeChannel
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