Struct zenoh_flow_nodes::prelude::Input
source · pub struct Input<T> { /* private fields */ }Expand description
A typed Input receiving Data<T>.
An Input will automatically try to downcast or deserialise the Payload it receives,
exposing a Data<T>.
The type of conversion performed depends on whether the upstream node resides on the same Zenoh-Flow runtime (downcast) or on another runtime (deserialisation).
§Performance
If the data is received serialised from the upstream node, an allocation is performed to host the deserialised T.
Implementations§
source§impl<T: Send + Sync + 'static> Input<T>
impl<T: Send + Sync + 'static> Input<T>
sourcepub async fn recv(&self) -> Result<(Data<T>, Timestamp)>
pub async fn recv(&self) -> Result<(Data<T>, Timestamp)>
Returns the first Data<T> that was received, asynchronously, on any of the channels
associated with this Input.
If several Data<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 serialised is deserialised (an allocation is performed to store an instance of
T), - data received “typed” are checked against the type associated to this
Input<T>.
§Synchronous alternative: try_recv
This method is an asynchronous alternative to it’s synchronous fail-fast counterpart: try_recv.
§Errors
Several errors can occur:
- a channel was disconnected,
- Zenoh-Flow failed at interpreting the received data as an instance of
T.
sourcepub fn try_recv(&self) -> Result<Option<(Data<T>, Timestamp)>>
pub fn try_recv(&self) -> Result<Option<(Data<T>, Timestamp)>>
Returns the first Data<T> that was received on any of the channels associated with this Input,
or None if all the channels are empty.
§Performance
As this method interprets the data received, additional operations are performed:
- data received serialised is deserialised (an allocation is performed to store an instance of
T), - data received “typed” are checked against the type associated to this
Input<T>.
§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.
§Errors
Several errors can occur:
- a channel was disconnected,
- 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<Option<LinkMessage>>
pub fn try_recv(&self) -> Result<Option<LinkMessage>>
Returns the first queued LinkMessage or None if there is no queued message.
§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.
§Errors
An error is returned if the associated channel is disconnected.
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.
§Errors
An error is returned if a channel was disconnected.