Skip to main content

CsvOptions

Struct CsvOptions 

Source
pub struct CsvOptions {
    pub trim: Option<bool>,
    pub comment: Option<bool>,
    pub number: Option<bool>,
    pub value: Option<bool>,
    pub header: bool,
    pub object: bool,
    pub strict: bool,
    pub field: FieldOptions,
    pub record: RecordOptions,
    pub string: StringOptions,
    pub stream: Option<Stream>,
}
Expand description

The plugin options: the counterpart of the TypeScript CsvOptions and Csv.defaults, and of the Go Defaults map. Default is the documented default set.

The three-state options (trim, comment, number, value) are Option<bool>: None is the TypeScript null, which means “off in strict mode, on in non-strict mode”.

Fields§

§trim: Option<bool>

Drop the whitespace around an unquoted field.

§comment: Option<bool>

Lex # comments, so a comment line is no record and a trailing comment is not field text.

§number: Option<bool>

Lex numbers, so 1e2 is the number 100 rather than text.

§value: Option<bool>

Lex the value keywords, so true, false and null are values rather than text.

§header: bool

The first row names the columns.

§object: bool

Each record is an object keyed by column name; false gives an array of field values.

§strict: bool

Every field is raw text. false lets a field body hold embedded jsonic ([1,2], {x:1}, a backslash-escaped string) and turns trim, comment, number and value on unless set.

§field: FieldOptions

Field options.

§record: RecordOptions

Record options.

§string: StringOptions

String options.

§stream: Option<Stream>

Stream records to a callback instead of collecting them. A closure cannot travel in the plugin option bag, so it is carried here, outside serialization, and reaches the plugin through plugin_with and make_with.

Implementations§

Source§

impl CsvOptions

Source

pub fn from_value(value: &Value) -> Result<Self, String>

Read options out of a plugin option bag, the form Tabnas::use_plugin merges and hands to the plugin. A missing key takes its default; an unknown key is ignored, as in the other two runtimes.

Source

pub fn to_value(&self) -> Value

The options as a plugin option bag, the form Plugin::with_defaults and Tabnas::use_plugin take. The stream callback does not travel; see plugin_with.

Trait Implementations§

Source§

impl Clone for CsvOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CsvOptions

Source§

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

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

impl Default for CsvOptions

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for CsvOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for CsvOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.