Struct gix_config::file::Section
source · pub struct Section<'a> { /* private fields */ }
Expand description
A section in a git-config file, like [core]
or [remote "origin"]
, along with all of its keys.
Implementations§
source§impl<'a> Section<'a>
impl<'a> Section<'a>
Access
sourcepub fn id(&self) -> SectionId
pub fn id(&self) -> SectionId
Return the unique id
of the section, for use with the *_by_id()
family of methods
in gix_config::File
.
sourcepub fn to_bstring(&self) -> BString
pub fn to_bstring(&self) -> BString
Serialize this type into a BString
for convenience.
Note that to_string()
can also be used, but might not be lossless.
Methods from Deref<Target = Body<'a>>§
sourcepub fn value(&self, key: impl AsRef<str>) -> Option<Cow<'_, BStr>>
pub fn value(&self, key: impl AsRef<str>) -> Option<Cow<'_, BStr>>
Retrieves the last matching value in a section with the given key, if present.
Note that we consider values without key separator =
non-existing.
sourcepub fn value_implicit(&self, key: &str) -> Option<Option<Cow<'_, BStr>>>
pub fn value_implicit(&self, key: &str) -> Option<Option<Cow<'_, BStr>>>
Retrieves the last matching value in a section with the given key, if present, and indicates an implicit value with Some(None)
,
and a non-existing one as None
sourcepub fn values(&self, key: &str) -> Vec<Cow<'_, BStr>>
pub fn values(&self, key: &str) -> Vec<Cow<'_, BStr>>
Retrieves all values that have the provided key name. This may return an empty vec, which implies there were no values with the provided key.
sourcepub fn keys(&self) -> impl Iterator<Item = &Key<'event>>
pub fn keys(&self) -> impl Iterator<Item = &Key<'event>>
Returns an iterator visiting all keys in order.
sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if the section contains the provided key.
sourcepub fn num_values(&self) -> usize
pub fn num_values(&self) -> usize
Returns the number of values in the section.
sourcepub fn is_void(&self) -> bool
pub fn is_void(&self) -> bool
Returns if the section is empty.
Note that this may count whitespace, see num_values()
for
another way to determine semantic emptiness.
Trait Implementations§
source§impl<'a> Ord for Section<'a>
impl<'a> Ord for Section<'a>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<'a> PartialEq for Section<'a>
impl<'a> PartialEq for Section<'a>
source§impl<'a> PartialOrd for Section<'a>
impl<'a> PartialOrd for Section<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more