Struct git_repository::config::Snapshot
source · [−]pub struct Snapshot<'repo> { /* private fields */ }
Expand description
A platform to access configuration values as read from disk.
Note that these values won’t update even if the underlying file(s) change.
Implementations
sourceimpl<'repo> Snapshot<'repo>
impl<'repo> Snapshot<'repo>
Access configuration values, frozen in time, using a key
which is a .
separated string of up to
three tokens, namely section_name.[subsection_name.]value_name
, like core.bare
or remote.origin.url
.
Note that single-value methods always return the last value found, which is the one set most recently in the hierarchy of configuration files, aka ‘last one wins’.
sourcepub fn boolean(&self, key: &str) -> Option<bool>
pub fn boolean(&self, key: &str) -> Option<bool>
Return the boolean at key
, or None
if there is no such value or if the value can’t be interpreted as
boolean.
For a non-degenerating version, use try_boolean(…)
.
Note that this method takes the most recent value at key
even if it is from a file with reduced trust.
sourcepub fn try_boolean(&self, key: &str) -> Option<Result<bool, Error>>
pub fn try_boolean(&self, key: &str) -> Option<Result<bool, Error>>
Like boolean()
, but it will report an error if the value couldn’t be interpreted as boolean.
sourcepub fn integer(&self, key: &str) -> Option<i64>
pub fn integer(&self, key: &str) -> Option<i64>
Return the resolved integer at key
, or None
if there is no such value or if the value can’t be interpreted as
integer or exceeded the value range.
For a non-degenerating version, use try_integer(…)
.
Note that this method takes the most recent value at key
even if it is from a file with reduced trust.
sourcepub fn try_integer(&self, key: &str) -> Option<Result<i64, Error>>
pub fn try_integer(&self, key: &str) -> Option<Result<i64, Error>>
Like integer()
, but it will report an error if the value couldn’t be interpreted as boolean.
Trait Implementations
Auto Trait Implementations
impl<'repo> !RefUnwindSafe for Snapshot<'repo>
impl<'repo> !Send for Snapshot<'repo>
impl<'repo> !Sync for Snapshot<'repo>
impl<'repo> Unpin for Snapshot<'repo>
impl<'repo> !UnwindSafe for Snapshot<'repo>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more