diff options
author | Radosław Kot <rdkt13@gmail.com> | 2021-09-30 22:23:23 +0200 |
---|---|---|
committer | Radosław Kot <rdkt13@gmail.com> | 2021-10-23 16:58:41 +0200 |
commit | 583a47764a93465ce8d846a6a7273a9bd38fd554 (patch) | |
tree | cb0b8a6bac0ca105ef9e8c04b5a135b3bb19a4dc /examples | |
parent | 6fa1b27f08afb8e8ec81f36ddfff69a23c2d73d6 (diff) |
Change FileExtensions signature
Diffstat (limited to 'examples')
-rw-r--r-- | examples/async_source/main.rs | 10 | ||||
-rw-r--r-- | examples/custom_format/main.rs | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/examples/async_source/main.rs b/examples/async_source/main.rs index 005a473..02f8cd7 100644 --- a/examples/async_source/main.rs +++ b/examples/async_source/main.rs @@ -1,6 +1,6 @@ -use std::error::Error; +use std::{collections::HashMap, error::Error, fmt::Debug}; -use config::{builder::AsyncState, AsyncSource, ConfigBuilder, ConfigError, FileFormat, Map}; +use config::{AsyncSource, ConfigBuilder, ConfigError, FileFormat, Format, builder::AsyncState, Map}; use async_trait::async_trait; use futures::{select, FutureExt}; @@ -49,13 +49,13 @@ async fn run_client() -> Result<(), Box<dyn Error>> { // Actual implementation of AsyncSource can be found below #[derive(Debug)] -struct HttpSource { +struct HttpSource<F : Format> { uri: String, - format: FileFormat, + format: F, } #[async_trait] -impl AsyncSource for HttpSource { +impl<F : Format + Send + Sync + Debug> AsyncSource for HttpSource<F> { async fn collect(&self) -> Result<Map<String, config::Value>, ConfigError> { reqwest::get(&self.uri) .await diff --git a/examples/custom_format/main.rs b/examples/custom_format/main.rs index 981dcb4..c149436 100644 --- a/examples/custom_format/main.rs +++ b/examples/custom_format/main.rs @@ -49,7 +49,7 @@ impl Format for MyFormat { // It is only required for File source, custom sources can use Format without caring for extensions static MY_FORMAT_EXT: Vec<&'static str> = vec![]; impl FileExtensions for MyFormat { - fn extensions(&self) -> &Vec<&'static str> { + fn extensions(&self) -> &'static [&'static str] { &MY_FORMAT_EXT } } |