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>
impl<'source, S: ?Sized> View<'source, S>
pub fn as_slice(&self) -> &'source [u8] ⓘ
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn select(&self, bytes: &[u8]) -> Option<View<'source, S>>
pub fn get(&self, range: Range<usize>) -> Option<View<'source, S>>
pub fn try_get(&self, range: Range<usize>) -> Result<Self, Error>
Sourcepub fn new(source: &'source S) -> Self
pub fn new(source: &'source S) -> Self
Borrows the complete initialized source without retaining or copying it.
Source§impl<S: Seal> View<'_, S>
impl<S: Seal> View<'_, S>
Sourcepub fn try_retain(self) -> Result<S, Error>
pub fn try_retain(self) -> Result<S, Error>
Retains this already-validated range without allocating or copying.
Trait Implementations§
impl<S: ?Sized> Copy for View<'_, S>
Source§impl<S: ?Sized> Store for View<'_, S>
impl<S: ?Sized> Store for View<'_, S>
Source§fn empty() -> Option<Self>
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>)
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.
fn advance<const MAX: u32>(prefix: Consumed<'_, '_, Self, MAX>)
fn advance_max(&mut self, max: usize) -> usizewhere
Self: 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>
impl<'source, S> Move for View<'source, S>where
S: ?Sized,
impl<'source, S> RefUnwindSafe for View<'source, S>
impl<'source, S> Send for View<'source, S>
impl<'source, S> Sync for View<'source, S>
impl<'source, S> Unpin for View<'source, S>
impl<'source, S> UnsafeUnpin for View<'source, S>
impl<'source, S> UnwindSafe for View<'source, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more