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