pub struct Input<T> { /* private fields */ }Expand description
A typed Input that tries to automatically downcast or deserialize the data received in order
to expose &T.
§Performance
If the data is received serialized from the upstream node, an allocation is performed to host
the deserialized T.
Implementations§
Source§impl<T: Send + Sync + 'static> Input<T>
impl<T: Send + Sync + 'static> Input<T>
Sourcepub async fn recv(&self) -> Result<(Message<T>, Timestamp)>
pub async fn recv(&self) -> Result<(Message<T>, Timestamp)>
Returns the first Message<T> that was received, asynchronously, on any of the channels
associated with this Input.
If several Message<T> are received at the same time, one is randomly selected.
This method interprets the data to the type associated with this Input<T>.
§Performance
As this method interprets the data received additional operations are performed:
- data received serialized is deserialized (an allocation is performed to store an instance
of
T), - data received “typed” are checked against the type associated to this
Input<T>.
§Error
Several errors can occur:
- all the channels are disconnected,
- Zenoh-Flow failed at interpreting the received data as an instance of
T.
Sourcepub fn try_recv(&self) -> Result<(Message<T>, Timestamp)>
pub fn try_recv(&self) -> Result<(Message<T>, Timestamp)>
Returns the first Message<T> that was received on any of the channels associated with this
Input, or None if all the channels are empty.
§Asynchronous alternative: recv
This method is a synchronous fail-fast alternative to it’s asynchronous counterpart: recv.
Although synchronous, this method will not block the thread on which it is executed.
§Error
Several errors can occur:
- no message was received (i.e. Empty error),
- Zenoh-Flow failed at interpreting the received data as an instance of
T.
Note that if some channels are disconnected, for each of such channel an error is logged.
Methods from Deref<Target = InputRaw>§
pub fn port_id(&self) -> &PortId
Sourcepub fn channels_count(&self) -> usize
pub fn channels_count(&self) -> usize
Returns the number of channels associated with this Input.
Sourcepub fn try_recv(&self) -> Result<LinkMessage>
pub fn try_recv(&self) -> Result<LinkMessage>
Returns the first LinkMessage that was received on any of the channels associated with
this Input, or an Empty error if there were no messages.
§Asynchronous alternative: recv
This method is a synchronous fail-fast alternative to it’s asynchronous counterpart: recv.
Although synchronous, but given it is “fail-fast”, this method will not block the thread on
which it is executed.
§Error
If no message was received, an Empty error is returned. Note that if some channels are
disconnected, for each of such channel an error is logged.
Sourcepub async fn recv(&self) -> Result<LinkMessage>
pub async fn recv(&self) -> Result<LinkMessage>
Returns the first LinkMessage that was received, asynchronously, on any of the channels associated with this Input.
If several LinkMessage are received at the same time, one is randomly selected.
§Error
An error is returned if all channels are disconnected. For each disconnected channel, an error is separately logged.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Input<T>
impl<T> !RefUnwindSafe for Input<T>
impl<T> Send for Input<T>
impl<T> Sync for Input<T>
impl<T> Unpin for Input<T>
impl<T> !UnwindSafe for Input<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more