pub struct InputBuilder { /* private fields */ }
Expand description

An InputBuilder is the intermediate structure to obtain either an Input<T> or an InputRaw.

The main difference between both is the type of data they expose: an Input<T> automatically tries to downcast or deserialize the data contained in the message to expose &T, while an InputRaw simply exposes a LinkMessage.

§Planned evolution

Zenoh-Flow will allow tweaking the behaviour of the underlying channels. For now, the receivers channels are unbounded and do not implement a dropping policy, which could lead to issues.

Implementations§

source§

impl InputBuilder

source

pub fn raw(self) -> InputRaw

Consume the InputBuilder to produce an InputRaw.

An InputRaw exposes the LinkMessage it receives, without trying to perform any conversion on the data.

The InputRaw was designed for use cases such as load-balancing or rate-limiting. In these scenarios, the node does not need to access the underlying data.

§InputRaw vs Input<T>

If the node needs access to the data to perform computations, an Input<T> should be favoured as it performs the conversion automatically.

§Example
let input_raw = inputs.take("test raw")
    .expect("No input name 'test raw' found")
    .raw();
source

pub fn typed<T>( self, deserializer: impl Fn(&[u8]) -> Result<T> + Send + Sync + 'static ) -> Input<T>

Consume the InputBuilder to produce an Input<T>.

An Input<T> tries to automatically convert the data contained in the LinkMessage in order to expose &T. Depending on if the data is received serialised or not, to perform this conversion either the deserialiser is called or a downcast is attempted.

§Input<T> vs InputRaw

If the node does need to access the data contained in the LinkMessage, an InputRaw should be favoured as it does not try to perform the extra conversion steps.

§Example
let input: Input<u64> = inputs.take("test typed")
    .expect("No input name 'test typed' found")
    .typed(
        |bytes| serde_json::from_slice(bytes).map_err(|e| anyhow!(e))
    );

Auto Trait Implementations§

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