Struct holochain::prelude::dependencies::kitsune_p2p_types::dependencies::rustls::internal::msgs::codec::Reader
pub struct Reader<'a> { /* private fields */ }
Expand description
Wrapper over a slice of bytes that allows reading chunks from with the current position state held using a cursor.
A new reader for a sub section of the the buffer can be created
using the sub
function or a section of a certain length can
be obtained using the take
function
Implementations§
§impl<'a> Reader<'a>
impl<'a> Reader<'a>
pub fn init(bytes: &[u8]) -> Reader<'_>
pub fn init(bytes: &[u8]) -> Reader<'_>
Creates a new Reader of the provided bytes
slice with
the initial cursor position of zero.
pub fn sub(&mut self, length: usize) -> Option<Reader<'_>>
pub fn sub(&mut self, length: usize) -> Option<Reader<'_>>
Attempts to create a new Reader on a sub section of this
readers bytes by taking a slice of the provided length
will return None if there is not enough bytes
pub fn rest(&mut self) -> &[u8] ⓘ
pub fn rest(&mut self) -> &[u8] ⓘ
Borrows a slice of all the remaining bytes that appear after the cursor position.
Moves the cursor to the end of the buffer length.
pub fn take(&mut self, length: usize) -> Option<&[u8]>
pub fn take(&mut self, length: usize) -> Option<&[u8]>
Attempts to borrow a slice of bytes from the current
cursor position of length
if there is not enough
bytes remaining after the cursor to take the length
then None is returned instead.
pub fn any_left(&self) -> bool
pub fn any_left(&self) -> bool
Used to check whether the reader has any content left after the cursor (cursor has not reached end of buffer)
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Reader<'a>
impl<'a> Send for Reader<'a>
impl<'a> Sync for Reader<'a>
impl<'a> Unpin for Reader<'a>
impl<'a> UnwindSafe for Reader<'a>
Blanket Implementations§
§impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.