1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-19 00:26:27 +03:00

Switch to camino's Utf8Path* instead of std::path::Path*

This commit is contained in:
Quentin Gliech
2022-11-18 18:50:11 +01:00
parent c76a1dd2e7
commit a86798d2b3
21 changed files with 99 additions and 74 deletions

View File

@@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::path::Path;
use anyhow::Context;
use async_trait::async_trait;
use camino::Utf8Path;
use figment::{
error::Error as FigmentError,
providers::{Env, Format, Serialized, Yaml},
@@ -65,20 +64,20 @@ pub trait ConfigurationSection<'a>: Sized + Deserialize<'a> + Serialize {
/// Load configuration from a list of files and environment variables.
fn load_from_files<P>(paths: &[P]) -> Result<Self, FigmentError>
where
P: AsRef<Path>,
P: AsRef<Utf8Path>,
{
let base = Figment::new().merge(Env::prefixed("MAS_").split("_"));
paths
.iter()
.fold(base, |f, path| f.merge(Yaml::file(path)))
.fold(base, |f, path| f.merge(Yaml::file(path.as_ref())))
.extract_inner(Self::path())
}
/// Load configuration from a file and environment variables.
fn load_from_file<P>(path: P) -> Result<Self, FigmentError>
where
P: AsRef<Path>,
P: AsRef<Utf8Path>,
{
Self::load_from_files(&[path])
}