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 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 location(self) -> SourceLocation

Returns this view’s current source location.

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 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 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 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 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 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 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 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 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 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 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 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 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.

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Same for T

Source§

type Output = T

Should always be Self
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.