docs
This commit is contained in:
parent
7cbdd46fde
commit
ebfd15b6d3
2 changed files with 17 additions and 1 deletions
13
src/file.rs
13
src/file.rs
|
@ -4,6 +4,7 @@ use std::collections::{HashMap, VecDeque};
|
||||||
use std::{borrow::Borrow, convert::TryFrom};
|
use std::{borrow::Borrow, convert::TryFrom};
|
||||||
use std::{borrow::Cow, fmt::Display};
|
use std::{borrow::Cow, fmt::Display};
|
||||||
|
|
||||||
|
/// All possible error types that may occur from interacting with [`GitConfig`].
|
||||||
#[derive(PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord, Debug)]
|
#[derive(PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord, Debug)]
|
||||||
pub enum GitConfigError<'a> {
|
pub enum GitConfigError<'a> {
|
||||||
/// The requested section does not exist.
|
/// The requested section does not exist.
|
||||||
|
@ -12,6 +13,8 @@ pub enum GitConfigError<'a> {
|
||||||
SubSectionDoesNotExist(Option<&'a str>),
|
SubSectionDoesNotExist(Option<&'a str>),
|
||||||
/// The key does not exist in the requested section.
|
/// The key does not exist in the requested section.
|
||||||
KeyDoesNotExist(&'a str),
|
KeyDoesNotExist(&'a str),
|
||||||
|
/// The conversion into the provided type for methods such as
|
||||||
|
/// [`GitConfig::get_value`] failed.
|
||||||
FailedConversion,
|
FailedConversion,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +54,8 @@ enum LookupTreeNode<'a> {
|
||||||
NonTerminal(HashMap<Cow<'a, str>, Vec<SectionId>>),
|
NonTerminal(HashMap<Cow<'a, str>, Vec<SectionId>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An intermediate representation of a mutable value obtained from
|
||||||
|
/// [`GitConfig`].
|
||||||
pub struct MutableValue<'borrow, 'lookup, 'event> {
|
pub struct MutableValue<'borrow, 'lookup, 'event> {
|
||||||
section: &'borrow mut Vec<Event<'event>>,
|
section: &'borrow mut Vec<Event<'event>>,
|
||||||
key: &'lookup str,
|
key: &'lookup str,
|
||||||
|
@ -117,6 +122,8 @@ impl MutableValue<'_, '_, '_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An imtermediate representation of a mutable multivar obtained from
|
||||||
|
/// [`GitConfig`].
|
||||||
pub struct MutableMultiValue<'borrow, 'lookup, 'event> {
|
pub struct MutableMultiValue<'borrow, 'lookup, 'event> {
|
||||||
section: &'borrow mut HashMap<SectionId, Vec<Event<'event>>>,
|
section: &'borrow mut HashMap<SectionId, Vec<Event<'event>>>,
|
||||||
key: &'lookup str,
|
key: &'lookup str,
|
||||||
|
@ -160,11 +167,14 @@ impl<'event> MutableMultiValue<'_, '_, 'event> {
|
||||||
Ok(values)
|
Ok(values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the size of values the multivar has.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.indices_and_sizes.len()
|
self.indices_and_sizes.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns if the multivar has any values. This might occur if the value
|
||||||
|
/// was deleted but not set with a new value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.indices_and_sizes.is_empty()
|
self.indices_and_sizes.is_empty()
|
||||||
|
@ -258,7 +268,8 @@ impl<'event> MutableMultiValue<'_, '_, 'event> {
|
||||||
/// High level `git-config` reader and writer.
|
/// High level `git-config` reader and writer.
|
||||||
///
|
///
|
||||||
/// Internally, this uses various acceleration data structures to improve
|
/// Internally, this uses various acceleration data structures to improve
|
||||||
/// performance.
|
/// performance of the typical usage behavior of many lookups and relatively
|
||||||
|
/// fewer insertions.
|
||||||
///
|
///
|
||||||
/// # Multivar behavior
|
/// # Multivar behavior
|
||||||
///
|
///
|
||||||
|
|
|
@ -430,7 +430,9 @@ impl Serialize for TrueVariant<'_> {
|
||||||
/// [`bitwise_offset`]: IntegerSuffix::bitwise_offset
|
/// [`bitwise_offset`]: IntegerSuffix::bitwise_offset
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
|
||||||
pub struct Integer {
|
pub struct Integer {
|
||||||
|
/// The value, without any suffix modification
|
||||||
pub value: i64,
|
pub value: i64,
|
||||||
|
/// A provided suffix, if any.
|
||||||
pub suffix: Option<IntegerSuffix>,
|
pub suffix: Option<IntegerSuffix>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,8 +600,11 @@ impl TryFrom<Vec<u8>> for IntegerSuffix {
|
||||||
/// foreground or background color.
|
/// foreground or background color.
|
||||||
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
|
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
|
||||||
pub struct Color {
|
pub struct Color {
|
||||||
|
/// A provided foreground color
|
||||||
pub foreground: Option<ColorValue>,
|
pub foreground: Option<ColorValue>,
|
||||||
|
/// A provided background color
|
||||||
pub background: Option<ColorValue>,
|
pub background: Option<ColorValue>,
|
||||||
|
/// A potentially empty list of text attributes
|
||||||
pub attributes: Vec<ColorAttribute>,
|
pub attributes: Vec<ColorAttribute>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue