Expand description
Implements the Preserves machine-oriented binary syntax.
The main entry points for reading are functions iovalue_from_bytes, annotated_iovalue_from_bytes, from_bytes, and annotated_from_bytes.
The main entry points for writing are PackedWriter::encode_iovalue and PackedWriter::encode.
§Summary of Binary Syntax
For a value V
, we write «V»
for the binary encoding of V
.
«#f» = [0x80]
«#t» = [0x81]
«@W V» = [0x85] ++ «W» ++ «V»
«#:V» = [0x86] ++ «V»
«V» if V ∈ Double = [0x87, 0x08] ++ binary64(V)
«V» if V ∈ SignedInteger = [0xB0] ++ varint(|intbytes(V)|) ++ intbytes(V)
«V» if V ∈ String = [0xB1] ++ varint(|utf8(V)|) ++ utf8(V)
«V» if V ∈ ByteString = [0xB2] ++ varint(|V|) ++ V
«V» if V ∈ Symbol = [0xB3] ++ varint(|utf8(V)|) ++ utf8(V)
«<L F_1...F_m>» = [0xB4] ++ «L» ++ «F_1» ++...++ «F_m» ++ [0x84]
«[X_1...X_m]» = [0xB5] ++ «X_1» ++...++ «X_m» ++ [0x84]
«#{E_1...E_m}» = [0xB6] ++ «E_1» ++...++ «E_m» ++ [0x84]
«{K_1:V_1...K_m:V_m}» = [0xB7] ++ «K_1» ++ «V_1» ++...++ «K_m» ++ «V_m» ++ [0x84]
varint(n) = [n] if n < 128
[(n & 127) | 128] ++ varint(n >> 7) if n ≥ 128
intbytes(n) = the empty sequence if n = 0, otherwise signedBigEndian(n)
signedBigEndian(n) = [n & 255] if -128 ≤ n ≤ 127
signedBigEndian(n >> 8) ++ [n & 255] otherwise
The function binary64(D)
yields the big-endian 8-byte IEEE 754 binary representation of D
.
Re-exports§
pub use reader::PackedReader;
pub use writer::PackedWriter;
Modules§
- Definitions of the tags used in the binary encoding.
- Implementation of Reader for the binary encoding.
- Implementation of Writer for the binary encoding.
Functions§
- As from_bytes, but includes annotations.
- As iovalue_from_bytes, but includes annotations.
- Reads a value from the given byte vector
bs
using the binary encoding, discarding annotations. - Reads an IOValue from the given byte vector
bs
using the binary encoding, discarding annotations.