Skip to main content

SliceScopedUnchecked

Struct SliceScopedUnchecked 

Source
pub struct SliceScopedUnchecked<'a, 'b, T> { /* private fields */ }
Expand description

Implementation of Reader over a slice that does not perform any bounds checks.

This implementation inherits the lifetime of its lexical scope, and can be used for non-borrowing Reader implementations.

Implementations§

Source§

impl<'b, T> SliceScopedUnchecked<'_, 'b, T>

Source

pub const unsafe fn new(buf: &'b [T]) -> Self

Create a new SliceScopedUnchecked from the given slice.

§Safety

SliceScopedUnchecked’s implementation of Reader will not perform any bounds checks on the slice. It is up to the caller to ensure that any Reader operations performed are within the bounds of the slice.

Trait Implementations§

Source§

impl<'a> Reader<'a> for SliceScopedUnchecked<'a, '_, u8>

Source§

const BORROW_KINDS: u8

Borrow capabilities of this reader. Read more
Source§

fn copy_into_slice(&mut self, dst: &mut [u8]) -> ReadResult<()>

Attempts to copy and consume exactly dst.len() bytes. Read more
Source§

fn copy_into_uninit_slice( &mut self, dst: &mut [MaybeUninit<u8>], ) -> ReadResult<()>

Attempts to copy and consume exactly dst.len() bytes into potentially uninitialized storage. Read more
Source§

fn take_array<const N: usize>(&mut self) -> ReadResult<[u8; N]>

Return exactly N bytes as [u8; N] and advance by N. Read more
Source§

fn take_scoped(&mut self, len: usize) -> ReadResult<&[u8]>

Return a call-site scoped slice of exactly len bytes and advance by len. Read more
Source§

fn supports_borrow(&self, kind: BorrowKind) -> bool

Checks if this reader supports the given borrow kind. Read more
Source§

fn take_byte(&mut self) -> ReadResult<u8>

Return the next byte and advance by 1. Read more
Source§

fn take_borrowed(&mut self, len: usize) -> ReadResult<&'a [u8]>

Return a borrowed slice of exactly len bytes and advance the reader by len. Read more
Source§

fn take_borrowed_mut(&mut self, len: usize) -> ReadResult<&'a mut [u8]>

Return a mutably borrowed slice of exactly len bytes and advance the reader by len. Read more
Source§

unsafe fn as_trusted_for( &mut self, n_bytes: usize, ) -> ReadResult<impl Reader<'a>>

Advance the parent by n_bytes and return a Reader that can elide bounds checks within that n_bytes window. Read more
Source§

unsafe fn as_trusted_for_seq( &mut self, len: usize, size: usize, ) -> Result<impl Reader<'a>, ReadError>

Construct a trusted window for a sequence of length len and serialized element size size. Read more
Source§

fn by_ref(&mut self) -> impl Reader<'a>

Get a mutable reference to the Reader. Read more
Source§

unsafe fn copy_into_t<T>(&mut self, dst: &mut MaybeUninit<T>) -> ReadResult<()>

Attempts to copy and consume exactly size_of::<T>() bytes from the Reader into dst. Read more
Source§

unsafe fn copy_into_slice_t<T>( &mut self, dst: &mut [MaybeUninit<T>], ) -> ReadResult<()>

Attempts to copy and consume exactly dst.len() * size_of::<T>() bytes from the Reader into dst. Read more

Auto Trait Implementations§

§

impl<'a, 'b, T> Freeze for SliceScopedUnchecked<'a, 'b, T>

§

impl<'a, 'b, T> RefUnwindSafe for SliceScopedUnchecked<'a, 'b, T>

§

impl<'a, 'b, T> Send for SliceScopedUnchecked<'a, 'b, T>
where SliceUnchecked<'b, T>: Send, PhantomData<&'a [T]>: Send,

§

impl<'a, 'b, T> Sync for SliceScopedUnchecked<'a, 'b, T>
where SliceUnchecked<'b, T>: Sync, PhantomData<&'a [T]>: Sync,

§

impl<'a, 'b, T> Unpin for SliceScopedUnchecked<'a, 'b, T>
where SliceUnchecked<'b, T>: Unpin, PhantomData<&'a [T]>: Unpin,

§

impl<'a, 'b, T> UnsafeUnpin for SliceScopedUnchecked<'a, 'b, T>

§

impl<'a, 'b, T> UnwindSafe for SliceScopedUnchecked<'a, 'b, T>

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