Skip to main content

View

Struct View 

Source
pub struct View<'source, S: ?Sized> { /* private fields */ }
Expand description

A range whose bounds were validated against one immutably borrowed source. The source borrow prevents mutation while the view is inspected or retained. Inspection and narrowing do not allocate, copy, or retain an owner.

Implementations§

Source§

impl<'source, S: ?Sized> View<'source, S>

Source

pub fn as_slice(&self) -> &'source [u8] ⓘ

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn select(&self, bytes: &[u8]) -> Option<View<'source, S>>

Source

pub fn get(&self, range: Range<usize>) -> Option<View<'source, S>>

Source

pub fn try_get(&self, range: Range<usize>) -> Result<Self, Error>

Source

pub fn new(source: &'source S) -> Self
where S: AsRef<[u8]>,

Borrows the complete initialized source without retaining or copying it.

Source§

impl<S: Seal> View<'_, S>

Source

pub fn try_retain(self) -> Result<S, Error>

Retains this already-validated range without allocating or copying.

Source§

impl View<'_, Shared<'_>>

Source

pub fn try_own(self) -> Result<Option<Shared>, Error>

Retains this validated range when its existing owner is independent. A scoped owner returns None without retaining or copying its bytes.

Source§

impl<'d> View<'_, Shared<Option<Account<'d>>>>

Source

pub fn try_retain(self) -> Result<Shared<Option<Account<'d>>>, Error>

Retains the proved extent using its existing registration, without admission.

Trait Implementations§

Source§

impl<S: ?Sized> AsRef<[u8]> for View<'_, S>

Source§

fn as_ref(&self) -> &[u8] ⓘ

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<S: ?Sized> Clone for View<'_, S>

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<S: ?Sized> Consume for View<'_, S>

Source§

fn consume<const MAX: u32>(prefix: Consumed<'_, '_, Self, MAX>)

Source§

impl<S: ?Sized> Consume for View<'_, S>

Source§

fn remaining(&self) -> usize

Source§

fn try_consume(&mut self, amount: usize) -> Result<(), Error>

Source§

fn consume_max(&mut self, max: usize) -> usize

Source§

impl<S: ?Sized> Copy for View<'_, S>

Source§

impl<'input, S: ?Sized> Read<'input> for View<'input, S>

Source§

fn as_slice(&self) -> &'input [u8] ⓘ

Source§

fn try_split<const N: usize>(self) -> Result<(&'input [u8; N], Self), Error>

Source§

impl<S: ?Sized> Store for View<'_, S>

Source§

fn empty() -> Option<Self>

Returns a canonical empty owner, or None to restrict the current owner according to its own empty-storage policy. A returned owner must expose no bytes and require no allocation.
Source§

fn restrict(slice: Slice<'_, '_, Self>)

Applies the selected extent. Nonempty selections must retain their original backing; empty selections preserve this owner’s empty-storage policy.
Source§

fn advance<const MAX: u32>(prefix: Consumed<'_, '_, Self, MAX>)

Source§

fn advance_max(&mut self, max: usize) -> usize
where Self: Source,

Source§

fn project(slice: Slice<'_, '_, Self>)

Auto Trait Implementations§

§

impl<'source, S> Forget for View<'source, S>
where S: ?Sized,

§

impl<'source, S> Freeze for View<'source, S>
where &'source S: Freeze, S: ?Sized,

§

impl<'source, S> RefUnwindSafe for View<'source, S>

§

impl<'source, S> Send for View<'source, S>
where &'source S: Send, S: ?Sized,

§

impl<'source, S> Sync for View<'source, S>
where &'source S: Sync, S: ?Sized,

§

impl<'source, S> Unpin for View<'source, S>
where &'source S: Unpin, S: ?Sized,

§

impl<'source, S> UnsafeUnpin for View<'source, S>

§

impl<'source, S> UnwindSafe for View<'source, S>

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

Source§

fn into(self) -> T

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> Source for T
where T: Consume,

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 = !

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.