Buffer

Struct Buffer 

Source
pub struct Buffer<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Buffer<'a>

Source

pub fn flatten(&mut self) -> &mut EncoderBuffer<'a>

Ensures an extra bytes are written into the main EncoderBuffer.

Source§

impl<'a> Buffer<'a>

Include a functional implementation when bytes is not available

Source

pub fn new(inner: EncoderBuffer<'a>) -> Buffer<'a>

Source

pub fn new_with_extra( inner: EncoderBuffer<'a>, extra: Option<&'static [u8]>, ) -> Buffer<'a>

Source

pub fn into_inner(self) -> (EncoderBuffer<'a>, Option<&'static [u8]>)

Source

pub fn inner_mut(&mut self) -> (&mut EncoderBuffer<'a>, &Option<&'static [u8]>)

Source

pub fn clear(&mut self)

Trait Implementations§

Source§

impl Encoder for Buffer<'_>

Source§

fn write_sized<F>(&mut self, len: usize, write: F)
where F: FnOnce(&mut [u8]),

Calls write with a slice of len bytes at the current write position
Source§

fn write_slice(&mut self, slice: &[u8])

Copies the slice into the buffer
Source§

fn write_zerocopy<T, F>(&mut self, write: F)

Writes a zerocopy value to the buffer
Source§

fn write_repeated(&mut self, count: usize, value: u8)

Repeatedly write a byte value for a given count Read more
Source§

fn capacity(&self) -> usize

Returns the total buffer capacity
Source§

fn len(&self) -> usize

Returns the number of bytes written to the buffer
Source§

fn encode<T>(&mut self, value: &T)
where T: EncoderValue,

Encode the given EncoderValue into the buffer
Source§

fn encode_with_len_prefix<Len, T>(&mut self, value: &T)
where Len: TryFrom<usize> + EncoderValue, T: EncoderValue, <Len as TryFrom<usize>>::Error: Debug,

Encode the given EncoderValue into the buffer with a prefix of Len
Source§

fn is_empty(&self) -> bool

Returns true if no bytes have been written
Source§

fn remaining_capacity(&self) -> usize

Returns the number of available bytes in the buffer

Auto Trait Implementations§

§

impl<'a> Freeze for Buffer<'a>

§

impl<'a> RefUnwindSafe for Buffer<'a>

§

impl<'a> Send for Buffer<'a>

§

impl<'a> Sync for Buffer<'a>

§

impl<'a> Unpin for Buffer<'a>

§

impl<'a> !UnwindSafe for Buffer<'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