pub struct CharsTape<Offset: OffsetType = i32, A: Allocator = Global> { /* private fields */ }Expand description
UTF-8 string view over RawTape.
Implementations§
Source§impl<Offset: OffsetType, A: Allocator> CharsTape<Offset, A>
impl<Offset: OffsetType, A: Allocator> CharsTape<Offset, A>
Sourcepub fn new() -> CharsTape<Offset, Global>
pub fn new() -> CharsTape<Offset, Global>
Creates a new, empty CharsTape with the global allocator.
Sourcepub fn with_capacity(
data_capacity: usize,
strings_capacity: usize,
) -> Result<CharsTape<Offset, Global>, StringTapeError>
pub fn with_capacity( data_capacity: usize, strings_capacity: usize, ) -> Result<CharsTape<Offset, Global>, StringTapeError>
Creates a new CharsTape with pre-allocated capacity using the global allocator.
Sourcepub fn with_capacity_in(
data_capacity: usize,
strings_capacity: usize,
allocator: A,
) -> Result<Self, StringTapeError>
pub fn with_capacity_in( data_capacity: usize, strings_capacity: usize, allocator: A, ) -> Result<Self, StringTapeError>
Creates a new CharsTape with pre-allocated capacity and a custom allocator.
Sourcepub fn push(&mut self, s: &str) -> Result<(), StringTapeError>
pub fn push(&mut self, s: &str) -> Result<(), StringTapeError>
Adds a string to the end of the CharsTape.
Sourcepub fn get(&self, index: usize) -> Option<&str>
pub fn get(&self, index: usize) -> Option<&str>
Returns a reference to the string at the given index, or None if out of bounds.
Sourcepub unsafe fn get_unchecked(&self, index: usize) -> &str
pub unsafe fn get_unchecked(&self, index: usize) -> &str
Returns a reference to the string at the given index without bounds checking.
§Safety
Caller must ensure index < self.len().
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of strings currently stored (same as len()).
Sourcepub fn data_capacity(&self) -> usize
pub fn data_capacity(&self) -> usize
Returns the number of bytes allocated for string data.
Sourcepub fn offsets_capacity(&self) -> usize
pub fn offsets_capacity(&self) -> usize
Returns the number of offset slots allocated.
Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Shortens the CharsTape, keeping the first len strings and dropping the rest.
Sourcepub fn shrink_to_fit(&mut self) -> Result<(), StringTapeError>
pub fn shrink_to_fit(&mut self) -> Result<(), StringTapeError>
Shrinks allocated capacity to fit current data.
Sourcepub fn extend<I>(&mut self, iter: I) -> Result<(), StringTapeError>
pub fn extend<I>(&mut self, iter: I) -> Result<(), StringTapeError>
Extends the CharsTape with the contents of an iterator.
Sourcepub fn as_raw_parts(&self) -> RawParts<Offset>
pub fn as_raw_parts(&self) -> RawParts<Offset>
Returns the raw parts of the CharsTape for Apache Arrow compatibility.
Sourcepub fn data_slice(&self) -> &[u8] ⓘ
pub fn data_slice(&self) -> &[u8] ⓘ
Returns a slice view of the data buffer.
Sourcepub fn offsets_slice(&self) -> &[Offset]
pub fn offsets_slice(&self) -> &[Offset]
Returns a slice view of the offsets buffer.
pub fn iter(&self) -> CharsTapeIter<'_, Offset, A> ⓘ
Sourcepub fn view(&self) -> CharsTapeView<'_, Offset>
pub fn view(&self) -> CharsTapeView<'_, Offset>
Creates a view of the entire CharsTape.
Sourcepub fn subview(
&self,
start: usize,
end: usize,
) -> Result<CharsTapeView<'_, Offset>, StringTapeError>
pub fn subview( &self, start: usize, end: usize, ) -> Result<CharsTapeView<'_, Offset>, StringTapeError>
Creates a subview of a continuous slice of this CharsTape.
Sourcepub fn as_reorderable<Length: LengthType>(
&self,
) -> Result<CharsCows<'_, Offset, Length>, StringTapeError>
pub fn as_reorderable<Length: LengthType>( &self, ) -> Result<CharsCows<'_, Offset, Length>, StringTapeError>
Creates a CharsCows view of the tape.
§Example
let mut tape = CharsTapeI32::new();
tape.extend(["apple", "banana", "cherry"])?;
let cows: CharsCows<i32, u16> = tape.as_reorderable()?;
assert_eq!(cows.get(0), Some("apple"));Sourcepub fn arrow_slices(&self) -> (&[u8], &[Offset])
pub fn arrow_slices(&self) -> (&[u8], &[Offset])
Returns data and offsets slices for zero-copy Arrow conversion.
Source§impl<Offset: OffsetType, A: Allocator> CharsTape<Offset, A>
impl<Offset: OffsetType, A: Allocator> CharsTape<Offset, A>
pub fn into_bytes_tape(self) -> BytesTape<Offset, A>
Trait Implementations§
Source§impl<'a, Offset: OffsetType, A: Allocator> Extend<&'a str> for CharsTape<Offset, A>
impl<'a, Offset: OffsetType, A: Allocator> Extend<&'a str> for CharsTape<Offset, A>
Source§fn extend<I: IntoIterator<Item = &'a str>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = &'a str>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)