### Basic Secret Service Operations with Tokio Source: https://github.com/open-source-cooperative/secret-service-rs/blob/master/README.md Demonstrates initializing the SecretService, interacting with collections, creating, searching, retrieving, and deleting items. This example uses the tokio runtime. ```rust use secret_service::SecretService; use secret_service::EncryptionType; use std::{collections::HashMap, error::Error}; #[tokio::main] async fn main() -> Result<(), Box> { // initialize secret service (dbus connection and encryption session) let ss = SecretService::connect(EncryptionType::Dh).await?; // get default collection let collection = ss.get_default_collection().await?; // create new item collection.create_item( "test_label", // label HashMap::from([("test", "test_value")]), // properties b"test_secret", // secret false, // replace item with same attributes "text/plain" // secret content type ).await?; // search items by properties let search_items = ss.search_items( HashMap::from([("test", "test_value")]) ).await?; let item = search_items.unlocked.first().ok_or("Not found!")?; // retrieve secret from item let secret = item.get_secret().await?; assert_eq!(secret, b"test_secret"); // delete item (deletes the dbus object, not the struct instance) item.delete().await?; Ok(()) } ``` -------------------------------- ### Add Secret Service Crate to Cargo.toml Source: https://github.com/open-source-cooperative/secret-service-rs/blob/master/README.md Specify the secret-service crate in your Cargo.toml file, selecting a feature flag for your desired runtime and cryptography backend. Ensure OpenSSL is available if using the -openssl feature. ```toml [dependencies] secret-service = { version = "5.0.0", features = ["rt-tokio-crypto-rust"] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.