Struct bitbuffer::BitWriteStream [−][src]
pub struct BitWriteStream<'a, E> where
E: Endianness, { /* fields omitted */ }
Expand description
Stream that provides an a way to write non bit aligned adata
Examples
use bitbuffer::{BitWriteStream, LittleEndian}; let mut data = Vec::new(); let mut stream = BitWriteStream::new(&mut data, LittleEndian); stream.write_bool(false)?; stream.write_int(123u16, 15)?;
Implementations
Write a boolean into the buffer
Examples
let mut data = Vec::new(); let mut stream = BitWriteStream::new(&mut data, LittleEndian); stream.write_bool(true)?;
Write an integer into the buffer
Examples
let mut data = Vec::new(); let mut stream = BitWriteStream::new(&mut data, LittleEndian); stream.write_int(123u16, 15)?;
pub fn write_float<T>(&mut self, value: T) -> Result<()> where
T: Float + UncheckedPrimitiveFloat,
pub fn write_float<T>(&mut self, value: T) -> Result<()> where
T: Float + UncheckedPrimitiveFloat,
Write a float into the buffer
Examples
let mut data = Vec::new(); let mut stream = BitWriteStream::new(&mut data, LittleEndian); stream.write_float(123.15f32)?;
Write a number of bytes into the buffer
Examples
let mut data = Vec::new(); let mut stream = BitWriteStream::new(&mut data, LittleEndian); stream.write_bytes(&[0, 1, 2 ,3])?;
Write bits from a read stream into the buffer
Write a string into the buffer
Examples
let mut data = Vec::new(); let mut stream = BitWriteStream::new(&mut data, LittleEndian); stream.write_string("zero terminated string", None)?; stream.write_string("fixed size string, zero padded", Some(64))?;
Write the type to stream
Write the length of a section before the section
Write the length in bytes of a section before the section, the section will be 0 padded to an even byte length