Expand description
Combinators for composing encodables.
This module contains a number of combinators that can be used to compose encodables. The objective is to provide a set of building blocks that can be combined to create more complex encodables that can be encoded into byte sequences.
§Available encodables
§Basic encodables
| Type | Description |
|---|---|
(...) | Encodes all encodables in sequence |
| i8, u8 | Encodes a single byte |
char | Encodes the character as a UTF-8 byte sequence |
&str | Encodes a string as a UTF-8 byte sequence |
&CStr | Encodes a string as a byte sequence with a null terminator (\0) |
&[u8] | Encodes a slice of bytes |
Arguments(format_args!) | Runs core::fmt machinery and encodes the result, without allocations |
§Encodable combinators
| Type | Description |
|---|---|
Option | Encodes T if Some, or does nothing on None |
Result | Encodes T if Ok, or bubbles up E on Err |
Cond | Conditionally encodes an encodable if the given predicate is true |
Flags | Encodes a set of bit flags as a byte |
LE | Encodes a number in little-endian order. |
BE | Encodes a number in big-endian order. |
Separated | Encodes a sequence of encodables separated by a delimiter. |
LengthPrefix | Encodes a value after its size. |
Iter | Encodes an iterator of encodables as a sequence. |
§alloc encodables (requires alloc feature)
Structs§
- BE
- Encodes a number in big-endian order.
- Cond
- Conditionally encodes an encodable.
- Flags
- A combinator that encodes a sequence of flags as a single byte.
- From
Error - A combinator that transforms the error type of an encodable.
- Iter
- A combinator that encodes an iterator of encodables as a sequence.
- LE
- Encodes a number in little-endian order.
- Length
Prefix - Encodes a length prefixed value (TLV).
- Separated
- A combinator that encodes an iterator of encodables as a sequence with separators.