use crate::Span; use bstr::BString; /// A key-value entry of a git-config file, like `name = value` pub struct Entry { pub name: BString, pub value: Option, pub(crate) span: Option, } /// A section or sub-section (in case `sub_name` is `Some()`), with all their entries. /// /// For example /// ```text /// [hello] /// a = 2 /// /// [hello.world] /// b = c /// x = y /// ``` pub struct Section { pub name: BString, pub sub_name: Option, pub entries: Vec, pub(crate) span: Option, } impl Entry { pub fn new(name: BString, value: Option) -> Self { Entry { name, value, span: None, } } pub fn name(mut self, name: impl Into) -> Self { self.name = name.into(); self } pub fn value(mut self, name: Option) -> Self { self.value = name; self } } impl Section { pub fn new(name: BString, sub_name: Option, entries: Vec) -> Self { Section { name, sub_name, entries, span: None, } } pub fn name(mut self, name: impl Into) -> Self { self.name = name.into(); self } pub fn sub_name(mut self, sub_name: Option) -> Self { self.sub_name = sub_name; self } }