Skip to main content

compmd_host/
registry.rs

1//! The registry rules ([the registry rules]; [hosting], H1): resolving a request's packs from registries, the policy
2//! before any download, checking a tarball and reading it, once, for every host. The rules do no I/O: a [`Resolution`]
3//! says what it needs next, and the host does it its own way, synchronously on a thread of its own or awaited, and
4//! gives the answer back.
5//!
6//! ```
7//! use std::collections::BTreeMap;
8//! use compmd_host::registry::{Answer, Next, Options, Resolution, Step};
9//!
10//! let options = Options::new(BTreeMap::from([("*".to_owned(), "https://registry.npmjs.org/".to_owned())]));
11//! let mut resolution = Resolution::new(options);
12//! let resolved = loop {
13//!     match resolution.next_steps() {
14//!         Next::Steps(steps) => {
15//!             for step in steps {
16//!                 // The host's I/O: here, a request that imports nothing.
17//!                 let answer = match step {
18//!                     Step::Missing { .. } => Answer::Missing { packs: Vec::new() },
19//!                     _ => Answer::Done,
20//!                 };
21//!                 resolution.give(step.id(), answer);
22//!             }
23//!         }
24//!         Next::Done(resolved) => break resolved,
25//!     }
26//! };
27//! assert!(resolved.releases.is_empty());
28//! ```
29//!
30//! [the registry rules]: https://github.com/comp-markdown/compmd/blob/main/docs/registry-rules.md
31//! [hosting]: https://github.com/comp-markdown/compmd/blob/main/docs/hosting.md
32
33#[cfg(feature = "client")]
34mod client;
35mod file_types;
36mod folder_cache;
37mod integrity;
38#[cfg(any(test, feature = "local-registry"))]
39mod local_registry;
40mod metadata;
41mod options;
42#[cfg(feature = "client")]
43mod proxy;
44mod resolution;
45#[cfg(feature = "client")]
46mod resolve;
47mod resolved;
48mod search;
49mod step;
50mod tar;
51
52#[cfg(feature = "client")]
53pub use client::{Client, Metadata};
54pub use folder_cache::FolderCache;
55#[cfg(any(test, feature = "local-registry"))]
56pub use local_registry::{LocalRegistry, ServedPack, tarball};
57pub use metadata::{
58    ABBREVIATED, VersionInfo, answered_versions, metadata_url, off_origin, versions_of,
59};
60pub use options::{DEFAULT_MAX_PACK_SIZE, Denied, Options};
61#[cfg(feature = "client")]
62pub use proxy::Proxy;
63pub use resolution::{Next, Resolution};
64#[cfg(feature = "client")]
65pub use resolve::resolve;
66pub use resolved::{FrameFile, Problem, Release, Resolved};
67pub use search::{PACK_KEYWORD, search_path, searched};
68pub use step::{Answer, Files, KeptRelease, KeptVersions, Needed, Step, StepId};