InputStream

Struct InputStream 

Source
pub struct InputStream { /* private fields */ }
Expand description

A structure for creating a transformation chain from input files.

Most of the time you’ll start your processing chain using .from_readers() or .from_paths() and then chain the methods of the RowStream trait. However there are more options for the cases where you need to customize how your input is read.

Trait Implementations§

Source§

impl IntoIterator for InputStream

Source§

type Item = Result<StringRecord, Error>

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl RowStream for InputStream

Source§

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.
Source§

fn add(self, column: ColSpec) -> Result<Add<Self>>
where Self: Sized,

Add a column to each row of the stream. Read more
Source§

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.
Source§

fn select(self, columns: Vec<&str>) -> Select<'_, Self>
where Self: Sized,

Outputs only the selected columns, ignoring the rest. Read more
Source§

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
Source§

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
Source§

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
Source§

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
Source§

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.
Source§

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.
Source§

fn rename(self, old_name: &str, new_name: &str) -> Rename<Self>
where Self: Sized,

Renames some columns
Source§

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
Source§

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.
Source§

fn filter_col<F>(self, col: &str, f: F) -> Result<FilterCol<Self, F>>
where Self: Sized, F: Fn(&str) -> bool,

filter entire rows out depending on one column’s value and a condition, leaving errored rows untouched.
Source§

fn filter_row<F>(self, f: F) -> FilterRow<Self, F>
where Self: Sized, F: Fn(&Headers, &Row) -> bool,

filter entire rows out depending on one column’s value and a condition, leaving errored rows untouched.

Auto Trait Implementations§

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