Struct tinkerforge::converting_callback_receiver::ConvertingCallbackReceiver [−][src]
pub struct ConvertingCallbackReceiver<T: FromByteSlice> { /* fields omitted */ }
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 implementFromByteSlice
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
impl<T: FromByteSlice> ConvertingCallbackReceiver<T>
[src]
impl<T: FromByteSlice> ConvertingCallbackReceiver<T>
[src]pub fn new(receiver: Receiver<Vec<u8>>) -> ConvertingCallbackReceiver<T>
[src]
pub fn new(receiver: Receiver<Vec<u8>>) -> ConvertingCallbackReceiver<T>
[src]Creates a new converting callback receiver which wraps the given Receiver
.
pub fn try_recv(&self) -> Result<T, CallbackTryRecvError>
[src]
pub fn try_recv(&self) -> Result<T, CallbackTryRecvError>
[src]pub fn recv_forever(&self) -> Result<T, CallbackRecvError>
[src]
pub fn recv_forever(&self) -> Result<T, CallbackRecvError>
[src]pub fn recv_timeout(
&self,
timeout: Duration
) -> Result<T, CallbackRecvTimeoutError>
[src]
pub fn recv_timeout(
&self,
timeout: Duration
) -> Result<T, 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.
pub fn iter(&self) -> Iter<'_, T>ⓘNotable traits for Iter<'a, T>
impl<'a, T: FromByteSlice> Iterator for Iter<'a, T> type Item = T;
[src]
Notable traits for Iter<'a, T>
impl<'a, T: FromByteSlice> Iterator for Iter<'a, T> type Item = T;
pub fn try_iter(&self) -> TryIter<'_, T>ⓘNotable traits for TryIter<'a, T>
impl<'a, T: FromByteSlice> Iterator for TryIter<'a, T> type Item = T;
[src]
Notable traits for TryIter<'a, T>
impl<'a, T: FromByteSlice> Iterator for TryIter<'a, T> type Item = T;
Trait Implementations
impl<'a, T: FromByteSlice> IntoIterator for &'a ConvertingCallbackReceiver<T>
[src]
impl<'a, T: FromByteSlice> IntoIterator for &'a ConvertingCallbackReceiver<T>
[src]type Item = T
type Item = T
The type of the elements being iterated over.
impl<T: FromByteSlice> IntoIterator for ConvertingCallbackReceiver<T>
[src]
impl<T: FromByteSlice> IntoIterator for ConvertingCallbackReceiver<T>
[src]type Item = T
type Item = T
The type of the elements being iterated over.
Auto Trait Implementations
impl<T> !RefUnwindSafe for ConvertingCallbackReceiver<T>
impl<T> Send for ConvertingCallbackReceiver<T> where
T: Send,
T: Send,
impl<T> !Sync for ConvertingCallbackReceiver<T>
impl<T> Unpin for ConvertingCallbackReceiver<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for ConvertingCallbackReceiver<T>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self