ZeroCopyContext

Struct ZeroCopyContext 

Source
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>

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a> Drop for ZeroCopyContext<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ZeroCopyContext<'a>

§

impl<'a> !RefUnwindSafe for ZeroCopyContext<'a>

§

impl<'a> Send for ZeroCopyContext<'a>

§

impl<'a> Sync for ZeroCopyContext<'a>

§

impl<'a> Unpin for ZeroCopyContext<'a>

§

impl<'a> !UnwindSafe for ZeroCopyContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V