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
impl ByteBufferMut
Sourcepub fn new() -> ByteBufferMut
pub fn new() -> ByteBufferMut
Creates an empty ByteBufferMut ready for writing.
Sourcepub fn data(self) -> Vec<u8> โ
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.
Sourcepub fn write_bool(&mut self, value: bool)
pub fn write_bool(&mut self, value: bool)
Write a boolean value to the end of the buffer.
Sourcepub fn write_byte(&mut self, value: u8)
pub fn write_byte(&mut self, value: u8)
Write a byte to the end of the buffer.
Sourcepub fn write_bytes(&mut self, value: &[u8])
pub fn write_bytes(&mut self, value: &[u8])
Write a raw byte slice to the end of the buffer.
Sourcepub fn write_var_int(&mut self, value: i32)
pub fn write_var_int(&mut self, value: i32)
Write a variable-length signed 32-bit integer to the end of the buffer.
Sourcepub fn write_var_uint(&mut self, value: u32)
pub fn write_var_uint(&mut self, value: u32)
Write a variable-length unsigned 32-bit integer to the end of the buffer.
Sourcepub fn write_var_float(&mut self, value: f32)
pub fn write_var_float(&mut self, value: f32)
Write a variable-length 32-bit floating-point number to the end of the buffer.
Sourcepub fn write_string(&mut self, value: &str)
pub fn write_string(&mut self, value: &str)
Write a UTF-8 string to the end of the buffer.
Sourcepub fn write_var_int64(&mut self, value: i64)
pub fn write_var_int64(&mut self, value: i64)
Write a variable-length signed 64-bit integer to the end of the buffer.
Sourcepub fn write_var_uint64(&mut self, value: u64)
pub fn write_var_uint64(&mut self, value: u64)
Write a variable-length unsigned 64-bit integer to the end of the buffer.