pub struct LockedKeyring { /* private fields */ }Expand description
A locked keyring that requires a secret to unlock.
Implementations§
Source§impl LockedKeyring
impl LockedKeyring
Sourcepub async fn validate_secret(&self, secret: &Secret) -> Result<bool, Error>
pub async fn validate_secret(&self, secret: &Secret) -> Result<bool, Error>
Validate that a secret can decrypt the items in this keyring.
For empty keyrings, this always returns true since there are no items
to validate against.
§Arguments
secret- The secret to validate.
pub async fn validate_unencrypted(&self) -> Result<bool, Error>
Sourcepub async fn modified_time(&self) -> Duration
pub async fn modified_time(&self) -> Duration
Get the modification timestamp
Sourcepub async fn items(&self) -> Result<Vec<LockedItem>, Error>
pub async fn items(&self) -> Result<Vec<LockedItem>, Error>
Retrieve the list of available LockedItems without decrypting them.
Sourcepub async fn unlock(self, secret: Secret) -> Result<UnlockedKeyring, Error>
pub async fn unlock(self, secret: Secret) -> Result<UnlockedKeyring, Error>
Unlocks a keyring and validates it
Sourcepub async unsafe fn unlock_unchecked(
self,
secret: Secret,
) -> Result<UnlockedKeyring, Error>
pub async unsafe fn unlock_unchecked( self, secret: Secret, ) -> Result<UnlockedKeyring, Error>
Unlocks a keyring without validating it
§Safety
This method skips validation and doesn’t verify that the secret can decrypt all items in the keyring. Use only for recovery scenarios where you need to access a partially corrupted keyring. The keyring may contain items that cannot be decrypted with the provided secret.
Sourcepub async fn unlock_unencrypted(self) -> Result<UnlockedKeyring, Error>
pub async fn unlock_unencrypted(self) -> Result<UnlockedKeyring, Error>
Unlocks a keyring without a secret, for unencrypted keyrings.
Validates that existing items (if any) can be read without
encryption. Returns Error::IncorrectSecret if encrypted items
are found.
Sourcepub async fn load(path: impl AsRef<Path>) -> Result<Self, Error>
pub async fn load(path: impl AsRef<Path>) -> Result<Self, Error>
Load a keyring from a file path.
Sourcepub async fn open_at(
data_dir: impl AsRef<Path>,
name: &str,
) -> Result<Self, Error>
pub async fn open_at( data_dir: impl AsRef<Path>, name: &str, ) -> Result<Self, Error>
Open a locked keyring at a specific data directory.
This is useful for tests and cases where you want explicit control over where keyrings are stored, avoiding the default XDG_DATA_HOME location.
§Arguments
data_dir- Base data directory (keyrings stored indata_dir/keyrings/v1/)name- The name of the keyring.