Store

Struct Store 

Source
pub struct Store {
    pub id: String,
    pub creds: CredMap,
    pub backing: Option<String>,
    pub self_ref: RwLock<SelfRef>,
}
Expand description

A credential store.

The credential data is kept in the CredMap. We keep the index of ourself in the STORES vector, so we can get a pointer to ourself whenever we need to build a credential.

Fields§

§id: String§creds: CredMap§backing: Option<String>§self_ref: RwLock<SelfRef>

Implementations§

Source§

impl Store

Source

pub fn new() -> Result<Arc<Self>>

Create a new store with a default configuration.

The default configuration is empty with no backing file.

Source

pub fn new_with_configuration(config: &HashMap<&str, &str>) -> Result<Arc<Self>>

Create a new store with a user-specified configuration.

The only allowed configuration option is the path to the backing file, which should be the value of the backing_file key in the config map. See new_with_backing for details.

Source

pub fn new_with_backing(path: &str) -> Result<Arc<Self>>

Create a new store from a backing file.

The backing file must be a valid path, but it need not exist, in which case the store starts off empty. If the file does exist, the initial contents of the store are loaded from it.

Source

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

Save this store to its backing file.

This is a no-op if there is no backing file.

Stores will save themselves to their backing file when they go out of scope (i.e., are dropped), but this call can be very useful if you specify an instance of your store as the keyring-core API default store, because the default store is kept in a static variable and thus is never dropped.

Source

pub fn new_internal(creds: CredMap, backing: Option<String>) -> Arc<Self>

Create a store with the given credentials and backing file.

Source

pub fn load_credentials(path: &str) -> Result<CredMap>

Loads store content from a backing file.

If the backing file does not exist, the returned store is empty.

Trait Implementations§

Source§

impl CredentialStoreApi for Store

Source§

fn vendor(&self) -> String

See the API docs.

Source§

fn id(&self) -> String

See the API docs.

The store ID is based on its sequence number in the list of created stores.

Source§

fn build( &self, service: &str, user: &str, mods: Option<&HashMap<&str, &str>>, ) -> Result<Entry>

See the API docs.

The only modifier you can specify is force-create, which forces immediate credential creation and can be used to create ambiguity.

When the force-create modifier is specified, the created credential gets an empty password/secret, a comment attribute with the value of the modifier, and a creation_date` attribute with a string for the current local time.

Source§

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

See the API docs.

The specification must contain exactly two keys - service and user - and their values must be valid regular expressions. Every credential whose service name matches the service regex and whose username matches the user regex will be returned. (The match is a substring match, so the empty string will match every value.)

Source§

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

See the API docs.

Source§

fn as_any(&self) -> &dyn Any

Return the inner store object cast to Any. Read more
Source§

fn persistence(&self) -> CredentialPersistence

The lifetime of credentials produced by this builder. Read more
Source§

impl Debug for Store

Source§

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

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

impl Drop for Store

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnwindSafe for Store

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.