Skip to main content

SectionRef

Struct SectionRef 

Source
pub struct SectionRef<'a> { /* private fields */ }
Expand description

A section in a git-config file, like [core] or [remote "origin"], along with all of its keys.

This is a view into data owned by its File.

Implementations§

Source§

impl<'file> SectionRef<'file>

Access

Source

pub fn to_owned(self) -> Section

Copy this view into a self-contained owned section.

Source

pub fn header(&self) -> HeaderRef<'file>

Return our header.

Source

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.

Source

pub fn body(&self) -> BodyRef<'file>

Return our body, containing all value names and values.

Source

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.

Source

pub fn write_to(&self, out: &mut dyn Write) -> Result<()>

Stream ourselves to the given out, in order to reproduce this section mostly losslessly as it was parsed.

Source

pub fn meta(&self) -> &'file Metadata

Return additional information about this sections origin.

Source

pub fn value(&self, value_name: impl AsRef<str>) -> Option<BString>

Retrieves the last matching value in this section with the given value name, if present.

Source

pub fn value_implicit(&self, value_name: &str) -> Option<Option<BString>>

Retrieves the last matching value in this section, including implicit values.

Source

pub fn values(&self, value_name: &str) -> Vec<BString>

Retrieves all values that have the provided value name.

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.

Trait Implementations§

Source§

impl<'a> Clone for SectionRef<'a>

Source§

fn clone(&self) -> SectionRef<'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 SectionRef<'a>

Source§

impl<'a> Debug for SectionRef<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Send for SectionRef<'a>

§

impl<'a> !Sync for SectionRef<'a>

§

impl<'a> Freeze for SectionRef<'a>

§

impl<'a> RefUnwindSafe for SectionRef<'a>

§

impl<'a> Unpin for SectionRef<'a>

§

impl<'a> UnsafeUnpin for SectionRef<'a>

§

impl<'a> UnwindSafe for SectionRef<'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.