[go: up one dir, main page]

Entry

Struct Entry 

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

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

This function will return an Error if the service or user values are invalid. The specific reasons for invalidity are platform-dependent, but include length constraints.

§Panics

In the very unlikely event that the internal credential builder’s `RwLock`` is poisoned, this function will panic. If you encounter this, and especially if you can reproduce it, please report a bug with the details (and preferably a backtrace) so the developers can investigate.

Source

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

Create an entry for the given target, service, and user.

The default credential builder is used.

Source

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

Create an entry that uses the given platform credential for storage.

Source

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

Set the password for this entry.

Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.

Source

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

Set the secret for this entry.

Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.

Source

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

Retrieve the password saved for this entry.

Returns a NoEntry error if there isn’t one.

Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.

Source

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

Retrieve the secret saved for this entry.

Returns a NoEntry error if there isn’t one.

Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.

Source

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

Get the attributes on the underlying credential for this entry.

Some of the underlying credential stores allow credentials to have named attributes that can be set to string values. See the documentation for each credential store for a list of which attribute names are supported by that store.

Returns a NoEntry error if there isn’t a credential for this entry.

Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.

Source

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

Update the attributes on the underlying credential for this entry.

Some of the underlying credential stores allow credentials to have named attributes that can be set to string values. See the documentation for each credential store for a list of which attribute names can be given values by this call. To support cross-platform use, each credential store ignores (without error) any specified attributes that aren’t supported by that store.

Returns a NoEntry error if there isn’t a credential for this entry.

Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.

Source

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

Delete the underlying credential for this entry.

Returns a NoEntry error if there isn’t one.

Can return an Ambiguous error if there is more than one platform credential that matches this entry. This can only happen on some platforms, and then only if a third-party application wrote the ambiguous credential.

Note: This does not affect the lifetime of the Entry structure, which is controlled by Rust. It only affects the underlying credential store.

Source

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

Return a reference to this entry’s wrapped credential.

The reference is of the Any type, so it can be downgraded to a concrete credential object. The client must know what type of concrete object to cast to.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V