bytebuff-0.1.1 doesn't have any documentation.
This crate is purely for marshalling and unmarshalling a data to send over a network,
main deal is ByteBuff witch is used for serilizing and deserilizing. There is also Marshal
trait that can be derivated on structs.
example
extern crate bytebuff;
use bytebuff::marshall_derive::Marshall;
use bytebuff::Marshall;
use bytebuff::ByteBuff;
#[derive(Marshall)]
struct Point {
x: f32,
y: f32,
}
#[derive(Marshall)]
struct Dummy {
#[marshall(nested)]
position: Point,
name: String,
#[marshall(ignore)]
useless_stuff: i128,
}
fn main() {
let mut buff = ByteBuff::new();
let dummy = Dummy {
useless_stuff: 10,
position: Point { x: 10.0, y: 70.0 },
name: String::from("Mlokogrgel"),
};
dummy.marshall(&mut buff);
let mut buff = ByteBuff::from_bytes(buff.data());
let de_dummy = Dummy::unmarshall(&mut buff).unwrap();
assert_eq!(de_dummy.useless_stuff, Default::default());
assert_eq!(10.0, de_dummy.position.x);
assert_eq!(70.0, de_dummy.position.y);
assert_eq!(String::from("Mlokogrgel"), de_dummy.name);
}