compmd_host/lib.rs
1//! `compmd-host`: what every host of CompMD documents shares, whatever its platform ([hosting], decision 1).
2//!
3//! A host builds a **bundle** before anyone reads (`@compmd/vite`, or `buildBundle`): the sandbox's frames under a
4//! content hash, the packs it installs by their place, and a `manifest.json` describing it all. This crate reads that
5//! bundle ([`Bundle`], [`Manifest`]), keeps the packs it fetches later in a [`Store`], and answers requests for both
6//! with [`respond`], the serving contract every adapter puts behind its origin: a Tauri scheme, an Electron protocol,
7//! a web server's route.
8//!
9//! ```
10//! use compmd_host::{respond, Bundle, NoStore};
11//!
12//! let bundle = Bundle::from_files([
13//! ("manifest.json", br#"{"format": 1, "frames": {"hash": "1df336e75685de8c"}}"#.to_vec()),
14//! ("frames/1df336e75685de8c/strict.html", b"<!doctype html>".to_vec()),
15//! ])?;
16//! let request = http::Request::get("/frames/1df336e75685de8c/strict.html").body(())?;
17//! let response = respond(&bundle, &NoStore, &request);
18//! assert_eq!(response.status(), http::StatusCode::OK);
19//! # Ok::<(), Box<dyn std::error::Error>>(())
20//! ```
21//!
22//! With the `processor` feature, [`HostPacks`] gives the processor (`compmd`) the same packs the frames load.
23//! Packs, releases, places and integrities are `compmd-pack`'s types, re-exported here as [`pack`], the same the
24//! processor uses.
25//!
26//! [hosting]: https://github.com/comp-markdown/compmd/blob/main/docs/hosting.md
27
28/// The names packs and their files are known by.
29pub use compmd_pack as pack;
30
31mod bundle;
32mod bundle_error;
33mod content_type;
34mod files;
35mod folder_store;
36mod frames_hash;
37mod manifest;
38mod manifest_error;
39#[cfg(feature = "processor")]
40mod packs;
41mod respond;
42mod store;
43
44pub use bundle::{Bundle, MANIFEST};
45pub use bundle_error::BundleError;
46pub use content_type::content_type;
47pub use files::Files;
48pub use folder_store::FolderStore;
49pub use frames_hash::FramesHash;
50pub use manifest::{BundledPack, FORMAT, Frames, Library, Manifest, Trust};
51pub use manifest_error::ManifestError;
52#[cfg(feature = "processor")]
53pub use packs::HostPacks;
54pub use respond::respond;
55pub use store::{NoStore, Store, StoredRelease};