nethsm_config/lib.rs
1//! A library for working with application configuration files for [Nitrokey NetHSM] devices
2//!
3//! Provides configuration file management for custom applications designed around working with
4//! [Nitrokey NetHSM] devices or containers.
5//! Configuration settings allow for individualizing the configuration use and its use-cases
6//! (interactive or non-interactive).
7//!
8//! A module for interactive prompts provides extra convenience around creating applications that
9//! may request further data from their users interactively.
10//!
11//! # Examples
12//!
13//! ```
14//! use nethsm::{ConnectionSecurity, UserRole};
15//! use nethsm_config::{Config, ConfigCredentials, ConfigInteractivity, ConfigSettings};
16//!
17//! # fn main() -> testresult::TestResult {
18//! // a configuration for a non-interactive application called "my_app"
19//! let config_settings = ConfigSettings::new(
20//! "my_app".to_string(),
21//! ConfigInteractivity::NonInteractive,
22//! None,
23//! );
24//!
25//! // let's assume a custom configuration file path
26//! let tmpfile = testdir::testdir!().join("my_app.conf");
27//! let config = Config::new(config_settings, Some(&tmpfile))?;
28//!
29//! // add a first device to commnicate with
30//! config.add_device(
31//! "nethsm1".to_string(),
32//! "https://example.org/api/v1".parse()?,
33//! ConnectionSecurity::Unsafe,
34//! )?;
35//!
36//! // add credentials to communicate with the the device
37//! config.add_credentials(
38//! "nethsm1".to_string(),
39//! ConfigCredentials::new(
40//! UserRole::Administrator,
41//! "admin1".parse()?,
42//! Some("my-passphrase".to_string()),
43//! ),
44//! )?;
45//!
46//! // write configuration to file
47//! config.store(Some(&tmpfile))?;
48//! # Ok(())
49//! # }
50//! ```
51//! [Nitrokey NetHSM]: https://docs.nitrokey.com/nethsm/
52mod config;
53mod credentials;
54mod prompt;
55
56pub use config::{Config, ConfigInteractivity, ConfigName, ConfigSettings, DeviceConfig, Error};
57pub use credentials::ConfigCredentials;
58pub use prompt::{PassphrasePrompt, UserPrompt};