Expand description
The on-binary layout shared by every crate in the embark toolkit.
An entry is one embedded file as it appears in the compiled binary: a
header naming how the bytes were transformed, followed by the transformed
bytes themselves. write_entry produces one at build time and
read_header parses one back at runtime; the payload starts at
Header::payload_offset.
§Entry layout
| bytes | meaning |
|---|---|
| 1 | tag: CodecId in the low nibble, CryptoId in the high nibble |
| 1..=10 | original (pre-compression) length, LEB128 varint |
| 12 | AEAD nonce, present only when the crypto id is not CryptoId::None |
| 16 | AEAD tag, present under the same condition |
| rest | payload: compressed, then encrypted, in that order |
Nothing here compresses or encrypts anything. This crate only decides
where the bytes go and what the ids mean, so that embark-codec,
embark-crypt, embark-macros and embark all agree on it without
depending on each other.
§Features
enc compiles the build-time writing half, dec the runtime reading
half. A consumer that only reads embedded files (the common case) needs
dec alone. Both imply alloc; std is the default and additionally
implies alloc.
Structs§
- Header
- The decoded header of one on-binary entry, as returned by
read_header.
Enums§
- CodecId
- Names the compression applied to an entry’s payload.
- Crypto
Id - Names the AEAD cipher an entry’s payload was sealed with, if any.
- Error
- Everything that can go wrong decoding an entry, shared by every crate in the toolkit.
Functions§
- read_
header dec - Parses the header at the front of
entry. - read_
varint - Reads one unsigned LEB128 varint from the front of
input, returning the value and how many bytes it occupied. - write_
entry enc - Appends one complete entry – header followed by
payload– toout. - write_
header enc - Appends the part of the header every entry has – the tag byte and the
length varint – to
out. - write_
varint alloc - Appends
valuetooutas an unsigned LEB128 varint: seven bits of payload per byte, little-endian, with the high bit set on every byte but the last.