BorrowedBytes

Struct BorrowedBytes 

Source
pub struct BorrowedBytes<'a> { /* private fields */ }
Expand description

Input wrapping a borrowed [[u8]] buffer.

Implementations§

Source§

impl<'a> BorrowedBytes<'a>

Source

pub fn new(bytes: &'a [u8]) -> Self

Create a new instance of BorrowedBytes wrapping the given buffer.

The input will be automatically padded internally, incurring at most two times MAX_BLOCK_SIZE of memory overhead.

Trait Implementations§

Source§

impl<'a> From<&'a [u8]> for BorrowedBytes<'a>

Source§

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

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for BorrowedBytes<'a>

Source§

fn from(value: &'a str) -> Self

Converts to this type from the input type.
Source§

impl Input for BorrowedBytes<'_>

Source§

type BlockIterator<'b, 'r, R, const N: usize> = BorrowedBytesBlockIterator<'r, TwoSidesPaddedInput<'b>, R, N> where Self: 'b, R: InputRecorder<&'b [u8]> + 'r

Type of the iterator used by iter_blocks, parameterized by the lifetime of source input and the size of the block.
Source§

type Error = Infallible

Type of errors that can occur when operating on this Input.
Source§

type Block<'b, const N: usize> = &'b [u8] where Self: 'b

Type of the blocks returned by the BlockIterator.
Source§

fn leading_padding_len(&self) -> usize

Return the length of the padding added at the start of the input. Read more
Source§

fn trailing_padding_len(&self) -> usize

Return the length of the padding added at the end of the input. Read more
Source§

fn len_hint(&self) -> Option<usize>

Return the length of the entire input, if known. Read more
Source§

fn iter_blocks<'b, 'r, R, const N: usize>( &'b self, recorder: &'r R, ) -> Self::BlockIterator<'b, 'r, R, N>
where R: InputRecorder<&'b [u8]>,

Iterate over blocks of size N of the input. N has to be a power of two larger than 1.
Source§

fn seek_backward(&self, from: usize, needle: u8) -> Option<usize>

Search for an occurrence of needle in the input, starting from from and looking back. Returns the index of the first occurrence or None if the needle was not found.
Source§

fn seek_forward<const N: usize>( &self, from: usize, needles: [u8; N], ) -> Result<Option<(usize, u8)>, Infallible>

Search for an occurrence of any of the needles in the input, starting from from and looking forward. Returns the index of the first occurrence and the needle found, or None if none of the needles were not found. Read more
Source§

fn seek_non_whitespace_forward( &self, from: usize, ) -> Result<Option<(usize, u8)>, Infallible>

Search for the first byte in the input that is not ASCII whitespace starting from from. Returns a pair: the index of first such byte, and the byte itself; or None if no non-whitespace characters were found. Read more
Source§

fn seek_non_whitespace_backward(&self, from: usize) -> Option<(usize, u8)>

Search for the first byte in the input that is not ASCII whitespace starting from from and looking back. Returns a pair: the index of first such byte, and the byte itself; or None if no non-whitespace characters were found.
Source§

fn is_member_match( &self, from: usize, to: usize, member: &StringPattern, ) -> Result<bool, Self::Error>

Decide whether the slice of input between from (inclusive) and to (exclusive) matches the member (comparing bitwise, including double quotes delimiters). Read more

Auto Trait Implementations§

§

impl<'a> Freeze for BorrowedBytes<'a>

§

impl<'a> RefUnwindSafe for BorrowedBytes<'a>

§

impl<'a> Send for BorrowedBytes<'a>

§

impl<'a> Sync for BorrowedBytes<'a>

§

impl<'a> Unpin for BorrowedBytes<'a>

§

impl<'a> UnwindSafe for BorrowedBytes<'a>

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, 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.