Skip to main content

BodyRef

Struct BodyRef 

Source
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

Source

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.

Source

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

Source

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.

Source

pub fn value_names(&self) -> impl Iterator<Item = String> + '_

Returns an iterator visiting all value names in order.

Source

pub fn contains_value_name(&self, value_name: &str) -> bool

Returns true if the section contains the provided value name.

Source

pub fn num_values(&self) -> usize

Returns the number of values in the section.

Source

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> Clone for BodyRef<'a>

Source§

fn clone(&self) -> BodyRef<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for BodyRef<'a>

Source§

impl<'a> Debug for BodyRef<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> IntoIterator for BodyRef<'a>

Source§

type Item = (String, BString)

The type of the elements being iterated over.
Source§

type IntoIter = BodyRefIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for BodyRef<'a>

§

impl<'a> RefUnwindSafe for BodyRef<'a>

§

impl<'a> Send for BodyRef<'a>

§

impl<'a> Sync for BodyRef<'a>

§

impl<'a> Unpin for BodyRef<'a>

§

impl<'a> UnsafeUnpin for BodyRef<'a>

§

impl<'a> UnwindSafe for BodyRef<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.