pub struct ZeroCopyByteRecord<'a> { /* private fields */ }Expand description
A view of a CSV record into a ZeroCopyReader buffer.
Implementations§
Source§impl<'a> ZeroCopyByteRecord<'a>
impl<'a> ZeroCopyByteRecord<'a>
Sourcepub fn len(&self) -> usize
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.
Sourcepub fn iter(&self) -> ZeroCopyByteRecordIter<'_>
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.
Sourcepub fn unquoted_iter(&self) -> ZeroCopyByteRecordUnquotedIter<'_>
pub fn unquoted_iter(&self) -> ZeroCopyByteRecordUnquotedIter<'_>
Returns an iterator over the record’s fields, unquoted.
See Self::unquote for more detail.
Sourcepub fn unescaped_iter(&self) -> ZeroCopyByteRecordUnescapedIter<'_>
pub fn unescaped_iter(&self) -> ZeroCopyByteRecordUnescapedIter<'_>
Returns an iterator over the record’s fields, unescaped.
See Self::unescape for more detail.
Sourcepub fn get(&self, index: usize) -> Option<&[u8]>
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.
Sourcepub fn unquote(&self, index: usize) -> Option<&[u8]>
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).
Sourcepub fn unescape(&self, index: usize) -> Option<Cow<'_, [u8]>>
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.
Sourcepub fn to_byte_record(&self) -> ByteRecord
pub fn to_byte_record(&self) -> ByteRecord
Converts the zero copy byte record into a proper, owned ByteRecord.