trident/package/manifest/mod.rs
1//! Content-addressed package manager for Trident.
2//!
3//! Parses `[dependencies]` from `trident.toml`, manages a lockfile
4//! (`trident.lock`), and caches dependency sources under `.trident/deps/`.
5//!
6//! Three dependency kinds:
7//! - **Hash** — pinned by a 64-hex-char BLAKE3 content hash.
8//! - **Registry** — resolved via a `RegistryClient` by name.
9//! - **Path** — local filesystem, re-read every build.
10
11use std::collections::BTreeMap;
12use std::path::PathBuf;
13
14// ─── Data Types ────────────────────────────────────────────────────
15
16/// A declared dependency in trident.toml.
17#[derive(Clone, Debug)]
18pub enum Dependency {
19 /// Pinned by content hash (64 hex chars).
20 Hash { hash: String },
21 /// Resolved via a registry by name.
22 Registry { name: String, registry: String },
23 /// Local filesystem path.
24 Path { path: PathBuf },
25}
26
27/// A resolved (locked) dependency.
28#[derive(Clone, Debug)]
29pub struct LockedDep {
30 pub name: String,
31 pub hash: String,
32 pub source: String, // "registry:<url>", "path:<relative>", "hash"
33}
34
35/// Package manifest: parsed `[dependencies]` from trident.toml.
36#[derive(Clone, Debug, Default)]
37pub struct Manifest {
38 pub dependencies: BTreeMap<String, Dependency>,
39}
40
41/// Lock file contents.
42#[derive(Clone, Debug, Default)]
43pub struct Lockfile {
44 pub locked: BTreeMap<String, LockedDep>,
45}
46
47mod lockfile;
48mod parse;
49mod resolve;
50
51pub use lockfile::{load_lockfile, save_lockfile};
52pub use parse::parse_dependencies;
53pub use resolve::{dep_source_path, dependency_search_paths, resolve_dependencies};
54
55#[cfg(test)]
56mod tests;