OctetsPtr

Struct OctetsPtr 

Source
pub struct OctetsPtr(/* private fields */);
Expand description

A (safe) raw pointer to an pinned Octets.

Methods from Deref<Target = Octets<'static>>§

Source

pub fn get_u8(&mut self) -> Result<u8>

Reads an unsigned 8-bit integer from the current offset and advances the buffer.

Source

pub fn peek_u8(&mut self) -> Result<u8>

Reads an unsigned 8-bit integer from the current offset without advancing the buffer.

Source

pub fn get_u16(&mut self) -> Result<u16>

Reads an unsigned 16-bit integer in network byte-order from the current offset and advances the buffer.

Source

pub fn get_u24(&mut self) -> Result<u32>

Reads an unsigned 24-bit integer in network byte-order from the current offset and advances the buffer.

Source

pub fn get_u32(&mut self) -> Result<u32>

Reads an unsigned 32-bit integer in network byte-order from the current offset and advances the buffer.

Source

pub fn get_u64(&mut self) -> Result<u64>

Reads an unsigned 64-bit integer in network byte-order from the current offset and advances the buffer.

Source

pub fn get_varint(&mut self) -> Result<u64>

Reads an unsigned variable-length integer in network byte-order from the current offset and advances the buffer.

Source

pub fn get_bytes(&mut self, len: usize) -> Result<Octets<'a>>

Reads len bytes from the current offset without copying and advances the buffer.

Source

pub fn get_bytes_with_u8_length(&mut self) -> Result<Octets<'a>>

Reads len bytes from the current offset without copying and advances the buffer, where len is an unsigned 8-bit integer prefix.

Source

pub fn get_bytes_with_u16_length(&mut self) -> Result<Octets<'a>>

Reads len bytes from the current offset without copying and advances the buffer, where len is an unsigned 16-bit integer prefix in network byte-order.

Source

pub fn get_bytes_with_varint_length(&mut self) -> Result<Octets<'a>>

Reads len bytes from the current offset without copying and advances the buffer, where len is an unsigned variable-length integer prefix in network byte-order.

Source

pub fn peek_bytes(&self, len: usize) -> Result<Octets<'a>>

Reads len bytes from the current offset without copying and without advancing the buffer.

Source

pub fn slice(&'a self, len: usize) -> Result<&'a [u8]>

Returns a slice of len elements from the current offset.

Source

pub fn slice_last(&'a self, len: usize) -> Result<&'a [u8]>

Returns a slice of len elements from the end of the buffer.

Source

pub fn skip(&mut self, skip: usize) -> Result<()>

Advances the buffer’s offset.

Source

pub fn cap(&self) -> usize

Returns the remaining capacity in the buffer.

Source

pub fn len(&self) -> usize

Returns the total length of the buffer.

Source

pub fn is_empty(&self) -> bool

Returns true if the buffer is empty.

Source

pub fn off(&self) -> usize

Returns the current offset of the buffer.

Source

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

Returns a reference to the internal buffer.

Source

pub fn to_vec(&self) -> Vec<u8>

Copies the buffer from the current offset into a new Vec<u8>.

Trait Implementations§

Source§

impl Debug for OctetsPtr

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for OctetsPtr

Source§

type Target = Octets<'static>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for OctetsPtr

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl From<&mut Octets<'_>> for OctetsPtr

Source§

fn from(value: &mut Octets<'_>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.