Struct clipivot::cli_settings::CsvSettings
source · pub struct CsvSettings { /* private fields */ }
Expand description
The core struct of the settings module, providing general settings and utilities for writing CSV command-line tools.
Implementations§
source§impl CsvSettings
impl CsvSettings
sourcepub fn parse_new(
fname: &Option<&str>,
delim: Option<&str>,
has_header: bool
) -> CsvCliResult<CsvSettings>
pub fn parse_new( fname: &Option<&str>, delim: Option<&str>, has_header: bool ) -> CsvCliResult<CsvSettings>
Tries to create a new CSVSettings struct. Returns an error if it fails to parse the delimiter. (If this happens, it is likely because the delimiter must be a single UTF-8 byte.)
sourcepub fn get_reader_from_path(&self, filename: &str) -> Result<Reader<File>>
pub fn get_reader_from_path(&self, filename: &str) -> Result<Reader<File>>
Returns a csv::Reader
object from a filepath, returning an error if the file doesn’t exist.
sourcepub fn get_reader_from_stdin(&self) -> Reader<Stdin>
pub fn get_reader_from_stdin(&self) -> Reader<Stdin>
Returns a csv::Reader
object from standard input.
sourcepub fn get_field_index(
&self,
colname: &str,
headers: &Vec<&str>
) -> CsvCliResult<usize>
pub fn get_field_index( &self, colname: &str, headers: &Vec<&str> ) -> CsvCliResult<usize>
Returns a single index where a single string appears. Allows you to validate a single column, rather than multiple columns.
sourcepub fn get_field_indexes(
&self,
user_defs: &Vec<&str>,
headers: &Vec<&str>
) -> CsvCliResult<Vec<usize>>
pub fn get_field_indexes( &self, user_defs: &Vec<&str>, headers: &Vec<&str> ) -> CsvCliResult<Vec<usize>>
Given a vector of column descriptions, returns indexes where they appear You can see a more complete description on GitHub, but at a basic level, the idea of this function is to allow users to describe columns either by their names or by their indexes.
Trait Implementations§
source§impl Debug for CsvSettings
impl Debug for CsvSettings
source§impl Default for CsvSettings
impl Default for CsvSettings
source§fn default() -> CsvSettings
fn default() -> CsvSettings
source§impl PartialEq<CsvSettings> for CsvSettings
impl PartialEq<CsvSettings> for CsvSettings
source§fn eq(&self, other: &CsvSettings) -> bool
fn eq(&self, other: &CsvSettings) -> bool
self
and other
values to be equal, and is used
by ==
.