pub struct ByteBufferMut { /* private fields */ }
Expand description

A Kiwi byte buffer meant for writing.

Example usage:

let mut bb = kiwi_schema::ByteBufferMut::new();
bb.write_string("🍕");
bb.write_var_float(123.456);
assert_eq!(bb.data(), [240, 159, 141, 149, 0, 133, 242, 210, 237]);

Implementations§

source§

impl ByteBufferMut

source

pub fn new() -> ByteBufferMut

Creates an empty ByteBufferMut ready for writing.

source

pub fn data(self) -> Vec<u8>

Consumes this buffer and returns the underlying backing store. Use this to get the data out when you’re done writing to the buffer.

source

pub fn len(&self) -> usize

Returns the number of bytes written so far.

source

pub fn write_bool(&mut self, value: bool)

Write a boolean value to the end of the buffer.

source

pub fn write_byte(&mut self, value: u8)

Write a byte to the end of the buffer.

source

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

Write a raw byte slice to the end of the buffer.

source

pub fn write_var_int(&mut self, value: i32)

Write a variable-length signed 32-bit integer to the end of the buffer.

source

pub fn write_var_uint(&mut self, value: u32)

Write a variable-length unsigned 32-bit integer to the end of the buffer.

source

pub fn write_var_float(&mut self, value: f32)

Write a variable-length 32-bit floating-point number to the end of the buffer.

source

pub fn write_string(&mut self, value: &str)

Write a UTF-8 string to the end of the buffer.

source

pub fn write_var_int64(&mut self, value: i64)

Write a variable-length signed 64-bit integer to the end of the buffer.

source

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

Write a variable-length unsigned 64-bit integer to the end of the buffer.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.