substrate-data 0.3.0

One data model, text syntax, binary form, packed frames and schema system — for any program's files, saves and wire messages.
Documentation
//! A value's first byte: what it is.

/// The tags, each a constant, and [`ALL`] of them by name.
macro_rules! tags {
    ($($(#[$doc:meta])* $name:ident = $value:expr;)*) => {
        $($(#[$doc])* pub const $name: u8 = $value;)*
        /// Every tag, by its name (what other languages' readers are generated from).
        pub const ALL: &[(&str, u8)] = &[$((stringify!($name), $value)),*];
    };
}

tags! {
    /// Null.
    NULL = 0;
    /// `false`.
    FALSE = 1;
    /// `true`.
    TRUE = 2;
    /// An integer, zigzag varint.
    INT = 3;
    /// A float, an `f64` little-endian.
    FLOAT = 4;
    /// A string: new (its bytes) or the table's.
    STR = 5;
    /// A list: a count, then the values.
    LIST = 6;
    /// A map: a count, then key and value pairs.
    MAP = 7;
    /// A reference: its kind and id strings.
    REF = 8;
    /// Bytes: a length, then them.
    BYTES = 9;
    /// A list of ints without a tag each: what a schema of numbers writes its lists as.
    INTS = 10;
    /// A list in a body of its own (its own strings): read lazily, cut out whole ([`crate::Stream`]).
    STREAM = 11;
    /// A float that is an `f32` exactly, 4 bytes.
    FLOAT32 = 12;
    /// Lists of floats without a tag each.
    FLOATS = 13;
    /// Lists of `f32`s without a tag each.
    FLOATS32 = 14;
    /// Version 2: a map whose keys are a shape (listed once, then named by
    /// number): the shape, then one value per key.
    MAP_SHAPE = 15;
    /// Version 2: a list of maps that all have one shape: a count, the
    /// shape, then each map's values with no tag of their own.
    RECORDS = 16;
}

/// Version 2: the first of 128 tags that are an int by themselves,
/// `tag - INT_INLINE + INLINE_INT_MIN` (-16 to 111): no payload.
pub const INT_INLINE: u8 = 128;

/// Version 2: the first of 32 tags that are a string already in the table,
/// by its index `tag - STR_INDEX` (0 to 31): no payload.
pub const STR_INDEX: u8 = 32;