nethsm/base/
mod.rs

1//! Functionality for accessing a [`NetHsm`].
2
3pub mod impl_base;
4pub mod impl_key;
5pub mod impl_noauth;
6pub mod impl_openpgp;
7pub mod impl_system;
8pub mod impl_user;
9pub mod utils;
10
11use std::{cell::RefCell, collections::HashMap};
12
13use ureq::Agent;
14
15use crate::{Credentials, Url, UserId};
16
17/// A network connection to a NetHSM.
18///
19/// Defines a network configuration for the connection and a list of user [`Credentials`] that can
20/// be used over this connection.
21#[derive(Debug)]
22pub struct NetHsm {
23    /// The agent for the requests
24    agent: RefCell<Agent>,
25    /// The URL path for the target API
26    url: RefCell<Url>,
27    /// The default [`Credentials`] to use for requests
28    current_credentials: RefCell<Option<UserId>>,
29    /// The list of all available credentials
30    credentials: RefCell<HashMap<UserId, Credentials>>,
31}