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>

source

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.
source

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>§

source

pub fn port_id(&self) -> &PortId

source

pub fn channels_count(&self) -> usize

Returns the number of channels associated with this Input.

source

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.

source

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.

Trait Implementations§

source§

impl<T: Send + Sync + 'static> Deref for Input<T>

§

type Target = InputRaw

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsNode<T> for T

source§

fn as_node(&self) -> &T

source§

impl<T> AsNodeMut<T> for T

source§

fn as_node_mut(&mut self) -> &mut T

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> SendSyncAny for T
where T: 'static + Send + Sync,

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more