Skip to main content

BorrowedSliceView

Struct BorrowedSliceView 

Source
pub struct BorrowedSliceView<'a> { /* private fields */ }
Expand description

Checked immutable view over a caller-supplied input buffer.

Implementations§

Source§

impl<'a> BorrowedSliceView<'a>

Source

pub fn from_raw_bytes( bytes: &'a [u8], kind: PrimitiveKind, elem_count: usize, ) -> Result<Self, VibeTrap>

Constructs a validated BorrowedSliceView from raw bytes and an element count.

When kind == PrimitiveKind::NQuin48, verifies the 5-word XOR parity on every record.

Source

pub fn from_aligned_bytes( bytes: &'a [u8], kind: PrimitiveKind, elem_count: usize, ) -> Result<Self, VibeTrap>

Constructs a validated BorrowedSliceView requiring pointer alignment kind.elem_align().

Source

pub fn from_nquins(quins: &'a [NQuin48]) -> Result<Self, VibeTrap>

Constructs a BorrowedSliceView from a slice of parity-verified NQuin48 records.

Source

pub const fn kind(&self) -> PrimitiveKind

Element kind.

Source

pub const fn primitive(&self) -> PrimitiveKind

Alias for kind().

Source

pub const fn elem_count(&self) -> usize

Number of typed elements.

Source

pub const fn len(&self) -> usize

Alias for elem_count().

Source

pub const fn is_empty(&self) -> bool

Returns true when elem_count == 0.

Source

pub const fn as_bytes(&self) -> &'a [u8]

Underlying byte slice.

Source

pub fn read_f64_le(&self, index: usize) -> Result<f64, VibeTrap>

Reads the index-th f64 (little-endian) without requiring 8-byte pointer alignment.

Source

pub fn read_f32_le(&self, index: usize) -> Result<f32, VibeTrap>

Reads the index-th f32 (little-endian).

Source

pub fn read_u64_le(&self, index: usize) -> Result<u64, VibeTrap>

Reads the index-th u64 (little-endian).

Source

pub fn read_i64_le(&self, index: usize) -> Result<i64, VibeTrap>

Reads the index-th i64 (little-endian).

Source

pub fn read_u32_le(&self, index: usize) -> Result<u32, VibeTrap>

Reads the index-th u32 (little-endian).

Source

pub fn read_i32_le(&self, index: usize) -> Result<i32, VibeTrap>

Reads the index-th i32 (little-endian).

Source

pub fn read_u8(&self, index: usize) -> Result<u8, VibeTrap>

Reads the index-th u8.

Source

pub fn read_bool(&self, index: usize) -> Result<bool, VibeTrap>

Reads the index-th bool.

Source

pub fn read_nquin(&self, index: usize) -> Result<NQuin48, VibeTrap>

Reads the index-th parity-verified NQuin48 (little-endian).

Source

pub fn read_resource_handle( &self, index: usize, ) -> Result<ResourceHandle, VibeTrap>

Reads the index-th ResourceHandle (little-endian 24-byte #[repr(C)] layout).

Source

pub fn read_utf8_bytes(&self) -> Result<&'a [u8], VibeTrap>

Returns the raw byte slice backing a PrimitiveKind::Utf8Bytes view after validating UTF-8.

Source

pub fn read_utf8_str(&self) -> Result<&'a str, VibeTrap>

Returns the UTF-8 string slice backing a PrimitiveKind::Utf8Bytes view.

Source§

impl<'a> BorrowedSliceView<'a>

Source

pub fn read_finite_f64(&self, index: usize) -> Result<f64, VibeTrap>

Reads the index-th f64 and traps with VibeTrap::NumericalDomainError if non-finite.

Source

pub fn read_finite_f32(&self, index: usize) -> Result<f32, VibeTrap>

Reads the index-th f32 and traps with VibeTrap::NumericalDomainError if non-finite.

Source

pub fn read_finite_f64_array<const N: usize>( &self, start_index: usize, ) -> Result<[f64; N], VibeTrap>

Reads N contiguous finite f64 values starting at start_index.

Source

pub fn read_finite_f32_array<const N: usize>( &self, start_index: usize, ) -> Result<[f32; N], VibeTrap>

Reads N contiguous finite f32 values starting at start_index.

Trait Implementations§

Source§

impl<'a> Clone for BorrowedSliceView<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for BorrowedSliceView<'a>

Source§

impl<'a> Debug for BorrowedSliceView<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for BorrowedSliceView<'a>

§

impl<'a> RefUnwindSafe for BorrowedSliceView<'a>

§

impl<'a> Send for BorrowedSliceView<'a>

§

impl<'a> Sync for BorrowedSliceView<'a>

§

impl<'a> Unpin for BorrowedSliceView<'a>

§

impl<'a> UnsafeUnpin for BorrowedSliceView<'a>

§

impl<'a> UnwindSafe for BorrowedSliceView<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.