miau/source/
mod.rs

1mod file;
2mod memory;
3
4use crate::error::ConfigurationError;
5use async_trait::async_trait;
6
7pub use file::FileSource;
8pub use memory::InMemorySource;
9
10/// Represents synchronous (blocking) config source.
11pub trait Source {
12    /// Synchronous function to fetch source data.
13    fn collect(&self) -> Result<Vec<u8>, ConfigurationError>;
14    /// Description of the source.
15    fn describe(&self) -> String;
16}
17
18#[async_trait]
19/// Represents asynchronous (non-blocking) config source.
20pub trait AsyncSource {
21    /// Asynchronous function to fetch source data.
22    ///
23    /// It uses [`async_trait`](async_trait::async_trait) which is required to implement `AsyncSource`.
24    async fn collect(&self) -> Result<Vec<u8>, ConfigurationError>;
25    /// Description of the source.
26    fn describe(&self) -> String;
27}