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: boolThe first row names the columns.
object: boolEach record is an object keyed by column name; false gives an
array of field values.
strict: boolEvery 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: FieldOptionsField options.
record: RecordOptionsRecord options.
string: StringOptionsString 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
impl CsvOptions
Sourcepub fn from_value(value: &Value) -> Result<Self, String>
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.
Sourcepub fn to_value(&self) -> Value
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.