pub struct VaultMetadata {
pub version: u32,
pub init_mode: VaultInitMode,
pub enrolled_factors: Vec<EnrolledFactor>,
pub auth_policy: AuthCombineMode,
pub created_at: u64,
pub policy_changed_at: u64,
}Expand description
Persistent metadata for a vault.
Fields§
§version: u32Metadata format version.
init_mode: VaultInitModeHow this vault was initialized.
enrolled_factors: Vec<EnrolledFactor>Which auth methods are enrolled.
auth_policy: AuthCombineModeThe unlock policy for this vault.
created_at: u64Timestamp of vault creation (Unix epoch seconds).
policy_changed_at: u64Timestamp of last policy change.
Implementations§
Source§impl VaultMetadata
impl VaultMetadata
Sourcepub fn path(config_dir: &Path, profile: &TrustProfileName) -> PathBuf
pub fn path(config_dir: &Path, profile: &TrustProfileName) -> PathBuf
Path to the metadata file for a profile.
Sourcepub fn load(
config_dir: &Path,
profile: &TrustProfileName,
) -> Result<Self, AuthError>
pub fn load( config_dir: &Path, profile: &TrustProfileName, ) -> Result<Self, AuthError>
Read metadata from disk.
§Errors
Returns an error if the file does not exist, is unreadable, unparseable, or has an unsupported version.
Sourcepub fn new_password(auth_policy: AuthCombineMode) -> Self
pub fn new_password(auth_policy: AuthCombineMode) -> Self
Create metadata for a new password-only vault.
Sourcepub fn new_ssh_only(fingerprint: &str, auth_policy: AuthCombineMode) -> Self
pub fn new_ssh_only(fingerprint: &str, auth_policy: AuthCombineMode) -> Self
Create metadata for a new SSH-key-only vault.
Sourcepub fn new_multi_factor(
factors: Vec<EnrolledFactor>,
auth_policy: AuthCombineMode,
) -> Self
pub fn new_multi_factor( factors: Vec<EnrolledFactor>, auth_policy: AuthCombineMode, ) -> Self
Create metadata for a new multi-factor vault.
Sourcepub fn has_factor(&self, factor: AuthFactorId) -> bool
pub fn has_factor(&self, factor: AuthFactorId) -> bool
Check whether a specific factor is enrolled.
Sourcepub fn add_factor(&mut self, factor_id: AuthFactorId, label: String)
pub fn add_factor(&mut self, factor_id: AuthFactorId, label: String)
Add an enrolled factor. Does nothing if already enrolled with the same ID.
Sourcepub fn remove_factor(&mut self, factor_id: AuthFactorId)
pub fn remove_factor(&mut self, factor_id: AuthFactorId)
Remove an enrolled factor by ID.
Sourcepub fn contribution_type(&self) -> FactorContribution
pub fn contribution_type(&self) -> FactorContribution
What kind of contribution each factor makes under this vault’s policy.
Trait Implementations§
Source§impl Clone for VaultMetadata
impl Clone for VaultMetadata
Source§fn clone(&self) -> VaultMetadata
fn clone(&self) -> VaultMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more