#[non_exhaustive]pub enum Headers {
First,
Skip,
None,
Given(&'static [&'static str]),
}Expand description
Where the names of the columns come from.
use std::collections::BTreeMap;
use deser_csv::{DeserializerConfig, Headers};
let rows: Vec<BTreeMap<String, u32>> =
deser_csv::from_str("a,b\n1,2\n").unwrap();
assert_eq!(rows[0]["b"], 2);
let config = DeserializerConfig::builder().headers(Headers::None).build();
let rows: Vec<Vec<u32>> = config.from_str("1,2\n3,4\n").unwrap();
assert_eq!(rows, [[1, 2], [3, 4]]);
let config = DeserializerConfig::builder().headers(Headers::Skip).build();
let rows: Vec<(String, u32)> =
config.from_str("name,age\njane,42\n").unwrap();
assert_eq!(rows, [("jane".to_string(), 42)]);
let config =
DeserializerConfig::builder().headers(Headers::Given(&["a", "b"])).build();
let rows: Vec<BTreeMap<String, u32>> = config.from_str("1,2\n").unwrap();
assert_eq!(rows[0]["a"], 1);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
First
The first record holds the names, records are maps.
Skip
The first record holds the names, but records are sequences (for instance to read them into tuples).
The names are still read (see StreamDeserializer::headers).
None
There are no names, records are sequences.
Given(&'static [&'static str])
The names are given (the first record is a regular record), records are maps.
Trait Implementations§
impl Copy for Headers
impl Eq for Headers
impl StructuralPartialEq for Headers
Auto Trait Implementations§
impl Freeze for Headers
impl RefUnwindSafe for Headers
impl Send for Headers
impl Sync for Headers
impl Unpin for Headers
impl UnsafeUnpin for Headers
impl UnwindSafe for Headers
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more