zenith_core/ast/library.rs
1//! Library block declaration AST types.
2//!
3//! The top-level `libraries` block is an imported-package manifest: each entry
4//! declares an external library dependency the document draws on. It is a
5//! sibling of the `assets`/`tokens`/`sections` blocks. The engine preserves and
6//! validates these declarations but does NOT fetch or verify package content;
7//! the optional `hash` lock string is round-tripped for an external tool.
8
9use std::collections::BTreeMap;
10
11use super::Span;
12use super::node::UnknownProperty;
13
14/// A single library declaration within a `libraries` block — one imported
15/// external package.
16#[derive(Debug, Clone, PartialEq)]
17pub struct LibraryDef {
18 /// The imported package identifier, e.g. "@acme/brand-kit". Required.
19 pub id: String,
20 /// Declared package version, e.g. "1.4.0". Optional (a lockfile/external tool may fill it).
21 pub version: Option<String>,
22 /// Content hash / lock string, e.g. "sha256-...". Optional; preserved for external
23 /// integrity checking (the engine round-trips it but does not fetch/verify package content).
24 pub hash: Option<String>,
25 /// Source declaration span, when available.
26 pub source_span: Option<Span>,
27 /// Forward-compat: unrecognized attributes preserved with typed values + annotations.
28 pub unknown_props: BTreeMap<String, UnknownProperty>,
29}