pub struct Span { /* private fields */ }Expand description
Where one field’s bytes are in the buffer it was read from.
A quoted field’s range is what is between its quotes. Whether a doubled quote or an escaped one
is in there is kept too, since then the bytes are not the value yet and Span::text has to
take the escapes out, which is the one case that copies before the value is used.
Eight bytes, two u32s with the escape in the top bit of the end, because a chunk holds one of
these for every field of eight thousand records and the converters walk them once per column.
That caps a chunk’s buffer at Span::MOST bytes, which the reader keeps to.
Implementations§
Source§impl Span
impl Span
Sourcepub fn new(start: usize, end: usize, escaped: bool) -> Self
pub fn new(start: usize, end: usize, escaped: bool) -> Self
The field from start to end, with escapes in it or not.
§Panics
In a debug build, if end is past Self::MOST, which the reader never lets a buffer be.
Sourcepub const fn is_empty(self) -> bool
pub const fn is_empty(self) -> bool
Whether the field is empty, which the reader turns into a null unless it was told a different null string.
A field with an escape in it is never empty once the escape is taken out, since every escape leaves a byte behind, so the range answers for the value.
Sourcepub fn raw(self, bytes: &[u8]) -> &[u8] ⓘ
pub fn raw(self, bytes: &[u8]) -> &[u8] ⓘ
The bytes of the field as they are in the buffer, escapes and all.
Sourcepub fn text(self, bytes: &[u8], dialect: Dialect) -> Cow<'_, str>
pub fn text(self, bytes: &[u8], dialect: Dialect) -> Cow<'_, str>
The field as text, borrowed from the buffer unless it had an escape or a byte that is not UTF-8 in it.
The bytes that are not UTF-8 become the replacement character, exactly as
String::from_utf8_lossy makes them, because that is what record does and the two have
to agree.