Expand description
Combinators for composing binary data formats.
Each format implements only the specification, proof, and executable traits
that its semantics justify. In particular, deliberately malleable formats
such as Alt and the permutation combinators do not claim
NonMalleable. See the
combinator guide
for the overall construction model.
§Primitive combinators
| Combinator | Description |
|---|---|
Fixed<N> | Exactly N bytes |
Varied<Len> | Variable-length bytes determined by a length parameter |
U8 | Unsigned 8-bit integer |
I8 | Signed 8-bit integer |
U16Le / U16Be | Unsigned 16-bit integer (little/big-endian) |
I16Le / I16Be | Signed 16-bit integer (little/big-endian) |
U24Le / U24Be | Unsigned 24-bit integer represented as u32 (little/big-endian) |
U32Le / U32Be | Unsigned 32-bit integer (little/big-endian) |
I32Le / I32Be | Signed 32-bit integer (little/big-endian) |
U64Le / U64Be | Unsigned 64-bit integer (little/big-endian) |
I64Le / I64Be | Signed 64-bit integer (little/big-endian) |
§Higher-order combinators
| Combinator | Description |
|---|---|
Pair<A, B> | Sequential composition |
Choice<A, B> | Non-malleable ordered alternative |
Alt<A, B> | Malleable ordered alternative |
Opt<A> | Optional value |
Optional<A, B> | Same as Pair(Opt<A>, B), but disambiguates A and B |
Star<A> | The Kleene star: zero-or-more repetitions |
Repeat<A, B> | Same as Pair(Star<A>, B), but disambiguates A and B |
RepeatN<C, Len> | Fixed number of repetitions determined by a length parameter |
Array<N, C> | Array of values of length N |
Preceded<A, AVal, B> | Same as Pair(A, B), but discards A’s value and uses a_val as its serialization witness |
Terminated<A, B, BVal> | Same as Pair(A, B), but discards B’s value and uses b_val as its serialization witness |
Permute2<P1, P2> | Accepts either order of two components, serializes the declared order (malleable) |
Permute3<A, B, C> | Accepts any of the 6 orders of three components (malleable) |
Permute4<A, B, C, D> | Accepts any of the 24 orders of four components (malleable) |
Permute5<A, B, C, D, E> | Accepts any of the 120 orders of five components (malleable) |
Mapped<Inner, M> | Isomorphic format transformation via a bijection |
TryMap<Inner, M> | Mapped plus a parse-time wf_in check |
Refined<Inner, Pred> | Format refinement via a predicate |
Const<Inner, T> | Matches and returns a specific constant value |
PrefixTagged<Tg, T, Of> | A format preceded by a tag value |
SuffixTagged<Of, Tg, T> | A format followed by a tag value |
Cond<Inner> | Boolean-gated combinator (most often used in branches of Choice / Alt) |
Named<Inner> | Like Inner, but annotates runtime parse errors with a static format name |
§Dependent combinators
| Combinator | Description |
|---|---|
Bind<A, B> | Like Pair<A, B>, but B can depend on A’s value |
§Tail combinators
| Combinator | Description |
|---|---|
Tail | Like Varied, but at the tail position (underspecify the format and allow trailing data) |
Eof | Signals end-of-file (no trailing data) |
OptionalEnd<C> | Same as Optional<C, Eof> (for convenience) |
RepeatTillEnd<C> | Same as Repeat<C, Eof> (for convenience) |
§Marker combinators
| Combinator | Description |
|---|---|
Empty | Unit (nothing interesting, but still occupies zero bytes) |
Void | Bottom (no value can satisfy this format) |
§Recursive combinators
| Combinator | Description |
|---|---|
FixWith<LIMIT, Body, Param> | Bounded fixpoint for recursive formats; use Param = () for context-free recursion |
Re-exports§
pub use bits::Bits;pub use bytes::AndThen;pub use bytes::ExactLen;pub use bytes::Fixed;pub use bytes::Varied;pub use choice::Alt;pub use choice::Choice;pub use choice::Dispatch;pub use choice::Sum;pub use cond::Cond;pub use implicit::Implicit;pub use length::AsLen;pub use mapped::Mapped;pub use mapped::TryMap;pub use marker::exec::ExecNever;pub use marker::Empty;pub use marker::Void;pub use named::Named;pub use opt::Opt;pub use opt::Optional;pub use permute::Permute2;pub use permute::Permute3;pub use permute::Permute4;pub use permute::Permute5;pub use preceded::Preceded;pub use recursive::FixWith;pub use reference::Ref;pub use refined::Const;pub use refined::PrefixTagged;pub use refined::Refined;pub use refined::SuffixTagged;pub use sints::I16Be;pub use sints::I16Le;pub use sints::I32Be;pub use sints::I32Le;pub use sints::I64Be;pub use sints::I64Le;pub use sints::I8;pub use star::Array;pub use star::Repeat;pub use star::RepeatN;pub use star::Star;pub use tail::Eof;pub use tail::OptionalEnd;pub use tail::RepeatTillEnd;pub use tail::Tail;pub use terminated::Terminated;pub use tuple::Bind;pub use tuple::Pair;pub use uints::U16Be;pub use uints::U16Le;pub use uints::U24Be;pub use uints::U24Le;pub use uints::U32Be;pub use uints::U32Le;pub use uints::U64Be;pub use uints::U64Le;pub use uints::U8;
Modules§
- bits
- Byte-aligned bitfield specification and proof combinator.
- bytes
- Fixed- and value-dependent byte sequence combinators.
- choice
- Alternative formats and their ambiguity conditions.
- cond
- Conditional format controlled by a boolean flag.
- congruence
- Congruence lemmas for parser, serializer, and preparation specifications.
- disjoint
- Broadcast lemmas establishing
disjoint_domainsfor common combinator compositions. - implicit
- Dependent sequencing that omits a parsed header from the public value.
- length
- The length abstraction
AsLenfor types usable as format length (or count) fields. - mapped
- Semantic type transformations over structural combinator values.
- marker
- Marker combinators for empty and impossible wire languages.
- named
- Name-carrying wrapper for runtime error reporting.
- opt
- Optional values selected by whether a child parser matches.
- permute
- Combinators for parsing permutations of sub-parsers.
- preceded
- Sequential composition that discards a prefix value.
- recursive
- Bounded fixpoint combinator for recursive and mutually recursive formats.
- reference
- Adapter for serializing a value through a shared reference.
- refined
- Predicate refinement and constant-value formats.
- sints
- Fixed-width signed integer combinators.
- star
- Repetition into vectors/sequences.
- tail
- Formats that consume the remaining input.
- terminated
- Sequential composition that discards a suffix value.
- tuple
- Sequential and dependent composition.
- uints
- Fixed-width unsigned integer combinators.