ZeroCopyByteRecord

Struct ZeroCopyByteRecord 

Source
pub struct ZeroCopyByteRecord<'a> { /* private fields */ }
Expand description

A view of a CSV record into a ZeroCopyReader buffer.

Implementations§

Source§

impl<'a> ZeroCopyByteRecord<'a>

Source

pub fn len(&self) -> usize

Number of fields of the record. Cannot be less than 1 since a CSV with no columns does not make sense.

Source

pub fn is_empty(&self) -> bool

Returns whether the record has no fields.

Source

pub fn as_slice(&self) -> &[u8]

Returns the underlying byte slice, delimiters and all.

Source

pub fn iter(&self) -> ZeroCopyByteRecordIter<'_>

Returns an iterator over the record’s fields, as-is.

This means fields might or might not be quoted and field bytes have not been unescaped at all.

Source

pub fn unquoted_iter(&self) -> ZeroCopyByteRecordUnquotedIter<'_>

Returns an iterator over the record’s fields, unquoted.

See Self::unquote for more detail.

Source

pub fn unescaped_iter(&self) -> ZeroCopyByteRecordUnescapedIter<'_>

Returns an iterator over the record’s fields, unescaped.

See Self::unescape for more detail.

Source

pub fn get(&self, index: usize) -> Option<&[u8]>

Returns the nth field of the zero copy byte record, if it is not out-of-bounds.

The field’s bytes will be given as-is, quoted or unquoted, and won’t be unescaped at all.

Source

pub fn unquote(&self, index: usize) -> Option<&[u8]>

Returns the nth field of the zero copy byte record, if it is not out-of-bounds.

The field’s bytes will be given unquoted (i.e. without surrounding quotes), but not unescaped (i.e. doubled double quotes will still be there).

The overhead vs. Self::get is only constant (we trim a leading and trailing quote if required).

Source

pub fn unescape(&self, index: usize) -> Option<Cow<'_, [u8]>>

Returns the nth field of the zero copy byte record, if it is not out-of-bounds.

The field’s bytes will be completely unescaped.

The overhead vs. Self::get is linear in the field’s number of bytes.

A Cow::Owned will be returned if the field actually needed unescaping, else a Cow::Borrowed will be returned.

Source

pub fn to_byte_record(&self) -> ByteRecord

Converts the zero copy byte record into a proper, owned ByteRecord.

Trait Implementations§

Source§

impl Debug for ZeroCopyByteRecord<'_>

Source§

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

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

impl Index<usize> for ZeroCopyByteRecord<'_>

Source§

type Output = [u8]

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &[u8]

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ZeroCopyByteRecord<'a>

§

impl<'a> RefUnwindSafe for ZeroCopyByteRecord<'a>

§

impl<'a> Send for ZeroCopyByteRecord<'a>

§

impl<'a> Sync for ZeroCopyByteRecord<'a>

§

impl<'a> Unpin for ZeroCopyByteRecord<'a>

§

impl<'a> UnwindSafe for ZeroCopyByteRecord<'a>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

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

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.