stryke/pkg/mod.rs
1//! stryke package manager — RFC: `docs/PACKAGE_REGISTRY.md`.
2//!
3//! This module hosts the local-only foundation (RFC phases 1–6):
4//! manifest parsing, lockfile read/write, store layout, path-dep
5//! resolution, and module-resolution wiring. Network (registry/git)
6//! deps and the PubGrub semver resolver land in later tiers.
7//!
8//! Surface area:
9//! - [`manifest`] — `stryke.toml` parser/serializer.
10//! - [`lockfile`] — `stryke.lock` parser/serializer with deterministic
11//! ordering and SHA-256 integrity hashes.
12//! - [`store`] — `~/.stryke/{store,cache,git,bin,index}/` layout helpers.
13//! - [`resolver`] — local-only resolver (path deps work, registry/git
14//! deps return a clear "not yet implemented" error).
15//! - [`commands`] — `s {init,new,add,remove,install,tree,info}` impls.
16
17pub mod commands;
18/// `lockfile` submodule.
19pub mod lockfile;
20/// `manifest` submodule.
21pub mod manifest;
22/// `resolver` submodule.
23pub mod resolver;
24/// `store` submodule.
25pub mod store;
26
27/// `Result` alias used throughout the package manager. Errors are stringly-typed
28/// for now (one user-facing diagnostic per failure path); structured errors land
29/// when we wire the registry protocol.
30pub type PkgResult<T> = Result<T, PkgError>;
31
32/// Errors emitted by the package manager. Display impl produces a one-line
33/// diagnostic suitable for emission to stderr and exit code 1.
34#[derive(Debug)]
35pub enum PkgError {
36 /// File I/O — read/write/create.
37 Io(String),
38 /// Manifest parse error (bad TOML, missing `[package]`, etc.).
39 Manifest(String),
40 /// Lockfile parse error or integrity-hash mismatch.
41 Lockfile(String),
42 /// Resolver error — unknown dep, conflicting versions, registry not wired.
43 Resolve(String),
44 /// Generic runtime error.
45 Other(String),
46}
47
48impl std::fmt::Display for PkgError {
49 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
50 match self {
51 PkgError::Io(s) => write!(f, "{}", s),
52 PkgError::Manifest(s) => write!(f, "{}", s),
53 PkgError::Lockfile(s) => write!(f, "{}", s),
54 PkgError::Resolve(s) => write!(f, "{}", s),
55 PkgError::Other(s) => write!(f, "{}", s),
56 }
57 }
58}
59
60impl From<std::io::Error> for PkgError {
61 fn from(e: std::io::Error) -> Self {
62 PkgError::Io(e.to_string())
63 }
64}