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;
18pub mod lockfile;
19pub mod manifest;
20pub mod resolver;
21pub mod store;
22
23/// `Result` alias used throughout the package manager. Errors are stringly-typed
24/// for now (one user-facing diagnostic per failure path); structured errors land
25/// when we wire the registry protocol.
26pub type PkgResult<T> = Result<T, PkgError>;
27
28/// Errors emitted by the package manager. Display impl produces a one-line
29/// diagnostic suitable for emission to stderr and exit code 1.
30#[derive(Debug)]
31pub enum PkgError {
32 /// File I/O — read/write/create.
33 Io(String),
34 /// Manifest parse error (bad TOML, missing `[package]`, etc.).
35 Manifest(String),
36 /// Lockfile parse error or integrity-hash mismatch.
37 Lockfile(String),
38 /// Resolver error — unknown dep, conflicting versions, registry not wired.
39 Resolve(String),
40 /// Generic runtime error.
41 Other(String),
42}
43
44impl std::fmt::Display for PkgError {
45 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46 match self {
47 PkgError::Io(s) => write!(f, "{}", s),
48 PkgError::Manifest(s) => write!(f, "{}", s),
49 PkgError::Lockfile(s) => write!(f, "{}", s),
50 PkgError::Resolve(s) => write!(f, "{}", s),
51 PkgError::Other(s) => write!(f, "{}", s),
52 }
53 }
54}
55
56impl From<std::io::Error> for PkgError {
57 fn from(e: std::io::Error) -> Self {
58 PkgError::Io(e.to_string())
59 }
60}