Entry

Struct Entry 

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

A named entry in a credential store.

Implementations§

Source§

impl Entry

Source

pub fn new(service: &str, user: &str) -> Result<Entry>

Create an entry for the given service and user.

The default credential builder is used.

§Errors

Returns an Invalid error if the service or user values are not acceptable to the default credential store.

Returns a NoDefaultStore error if the default credential store has not been set.

Source

pub fn new_with_modifiers( service: &str, user: &str, modifiers: &HashMap<&str, &str>, ) -> Result<Entry>

Create an entry for the given service and user, passing store-specific modifiers.

The default credential builder is used.

See the documentation for each credential store to understand what modifiers may be specified for that store.

§Errors

Returns an Invalid error if the service, user, or modifier pairs are not acceptable to the default credential store.

Returns a NoDefaultStore error if the default credential store has not been set.

Source

pub fn new_with_credential(credential: Arc<Credential>) -> Entry

Create an entry that wraps a pre-existing credential. The credential can be from any credential store.

Source

pub fn search(spec: &HashMap<&str, &str>) -> Result<Vec<Entry>>

Search for credentials, returning entries that wrap any found.

The default credential store is searched. See the documentation of each credential store for how searches are specified.

§Errors

Returns an Invalid error if the spec value is not acceptable to the default credential store.

Returns a NoDefaultStore error if the default credential store has not been set.

Source

pub fn set_password(&self, password: &str) -> Result<()>

Set the password for this entry.

If a credential for this entry already exists in the store, this will update its password. Otherwise, a new credential will be created to store the password.

§Errors

If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.

If this entry is a wrapper, and the underlying credential has been deleted, may return a NoEntry error.

If a credential cannot store the given password (not all stores support empty passwords, and some have length limits), then an Invalid error is returned.

Source

pub fn set_secret(&self, secret: &[u8]) -> Result<()>

Set the secret for this entry.

If a credential for this entry already exists in the store, this will update its secret. Otherwise, a new credential will be created to store the secret.

§Errors

If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.

If this entry is a wrapper, and the underlying credential has been deleted, may return a NoEntry error.

If a credential cannot store the given password (not all stores support empty passwords, and some have length limits), then an Invalid error is returned.

Source

pub fn get_password(&self) -> Result<String>

Retrieve the password saved for this entry.

§Errors

If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.

If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.

If this entry is a wrapper, the underlying credential has been deleted, and the store cannot recreate it, returns a NoEntry error.

Will return a BadEncoding error containing the data as a byte array if the password is not a valid UTF-8 string.

Source

pub fn get_secret(&self) -> Result<Vec<u8>>

Retrieve the secret saved for this entry.

§Errors

If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.

If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.

If this entry is a wrapper, and the underlying credential has been deleted, returns a NoEntry error.

Source

pub fn get_attributes(&self) -> Result<HashMap<String, String>>

Get the store-specific decorations on this entry’s credential.

See the documentation for each credential store for details of what decorations are supported and how they are returned.

§Errors

If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.

If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.

If this entry is a wrapper, and the underlying credential has been deleted, returns a NoEntry error.

Source

pub fn update_attributes(&self, attributes: &HashMap<&str, &str>) -> Result<()>

Update the store-specific decorations on this entry’s credential.

See the documentation for each credential store for details of what decorations can be updated and how updates are expressed.

§Errors

If one of the attributes supplied is not valid for the underlying store, returns an Invalid error.

If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.

If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.

If this entry is a wrapper, and the underlying credential has been deleted, returns a NoEntry error.

Source

pub fn delete_credential(&self) -> Result<()>

Delete the matching credential for this entry.

This call does not affect the lifetime of the Entry structure, only that of the underlying credential.

§Errors

If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.

If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.

If this entry is a wrapper, and the underlying credential has been deleted, returns a NoEntry error.

Source

pub fn get_credential(&self) -> Result<Entry>

Get a wrapper for the currently matching credential.

§Errors

If this entry is a specifier, and there is no matching credential in the store, returns a NoEntry error.

If this entry is a specifier, and there is more than one matching credential in the store, returns an Ambiguous error.

If this entry is a wrapper, and the underlying credential has been deleted, returns a NoEntry error.

Source

pub fn get_specifiers(&self) -> Option<(String, String)>

Get the <service, user> pair for this entry, if any.

Source

pub fn as_any(&self) -> &dyn Any

Return a reference to the inner store-specific object in this entry.

The reference is of the Any type, so it can be downgraded to a concrete object for the containing store.

Trait Implementations§

Source§

impl Debug for Entry

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Entry

§

impl !RefUnwindSafe for Entry

§

impl Send for Entry

§

impl Sync for Entry

§

impl Unpin for Entry

§

impl !UnwindSafe for Entry

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.

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