Skip to main content

View

Struct View 

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

A bounded window over one address space.

Implementations§

Source§

impl<'a> View<'a>

Source

pub fn over_retained(bytes: &'a [u8]) -> View<'a>

Bounded window over retained bytes that left the live space chain.

Prefer views returned by DecodeContext. This constructor exists for opportunistic scanners over owned payloads that were copied out of the arena; locations report SpaceId::ROOT.

Source

pub fn position(self) -> usize

Returns the absolute position within the space.

Source

pub fn start(self) -> usize

Returns the window’s inclusive lower bound.

Source

pub fn end(self) -> usize

Returns the window’s exclusive upper bound.

Source

pub fn remaining(self) -> usize

Returns the number of unread bytes before the window’s end.

Source

pub fn is_empty(self) -> bool

Returns whether all bounded bytes have been read.

Source

pub fn location(self) -> SourceLocation

Returns this view’s current source location.

Source

pub fn location_at(self, offset: usize) -> SourceLocation

Returns a source location at an absolute offset in this view’s space.

Source

pub fn window(self) -> &'a [u8] ⓘ

Returns the readable window start..end as a slice.

Source

pub fn take(&mut self, count: usize) -> Option<&'a [u8]>

Takes count bytes, advancing only on success.

Source

pub fn array<const N: usize>(&mut self) -> Option<[u8; N]>

Takes a fixed-size byte array, advancing only on success.

Source

pub fn skip(&mut self, count: usize) -> Option<()>

Skips exactly count bytes.

Source

pub fn seek(&mut self, position: usize) -> Option<()>

Moves to an absolute offset, honoring the stored lower bound.

Source

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

Reads a single byte.

Source

pub fn child(self, start: usize, end: usize) -> Option<View<'a>>

Returns an exactly contained child window.

Source

pub fn counted( self, count: u64, min_element_size: usize, ) -> Option<BoundedCount>

Proves a declared element count could fit in the unread bytes.

Source

pub fn read_counted<T>( &mut self, count: u64, element_size: usize, read: impl FnMut(&mut Self) -> Option<T>, ) -> Option<Vec<T>>

Reads count elements of at least element_size encoded bytes each.

The count is validated with View::counted before any allocation, and the reader closure’s first failure aborts the read.

Source

pub fn utf16_le(&mut self, count: usize) -> Option<String>

Decodes count UTF-16LE code units from the current position.

Strict from_utf16; unpaired surrogates and a truncated window yield None. Does not advance on failure.

Source

pub fn utf16le_at( bytes: &[u8], offset: usize, count: usize, ) -> Option<(String, usize)>

Decodes count UTF-16LE code units at offset and returns the string and end offset.

Sequential readers should keep a live View and call View::utf16_le instead.

Source

pub fn req_take(&mut self, count: usize) -> Result<&'a [u8], ParseError>

Required-read mirror of View::take.

Source

pub fn req_u8(&mut self) -> Result<u8, ParseError>

Required-read mirror of View::u8.

Source§

impl View<'_>

Source

pub fn u16_le(&mut self) -> Option<u16>

Probe read of a u16 via from_le_bytes.

Source

pub fn req_u16_le(&mut self) -> Result<u16, ParseError>

Required-read mirror of View::u16_le.

Source

pub fn u16_le_at(bytes: &[u8], offset: usize) -> Option<u16>

Offset probe of a u16 over retained bytes. Sequential readers should keep a live View and call View::u16_le instead.

Source

pub fn i16_le(&mut self) -> Option<i16>

Probe read of a i16 via from_le_bytes.

Source

pub fn req_i16_le(&mut self) -> Result<i16, ParseError>

Required-read mirror of View::i16_le.

Source

pub fn i16_le_at(bytes: &[u8], offset: usize) -> Option<i16>

Offset probe of a i16 over retained bytes. Sequential readers should keep a live View and call View::i16_le instead.

Source

pub fn u32_le(&mut self) -> Option<u32>

Probe read of a u32 via from_le_bytes.

Source

pub fn req_u32_le(&mut self) -> Result<u32, ParseError>

Required-read mirror of View::u32_le.

Source

pub fn u32_le_at(bytes: &[u8], offset: usize) -> Option<u32>

Offset probe of a u32 over retained bytes. Sequential readers should keep a live View and call View::u32_le instead.

Source

pub fn i32_le(&mut self) -> Option<i32>

Probe read of a i32 via from_le_bytes.

Source

pub fn req_i32_le(&mut self) -> Result<i32, ParseError>

Required-read mirror of View::i32_le.

Source

pub fn i32_le_at(bytes: &[u8], offset: usize) -> Option<i32>

Offset probe of a i32 over retained bytes. Sequential readers should keep a live View and call View::i32_le instead.

Source

pub fn u64_le(&mut self) -> Option<u64>

Probe read of a u64 via from_le_bytes.

Source

pub fn req_u64_le(&mut self) -> Result<u64, ParseError>

Required-read mirror of View::u64_le.

Source

pub fn u64_le_at(bytes: &[u8], offset: usize) -> Option<u64>

Offset probe of a u64 over retained bytes. Sequential readers should keep a live View and call View::u64_le instead.

Source

pub fn i64_le(&mut self) -> Option<i64>

Probe read of a i64 via from_le_bytes.

Source

pub fn req_i64_le(&mut self) -> Result<i64, ParseError>

Required-read mirror of View::i64_le.

Source

pub fn i64_le_at(bytes: &[u8], offset: usize) -> Option<i64>

Offset probe of a i64 over retained bytes. Sequential readers should keep a live View and call View::i64_le instead.

Source

pub fn f32_le(&mut self) -> Option<f32>

Probe read of a f32 via from_le_bytes.

Source

pub fn req_f32_le(&mut self) -> Result<f32, ParseError>

Required-read mirror of View::f32_le.

Source

pub fn f32_le_at(bytes: &[u8], offset: usize) -> Option<f32>

Offset probe of a f32 over retained bytes. Sequential readers should keep a live View and call View::f32_le instead.

Source

pub fn f64_le(&mut self) -> Option<f64>

Probe read of a f64 via from_le_bytes.

Source

pub fn req_f64_le(&mut self) -> Result<f64, ParseError>

Required-read mirror of View::f64_le.

Source

pub fn f64_le_at(bytes: &[u8], offset: usize) -> Option<f64>

Offset probe of a f64 over retained bytes. Sequential readers should keep a live View and call View::f64_le instead.

Source

pub fn u16_be(&mut self) -> Option<u16>

Probe read of a u16 via from_be_bytes.

Source

pub fn req_u16_be(&mut self) -> Result<u16, ParseError>

Required-read mirror of View::u16_be.

Source

pub fn u16_be_at(bytes: &[u8], offset: usize) -> Option<u16>

Offset probe of a u16 over retained bytes. Sequential readers should keep a live View and call View::u16_be instead.

Source

pub fn i16_be(&mut self) -> Option<i16>

Probe read of a i16 via from_be_bytes.

Source

pub fn req_i16_be(&mut self) -> Result<i16, ParseError>

Required-read mirror of View::i16_be.

Source

pub fn i16_be_at(bytes: &[u8], offset: usize) -> Option<i16>

Offset probe of a i16 over retained bytes. Sequential readers should keep a live View and call View::i16_be instead.

Source

pub fn u32_be(&mut self) -> Option<u32>

Probe read of a u32 via from_be_bytes.

Source

pub fn req_u32_be(&mut self) -> Result<u32, ParseError>

Required-read mirror of View::u32_be.

Source

pub fn u32_be_at(bytes: &[u8], offset: usize) -> Option<u32>

Offset probe of a u32 over retained bytes. Sequential readers should keep a live View and call View::u32_be instead.

Source

pub fn i32_be(&mut self) -> Option<i32>

Probe read of a i32 via from_be_bytes.

Source

pub fn req_i32_be(&mut self) -> Result<i32, ParseError>

Required-read mirror of View::i32_be.

Source

pub fn i32_be_at(bytes: &[u8], offset: usize) -> Option<i32>

Offset probe of a i32 over retained bytes. Sequential readers should keep a live View and call View::i32_be instead.

Source

pub fn u64_be(&mut self) -> Option<u64>

Probe read of a u64 via from_be_bytes.

Source

pub fn req_u64_be(&mut self) -> Result<u64, ParseError>

Required-read mirror of View::u64_be.

Source

pub fn u64_be_at(bytes: &[u8], offset: usize) -> Option<u64>

Offset probe of a u64 over retained bytes. Sequential readers should keep a live View and call View::u64_be instead.

Source

pub fn i64_be(&mut self) -> Option<i64>

Probe read of a i64 via from_be_bytes.

Source

pub fn req_i64_be(&mut self) -> Result<i64, ParseError>

Required-read mirror of View::i64_be.

Source

pub fn i64_be_at(bytes: &[u8], offset: usize) -> Option<i64>

Offset probe of a i64 over retained bytes. Sequential readers should keep a live View and call View::i64_be instead.

Source

pub fn f32_be(&mut self) -> Option<f32>

Probe read of a f32 via from_be_bytes.

Source

pub fn req_f32_be(&mut self) -> Result<f32, ParseError>

Required-read mirror of View::f32_be.

Source

pub fn f32_be_at(bytes: &[u8], offset: usize) -> Option<f32>

Offset probe of a f32 over retained bytes. Sequential readers should keep a live View and call View::f32_be instead.

Source

pub fn f64_be(&mut self) -> Option<f64>

Probe read of a f64 via from_be_bytes.

Source

pub fn req_f64_be(&mut self) -> Result<f64, ParseError>

Required-read mirror of View::f64_be.

Source

pub fn f64_be_at(bytes: &[u8], offset: usize) -> Option<f64>

Offset probe of a f64 over retained bytes. Sequential readers should keep a live View and call View::f64_be instead.

Trait Implementations§

Source§

impl<'a> Clone for View<'a>

Source§

fn clone(&self) -> View<'a>

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 View<'a>

Source§

impl<'a> Debug for View<'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 View<'a>

§

impl<'a> RefUnwindSafe for View<'a>

§

impl<'a> Send for View<'a>

§

impl<'a> Sync for View<'a>

§

impl<'a> Unpin for View<'a>

§

impl<'a> UnsafeUnpin for View<'a>

§

impl<'a> UnwindSafe for View<'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> 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.