web_static_pack_common/pack.rs
1//! Pack is the root entity, a collection of files.
2
3use crate::{file::File, pack_path::PackPath};
4use rkyv::{Archive, Serialize};
5use std::collections::HashMap;
6
7/// Pack represents a group of files distinguished by their path.
8///
9/// [Pack] is a bit like a `zip`, single entity containing directory/file tree.
10/// [Pack] will usually be built with
11/// [web-static-pack-packer](https://crates.io/crates/web-static-pack-packer)
12/// crate, either with command line tool or by a script/build.rs. After [Pack]
13/// is built, it will be serialized (called "Archived" by [rkyv] we use for that
14/// purpose) into zero-copy deserializable representation - [PackArchived]. This
15/// representation will be then included by your target program into binary (or
16/// read/mmaped from fs) and served with
17/// [web-static-pack](https://crates.io/crates/web-static-pack)
18/// crate.
19#[derive(Archive, Serialize, Debug)]
20#[rkyv(archived = PackArchived)]
21#[rkyv(derive(Debug))]
22#[rkyv(attr(allow(missing_docs)))] // TODO: resolve with https://github.com/rkyv/rkyv/issues/561
23pub struct Pack {
24 /// List of contained files by their paths.
25 pub files_by_path: HashMap<PackPath, File>,
26}