Skip to main content

Tools

Trait Tools 

Source
pub trait Tools<Item>
where Self: Stream<Item = Item> + Send + Sized, <Self as Stream>::Item: Send,
{ // Required methods fn counts(self) -> impl Future<Output = HashMap<Item, usize>> + Send where <Self as Stream>::Item: Eq + Hash; fn counts_by<K, F>( self, f: F, ) -> impl Future<Output = HashMap<K, usize>> + Send where F: Fn(Item) -> K + Send, K: Eq + Hash + Send; fn counts_by_with_cap<const CAP: usize, K, F>( self, f: F, ) -> impl Future<Output = HashMap<K, usize>> + Send where F: Fn(Item) -> K + Send, K: Eq + Hash + Send; fn counts_with_cap<const CAP: usize>( self, ) -> impl Future<Output = HashMap<Item, usize>> + Send where <Self as Stream>::Item: Eq + Hash; fn sample_by<const N: usize, K, F>( self, f: F, ) -> impl Future<Output = ArrayVec<K, N>> + Send where F: Fn(Item) -> K + Send, K: Send; fn fold_default<T, F, Fut>(self, f: F) -> impl Future<Output = T> + Send where F: Fn(T, Item) -> Fut + Send, Fut: Future<Output = T> + Send, T: Default + Send; }
Expand description

StreamTools

This interface is not necessarily complete; feel free to add as-needed.

Required Methods§

Source

fn counts(self) -> impl Future<Output = HashMap<Item, usize>> + Send
where <Self as Stream>::Item: Eq + Hash,

Source

fn counts_by<K, F>(self, f: F) -> impl Future<Output = HashMap<K, usize>> + Send
where F: Fn(Item) -> K + Send, K: Eq + Hash + Send,

Source

fn counts_by_with_cap<const CAP: usize, K, F>( self, f: F, ) -> impl Future<Output = HashMap<K, usize>> + Send
where F: Fn(Item) -> K + Send, K: Eq + Hash + Send,

Source

fn counts_with_cap<const CAP: usize>( self, ) -> impl Future<Output = HashMap<Item, usize>> + Send
where <Self as Stream>::Item: Eq + Hash,

Source

fn sample_by<const N: usize, K, F>( self, f: F, ) -> impl Future<Output = ArrayVec<K, N>> + Send
where F: Fn(Item) -> K + Send, K: Send,

Reservoir-samples up to N items uniformly at random in a single pass, applying f only to the items retained. Items are drawn without replacement; the keys f derives may still repeat, so a key produced by twice as many items is twice as likely to appear.

Source

fn fold_default<T, F, Fut>(self, f: F) -> impl Future<Output = T> + Send
where F: Fn(T, Item) -> Fut + Send, Fut: Future<Output = T> + Send, T: Default + Send,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<Item, S> Tools<Item> for S
where S: Stream<Item = Item> + Send + Sized, <Self as Stream>::Item: Send,