Struct untrusted::Input[][src]

pub struct Input<'a> { /* fields omitted */ }
Expand description

A wrapper around &'a [u8] that helps in writing panic-free code.

No methods of Input will ever panic.

Implementations

impl<'a> Input<'a>[src]

pub const fn from(bytes: &'a [u8]) -> Self[src]

Construct a new Input for the given input bytes.

pub fn is_empty(&self) -> bool[src]

Returns true if the input is empty and false otherwise.

pub fn len(&self) -> usize[src]

Returns the length of the Input.

pub fn read_all<F, R, E>(&self, incomplete_read: E, read: F) -> Result<R, E> where
    F: FnOnce(&mut Reader<'a>) -> Result<R, E>, 
[src]

Calls read with the given input as a Reader, ensuring that read consumed the entire input. If read does not consume the entire input, incomplete_read is returned.

pub fn as_slice_less_safe(&self) -> &'a [u8][src]

Access the input as a slice so it can be processed by functions that are not written using the Input/Reader framework.

Trait Implementations

impl<'a> Clone for Input<'a>[src]

fn clone(&self) -> Input<'a>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a> Debug for Input<'a>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'a> From<&'a [u8]> for Input<'a>[src]

fn from(value: &'a [u8]) -> Self[src]

Performs the conversion.

impl PartialEq<[u8]> for Input<'_>[src]

fn eq(&self, other: &[u8]) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<Input<'_>> for Input<'_>[src]

fn eq(&self, other: &Input<'_>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a> Copy for Input<'a>[src]

impl<'a> Eq for Input<'a>[src]

impl<'a> StructuralEq for Input<'a>[src]

Auto Trait Implementations

impl<'a> Send for Input<'a>

impl<'a> Sync for Input<'a>

impl<'a> Unpin for Input<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.