pub struct ProtectedStore { /* private fields */ }Expand description
Secure key-value storage for user secrets, backed by the platform’s secure keyring when available and falling back to an on-disk insecure keyring when permitted by config.
Implementations§
Source§impl ProtectedStore
impl ProtectedStore
Sourcepub fn delete_all(&self)
pub fn delete_all(&self)
Remove every known Veilid-managed protected store key, logging any failures.
Idempotent: keys already absent are skipped. Blocks on the keyring backend (OS keyring or disk) once per key.
Sourcepub fn save_user_secret_string<K: AsRef<str> + Debug, V: AsRef<str> + Debug>(
&self,
key: K,
value: V,
) -> VeilidAPIResult<bool>
pub fn save_user_secret_string<K: AsRef<str> + Debug, V: AsRef<str> + Debug>( &self, key: K, value: V, ) -> VeilidAPIResult<bool>
Store a string secret under a key. Returns true if a value already existed for that key.
Overwrites any prior value, so re-saving the same key/value is idempotent. Holds the inner lock and blocks on the keyring backend (OS keyring or disk).
Errors with VeilidAPIError::NotInitialized if the store has no open keyring, or VeilidAPIError::Generic if the keyring backend rejects the write.
Sourcepub fn load_user_secret_string<K: AsRef<str> + Debug>(
&self,
key: K,
) -> VeilidAPIResult<Option<String>>
pub fn load_user_secret_string<K: AsRef<str> + Debug>( &self, key: K, ) -> VeilidAPIResult<Option<String>>
Load a string secret by key, or None if no value is stored for it.
Holds the inner lock and blocks on the keyring backend (OS keyring or disk).
A missing key returns Ok(None). Errors with VeilidAPIError::NotInitialized if the store has no open keyring, or VeilidAPIError::Generic if the keyring backend fails the read.
Sourcepub fn save_user_secret_json<K, T>(
&self,
key: K,
value: &T,
) -> VeilidAPIResult<bool>
pub fn save_user_secret_json<K, T>( &self, key: K, value: &T, ) -> VeilidAPIResult<bool>
Serialize a value to JSON and store it as a secret. Returns true if a value already existed for that key.
Overwrites any prior value. Blocks on the keyring backend (OS keyring or disk).
Errors with VeilidAPIError::Generic if value fails to serialize, if the keyring backend rejects the write, or VeilidAPIError::NotInitialized if the store has no open keyring.
Sourcepub fn load_user_secret_json<K, T>(&self, key: K) -> VeilidAPIResult<Option<T>>
pub fn load_user_secret_json<K, T>(&self, key: K) -> VeilidAPIResult<Option<T>>
Load a secret by key and deserialize it from JSON, or None if no value is stored for it.
Blocks on the keyring backend (OS keyring or disk).
A missing key returns Ok(None). Errors with VeilidAPIError::Generic if the stored bytes fail to deserialize or are not a valid buffer, or VeilidAPIError::NotInitialized if the store has no open keyring.
Sourcepub fn save_user_secret<K: AsRef<str> + Debug>(
&self,
key: K,
value: &[u8],
) -> VeilidAPIResult<bool>
pub fn save_user_secret<K: AsRef<str> + Debug>( &self, key: K, value: &[u8], ) -> VeilidAPIResult<bool>
Store a byte buffer as a secret. Returns true if a value already existed for that key.
Overwrites any prior value. Blocks on the keyring backend (OS keyring or disk).
Errors with VeilidAPIError::NotInitialized if the store has no open keyring, or VeilidAPIError::Generic if the keyring backend rejects the write.
Sourcepub fn load_user_secret<K: AsRef<str> + Debug>(
&self,
key: K,
) -> VeilidAPIResult<Option<Vec<u8>>>
pub fn load_user_secret<K: AsRef<str> + Debug>( &self, key: K, ) -> VeilidAPIResult<Option<Vec<u8>>>
Load a byte buffer secret by key, or None if no value is stored for it.
Blocks on the keyring backend (OS keyring or disk).
A missing key returns Ok(None). Errors with VeilidAPIError::Generic if the stored value lacks the buffer marker or fails base64 decode, or VeilidAPIError::NotInitialized if the store has no open keyring.
Sourcepub fn remove_user_secret<K: AsRef<str> + Debug>(
&self,
key: K,
) -> VeilidAPIResult<bool>
pub fn remove_user_secret<K: AsRef<str> + Debug>( &self, key: K, ) -> VeilidAPIResult<bool>
Remove a secret by key. Returns true if a value was present and deleted.
No-op returning false when the key is absent, so repeated removes are idempotent. Holds the inner lock and blocks on the keyring backend (OS keyring or disk).
An absent key returns Ok(false). Errors with VeilidAPIError::NotInitialized if the store has no open keyring, or VeilidAPIError::Generic if the keyring backend fails the delete.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ProtectedStore
impl !RefUnwindSafe for ProtectedStore
impl !UnwindSafe for ProtectedStore
impl Send for ProtectedStore
impl Sync for ProtectedStore
impl Unpin for ProtectedStore
impl UnsafeUnpin for ProtectedStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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