1use crate::{Configuration, Value};
2use std::{borrow::Borrow, ops::Deref};
3
4pub trait ConfigurationSection:
6 Configuration + AsRef<dyn Configuration> + Borrow<dyn Configuration> + Deref<Target = dyn Configuration>
7{
8 fn key(&self) -> &str;
10
11 fn path(&self) -> &str;
13
14 fn value(&self) -> Value;
16
17 fn as_config(&self) -> Box<dyn Configuration>;
19}
20
21pub mod ext {
22
23 use super::*;
24
25 pub trait ConfigurationSectionExtensions {
27 fn exists(&self) -> bool;
34 }
35
36 impl ConfigurationSectionExtensions for dyn ConfigurationSection + '_ {
37 fn exists(&self) -> bool {
38 !self.value().is_empty() || !self.children().is_empty()
39 }
40 }
41
42 impl<T: ConfigurationSection> ConfigurationSectionExtensions for T {
43 fn exists(&self) -> bool {
44 !self.value().is_empty() || !self.children().is_empty()
45 }
46 }
47}