Struct bcder::decode::BytesSource
source · [−]pub struct BytesSource { /* private fields */ }
Expand description
A source for a bytes value.
Implementations
sourceimpl BytesSource
impl BytesSource
sourcepub fn with_offset(data: Bytes, offset: Pos) -> Self
pub fn with_offset(data: Bytes, offset: Pos) -> Self
Creates a new bytes source with an explicit offset.
When this function is used to create a bytes source, Source::pos
will report a value increates by offset
.
sourcepub fn split_to(&mut self, len: usize) -> Bytes
pub fn split_to(&mut self, len: usize) -> Bytes
Splits the first len
bytes off the source and returns them.
Panics
This method panics of len
is larger than self.len()
.
sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Converts the source into the remaining bytes.
Trait Implementations
sourceimpl Clone for BytesSource
impl Clone for BytesSource
sourcefn clone(&self) -> BytesSource
fn clone(&self) -> BytesSource
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for BytesSource
impl Debug for BytesSource
sourceimpl Source for BytesSource
impl Source for BytesSource
type Error = Infallible
type Error = Infallible
The error produced when the source failed to read more data.
sourcefn request(&mut self, _len: usize) -> Result<usize, Self::Error>
fn request(&mut self, _len: usize) -> Result<usize, Self::Error>
Request at least len
bytes to be available. Read more
sourcefn slice(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
fn slice(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
Returns a bytes slice with the available data. Read more
sourcefn bytes(&self, start: usize, end: usize) -> Bytes
fn bytes(&self, start: usize, end: usize) -> Bytes
Produces a Bytes
value from part of the data. Read more
sourcefn skip(&mut self, len: usize) -> Result<usize, Self::Error>
fn skip(&mut self, len: usize) -> Result<usize, Self::Error>
Skip over the next len
bytes. Read more
sourcefn take_u8(&mut self) -> Result<u8, DecodeError<Self::Error>>
fn take_u8(&mut self) -> Result<u8, DecodeError<Self::Error>>
Takes a single octet from the source. Read more
sourcefn take_opt_u8(&mut self) -> Result<Option<u8>, Self::Error>
fn take_opt_u8(&mut self) -> Result<Option<u8>, Self::Error>
Takes an optional octet from the source. Read more
sourcefn content_err(&self, err: impl Into<ContentError>) -> DecodeError<Self::Error>
fn content_err(&self, err: impl Into<ContentError>) -> DecodeError<Self::Error>
Returns a content error at the current position of the source.
Auto Trait Implementations
impl RefUnwindSafe for BytesSource
impl Send for BytesSource
impl Sync for BytesSource
impl Unpin for BytesSource
impl UnwindSafe for BytesSource
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more