Inputs

Struct Inputs 

Source
pub struct Inputs<T> { /* private fields */ }

Implementations§

Source§

impl<T> Inputs<T>

Source

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

Source

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

Source

pub async fn recv_all(&mut self) -> Result<Vec<T>, RecvError>

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::bounded(1);
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 fn recv_blocking(&mut self) -> Result<Option<T>, RecvError>

Trait Implementations§

Source§

impl<T> AsMut<Receiver<T>> for Inputs<T>

Source§

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

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

impl<T> AsRef<Receiver<T>> for Inputs<T>

Source§

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

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

impl<T> Debug for Inputs<T>

Source§

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

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

impl<T> From<Receiver<T>> for Inputs<T>

Source§

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

Converts to this type from the input type.
Source§

impl<T: Send> InputPort<T> for Inputs<T>

Source§

fn is_empty(&self) -> bool

Checks if a 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§

impl<T> MaybeLabeled for Inputs<T>

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> MaybeNamed for Inputs<T>

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> Port<T> for Inputs<T>

Source§

fn is_closed(&self) -> bool

Checks if a port is closed.
Source§

fn close(&mut self)

Closes the port without dropping it.
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> Freeze for Inputs<T>

§

impl<T> RefUnwindSafe for Inputs<T>

§

impl<T> Send for Inputs<T>
where T: Send,

§

impl<T> Sync for Inputs<T>
where T: Send,

§

impl<T> Unpin for Inputs<T>

§

impl<T> UnwindSafe for Inputs<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> 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.