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

A wrapper for Receiver, which converts received byte vectors to structured data.

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

Note

Calling recv will not block indefinitely. Instead the timeout passed to the new method is used for a call of recv_timeout

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. Additionally errors raised by the brick or bricklet, such as InvalidParameter, FunctionNotSupported and UnknownError will be returned. If the received response can not be interpreted as the result type T, a MalformedPacket error is raised.

Note

If the device is configured to send no response for a result-less setter, the Error SuccessButResponseExpectedIsDisabled will be returned. This indicates, that the request was sent to the device, but no further guarantees can be made.

Implementations

Creates a new converting receiver which wraps the given Receiver. recv calls will time out after the given timeout.

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

Errors

Returns an error on the following conditions:

  • There is no connection to a brick daemon.
  • The brick or bricklet returns an error.
  • The queue was disconnected or currently empty.
  • Response expected was disabled for a result-less setter. This is not an error.

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:

  • There is no connection to a brick daemon.
  • The brick or bricklet returns an error.
  • The queue was disconnected.
  • Response expected was disabled for a result-less setter. This is not an error.
  • Blocked longer than the configured time out.

Trait Implementations

The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.