merka_vault/
lib.rs

1//! merka-vault - Vault provisioning library
2//!
3//! This crate provides tools to initialize and configure a HashiCorp Vault server.
4//! It includes an Actix actor (`VaultActor`) for use in async systems and
5//! standalone functions for direct use or CLI.
6//!
7//! ## Architecture
8//!
9//! The crate follows a layered architecture with the following dependencies:
10//!
11//! - `server` module - HTTP API layer (can only access actor module)
12//! - `actor` module - Domain layer (can access vault and database modules)
13//! - `cli` module - Command-line interface (can access actor module)
14//! - `vault` module - Vault implementation (core functionality, private to crate)
15//! - `database` module - Persistence layer (accessed through actor module)
16//!
17//! This enforces separation of concerns and a clean dependency hierarchy.
18//! The vault module is private to the crate, ensuring all external access
19//! goes through the actor module, which enforces business rules and manages
20//! persistence.
21
22// Make modules available with appropriate visibility
23pub mod actor;
24pub mod cli;
25pub mod database;
26
27// Interface module is available to all other modules
28pub mod interface;
29
30// Vault module is private to the crate to enforce the architectural constraints
31pub(crate) mod vault;
32
33// Server module is public for the binary but should only use actor
34pub mod server;
35
36// Re-export public types for convenience
37pub use actor::VaultActor;
38pub use database::{DatabaseManager, VaultCredentials};
39
40/// Initialize logging for the application
41#[allow(dead_code)]
42fn init_logging() {
43    let _ = tracing_subscriber::fmt()
44        .with_env_filter("info")
45        .with_test_writer() // This ensures output goes to both stdout and test output
46        .try_init();
47}
48
49pub trait VaultService {
50    fn run_api_server(
51        &self,
52        root_vault_addr: &str,
53        sub_vault_addr: &str,
54        listen_addr: &str,
55    ) -> impl std::future::Future<Output = Result<(), Box<dyn std::error::Error>>> + Send;
56}