Expand description
serialization library built with a combinator design similar to nom.
Serializers are built up from single purpose serializers, like slice
to write a raw byte slice, or be_u16
to write a u16
integer in big
endian form.
Those small serializers can then be assembled by using combinators.
As an example, all(["abcd", "efgh", "ijkl"].iter().map(string))(output)
will write "abcdefghijkl"
to output
.
Modules§
- async_
bufwriter - bytes
- bytes and numbers related serialization functions
- combinator
- basic serializers
- gen
- legacy serializers, kept for backwards compatibility from previous cookie factory versions
- lib
- lib module necessary to reexport what we need from std in
no_std
mode - multi
- serializers working on a list of elements (vectors, iterators, etc)
- sequence
- serializers working a sequence of objects (pairs, tuples, etc)
Macros§
- do_gen
- Applies sub-generators in a sequence.
- gen_
align gen_align!(I, u8) => I -> Result<I,E>
Align the output buffer to the next multiple of specified value.- gen_
at_ offset gen_at_offset!(usize, I -> Result<I,E>) => I -> Result<I,E>
Combinator to call generator at an absolute offset.- gen_
at_ rel_ offset gen_at_offset!(usize, I -> Result<I,E>) => I -> Result<I,E>
Combinator to call generator at a relative offset.- gen_
be_ f32 gen_be_f32!(I, f32) => I -> Result<I,E>
Write a 4 byte float.- gen_
be_ f64 gen_be_f64!(I, f64) => I -> Result<I,E>
Write a 8 byte float.- gen_
be_ i8 gen_be_i8!(I, i8) => I -> Result<I,E>
Write a signed 1 byte integer.- gen_
be_ i16 gen_be_i16!(I, i16) => I -> Result<I,E>
Write a signed 2 byte integer.- gen_
be_ i24 gen_be_i24!(I, i24) => I -> Result<I,E>
Write a signed 3 byte integer.- gen_
be_ i32 gen_be_i32!(I, i32) => I -> Result<I,E>
Write a signed 4 byte integer.- gen_
be_ i64 gen_be_i64!(I, i64) => I -> Result<I,E>
Write a signed 8 byte integer.- gen_
be_ u8 gen_be_u8!(I, u8) => I -> Result<I,E>
Write an unsigned 1 byte integer.- gen_
be_ u16 gen_be_u16!(I, u8) => I -> Result<I,E>
Write an unsigned 2 bytes integer (using big-endian order).- gen_
be_ u24 gen_be_u24!(I, u8) => I -> Result<I,E>
Write an unsigned 3 bytes integer (using big-endian order).- gen_
be_ u32 gen_be_u32!(I, u8) => I -> Result<I,E>
Write an unsigned 4 bytes integer (using big-endian order).- gen_
be_ u64 gen_be_u64!(I, u8) => I -> Result<I,E>
Write an unsigned 8 bytes integer (using big-endian order).- gen_
call - Used to wrap common expressions and function as macros
- gen_
cond gen_cond!(bool, I -> Result<I,E>) => I -> Result<I,E>
Conditional combinator- gen_
copy gen_copy!(I, &[u8], u8) => I -> Result<I,E>
Writes a slice, copying only the specified number of bytes to the output buffer.- gen_
if_ else gen_if_else!(bool, I -> Result<I,E>, I -> Result<I,E>) => I -> Result<I,E>
Conditional combinator, with alternate generator.- gen_
le_ f32 gen_le_f32!(I, f32) => I -> Result<I,E>
Write a 4 byte float.- gen_
le_ f64 gen_le_f64!(I, f64) => I -> Result<I,E>
Write a 8 byte float.- gen_
le_ i8 gen_le_i8!(I, i8) => I -> Result<I,E>
Write a signed 1 byte integer.- gen_
le_ i16 gen_le_i16!(I, i16) => I -> Result<I,E>
Write a signed 2 byte integer.- gen_
le_ i24 gen_le_i24!(I, i24) => I -> Result<I,E>
Write a signed 3 byte integer.- gen_
le_ i32 gen_le_i32!(I, i32) => I -> Result<I,E>
Write a signed 4 byte integer.- gen_
le_ i64 gen_le_i64!(I, i64) => I -> Result<I,E>
Write a signed 8 byte integer.- gen_
le_ u8 gen_le_u8!(I, u8) => I -> Result<I,E>
Write an unsigned 1 byte integer.- gen_
le_ u16 gen_le_u16!(I, u8) => I -> Result<I,E>
Write an unsigned 2 bytes integer (using little-endian order).- gen_
le_ u24 gen_le_u24!(I, u8) => I -> Result<I,E>
Write an unsigned 3 bytes integer (using little-endian order).- gen_
le_ u32 gen_le_u32!(I, u8) => I -> Result<I,E>
Write an unsigned 4 bytes integer (using little-endian order).- gen_
le_ u64 gen_le_u64!(I, u8) => I -> Result<I,E>
Write an unsigned 8 bytes integer (using little-endian order).- gen_
length_ slice - gen_
many gen_many!(I, Iterable<V>, Fn(I,V)) => I -> Result<I,E>
Applies the generator$f
to every element of$l
, passing arguments by value.- gen_
many_ byref gen_many_byref!(I, Iterable<V>, Fn(I,V)) => I -> Result<I,E>
Applies the generator$f
to every element of$l
, where arguments of $l are references- gen_
many_ ref gen_many_ref!(I, Iterable<V>, Fn(I,V)) => I -> Result<I,E>
Applies the generator$f
to every element of$l
, passing arguments by reference.- gen_
skip gen_skip!(I, u8) => I -> Result<I,E>
Skip the specified number of bytes.- gen_
slice gen_slice!(I, &[u8]) => I -> Result<I,E>
Writes a slice, copying it entirely to the output buffer.
Structs§
- Write
Context - Context around a
Write
impl that is passed through serializing functions
Enums§
- GenError
- Base type for generator errors
Traits§
- Back
ToThe Buffer - Trait for
Write
types that allow skipping and reserving a slice, then writing some data, then write something in the slice we reserved using the return for our data write. - Seek
- Trait for
Seek
types that want to automatically implementBackToTheBuffer
- Serialize
Fn - Trait for serializing functions
- Skip
- Trait for
Write
types that allow skipping over the data
Functions§
- gen
- Runs the given serializer
f
with theWrite
implw
and returns the result - gen_
simple - Runs the given serializer
f
with theWrite
implw
and returns the updatedw
Type Aliases§
- GenResult
- Holds the result of serializing functions