Struct rustls::internal::msgs::codec::Reader

source ·
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§

source§

impl<'a> Reader<'a>

source

pub fn init(bytes: &[u8]) -> Reader<'_>

Creates a new Reader of the provided bytes slice with the initial cursor position of zero.

source

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

source

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.

source

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.

source

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)

source

pub fn used(&self) -> usize

Returns the cursor position which is also the number of bytes that have been read from the buffer.

source

pub fn left(&self) -> usize

Returns the number of bytes that are still able to be read (The number of remaining takes)

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.