[−][src]Crate pigeon
A crate for reading/writing from/to byte buffers.
This crate uses big-endian for all numbers.
Usage Example
use { pigeon::{ FrameWriter, FrameReader, FrameTarget, Grab, Dump, ShortStr, }, }; pub struct Animal { pub position: (f32, f32, f32), pub fluffy: bool, pub name: String, pub weight: f32, } impl Dump for Animal { fn dump_to<T: FrameTarget>(&self, writer: &mut FrameWriter<T>) { writer.write(self.position); writer.write(self.fluffy); writer.write(ShortStr(&self.name)); writer.write(self.weight); } } impl<'a> Grab<'a> for Animal { fn grab_from(reader: &mut FrameReader<'a>) -> Option<Self> { let position = reader.read()?; let fluffy = reader.read()?; let ShortStr(name) = reader.read()?; let weight = reader.read()?; Some(Animal { position, fluffy, name: name.to_owned(), weight, }) } }
Structs
FrameReader | A type that can be used to read from a buffer. |
FrameWriter | A type which can be used for writing to a type that implements |
ShortStr | A UTF-8 string that is prefixed with its length, where the length field is a |
Traits
Dump | Types which can get written to a |
FrameTarget | A type which can be written to by a |
Grab | Types which can get read from a |
Functions
dump_to_buffer | Dump the type to a buffer directly. |
grab_from_buffer | Read a type which implement |