Struct DecoderBufferMut

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

A BPF-aware version of s2n_codec::DecoderBufferMut

The Linux BPF verifier requires that every pointer be checked against the end pointer. This means that it struggles with regular Rust slices that use ptr + len instead of ptr + end.

Implementations§

Source§

impl<'a> DecoderBufferMut<'a>

Source

pub unsafe fn new(start: *mut u8, end: *mut u8) -> Self

Creates a new DecoderBufferMut.

§Safety

The start and end pointers must be a valid range of bytes, ideally directly coming from the BPF/XDP context argument.

Source

pub fn decode<T: DecoderValueMut<'a>>(self) -> Result<(T, Self), DecoderError>

Decodes a T from the buffer, if possible

Source

pub fn decode_slice(self, len: usize) -> Result<(Self, Self), DecoderError>

Decodes a slice of bytes with the given len, if possible

Source

pub fn into_less_safe_slice(self) -> &'a mut [u8]

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl<'a> Decoder<'a> for DecoderBufferMut<'a>

Source§

fn decode<T: DecoderValue<'a> + DecoderValueMut<'a>>( self, ) -> Result<(T, Self), DecoderError>

Source§

fn decode_slice(self, len: usize) -> Result<(Self, Self), DecoderError>

Auto Trait Implementations§

§

impl<'a> Freeze for DecoderBufferMut<'a>

§

impl<'a> RefUnwindSafe for DecoderBufferMut<'a>

§

impl<'a> !Send for DecoderBufferMut<'a>

§

impl<'a> !Sync for DecoderBufferMut<'a>

§

impl<'a> Unpin for DecoderBufferMut<'a>

§

impl<'a> !UnwindSafe for DecoderBufferMut<'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.
Source§

impl<T, U> Upcast<T> for U
where T: UpcastFrom<U>,

Source§

fn upcast(self) -> T

Source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

Source§

fn upcast_from(value: Counter<T, B>) -> T