Struct Stage

Source
pub struct Stage<T: Flows> { /* private fields */ }
Expand description

Group of data processors sharing a FlowSubscriber.

Implementations§

Source§

impl<T: Flows> Stage<T>

Source

pub fn flow(&self) -> Flow<T>

Returns a Flow handle connected to the stage.

Source

pub fn add_proc<D>(&mut self, proc: impl Procs<D>)
where T: TryAsFormat<D>,

Adds a new processor to the stage.

proc may accept any data type T which the flow’s data D can be “tried as”. proc will only be invoked for data in the flow which is successfully interperable as D .

Source

pub fn proc(&mut self) -> Result<u64, Error>

Invokes each processor at least once if the flow is active and data is available, returning the number of data processed.

Source

pub async fn proc_loop(self)

Runs Self::proc in an infinite loop.

When the flow is idle, async_support::yield_now will be invoked to temporarily yield execution back to the async runtime. Invoke Self::proc_loop_with_waiter instead of this function to use a different waiter.

Source

pub async fn proc_loop_with_waiter<W, Fut>(self, waiter: W)
where W: Fn() -> Fut, Fut: Future<Output = ()>,

Runs Self::proc in an infinite loop, calling waiter when the flow is idle.

Calling this function with an async runtime’s “native” yield function can improve throughput by ~50% or more (as compared to Self::proc_loop).

On Tokio runtimes, it’s highly recommended to call this function with tokio::task::yield_now.

Trait Implementations§

Source§

impl<T: Flows> From<FlowSubscriber<T>> for Stage<T>

Source§

fn from(value: FlowSubscriber<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> Freeze for Stage<T>

§

impl<T> !RefUnwindSafe for Stage<T>

§

impl<T> Send for Stage<T>

§

impl<T> !Sync for Stage<T>

§

impl<T> Unpin for Stage<T>

§

impl<T> !UnwindSafe for Stage<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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> TryAsFormat<T> for T

Source§

type Error = Infallible

Type of error returned when self doesn’t contain data of format D. Read more
Source§

fn try_as_format(&self) -> Result<&T, <T as TryAsFormat<T>>::Error>

Returns a D-formatted reference to the data.
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.