Skip to main content

RepositoryApiFallback

Trait RepositoryApiFallback 

Source
pub trait RepositoryApiFallback {
    // Required methods
    fn with_fallback<F, Fut, T>(
        &mut self,
        operation: F,
    ) -> impl Future<Output = Result<T>> + Send
       where F: FnMut(&mut Self) -> Fut + Send,
             Fut: Future<Output = Result<T>> + Send,
             T: Send + 'static;
    fn ensure_provider_with_fallback(
        &mut self,
    ) -> impl Future<Output = Result<bool>> + Send;
}
Expand description

Extension trait for RepositoryApi to add fallback support

Required Methods§

Source

fn with_fallback<F, Fut, T>( &mut self, operation: F, ) -> impl Future<Output = Result<T>> + Send
where F: FnMut(&mut Self) -> Fut + Send, Fut: Future<Output = Result<T>> + Send, T: Send + 'static,

Perform operation with automatic fallback.

Executes the closure; if it fails with a network-related error and the current provider is cloud/remote, offers fallback to local. On successful fallback, retries the operation once.

Source

fn ensure_provider_with_fallback( &mut self, ) -> impl Future<Output = Result<bool>> + Send

Check provider health and fallback if needed. Returns Ok(true) if provider is healthy or fallback succeeded.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§