pub struct ConvertingCallbackReceiver<T: FromByteSlice> { /* private fields */ }
Expand description

A wrapper for Receiver, which converts received byte vectors to structured data. This variant of ConvertingReceiver is used for events.

This receiver wraps a Receiver receiving raw bytes. Calling recv_forever, recv_timeout or try_recv will call equivalent methods on the wrapped Receiver and then convert the received bytes to a instance of T.

§Type parameters

  • T - Type which is created from received byte vectors. Must implement FromByteSlice

§Errors

Returned errors are equivalent to those returned from methods of a Receiver. If the received response can not be interpreted as the result type T, a MalformedPacket error is raised.

Implementations§

source§

impl<T: FromByteSlice> ConvertingCallbackReceiver<T>

source

pub fn new(receiver: Receiver<Vec<u8>>) -> ConvertingCallbackReceiver<T>

Creates a new converting callback receiver which wraps the given Receiver.

source

pub fn try_recv(&self) -> Result<T, CallbackTryRecvError>

Attempts to return a pending value on this receiver without blocking. This method behaves like try_recv.

§Errors

Returns an error if the queue was disconnected or currently empty, or if the received packet was malformed.

source

pub fn recv_forever(&self) -> Result<T, CallbackRecvError>

Attempts to wait for a value on this receiver, returning an error if the corresponding channel has hung up. This method behaves like recv.

§Errors

Returns an error if the queue was disconnected or currently empty, or if the received packet was malformed.

source

pub fn recv_timeout( &self, timeout: Duration ) -> Result<T, CallbackRecvTimeoutError>

Attempts to wait for a value on this receiver, returning an error if the corresponding channel has hung up, or if it waits more than timeout. This method behaves like recv_timeout.

§Errors

Returns an error on one of the following conditions:

  • The queue was disconnected.
  • The received packet was malformed.
  • Blocked longer than the configured time out.
source

pub fn iter(&self) -> Iter<'_, T>

source

pub fn try_iter(&self) -> TryIter<'_, T>

Trait Implementations§

source§

impl<'a, T: FromByteSlice> IntoIterator for &'a ConvertingCallbackReceiver<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Iter<'a, T>

Creates an iterator from a value. Read more
source§

impl<T: FromByteSlice> IntoIterator for ConvertingCallbackReceiver<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> IntoIter<T>

Creates an iterator from a value. Read more

Auto Trait Implementations§

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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.
§

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

§

fn vzip(self) -> V