layline
Binary wire formats as Rust types.
Derive Layout for fixed-size records and Message for variable-length ones.
Fields must cover every bit, or the build fails. Encode fills in counts, lengths
and checksums; decode checks them.
[]
= "0.1"
Layouts
use Layout;
let header = decode;
assert_eq!;
assert_eq!;
A layout of up to 64 bits is shifts and masks on one integer. At 8, 16, 32 or 64 bits it also
converts to and from that integer: Header::from_bits(0x1A05) is the header above, read
big-endian. Add truncate to #[layout(..)] to have encode keep the low bits of an oversized
value, as a hardware register does, instead of panicking.
Messages
use Message;
use Crc;
type Crc16 = ;
let frame = Frame ;
let wire = frame.encode;
assert_eq!;
let = decode.unwrap;
assert_eq!;
Switches
use ;
let = decode.unwrap;
assert_eq!;
Every attribute is documented on its derive.
Features
| Feature | Enables | Default |
|---|---|---|
derive |
The derive macros | Yes |
alloc |
Vec, String and Box fields |
Yes |
frame |
Stream framing | No |
num |
LEB128, Exp-Golomb and reserved values | No |
serde |
Serialize for U, I and Reserved |
No |
Crates
layline-core: theno_stdruntime, with no dependencies.layline-derive: the derive macros.layline-codegen: generates Rust source from a model, for formats defined outside Rust.
License
MPL-2.0