ConfigProvider

Trait ConfigProvider 

Source
pub trait ConfigProvider: Send + Sync {
    // Required methods
    fn load_config<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Config>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn save_config<'life0, 'life1, 'async_trait>(
        &'life0 self,
        config: &'life1 Config,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn validate_config<'life0, 'life1, 'async_trait>(
        &'life0 self,
        config: &'life1 Config,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn config_exists<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn config_path(&self) -> Option<&Path>;
    fn as_any(&self) -> &dyn Any;
}
Expand description

Trait for configuration providers (YAML, JSON, environment, etc.)

Required Methods§

Source

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

Load configuration from the provider

Source

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

Save configuration to the provider

Source

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

Validate configuration format and structure

Source

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

Check if configuration exists

Source

fn config_path(&self) -> Option<&Path>

Get configuration file path (if applicable)

Source

fn as_any(&self) -> &dyn Any

Downcasting support for concrete implementations

Implementors§