Skip to main content

MoiraiIterator

Struct MoiraiIterator 

Source
pub struct MoiraiIterator<T> { /* private fields */ }
Expand description

Main iterator type that adapts to different execution contexts.

Implementations§

Source§

impl<T> MoiraiIterator<T>
where T: Send + 'static,

Source

pub fn new(data: Vec<T>, context: ExecutionContext) -> MoiraiIterator<T>

Create a new iterator with the given execution context.

Source

pub fn parallel(data: Vec<T>) -> MoiraiIterator<T>

Create with parallel context.

Source

pub fn async_iter(data: Vec<T>) -> MoiraiIterator<T>

Create with async context.

Source

pub fn hybrid(data: Vec<T>) -> MoiraiIterator<T>

Create with hybrid context.

Source

pub fn map<F, R>(self, func: F) -> MoiraiIterator<R>
where F: Fn(T) -> R + Send + Sync + 'static, R: Send + 'static,

Map operation that preserves the execution context.

Source

pub async fn map_async<F, Fut, R>(self, func: F) -> MoiraiIterator<R>
where F: Fn(T) -> Fut + Send + Sync + 'static, Fut: Future<Output = R> + Send + 'static, R: Send + 'static,

Async map operation for I/O-bound transformations.

Source

pub fn filter<F>(self, predicate: F) -> MoiraiIterator<T>
where F: Fn(&T) -> bool + Send + Sync + 'static,

Filter operation.

Source

pub async fn filter_async<F, Fut>(self, predicate: F) -> MoiraiIterator<T>
where F: Fn(&T) -> Fut + Send + Sync + 'static, Fut: Future<Output = bool> + Send + 'static,

Async filter operation.

Source

pub async fn collect(self) -> Vec<T>

Collect the results.

Source

pub async fn collect_async(self) -> Vec<T>

Async collect that waits for all tasks to complete.

Source

pub async fn reduce<F>(self, func: F) -> Option<T>
where F: Fn(T, T) -> T + Send + Sync + 'static,

Reduce operation.

Source

pub async fn reduce_parallel<F>(self, func: F) -> Option<T>
where F: Fn(T, T) -> T + Send + Sync + 'static,

Parallel reduce with work-stealing.

Source

pub async fn for_each<F>(self, func: F)
where F: Fn(T) + Send + Sync + 'static,

For each operation with side effects.

Source

pub async fn for_each_async<F, Fut>(self, func: F)
where F: Fn(T) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static,

Async for each operation.

Source

pub fn into_async_stream(self) -> impl Stream<Item = T> + Send + 'static
where T: 'static,

Convert to async stream for streaming processing.

Auto Trait Implementations§

§

impl<T> Freeze for MoiraiIterator<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for MoiraiIterator<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for MoiraiIterator<T>
where Vec<T>: Send,

§

impl<T> Sync for MoiraiIterator<T>
where Vec<T>: Sync,

§

impl<T> Unpin for MoiraiIterator<T>
where Vec<T>: Unpin,

§

impl<T> UnsafeUnpin for MoiraiIterator<T>
where Vec<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for MoiraiIterator<T>
where Vec<T>: UnwindSafe,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.