Skip to main content

CredentialStorage

Trait CredentialStorage 

Source
pub trait CredentialStorage: Send + Sync {
    // Required methods
    fn read_first(&mut self, filter: CredentialFilter) -> Result<Credential>;
    fn read_next(&mut self) -> Result<Credential>;
    fn read(&mut self, id: &[u8]) -> Result<Credential>;
    fn write(&mut self, cred: CredentialRef<'_>) -> Result<()>;
    fn delete(&mut self, id: &[u8]) -> Result<()>;
    fn count_credentials(&self) -> usize;

    // Provided methods
    fn disable_user_verification(&self) -> bool { ... }
    fn cleanup_expired_cache(&mut self) { ... }
}
Expand description

Trait defining the storage interface for credentials

Any storage backend must implement this trait.

Required Methods§

Source

fn read_first(&mut self, filter: CredentialFilter) -> Result<Credential>

Start a new iteration and return the first matching credential

Source

fn read_next(&mut self) -> Result<Credential>

Continue the current iteration and return the next credential

Source

fn read(&mut self, id: &[u8]) -> Result<Credential>

Read a specific credential by ID and RP

Source

fn write(&mut self, cred: CredentialRef<'_>) -> Result<()>

Store a new credential

Source

fn delete(&mut self, id: &[u8]) -> Result<()>

Delete a credential by ID

Source

fn count_credentials(&self) -> usize

Count total number of stored credentials

Provided Methods§

Source

fn disable_user_verification(&self) -> bool

Check if user verification should be disabled for this backend

Some backends (like pass) don’t support user verification. The default implementation returns false (UV enabled).

§Returns

true if UV should be disabled, false otherwise

Source

fn cleanup_expired_cache(&mut self)

Cleanup expired cache entries (if caching is supported)

This method should be called periodically to ensure cached credentials don’t remain in memory beyond their TTL, even when idle.

Default implementation does nothing (for backends without caching).

§Security

Important for security: ensures sensitive data is removed promptly.

Trait Implementations§

Source§

impl CredentialStorage for Box<dyn CredentialStorage>

Source§

fn read_first(&mut self, filter: CredentialFilter) -> Result<Credential>

Start a new iteration and return the first matching credential
Source§

fn read_next(&mut self) -> Result<Credential>

Continue the current iteration and return the next credential
Source§

fn read(&mut self, id: &[u8]) -> Result<Credential>

Read a specific credential by ID and RP
Source§

fn write(&mut self, cred: CredentialRef<'_>) -> Result<()>

Store a new credential
Source§

fn delete(&mut self, id: &[u8]) -> Result<()>

Delete a credential by ID
Source§

fn count_credentials(&self) -> usize

Count total number of stored credentials
Source§

fn disable_user_verification(&self) -> bool

Check if user verification should be disabled for this backend Read more
Source§

fn cleanup_expired_cache(&mut self)

Cleanup expired cache entries (if caching is supported) Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl CredentialStorage for Box<dyn CredentialStorage>

Source§

fn read_first(&mut self, filter: CredentialFilter) -> Result<Credential>

Source§

fn read_next(&mut self) -> Result<Credential>

Source§

fn read(&mut self, id: &[u8]) -> Result<Credential>

Source§

fn write(&mut self, cred: CredentialRef<'_>) -> Result<()>

Source§

fn delete(&mut self, id: &[u8]) -> Result<()>

Source§

fn count_credentials(&self) -> usize

Source§

fn disable_user_verification(&self) -> bool

Source§

fn cleanup_expired_cache(&mut self)

Implementors§