Skip to main content

LockedKeyring

Struct LockedKeyring 

Source
pub struct LockedKeyring { /* private fields */ }
Expand description

A locked keyring that requires a secret to unlock.

Implementations§

Source§

impl LockedKeyring

Source

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.
Source

pub async fn validate_unencrypted(&self) -> Result<bool, Error>

Source

pub fn path(&self) -> Option<&Path>

Return the associated file if any.

Source

pub async fn modified_time(&self) -> Duration

Get the modification timestamp

Source

pub async fn items(&self) -> Result<Vec<LockedItem>, Error>

Retrieve the list of available LockedItems without decrypting them.

Source

pub async fn unlock(self, secret: Secret) -> Result<UnlockedKeyring, Error>

Unlocks a keyring and validates it

Source

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.

Source

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.

Source

pub async fn load(path: impl AsRef<Path>) -> Result<Self, Error>

Load a keyring from a file path.

Source

pub async fn open(name: &str) -> Result<Self, Error>

Open a named keyring.

Source

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 in data_dir/keyrings/v1/)
  • name - The name of the keyring.

Trait Implementations§

Source§

impl Debug for LockedKeyring

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<LockedKeyring> for Keyring

Source§

fn from(keyring: LockedKeyring) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more