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>
Access
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, value_name: impl AsRef<str>) -> Option<Cow<'_, BStr>>
pub fn value(&self, value_name: impl AsRef<str>) -> Option<Cow<'_, BStr>>
Retrieves the last matching value in a section with the given value name, if present.
Note that we consider values without separator = non-existing, i.e. [core]\na would not exist.
If that’s expected, Self::value_implicit() must be used instead.
Sourcepub fn value_implicit(&self, value_name: &str) -> Option<Option<Cow<'_, BStr>>>
pub fn value_implicit(&self, value_name: &str) -> Option<Option<Cow<'_, BStr>>>
Retrieves the last matching value in a section with the given value name, if present, and indicates
an implicit value with Some(None), and a non-existing one as None
Sourcepub fn values(&self, value_name: &str) -> Vec<Cow<'_, BStr>>
pub fn values(&self, value_name: &str) -> Vec<Cow<'_, BStr>>
Retrieves all values that have the provided value name. This may return an empty vec, which implies there were no values with the provided key.
Sourcepub fn value_names(&self) -> impl Iterator<Item = &ValueName<'event>>
pub fn value_names(&self) -> impl Iterator<Item = &ValueName<'event>>
Returns an iterator visiting all value names in order.
Sourcepub fn contains_value_name(&self, value_name: &str) -> bool
pub fn contains_value_name(&self, value_name: &str) -> bool
Returns true if the section contains the provided value name.
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> PartialOrd for Section<'a>
impl<'a> PartialOrd for Section<'a>
impl<'a> Eq for Section<'a>
impl<'a> StructuralPartialEq for Section<'a>
Auto Trait Implementations§
impl<'a> Freeze for Section<'a>
impl<'a> RefUnwindSafe for Section<'a>
impl<'a> Send for Section<'a>
impl<'a> Sync for Section<'a>
impl<'a> Unpin for Section<'a>
impl<'a> UnwindSafe for Section<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.