pub struct Keyring {
pub keys: Vec<KeyEntry>,
}Expand description
The on-disk registry (keys.json).
Fields§
§keys: Vec<KeyEntry>Implementations§
Source§impl Keyring
impl Keyring
Sourcepub fn load_default() -> Result<Keyring, KeyringError>
pub fn load_default() -> Result<Keyring, KeyringError>
Load from the default config path. A missing file yields an empty registry (reading records nothing).
Sourcepub fn load_from(path: &Path) -> Result<Keyring, KeyringError>
pub fn load_from(path: &Path) -> Result<Keyring, KeyringError>
Load from a specific path. A missing file yields an empty registry.
Sourcepub fn save_default(&self) -> Result<PathBuf, KeyringError>
pub fn save_default(&self) -> Result<PathBuf, KeyringError>
Persist to the default config path, creating parent dirs. Opt-in: only call this from an explicit user action. Returns the path written.
Sourcepub fn save_to(&self, path: &Path) -> Result<(), KeyringError>
pub fn save_to(&self, path: &Path) -> Result<(), KeyringError>
Persist to a specific path, creating parent dirs. Opt-in.
Sourcepub fn add(&mut self, entry: KeyEntry) -> Result<(), KeyringError>
pub fn add(&mut self, entry: KeyEntry) -> Result<(), KeyringError>
Add a new entry. Rejects duplicate names and duplicate serials.
Sourcepub fn remove(&mut self, name: &str) -> bool
pub fn remove(&mut self, name: &str) -> bool
Remove the entry with name. Returns true if one was removed.
pub fn by_name(&self, name: &str) -> Option<&KeyEntry>
pub fn by_serial(&self, serial: &str) -> Option<&KeyEntry>
Sourcepub fn name_for(&self, serial: Option<&str>) -> Option<&str>
pub fn name_for(&self, serial: Option<&str>) -> Option<&str>
The friendly name for a connected device’s serial, if one is registered.
Used by list to annotate devices.
Sourcepub fn resolve<'a>(
&self,
name: &str,
connected: &'a [ConnectedKey],
) -> Result<&'a ConnectedKey, ResolveError>
pub fn resolve<'a>( &self, name: &str, connected: &'a [ConnectedKey], ) -> Result<&'a ConnectedKey, ResolveError>
Resolve a --name to a connected device by matching serials.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Keyring
impl<'de> Deserialize<'de> for Keyring
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Keyring
impl RefUnwindSafe for Keyring
impl Send for Keyring
impl Sync for Keyring
impl Unpin for Keyring
impl UnsafeUnpin for Keyring
impl UnwindSafe for Keyring
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more