Struct csvsc::MockStream
source · [−]pub struct MockStream<I> { /* private fields */ }
Expand description
A simple struct that helps create RowStreams from vectors.
Implementations
sourceimpl<I> MockStream<I> where
I: Iterator<Item = RowResult>,
impl<I> MockStream<I> where
I: Iterator<Item = RowResult>,
sourcepub fn new(iter: I, headers: Headers) -> MockStream<I>
pub fn new(iter: I, headers: Headers) -> MockStream<I>
Creates a new object implementing the RowStream trait from an iterator and some headers.
sourcepub fn from_rows(iter: I) -> Result<MockStream<I>, BuildError>
pub fn from_rows(iter: I) -> Result<MockStream<I>, BuildError>
Creates a new object implementing the RowStream trait from an iterator of RowResult objects, the first of which must be the header row.
Trait Implementations
sourceimpl<I: Debug> Debug for MockStream<I>
impl<I: Debug> Debug for MockStream<I>
sourceimpl<I> IntoIterator for MockStream<I> where
I: Iterator<Item = RowResult>,
impl<I> IntoIterator for MockStream<I> where
I: Iterator<Item = RowResult>,
sourceimpl<I> RowStream for MockStream<I> where
MockStream<I>: IntoIterator<Item = RowResult>,
impl<I> RowStream for MockStream<I> where
MockStream<I>: IntoIterator<Item = RowResult>,
sourcefn headers(&self) -> &Headers
fn headers(&self) -> &Headers
Must return headers as they are in this point of the chain. For example
if implementor adds a column, its headers()
function must return the
new headers including the one just added. Read more
sourcefn add(self, column: ColSpec) -> Result<Add<Self>> where
Self: Sized,
fn add(self, column: ColSpec) -> Result<Add<Self>> where
Self: Sized,
Add a column to each row of the stream. Read more
sourcefn del(self, columns: Vec<&str>) -> Del<'_, Self> where
Self: Sized,
fn del(self, columns: Vec<&str>) -> Del<'_, Self> where
Self: Sized,
Deletes the specified columns from each row of the stream. If you have
too many columns to delete perhaps instead use RowStream::select
. Read more
sourcefn select(self, columns: Vec<&str>) -> Select<'_, Self> where
Self: Sized,
fn select(self, columns: Vec<&str>) -> Select<'_, Self> where
Self: Sized,
Outputs only the selected columns, ignoring the rest. Read more
sourcefn add_with<F>(
self,
colname: &str,
f: F
) -> Result<AddWith<Self, F>, BuildError> where
Self: Sized,
F: FnMut(&Headers, &Row) -> Result<String>,
fn add_with<F>(
self,
colname: &str,
f: F
) -> Result<AddWith<Self, F>, BuildError> where
Self: Sized,
F: FnMut(&Headers, &Row) -> Result<String>,
Adds a column to each row of the stream using a closure to compute its value. Read more
sourcefn reduce(self, columns: Vec<Box<dyn Aggregate>>) -> Result<Reduce<Self>> where
Self: Sized,
fn reduce(self, columns: Vec<Box<dyn Aggregate>>) -> Result<Reduce<Self>> where
Self: Sized,
Reduce all the incoming stream into one row, computing some aggregates in the way. All the stream collapses into one row. Read more
sourcefn adjacent_group<F, R, G>(self, grouping: G, f: F) -> AdjacentGroup<Self, F, G> where
F: Fn(MockStream<IntoIter<RowResult>>) -> R,
R: RowStream,
G: GroupCriteria,
Self: Sized,
fn adjacent_group<F, R, G>(self, grouping: G, f: F) -> AdjacentGroup<Self, F, G> where
F: Fn(MockStream<IntoIter<RowResult>>) -> R,
R: RowStream,
G: GroupCriteria,
Self: Sized,
Groups rows by the given criteria, but assuming a “group” is a set of adjacent rows. Read more
sourcefn group<F, R, G>(self, grouping: G, f: F) -> Group<Self, F, G> where
F: Fn(MockStream<IntoIter<RowResult>>) -> R,
R: RowStream,
G: GroupCriteria,
Self: Sized,
fn group<F, R, G>(self, grouping: G, f: F) -> Group<Self, F, G> where
F: Fn(MockStream<IntoIter<RowResult>>) -> R,
R: RowStream,
G: GroupCriteria,
Self: Sized,
Groups rows by the given criteria. You’ll be given a RowStream instance as the first argument of a closure that you can use to further process the grouped rows. Read more
sourcefn flush<T>(self, target: T) -> Result<Flush<Self, T>> where
Self: Sized,
fn flush<T>(self, target: T) -> Result<Flush<Self, T>> where
Self: Sized,
When consumed, writes to destination specified by the column given in
the first argument. Other than that this behaves like an id(x)
function so you can specify more links in the chain and even more
flushers. Read more
sourcefn review<F>(self, f: F) -> Inspect<Self, F> where
Self: Sized,
F: FnMut(&Headers, &RowResult),
fn review<F>(self, f: F) -> Inspect<Self, F> where
Self: Sized,
F: FnMut(&Headers, &RowResult),
Mostly for debugging, calls a closure on each element. Behaves like the identity function on the stream returning each row untouched. Read more
sourcefn rename(self, old_name: &str, new_name: &str) -> Rename<Self> where
Self: Sized,
fn rename(self, old_name: &str, new_name: &str) -> Rename<Self> where
Self: Sized,
Renames some columns
sourcefn map_row<F, H, R>(self, f: F, header_map: H) -> MapRow<Self, F> where
Self: Sized,
F: Fn(&Headers, &Row) -> Result<R>,
H: Fn(&Headers) -> Headers,
R: Iterator<Item = RowResult>,
fn map_row<F, H, R>(self, f: F, header_map: H) -> MapRow<Self, F> where
Self: Sized,
F: Fn(&Headers, &Row) -> Result<R>,
H: Fn(&Headers) -> Headers,
R: Iterator<Item = RowResult>,
Apply a function to every row and use the return values to build the row stream. Read more
sourcefn map_col<F>(self, col: &str, f: F) -> MapCol<Self, F> where
Self: Sized,
F: Fn(&str) -> Result<String>,
fn map_col<F>(self, col: &str, f: F) -> MapCol<Self, F> where
Self: Sized,
F: Fn(&str) -> Result<String>,
Apply a function to a single column of the stream, this function dones’t fail if the column dones’t exist. Read more
Auto Trait Implementations
impl<I> RefUnwindSafe for MockStream<I> where
I: RefUnwindSafe,
impl<I> Send for MockStream<I> where
I: Send,
impl<I> Sync for MockStream<I> where
I: Sync,
impl<I> Unpin for MockStream<I> where
I: Unpin,
impl<I> UnwindSafe for MockStream<I> where
I: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more