Expand description
zlo
is a crate for encoding and decoding using a bit-compact
serialization strategy.
§Using Basic Functions
extern crate zlo;
use zlo::{serialize, deserialize, Bounded};
fn main() {
// The object that we will serialize.
let target = Some("hello world".to_string());
// The maximum size of the encoded message.
let limit = Bounded(20);
let encoded: Vec<u8> = serialize(&target, limit).unwrap();
let decoded: Option<String> = deserialize(&encoded[..]).unwrap();
assert_eq!(target, decoded);
}
Structs§
- Bounded
- A SizeLimit that restricts serialized or deserialized messages from exceeding a certain bit length.
- Deserializer
- A Deserializer that reads bytes from a buffer.
- Infinite
- A SizeLimit without a limit! Use this if you don’t care about the size of encoded or decoded messages.
- Serializer
- An Serializer that encodes values directly into a Writer.
Enums§
- Error
- The kind of error that can be produced during a serialization or deserialization.
Traits§
- Size
Limit - A limit on the amount of bits that can be read or written.
Functions§
- deserialize
- Deserializes a slice of bytes into an object.
- deserialize_
from - Deserializes an object directly from a
Buffer
ed Reader. - serialize
- Serializes a serializable object into a
Vec
of bytes. - serialize_
into - Serializes an object directly into a
Writer
. - serialized_
size - Returns the size that an object would be if serialized using zlo.
- serialized_
size_ bounded - Given a maximum size limit, check how large an object would be if it were to be serialized.
Type Aliases§
- Result
- The result of a serialization or deserialization operation.