wash_lib/keys/
mod.rs

1//! A common set of types and traits for managing collections of nkeys used for wasmCloud
2
3use anyhow::Result;
4use nkeys::KeyPair;
5
6/// Convenience re-export of nkeys to make key functionality easier to manage
7pub use nkeys;
8
9pub mod fs;
10
11/// A trait that can be implemented by anything that needs to manage nkeys
12pub trait KeyManager {
13    /// Returns the named keypair. Returns None if the key doesn't exist in the manager
14    fn get(&self, name: &str) -> Result<Option<KeyPair>>;
15
16    /// List all key names available
17    fn list_names(&self) -> Result<Vec<String>>;
18
19    /// Retrieves all keys. Note that this could be an expensive operation depending on the
20    /// implementation
21    fn list(&self) -> Result<Vec<KeyPair>>;
22
23    /// Deletes a named keypair
24    fn delete(&self, name: &str) -> Result<()>;
25
26    /// Saves the given keypair with the given name
27    fn save(&self, name: &str, key: &KeyPair) -> Result<()>;
28}