manta_shared/common/app_context.rs
1//! CLI context struct threaded through `manta-cli`'s call stack.
2//!
3//! The server's analogous `InfraContext` (with backend dispatcher and
4//! per-site URLs) lives in `manta-server::common::app_context` — it
5//! depends on `StaticBackendDispatcher` which the CLI never touches.
6
7use config::Config;
8
9/// Top-level CLI context, passed as `&AppContext` through CLI
10/// handlers and commands.
11#[derive(Debug)]
12pub struct AppContext<'a> {
13 /// Site name used to set the `X-Manta-Site` header on outbound
14 /// `MantaClient` requests.
15 pub site_name: &'a str,
16 /// URL of the manta HTTP server this CLI talks to. Required.
17 pub manta_server_url: &'a str,
18 /// Optional default HSM group name from `cli.toml`'s
19 /// `parent_hsm_group`; threaded into the typed `*Params`'
20 /// `settings_hsm_group_name` field by every command that builds one.
21 pub settings_hsm_group_name_opt: Option<&'a str>,
22 /// Optional per-request HTTP timeout (seconds) for outbound
23 /// `MantaClient` calls — read from `cli.toml`'s
24 /// `request_timeout_secs`. Honoured by commands that build their
25 /// `MantaClient` via `MantaClient::new_with_timeout`. Other commands
26 /// keep the default no-timeout behaviour.
27 pub request_timeout_secs: Option<u64>,
28 /// Raw loaded `cli.toml` settings; held alongside the parsed
29 /// `CliConfiguration` so handlers can read fields (e.g. `log`)
30 /// that don't live on the typed struct.
31 pub settings: &'a Config,
32}