Struct WriteBuffer

Source
pub struct WriteBuffer { /* private fields */ }
Expand description

A buffer for writing codec data

Implementations§

Source§

impl WriteBuffer

Source

pub fn new(capacity: usize) -> Self

Creates a new write buffer

Source

pub fn write_varint(&mut self, value: u64)

Writes a varint-encoded unsigned integer

Source

pub fn len(&self) -> usize

Returns the current length of the buffer

Source

pub fn capacity(&self) -> usize

Returns the total capacity of the buffer

Source

pub fn remaining_mut(&mut self) -> usize

Source

pub fn is_empty(&self) -> bool

Checks if the buffer is empty

Source

pub fn freeze(self) -> Bytes

Freezes the buffer and returns the bytes

Source

pub fn clear(&mut self)

Resets the buffer

Source

pub fn put_u8(&mut self, v: u8)

Source

pub fn put_u16(&mut self, v: u16)

Source

pub fn put_u32(&mut self, v: u32)

Source

pub fn put_u64(&mut self, v: u64)

Source

pub fn put_u128(&mut self, v: u128)

Source

pub fn put_i8(&mut self, v: i8)

Source

pub fn put_i16(&mut self, v: i16)

Source

pub fn put_i32(&mut self, v: i32)

Source

pub fn put_i64(&mut self, v: i64)

Source

pub fn put_i128(&mut self, v: i128)

Source

pub fn put_f32(&mut self, v: f32)

Source

pub fn put_f64(&mut self, v: f64)

Source

pub fn put_slice(&mut self, src: &[u8])

Trait Implementations§

Source§

impl AsRef<[u8]> for WriteBuffer

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for WriteBuffer

Source§

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

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

impl From<WriteBuffer> for Bytes

Source§

fn from(buffer: WriteBuffer) -> Self

Converts to this type from the input type.
Source§

impl From<WriteBuffer> for Vec<u8>

Source§

fn from(buffer: WriteBuffer) -> Self

Converts to this type from the input type.
Source§

impl Writer for WriteBuffer

Source§

fn write<T: Codec>(&mut self, value: &T)

Writes a value of type T
Source§

fn write_u8(&mut self, value: u8)

Writes a u8 value
Source§

fn write_u16(&mut self, value: u16)

Writes a u16 value
Source§

fn write_u32(&mut self, value: u32)

Writes a u32 value
Source§

fn write_u64(&mut self, value: u64)

Writes a u64 value
Source§

fn write_u128(&mut self, value: u128)

Writes a u128 value
Source§

fn write_i8(&mut self, value: i8)

Writes a i8 value
Source§

fn write_i16(&mut self, value: i16)

Writes a i16 value
Source§

fn write_i32(&mut self, value: i32)

Writes a i32 value
Source§

fn write_i64(&mut self, value: i64)

Writes a i64 value
Source§

fn write_i128(&mut self, value: i128)

Writes a i128 value
Source§

fn write_f32(&mut self, value: f32)

Writes a f32 value
Source§

fn write_f64(&mut self, value: f64)

Writes a f64 value
Source§

fn write_varint(&mut self, value: u64)

Writes a varint-encoded integer
Source§

fn write_bytes(&mut self, bytes: &[u8])

Writes bytes with a length prefix
Source§

fn write_fixed(&mut self, bytes: &[u8])

Writes a fixed-size byte array
Source§

fn write_bool(&mut self, value: bool)

Writes a boolean value
Source§

fn write_option<T: Codec>(&mut self, value: &Option<T>)

Writes an option value
Source§

fn write_vec<T: Codec>(&mut self, values: &[T])

Writes a vector with a length prefix

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