1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! 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`.
// docs.rs builds with `--cfg docsrs` (see each manifest's
// `[package.metadata.docs.rs]`), which turns this on and makes rustdoc label
// every item with the feature that gates it. Nearly all of this API is
// behind one, so without the label the rendered docs read as though it were
// all unconditional. Inert on stable, where `docsrs` is never set.
extern crate alloc;
pub use Header;
pub use read_header;
pub use ;
pub use ;
pub use ;
pub use read_varint;
pub use write_varint;