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

source

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

source

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.

source

pub fn get_reader_from_stdin(&self) -> Reader<Stdin>

Returns a csv::Reader object from standard input.

source

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.

source

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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CsvSettings

source§

fn default() -> CsvSettings

Returns the “default value” for a type. Read more
source§

impl PartialEq<CsvSettings> for CsvSettings

source§

fn eq(&self, other: &CsvSettings) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for CsvSettings

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.