CaptureSource

Struct CaptureSource 

Source
pub struct CaptureSource<'a, S: 'a> { /* private fields */ }
Expand description

A source that captures what has been advanced over.

A capture source wraps a mutable reference to some other source and provides the usual source access. However, instead of dropping octets that have been advanced over, it keeps them around and allows taking them out as a bytes value.

This type is used by Constructed::capture.

Implementations§

Source§

impl<'a, S: Source> CaptureSource<'a, S>

Source

pub fn new(source: &'a mut S) -> Self

Creates a new capture source using a reference to some other source.

Source

pub fn into_bytes(self) -> Bytes

Converts the capture source into the captured bytes.

Source

pub fn skip(self)

Drops the captured bytes.

Advances the underlying source to the end of the captured bytes.

Trait Implementations§

Source§

impl<'a, S: Source + 'a> Source for CaptureSource<'a, S>

Source§

type Error = <S as Source>::Error

The error produced when the source failed to read more data.
Source§

fn pos(&self) -> Pos

Returns the current logical postion within the sequence of data.
Source§

fn request(&mut self, len: usize) -> Result<usize, Self::Error>

Request at least len bytes to be available. Read more
Source§

fn slice(&self) -> &[u8]

Returns a bytes slice with the available data. Read more
Source§

fn bytes(&self, start: usize, end: usize) -> Bytes

Produces a Bytes value from part of the data. Read more
Source§

fn advance(&mut self, len: usize)

Advance the source by len bytes. Read more
Source§

fn skip(&mut self, len: usize) -> Result<usize, Self::Error>

Skip over the next len bytes. Read more
Source§

fn take_u8(&mut self) -> Result<u8, DecodeError<Self::Error>>

Takes a single octet from the source. Read more
Source§

fn take_opt_u8(&mut self) -> Result<Option<u8>, Self::Error>

Takes an optional octet from the source. Read more
Source§

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<'a, S> Freeze for CaptureSource<'a, S>

§

impl<'a, S> RefUnwindSafe for CaptureSource<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for CaptureSource<'a, S>
where S: Send,

§

impl<'a, S> Sync for CaptureSource<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for CaptureSource<'a, S>

§

impl<'a, S> !UnwindSafe for CaptureSource<'a, 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> 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> IntoSource for T
where T: Source,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.