Struct git_config::file::MutableSection[][src]

pub struct MutableSection<'borrow, 'event> { /* fields omitted */ }

A opaque type that represents a mutable reference to a section.

Implementations

impl<'borrow, 'event> MutableSection<'borrow, 'event>[src]

pub fn push(&mut self, key: Key<'event>, value: Cow<'event, [u8]>)[src]

Adds an entry to the end of this section.

pub fn pop(&mut self) -> Option<(Key<'_>, Cow<'event, [u8]>)>[src]

Removes all events until a key value pair is removed. This will also remove the whitespace preceding the key value pair, if any is found.

pub fn set(
    &mut self,
    key: Key<'event>,
    value: Cow<'event, [u8]>
) -> Option<Cow<'event, [u8]>>
[src]

Sets the last key value pair if it exists, or adds the new value. Returns the previous value if it replaced a value, or None if it adds the value.

pub fn remove(&mut self, key: &Key<'event>) -> Option<Cow<'event, [u8]>>[src]

Removes the latest value by key and returns it, if it exists.

pub fn push_newline(&mut self)[src]

Adds a new line event. Note that you don’t need to call this unless you’ve disabled implicit newlines.

pub fn implicit_newline(&mut self, on: bool)[src]

Enables or disables automatically adding newline events after adding a value. This is enabled by default.

pub fn set_whitespace(&mut self, num: usize)[src]

Sets the number of spaces before the start of a key value. By default, this is set to two. Set to 0 to disable adding whitespace before a key value.

#[must_use]pub const fn whitespace(&self) -> usize[src]

Returns the number of whitespace this section will insert before the beginning of a key.

Methods from Deref<Target = SectionBody<'event>>

#[must_use]pub fn value(&self, key: &Key<'_>) -> Option<Cow<'event, [u8]>>[src]

Retrieves the last matching value in a section with the given key. Returns None if the key was not found.

pub fn value_as<T: TryFrom<Cow<'event, [u8]>>>(
    &self,
    key: &Key<'_>
) -> Result<T, GitConfigError<'event>>
[src]

Retrieves the last matching value in a section with the given key, and attempts to convert the value into the provided type.

Errors

Returns an error if the key was not found, or if the conversion failed.

#[must_use]pub fn values(&self, key: &Key<'_>) -> Vec<Cow<'event, [u8]>>[src]

Retrieves all values that have the provided key name. This may return an empty vec, which implies there was values with the provided key.

pub fn values_as<T: TryFrom<Cow<'event, [u8]>>>(
    &self,
    key: &Key<'_>
) -> Result<Vec<T>, GitConfigError<'event>>
[src]

Retrieves all values that have the provided key name. This may return an empty vec, which implies there was values with the provided key.

Errors

Returns an error if the conversion failed.

pub fn keys(&self) -> impl Iterator<Item = &Key<'event>>[src]

Returns an iterator visiting all keys in order.

#[must_use]pub fn contains_key(&self, key: &Key<'_>) -> bool[src]

Checks if the section contains the provided key.

#[must_use]pub fn len(&self) -> usize[src]

Returns the number of entries in the section.

#[must_use]pub fn is_empty(&self) -> bool[src]

Returns if the section is empty.

Trait Implementations

impl<'borrow, 'event> Debug for MutableSection<'borrow, 'event>[src]

impl<'event> Deref for MutableSection<'_, 'event>[src]

type Target = SectionBody<'event>

The resulting type after dereferencing.

impl<'borrow, 'event> Eq for MutableSection<'borrow, 'event>[src]

impl<'borrow, 'event> Hash for MutableSection<'borrow, 'event>[src]

impl<'borrow, 'event> Ord for MutableSection<'borrow, 'event>[src]

impl<'borrow, 'event> PartialEq<MutableSection<'borrow, 'event>> for MutableSection<'borrow, 'event>[src]

impl<'borrow, 'event> PartialOrd<MutableSection<'borrow, 'event>> for MutableSection<'borrow, 'event>[src]

impl<'borrow, 'event> StructuralEq for MutableSection<'borrow, 'event>[src]

impl<'borrow, 'event> StructuralPartialEq for MutableSection<'borrow, 'event>[src]

Auto Trait Implementations

impl<'borrow, 'event> RefUnwindSafe for MutableSection<'borrow, 'event>

impl<'borrow, 'event> Send for MutableSection<'borrow, 'event>

impl<'borrow, 'event> Sync for MutableSection<'borrow, 'event>

impl<'borrow, 'event> Unpin for MutableSection<'borrow, 'event> where
    'event: 'borrow, 

impl<'borrow, 'event> !UnwindSafe for MutableSection<'borrow, 'event>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.