//! A module for managing and sharing secrets in the Wooly Vault application. //! //! This module provides a [`Vault`] struct that holds a secret and allows it to be shared safely //! across the application using an [`Arc`] (Atomic Reference Counted) pointer. use std::sync::Arc; /// A type alias for an [`Arc`] pointer to a [`Vault`] instance. /// /// This type is used to share a [`Vault`] instance across multiple parts of the application. pub type VaultRef = Arc; /// A struct that holds a secret and provides methods for accessing it. /// /// The [`Vault`] struct is designed to be shared safely across the application using an [`Arc`] pointer. #[derive(Debug, Clone, PartialEq)] pub struct Vault { /// The secret stored in the vault secret: String, } impl Vault { /// Creates a new [`Vault`] instance with the given secret. /// /// Returns an [`Arc`] pointer to the new [`Vault`] instance. /// /// # Returns /// /// A new [`Vault`] instance with the given secret. pub fn new(secret: &str) -> VaultRef { let v = Self { secret: secret.to_string(), }; Arc::new(v) } /// Returns a reference to the secret stored in the vault. /// /// # Returns /// /// A reference to the secret stored in the vault. pub fn secret(&self) -> &str { &self.secret } }