Crate zlo

Source
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§

SizeLimit
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 Buffered 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.