Trait config::AsyncSource

source ·
pub trait AsyncSource: Debug + Sync {
    // Required method
    fn collect<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<Map<String, Value>, ConfigError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn collect_to<'life0, 'life1, 'async_trait>(
        &'life0 self,
        cache: &'life1 mut Value
    ) -> Pin<Box<dyn Future<Output = Result<(), ConfigError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Describes a generic source of configuration properties capable of using an async runtime.

At the moment this library does not implement it, although it allows using its implementations within builders. Due to the scattered landscape of asynchronous runtimes, it is impossible to cater to all needs with one implementation. Also, this trait might be most useful with remote configuration sources, reachable via the network, probably using HTTP protocol. Numerous HTTP libraries exist, making it even harder to find one implementation that rules them all.

For those reasons, it is left to other crates to implement runtime-specific or proprietary details.

It is advised to use async_trait crate while implementing this trait.

See examples for sample implementation.

Required Methods§

source

fn collect<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Map<String, Value>, ConfigError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Collects all configuration properties available from this source and return a Map as an async operations.

Provided Methods§

source

fn collect_to<'life0, 'life1, 'async_trait>( &'life0 self, cache: &'life1 mut Value ) -> Pin<Box<dyn Future<Output = Result<(), ConfigError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Collects all configuration properties to a provided cache.

Trait Implementations§

source§

impl Clone for Box<dyn AsyncSource + Send + Sync>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§