Skip to main content

StorageAdapter

Trait StorageAdapter 

Source
pub trait StorageAdapter: Send + Sync {
    // Required methods
    fn load<'life0, 'async_trait>(
        &'life0 self,
        profile: String,
    ) -> Pin<Box<dyn Future<Output = Result<Option<String>, AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn prepare_write<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn save<'life0, 'async_trait>(
        &'life0 self,
        profile: String,
        token: String,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn remove<'life0, 'async_trait>(
        &'life0 self,
        profile: String,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn acquire_lock<'life0, 'async_trait>(
        &'life0 self,
        profile: String,
        timeout_millis: u64,
    ) -> Pin<Box<dyn Future<Output = Result<String, AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn release_lock<'life0, 'async_trait>(
        &'life0 self,
        lease: String,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn name(&self) -> String;
}
Expand description

Foreign-language persistence contract; implement every method in Node or Python.

UniFFI callback interfaces do not inherit Rust default method bodies. A store must explicitly implement locking and may implement prepare_write as a no-op when writes need no preflight. Credential JSON can contain refresh tokens.

Required Methods§

Source

fn load<'life0, 'async_trait>( &'life0 self, profile: String, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, AuthError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Load credential JSON, returning None when the key does not exist.

Source

fn prepare_write<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Check write readiness before a provider rotates a refresh token.

Source

fn save<'life0, 'async_trait>( &'life0 self, profile: String, token: String, ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Persist credential JSON without discarding unrelated keys.

Source

fn remove<'life0, 'async_trait>( &'life0 self, profile: String, ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Delete only the specified credential.

Source

fn acquire_lock<'life0, 'async_trait>( &'life0 self, profile: String, timeout_millis: u64, ) -> Pin<Box<dyn Future<Output = Result<String, AuthError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Acquire an exclusive refresh lease or fail within the timeout.

Source

fn release_lock<'life0, 'async_trait>( &'life0 self, lease: String, ) -> Pin<Box<dyn Future<Output = Result<(), AuthError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Release the lease returned by acquire_lock.

Source

fn name(&self) -> String

Return a human-readable backend identifier.

Trait Implementations§

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§