BytesTape

Struct BytesTape 

Source
pub struct BytesTape<Offset: OffsetType = i32, A: Allocator = Global> { /* private fields */ }
Expand description

Binary bytes view over RawTape.

Implementations§

Source§

impl<Offset: OffsetType, A: Allocator> BytesTape<Offset, A>

Source

pub fn new() -> BytesTape<Offset, Global>

Creates a new, empty BytesTape with the global allocator.

Source

pub fn new_in(allocator: A) -> Self

Creates a new, empty BytesTape with a custom allocator.

Source

pub fn with_capacity( data_capacity: usize, items_capacity: usize, ) -> Result<BytesTape<Offset, Global>, StringTapeError>

Creates a new BytesTape with pre-allocated capacity using the global allocator.

Source

pub fn with_capacity_in( data_capacity: usize, items_capacity: usize, allocator: A, ) -> Result<Self, StringTapeError>

Creates a new BytesTape with pre-allocated capacity and a custom allocator.

Source

pub fn push(&mut self, bytes: &[u8]) -> Result<(), StringTapeError>

Adds bytes to the end of the tape.

Source

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

Returns a reference to the bytes at the given index, or None if out of bounds.

Source

pub unsafe fn get_unchecked(&self, index: usize) -> &[u8]

Returns a reference to the bytes at the given index without bounds checking.

§Safety

Caller must ensure index < self.len().

Source

pub fn len(&self) -> usize

Returns the number of items in the tape.

Source

pub fn is_empty(&self) -> bool

Returns true if the tape contains no items.

Source

pub fn data_len(&self) -> usize

Returns the total number of bytes used by data.

Source

pub fn data_capacity(&self) -> usize

Returns the number of bytes allocated for data.

Source

pub fn offsets_capacity(&self) -> usize

Returns the number of offset slots allocated.

Source

pub fn clear(&mut self)

Removes all items from the tape, keeping allocated capacity.

Source

pub fn truncate(&mut self, len: usize)

Shortens the tape, keeping the first len items and dropping the rest.

Source

pub fn first(&self) -> Option<&[u8]>

Returns a reference to the first item, or None if empty.

Source

pub fn last(&self) -> Option<&[u8]>

Returns a reference to the last item, or None if empty.

Source

pub fn pop(&mut self) -> Option<()>

Removes and returns the last item, or None if empty.

Source

pub fn contains(&self, item: &[u8]) -> bool

Returns true if the tape contains the given byte slice.

Source

pub fn shrink_to_fit(&mut self) -> Result<(), StringTapeError>

Shrinks allocated capacity to fit current data.

Source

pub fn extend<I>(&mut self, iter: I) -> Result<(), StringTapeError>
where I: IntoIterator, I::Item: AsRef<[u8]>,

Extends the tape with the contents of an iterator of bytes.

Source

pub fn as_raw_parts(&self) -> RawParts<Offset>

Returns the raw parts of the tape for Apache Arrow compatibility.

Source

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

Returns a slice view of the data buffer.

Source

pub fn offsets_slice(&self) -> &[Offset]

Returns a slice view of the offsets buffer.

Source

pub fn allocator(&self) -> &A

Returns a reference to the allocator used by this BytesTape.

Source

pub fn view(&self) -> BytesTapeView<'_, Offset>

Creates a view of the entire BytesTape.

Source

pub fn iter(&self) -> BytesTapeIter<'_, Offset, A>

Returns an iterator over the byte cows.

Source

pub fn subview( &self, start: usize, end: usize, ) -> Result<BytesTapeView<'_, Offset>, StringTapeError>

Creates a subview of a continuous slice of this BytesTape.

Source

pub fn as_reorderable<Length: LengthType>( &self, ) -> Result<BytesCows<'_, Offset, Length>, StringTapeError>

Creates a BytesCows view of the tape.

§Example
let mut tape = BytesTapeI32::new();
tape.push(&[1, 2, 3])?;
tape.push(&[4, 5, 6])?;
tape.push(&[7, 8, 9])?;

let cows: BytesCows<i32, u16> = tape.as_reorderable()?;
assert_eq!(cows.get(0), Some(&[1, 2, 3][..]));
Source

pub fn arrow_slices(&self) -> (&[u8], &[Offset])

Returns data and offsets slices for zero-copy Arrow conversion.

Source§

impl<Offset: OffsetType, A: Allocator> BytesTape<Offset, A>

Trait Implementations§

Source§

impl<Offset: OffsetType, A: Allocator + Clone> Clone for BytesTape<Offset, A>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Offset: OffsetType, A: Allocator> Debug for BytesTape<Offset, A>

Source§

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

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

impl<Offset: OffsetType> Default for BytesTape<Offset, Global>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, Offset: OffsetType, A: Allocator> Extend<&'a [u8]> for BytesTape<Offset, A>

Source§

fn extend<I: IntoIterator<Item = &'a [u8]>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<Offset: OffsetType, A: Allocator> From<CharsTape<Offset, A>> for BytesTape<Offset, A>

Source§

fn from(chars_tape: CharsTape<Offset, A>) -> Self

Converts to this type from the input type.
Source§

impl<'a, Offset: OffsetType> FromIterator<&'a [u8]> for BytesTape<Offset, Global>

Source§

fn from_iter<I: IntoIterator<Item = &'a [u8]>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<Offset: OffsetType> FromIterator<Vec<u8>> for BytesTape<Offset, Global>

Source§

fn from_iter<I: IntoIterator<Item = Vec<u8>>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<Offset: OffsetType, A: Allocator> Hash for BytesTape<Offset, A>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Offset: OffsetType, A: Allocator> Index<usize> for BytesTape<Offset, A>

Source§

type Output = [u8]

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

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

impl<'a, Offset: OffsetType, A: Allocator> IntoIterator for &'a BytesTape<Offset, A>

Source§

type Item = &'a [u8]

The type of the elements being iterated over.
Source§

type IntoIter = BytesTapeIter<'a, Offset, A>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<Offset: OffsetType, A: Allocator> Ord for BytesTape<Offset, A>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<Offset: OffsetType, A: Allocator> PartialEq for BytesTape<Offset, A>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Offset: OffsetType, A: Allocator> PartialOrd for BytesTape<Offset, A>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<Offset: OffsetType, A: Allocator> TryFrom<BytesTape<Offset, A>> for CharsTape<Offset, A>

Source§

type Error = StringTapeError

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

fn try_from(bytes_tape: BytesTape<Offset, A>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<Offset: OffsetType, A: Allocator> Eq for BytesTape<Offset, A>

Source§

impl<Offset: OffsetType + Send, A: Allocator + Send> Send for BytesTape<Offset, A>

Source§

impl<Offset: OffsetType + Sync, A: Allocator + Sync> Sync for BytesTape<Offset, A>

Auto Trait Implementations§

§

impl<Offset, A> Freeze for BytesTape<Offset, A>
where A: Freeze,

§

impl<Offset, A> RefUnwindSafe for BytesTape<Offset, A>
where A: RefUnwindSafe, Offset: RefUnwindSafe,

§

impl<Offset, A> Unpin for BytesTape<Offset, A>
where A: Unpin, Offset: Unpin,

§

impl<Offset, A> UnwindSafe for BytesTape<Offset, A>
where A: UnwindSafe, Offset: UnwindSafe + RefUnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.