Outputs

Struct Outputs 

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

Implementations§

Source§

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

Source

pub fn close(&mut self)

Source

pub fn direction(&self) -> PortDirection

Source

pub fn state(&self) -> PortState

Source

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

Source

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

Source

pub async fn send(&self, message: T) -> Result<(), SendError>

Examples found in repository?
examples/sqrt.rs (line 20)
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 9)
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 send_event(&self, event: PortEvent<T>) -> Result<(), SendError>

Source

pub fn blocking_send(&self, _message: T) -> Result<(), SendError>

Trait Implementations§

Source§

impl<T, const N: usize> AsMut<Sender<PortEvent<T>>> for Outputs<T, N>

Source§

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

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

impl<T, const N: usize> AsRef<Sender<PortEvent<T>>> for Outputs<T, N>

Source§

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

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

impl<T: Clone, const N: usize> Clone for Outputs<T, N>

Source§

fn clone(&self) -> Outputs<T, N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, const N: usize> Debug for Outputs<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 Outputs<T, N>

Source§

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

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

impl<T, const N: usize> From<&Sender<PortEvent<T>>> for Outputs<T, N>

Source§

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

Converts to this type from the input type.
Source§

impl<T, const N: usize> From<Sender<PortEvent<T>>> for Outputs<T, N>

Source§

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

Converts to this type from the input type.
Source§

impl<T, const N: usize> MaybeLabeled for Outputs<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 Outputs<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 + 'static, const N: usize> OutputPort<T> for Outputs<T, N>

Source§

fn send<'life0, 'async_trait>( &'life0 self, message: T, ) -> Pin<Box<dyn Future<Output = Result<(), SendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<T: Send, const N: usize> Port<T> for Outputs<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 Outputs<T, N>

§

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

§

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

§

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

§

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

§

impl<T, const N: usize> UnwindSafe for Outputs<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.