pub struct ZeroCopyContext<'a> { /* private fields */ }
Expand description
Borrows a Receiver
for the purpose of doing zero-copy deserialization of messages
containing references.
An instance of this type may only be used to deserialize a single message before it is dropped because the
Drop
implementation is what advances the ring buffer
pointer. Also, the borrowed Receiver
may not be used directly while it is borrowed
by a ZeroCopyContext
.
Use Receiver::zero_copy_context
to create an instance.
Implementations§
Source§impl<'a> ZeroCopyContext<'a>
impl<'a> ZeroCopyContext<'a>
Sourcepub fn try_recv<'b, T: Deserialize<'b>>(&'b mut self) -> Result<Option<T>>
pub fn try_recv<'b, T: Deserialize<'b>>(&'b mut self) -> Result<Option<T>>
Attempt to read a message without blocking.
This will return Ok(None)
if there are no messages immediately available. It will return
Err(
Error::AlreadyReceived
))
if this instance has already
been used to read a message.
Sourcepub fn recv<'b, T: Deserialize<'b>>(&'b mut self) -> Result<T>
pub fn recv<'b, T: Deserialize<'b>>(&'b mut self) -> Result<T>
Attempt to read a message, blocking if necessary until one becomes available.
This will return Err(
Error::AlreadyReceived
))
if this
instance has already been used to read a message.
Sourcepub fn recv_timeout<'b, T: Deserialize<'b>>(
&'b mut self,
timeout: Duration,
) -> Result<Option<T>>
pub fn recv_timeout<'b, T: Deserialize<'b>>( &'b mut self, timeout: Duration, ) -> Result<Option<T>>
Attempt to read a message, blocking for up to the specified duration if necessary until one becomes available.
This will return Err(
Error::AlreadyReceived
))
if this
instance has already been used to read a message.