pub struct BodyRef<'a> { /* private fields */ }Expand description
A view of a section body whose bytes are owned by the containing File.
Implementations§
Source§impl BodyRef<'_>
Access
impl BodyRef<'_>
Access
Sourcepub fn value(&self, value_name: impl AsRef<str>) -> Option<BString>
pub fn value(&self, value_name: impl AsRef<str>) -> Option<BString>
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<BString>>
pub fn value_implicit(&self, value_name: &str) -> Option<Option<BString>>
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<BString>
pub fn values(&self, value_name: &str) -> Vec<BString>
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 = String> + '_
pub fn value_names(&self) -> impl Iterator<Item = String> + '_
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.