arrow::array

Struct ByteView

#[repr(C)]
pub struct ByteView { pub length: u32, pub prefix: u32, pub buffer_index: u32, pub offset: u32, }
Expand description

Helper to access views of GenericByteViewArray (StringViewArray and BinaryViewArray) where the length is greater than 12 bytes.

See Also:

  • GenericByteViewArray for more information on the layout of the views.
  • [validate_binary_view] and [validate_string_view] to validate

§Example: Create a new u128 view

// Create a view for a string of length 20
// first four bytes are "Rust"
// stored in buffer 3
// at offset 42
let prefix = "Rust";
let view = ByteView::new(20, prefix.as_bytes())
  .with_buffer_index(3)
  .with_offset(42);

// create the final u128
let v = view.as_u128();
assert_eq!(v, 0x2a000000037473755200000014);

§Example: decode a u128 into its constituent fields

// Convert a u128 to a ByteView
// See validate_{string,binary}_view functions to validate
let v = ByteView::from(0x2a000000037473755200000014);

assert_eq!(v.length, 20);
assert_eq!(v.prefix, 0x74737552);
assert_eq!(v.buffer_index, 3);
assert_eq!(v.offset, 42);

Fields§

§length: u32

The length of the string/bytes.

§prefix: u32

First 4 bytes of string/bytes data.

§buffer_index: u32

The buffer index.

§offset: u32

The offset into the buffer.

Implementations§

§

impl ByteView

pub fn new(length: u32, prefix: &[u8]) -> ByteView

Construct a ByteView for data length of bytes with the specified prefix.

See example on ByteView docs

Notes:

  • the length should always be greater than 12 (Data less than 12 bytes is stored as an inline view)
  • buffer and offset are set to 0
§Panics

If the prefix is not exactly 4 bytes

pub fn with_buffer_index(self, buffer_index: u32) -> ByteView

Set the Self::buffer_index field

pub fn with_offset(self, offset: u32) -> ByteView

Set the Self::offset field

pub fn as_u128(self) -> u128

Convert ByteView to u128 by concatenating the fields

Trait Implementations§

§

impl Clone for ByteView

§

fn clone(&self) -> ByteView

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

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

Performs copy-assignment from source. Read more
§

impl Debug for ByteView

§

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

Formats the value using the given formatter. Read more
§

impl Default for ByteView

§

fn default() -> ByteView

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

impl From<u128> for ByteView

§

fn from(value: u128) -> ByteView

Converts to this type from the input type.
§

impl Copy for ByteView

Auto Trait Implementations§

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

§

impl<T> Ungil for T
where T: Send,