Skip to main content

microvms_app/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2//! The MicroVMs client's use cases, written only against ports (ARCH-7).
3//!
4//! The control-plane client, [`sandbox::Sandbox`], [`session::Session`], `ensure_image`, the
5//! agent recipes and the daemon release's verification policy are here. Everything they do
6//! outside the process goes through a trait this crate declares:
7//! [`control::transport::Transport`] for the control plane, [`control::BuildServices`] for STS
8//! and S3, [`session::HttpBackend`] for the daemon, [`session::TokenMinter`] for proxy tokens,
9//! [`names::NameStore`] for the name registry, [`clock::Clock`] for time, [`entropy::Entropy`]
10//! for randomness, [`adapters::Adapters`] for the pieces a use case builds partway through, and
11//! [`provision::ReleaseSource`] and [`provision::AttestationVerifier`] for the daemon release a
12//! fetch proves.
13//!
14//! # What this crate can't do
15//!
16//! Reach the network, AWS, the filesystem, a subprocess, the wall clock or the OS random pool.
17//! A use case that did one of those directly couldn't be tested without the real thing, and it
18//! would bypass the port a test replaces. These checks hold that:
19//!
20//! * the exact dependency set in `verify/arch/placement.toml`, which
21//!   `crates/microvms-cli/tests/dependency_direction.rs` asserts along with each dependency's
22//!   features, keeps reqwest, the AWS crates, getrandom and the socket crates out;
23//! * `clippy.toml` beside this crate's manifest bans the std file, network, process,
24//!   environment and clock calls, and tokio's `net`, `fs` and `process` items, which feature
25//!   unification would otherwise let this crate name;
26//! * the crate root below forbids both lints, so a hit fails the build and an inner `#[allow]`
27//!   or `#[expect]` is itself an error.
28//!
29//! The production implementations are in `microvms-edges`. `microvms-core` wires them into the
30//! constructors a caller has always used (`ControlPlane::new`, `Sandbox::new`,
31//! `Session::connect`) and re-exports every item here at its `microvms_core::` path, so a
32//! consumer names these types through core and never depends on this crate.
33//!
34//! The shared test doubles are in `testing`, behind the `test-support` feature.
35
36// CLI-7: a print macro panics when its stream's reader has gone (#216). Every write goes
37// through a checked writer instead.
38#![deny(clippy::print_stdout, clippy::print_stderr)]
39// ARCH-7: `clippy.toml` beside this crate's manifest names the file, process, network,
40// environment and clock items this crate may not touch. Forbidden rather than denied, so a hit
41// fails the build and an inner `#[allow]` or `#[expect]` is itself an error (E0453): a use case
42// that needs one of them needs a port.
43#![forbid(clippy::disallowed_methods, clippy::disallowed_types)]
44
45pub mod adapters;
46pub mod agents;
47pub mod clock;
48pub mod control;
49pub mod defaults;
50pub mod entropy;
51pub mod names;
52pub mod preflight;
53pub mod provision;
54pub mod sandbox;
55pub mod session;
56#[cfg(any(test, feature = "test-support"))]
57pub mod testing;
58pub mod workspace;
59
60// The rules and values the use cases compute with, at the paths the moved code names them by.
61pub use microvms_domain::{constants, cost, duration, error, hooks, identity, region, sizing};
62
63// Re-exported so the use cases and their callers name wire types through one crate.
64pub use protocol;
65
66pub use error::{Error, ErrorKind, WireKind};
67pub use hooks::{BuildHookTimeout, RunHookTimeout};
68pub use region::Region;
69pub use sizing::SizeClass;