pub enum Keyring {
// some variants omitted
}Expand description
A Secret Service or file backed keyring implementation.
It will automatically use the file backend if the application is sandboxed and otherwise falls back to the DBus service using it default collection.
The File backend requires a org.freedesktop.portal.Secret implementation
to retrieve the key that will be used to encrypt the backend file.
Implementations§
Source§impl Keyring
impl Keyring
Sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Create a new instance of the Keyring.
Auto-detects whether the application is sandboxed and uses the appropriate backend (file backend for sandboxed apps, D-Bus service for host apps). Falls back to D-Bus if the secret portal is not available.
Sourcepub async fn sandboxed() -> Result<Self>
pub async fn sandboxed() -> Result<Self>
Use the file backend with secret portal (for sandboxed apps).
Sourcepub async fn sandboxed_with_path(
path: impl AsRef<Path>,
secret: Secret,
) -> Result<Self>
pub async fn sandboxed_with_path( path: impl AsRef<Path>, secret: Secret, ) -> Result<Self>
Use the file backend with a custom path.
§Arguments
path- Path to the keyring filesecret- Secret to unlock the keyring (useSecret::sandboxed()orSecret::random()for tests)
Sourcepub async fn host_with_connection(connection: Connection) -> Result<Self>
pub async fn host_with_connection(connection: Connection) -> Result<Self>
Use the D-Bus Secret Service with a custom connection.
Sourcepub async fn delete(&self, attributes: &impl AsAttributes) -> Result<()>
pub async fn delete(&self, attributes: &impl AsAttributes) -> Result<()>
Remove items that matches the attributes.
Sourcepub async fn create_item(
&self,
label: &str,
attributes: &impl AsAttributes,
secret: impl Into<Secret>,
replace: bool,
) -> Result<()>
pub async fn create_item( &self, label: &str, attributes: &impl AsAttributes, secret: impl Into<Secret>, replace: bool, ) -> Result<()>
Create a new item.
Sourcepub async fn search_items(
&self,
attributes: &impl AsAttributes,
) -> Result<Vec<Item>>
pub async fn search_items( &self, attributes: &impl AsAttributes, ) -> Result<Vec<Item>>
Find items based on their attributes.