pub struct KeyService { /* private fields */ }Implementations§
Source§impl KeyService
impl KeyService
pub fn new(dev_mode: bool, library_id: String) -> Self
pub fn is_dev_mode(&self) -> bool
Sourcepub fn library_id(&self) -> &str
pub fn library_id(&self) -> &str
The library this key service is scoped to. Lets host apps namespace their own keyring accounts the same way coven does.
Sourcepub fn get_encryption_key(&self) -> Result<Option<String>, KeyError>
pub fn get_encryption_key(&self) -> Result<Option<String>, KeyError>
Read the encryption master key. Ok(None) if not configured, Err
if the underlying read failed (keyring backend error or non-utf8 env).
Dev mode: reads BAE_ENCRYPTION_KEY env var.
Prod mode: reads from OS keyring (may trigger a system prompt on first access).
Sourcepub fn get_or_create_encryption_key(&self) -> Result<String, KeyError>
pub fn get_or_create_encryption_key(&self) -> Result<String, KeyError>
Get the encryption key, creating a new one if none exists. Errors in dev mode (use environment variables instead).
Sourcepub fn set_encryption_key(&self, value: &str) -> Result<(), KeyError>
pub fn set_encryption_key(&self, value: &str) -> Result<(), KeyError>
Save the encryption master key to the OS keyring. Errors in dev mode (use environment variables instead).
Sourcepub fn get_cloud_home_credentials(
&self,
) -> Result<Option<CloudHomeCredentials>, KeyError>
pub fn get_cloud_home_credentials( &self, ) -> Result<Option<CloudHomeCredentials>, KeyError>
Read cloud home credentials. Returns Ok(None) if not set,
Err if the stored value can’t be parsed.
Dev mode: reads BAE_CLOUD_HOME_CREDENTIALS env var (JSON).
Prod mode: reads from OS keyring.
Sourcepub fn set_cloud_home_credentials(
&self,
creds: &CloudHomeCredentials,
) -> Result<(), KeyError>
pub fn set_cloud_home_credentials( &self, creds: &CloudHomeCredentials, ) -> Result<(), KeyError>
Save cloud home credentials.
Dev mode: sets the env var. Prod mode: writes to OS keyring.
Sourcepub fn delete_cloud_home_credentials(&self) -> Result<(), KeyError>
pub fn delete_cloud_home_credentials(&self) -> Result<(), KeyError>
Delete cloud home credentials.
Dev mode: removes the env var. Prod mode: deletes from OS keyring. Silently ignores missing entries.
Sourcepub fn get_user_keypair(&self) -> Result<UserKeypair, KeyError>
pub fn get_user_keypair(&self) -> Result<UserKeypair, KeyError>
Load the user’s Ed25519 keypair from the keyring. Returns an error if
no keypair exists (unlike get_or_create_user_keypair which creates one).
Sourcepub fn get_or_create_user_keypair(&self) -> Result<UserKeypair, KeyError>
pub fn get_or_create_user_keypair(&self) -> Result<UserKeypair, KeyError>
Load the user’s Ed25519 keypair from the keyring, creating a new one if none exists. This is a global identity shared across all libraries.
Dev mode: reads env vars namespaced by library_id (hex). Falls back to generating and storing in env vars so tests can round-trip.
Trait Implementations§
Source§impl Clone for KeyService
impl Clone for KeyService
Source§fn clone(&self) -> KeyService
fn clone(&self) -> KeyService
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for KeyService
impl RefUnwindSafe for KeyService
impl Send for KeyService
impl Sync for KeyService
impl Unpin for KeyService
impl UnwindSafe for KeyService
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more