microvms_domain/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2//! The MicroVMs client's rules and values, with no I/O (ARCH-6).
3//!
4//! Every surface has to agree on these: the size classes, the cost engine and its rate table,
5//! region parsing, the service constraints, VM name validation, the error kinds, and the
6//! tunnel identity's derivation and pin. A rule that read ambient state would give different
7//! answers on different machines, and it couldn't be tested without faking that state
8//! globally. So nothing here reads the network, the filesystem, the environment, the clock
9//! or the OS random pool, or starts a subprocess; each input a rule needs is a parameter.
10//! [`region::Region::from_env`] takes a lookup, [`cost::CalendarDate::from_unix_secs`] takes
11//! the time, and [`identity::LaunchIdentity::from_seeds`] takes the seeds.
12//!
13//! Two checks hold that. `clippy.toml` beside this crate's manifest bans the std calls and
14//! the clock and entropy calls of the crates this one uses, and the crate root below forbids
15//! both lints. The crates that could do I/O through a dependency (tokio, getrandom, reqwest)
16//! are kept out by the exact dependency set in `verify/arch/placement.toml`, which
17//! `crates/microvms-cli/tests/dependency_direction.rs` asserts along with each dependency's features.
18//!
19//! `microvms-core` re-exports every module here at its old path (ARCH-1), so a consumer names
20//! these items as `microvms_core::cost::CalendarDate` and never depends on this crate. Core's
21//! `prelude` supplies the clock and entropy reads these types used to do themselves.
22
23// CLI-7: a print macro panics when its stream's reader has gone (#216). Every write goes
24// through a checked writer instead.
25#![deny(clippy::print_stdout, clippy::print_stderr)]
26// ARCH-6: `clippy.toml` beside this crate's manifest names the file, process, network,
27// environment, clock and entropy items this crate may not touch. Forbidden rather than denied,
28// so a hit fails the build and an inner `#[allow]` or `#[expect]` is itself an error (E0453):
29// the adapters list each reviewed exception, and the domain has none to list.
30#![forbid(clippy::disallowed_methods, clippy::disallowed_types)]
31
32pub mod constants;
33pub mod cost;
34pub mod duration;
35pub mod error;
36pub mod hooks;
37pub mod identity;
38pub mod names;
39pub mod preflight;
40pub mod provision;
41pub mod region;
42pub mod sizing;
43
44#[cfg(test)]
45mod sizing_fuzz;
46
47pub use error::{Error, ErrorKind, WireKind};
48pub use hooks::{BuildHookTimeout, RunHookTimeout};
49pub use region::Region;
50pub use sizing::SizeClass;