[][src]Struct tinkerforge::converting_high_level_callback_receiver::ConvertingHighLevelCallbackReceiver

pub struct ConvertingHighLevelCallbackReceiver<PayloadT: Default + Copy + Clone, ResultT, T: FromByteSlice + LowLevelRead<PayloadT, ResultT>> { /* fields omitted */ }

A wrapper for Receiver, which converts received byte vectors to structured data. This variant of ConvertingReceiver is used for high level events, for use cases such as streaming.

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

  • PayloadT - Type of the payload which will be streamed. Must be trivially copy- and constructable.
  • ResultT - Type of additional return values which don't change between streaming events of the same stream.
  • T - Type which is created from received byte vectors. Must implement FromByteSlice. Also this type has to provide low level steaming information by implementing LowLevelRead for PayloadT and ResultT.

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.

Methods

impl<PayloadT: Default + Copy + Clone, ResultT, T: FromByteSlice + LowLevelRead<PayloadT, ResultT>> ConvertingHighLevelCallbackReceiver<PayloadT, ResultT, T>[src]

Important traits for ConvertingHighLevelCallbackReceiver<PayloadT, ResultT, T>
pub fn new(
    receiver: ConvertingCallbackReceiver<T>
) -> ConvertingHighLevelCallbackReceiver<PayloadT, ResultT, T>
[src]

Creates a new converting high level callback receiver which wraps the given ConvertingCallbackReceiver.

pub fn try_recv(
    &mut self
) -> Result<(Vec<PayloadT>, ResultT), CallbackTryRecvError>
[src]

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.

pub fn recv_forever(
    &mut self
) -> Result<(Vec<PayloadT>, ResultT), CallbackRecvError>
[src]

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 if the received packet was malformed.

pub fn recv_timeout(
    &mut self,
    timeout: Duration
) -> Result<(Vec<PayloadT>, ResultT), CallbackRecvTimeoutError>
[src]

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.

Trait Implementations

impl<PayloadT: Default + Copy + Clone, ResultT, T: FromByteSlice + LowLevelRead<PayloadT, ResultT>> Iterator for ConvertingHighLevelCallbackReceiver<PayloadT, ResultT, T>[src]

type Item = Option<(Vec<PayloadT>, ResultT)>

The type of the elements being iterated over.

Auto Trait Implementations

impl<PayloadT, ResultT, T> Send for ConvertingHighLevelCallbackReceiver<PayloadT, ResultT, T> where
    PayloadT: Send,
    ResultT: Send,
    T: Send

impl<PayloadT, ResultT, T> !Sync for ConvertingHighLevelCallbackReceiver<PayloadT, ResultT, T>

impl<PayloadT, ResultT, T> Unpin for ConvertingHighLevelCallbackReceiver<PayloadT, ResultT, T> where
    PayloadT: Unpin,
    ResultT: Unpin,
    T: Unpin

impl<PayloadT, ResultT, T> !UnwindSafe for ConvertingHighLevelCallbackReceiver<PayloadT, ResultT, T>

impl<PayloadT, ResultT, T> !RefUnwindSafe for ConvertingHighLevelCallbackReceiver<PayloadT, ResultT, T>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self