Inputs

Struct Inputs 

Source
pub struct Inputs<T, const N: usize = 0> { /* private fields */ }

Implementations§

Source§

impl<T, const N: usize> Inputs<T, N>

Source

pub fn close(&mut self)

Source

pub fn disconnect(&mut self)

Source

pub fn direction(&self) -> PortDirection

Source

pub fn state(&self) -> PortState

Source

pub fn is_empty(&self) -> bool

Source

pub fn capacity(&self) -> Option<usize>

Source

pub fn max_capacity(&self) -> Option<usize>

Source

pub async fn recv(&mut self) -> Result<Option<T>, RecvError>

Examples found in repository?
examples/sqrt.rs (line 18)
17async fn sqrt(mut inputs: Inputs<f64>, outputs: Outputs<f64>) -> Result {
18    while let Some(input) = inputs.recv().await? {
19        let output = input.sqrt();
20        outputs.send(output).await?;
21    }
22    Ok(())
23}
More examples
Hide additional examples
examples/basic.rs (line 13)
5pub async fn main() {
6    let (outputs, mut inputs) = async_flow::Channel::bounded(1).into_inner();
7
8    tokio::spawn(async move {
9        outputs.send("value1").await.unwrap();
10        outputs.send("value2").await.unwrap();
11    });
12
13    while let Some(message) = inputs.recv().await.unwrap() {
14        eprintln!("recv: {}", message);
15    }
16}
Source

pub async fn recv_event(&mut self) -> Result<Option<PortEvent<T>>, RecvError>

Source

pub fn blocking_recv(&mut self) -> Result<Option<T>, RecvError>

Trait Implementations§

Source§

impl<T, const N: usize> AsMut<Receiver<PortEvent<T>>> for Inputs<T, N>

Source§

fn as_mut(&mut self) -> &mut Receiver<PortEvent<T>>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T, const N: usize> AsRef<Receiver<PortEvent<T>>> for Inputs<T, N>

Source§

fn as_ref(&self) -> &Receiver<PortEvent<T>>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T, const N: usize> Debug for Inputs<T, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default, const N: usize> Default for Inputs<T, N>

Source§

fn default() -> Inputs<T, N>

Returns the “default value” for a type. Read more
Source§

impl<T, const N: usize> From<Receiver<PortEvent<T>>> for Inputs<T, N>

Source§

fn from(input: Receiver<PortEvent<T>>) -> Self

Converts to this type from the input type.
Source§

impl<T: Send + 'static, const N: usize> InputPort<T> for Inputs<T, N>

Source§

fn is_empty(&self) -> bool

Checks if this port is empty.
Source§

fn recv<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<T>, RecvError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn recv_all<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>, RecvError>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Source§

impl<T, const N: usize> MaybeLabeled for Inputs<T, N>

Source§

fn label(&self) -> Option<Cow<'_, str>>

Returns the human-readable label, if any, of the object.
Source§

fn is_labeled(&self) -> bool

Checks whether the object has a human-readable label.
Source§

impl<T, const N: usize> MaybeNamed for Inputs<T, N>

Source§

fn name(&self) -> Option<Cow<'_, str>>

Returns the name, if any, of the object.
Source§

fn is_named(&self) -> bool

Checks whether the object has a name.
Source§

impl<T: Send, const N: usize> Port<T> for Inputs<T, N>

Source§

fn close(&mut self)

Closes this port without dropping it, returning immediately. Read more
Source§

fn direction(&self) -> PortDirection

The dataflow direction of this port.
Source§

fn state(&self) -> PortState

The current state of this port.
Source§

fn is_input(&self) -> bool

Checks whether this port is an input port.
Source§

fn is_output(&self) -> bool

Checks whether this port is an output port.
Source§

fn is_unconnected(&self) -> bool

Checks whether this port is currently unconnected.
Source§

fn is_connected(&self) -> bool

Checks whether this port is currently connected.
Source§

fn is_disconnected(&self) -> bool

Checks whether this port is currently disconnected.
Source§

fn is_closed(&self) -> bool

Checks whether this port is currently closed.
Source§

fn capacity(&self) -> Option<usize>

Returns the remaining buffer capacity of the connection.
Source§

fn max_capacity(&self) -> Option<usize>

Returns the maximum buffer capacity of the connection.

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for Inputs<T, N>

§

impl<T, const N: usize> RefUnwindSafe for Inputs<T, N>

§

impl<T, const N: usize> Send for Inputs<T, N>
where T: Send,

§

impl<T, const N: usize> Sync for Inputs<T, N>
where T: Send,

§

impl<T, const N: usize> Unpin for Inputs<T, N>

§

impl<T, const N: usize> UnwindSafe for Inputs<T, N>

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> 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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.