Struct csvsc::prelude::Headers [−][src]
A structure for keeping relationship between the headers and their positions
Implementations
impl Headers
[src]
pub fn new() -> Headers
[src]
Creates an empty Headers object.
pub fn get_field<'r>(&self, row: &'r Row, field: &str) -> Option<&'r str>
[src]
Retrieves a field from a row given it’s header name
use csvsc::{Headers, Row}; let headers: Headers = Row::from(vec!["id", "val"]).into(); let row = Row::from(vec!["1", "40"]); assert_eq!(headers.get_field(&row, "id"), Some("1")); assert_eq!(headers.get_field(&row, "val"), Some("40")); assert_eq!(headers.get_field(&row, "foo"), None);
pub fn add(&mut self, colname: &str) -> Result<(), ()>
[src]
Adds a new header. It’ll fail if the header is already present
use csvsc::{Headers, Row}; let mut h: Headers = Row::from(vec!["name"]).into(); h.add("value").unwrap(); assert_eq!(h, Row::from(vec!["name", "value"]).into()); assert_eq!(h.add("name"), Err(())); assert_eq!(h, Row::from(vec!["name", "value"]).into());
pub fn len(&self) -> usize
[src]
pub fn as_row(&self) -> &Row
[src]
pub fn into_row(self) -> Row
[src]
Consumes this Headers object and returns the underlaying Row containing the names.
pub fn index(&self, field: &str) -> Option<usize>
[src]
Obtains the index of the given field in the headers
pub fn contains_key(&self, field: &str) -> bool
[src]
pub fn iter(&self) -> StringRecordIter<'_>
[src]
Trait Implementations
impl Clone for Headers
[src]
impl Debug for Headers
[src]
impl From<Headers> for Row
[src]
impl From<StringRecord> for Headers
[src]
impl PartialEq<Headers> for Headers
[src]
impl PartialEq<Headers> for Row
[src]
fn eq(&self, other: &Headers) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralPartialEq for Headers
[src]
Auto Trait Implementations
impl RefUnwindSafe for Headers
impl Send for Headers
impl Sync for Headers
impl Unpin for Headers
impl UnwindSafe for Headers
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,