intermodal/crates/data/tests/manifest.rs
Casey Rodarmor 173c0e5ac5
Initial commit of the data crate
The `data` crate is intended to be used as the manifest serialization
and deserialization format.

This blog post describes the motivation and goals for this crate:

    https://rodarmor.com/blog/data

type: added
2020-05-10 21:38:59 -07:00

49 lines
746 B
Rust

#[cfg(aspirational)]
mod aspirational {
#[data::structure]
struct Manifest {
magic_number: [u8; 8], // IMDL + 4 bytes that aren't valid UTF-8
version: Version, // 256.256.256
}
#[data::structure]
struct Version {
major: u64,
minor: u64,
patch: u64,
}
#[data::table]
struct Manifest;
#[data::table_impl]
impl Manifest {
fn files(&self) -> Slice<Hash>;
fn directory(&self) -> Directory;
}
#[data::structure]
struct Directory {
records: Slice<Record>,
}
#[data::structure]
struct Record {
name: &str,
node: Node,
}
#[data::enumeration]
enum Node {
Directory(Directory),
File(u64),
}
#[data::structure]
struct Hash {
bytes: [u8; 32],
}
}