From ebfd15b6d38a7467dcc17d6d93a1d519a4cf2dab Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Wed, 3 Mar 2021 18:44:28 -0500 Subject: [PATCH] docs --- src/file.rs | 13 ++++++++++++- src/values.rs | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/file.rs b/src/file.rs index 0247194..cb7417e 100644 --- a/src/file.rs +++ b/src/file.rs @@ -4,6 +4,7 @@ use std::collections::{HashMap, VecDeque}; use std::{borrow::Borrow, convert::TryFrom}; 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)] pub enum GitConfigError<'a> { /// The requested section does not exist. @@ -12,6 +13,8 @@ pub enum GitConfigError<'a> { SubSectionDoesNotExist(Option<&'a str>), /// The key does not exist in the requested section. KeyDoesNotExist(&'a str), + /// The conversion into the provided type for methods such as + /// [`GitConfig::get_value`] failed. FailedConversion, } @@ -51,6 +54,8 @@ enum LookupTreeNode<'a> { NonTerminal(HashMap, Vec>), } +/// An intermediate representation of a mutable value obtained from +/// [`GitConfig`]. pub struct MutableValue<'borrow, 'lookup, 'event> { section: &'borrow mut Vec>, 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> { section: &'borrow mut HashMap>>, key: &'lookup str, @@ -160,11 +167,14 @@ impl<'event> MutableMultiValue<'_, '_, 'event> { Ok(values) } + /// Returns the size of values the multivar has. #[inline] pub fn len(&self) -> usize { 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] pub fn is_empty(&self) -> bool { self.indices_and_sizes.is_empty() @@ -258,7 +268,8 @@ impl<'event> MutableMultiValue<'_, '_, 'event> { /// High level `git-config` reader and writer. /// /// 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 /// diff --git a/src/values.rs b/src/values.rs index 964f700..5bb822d 100644 --- a/src/values.rs +++ b/src/values.rs @@ -430,7 +430,9 @@ impl Serialize for TrueVariant<'_> { /// [`bitwise_offset`]: IntegerSuffix::bitwise_offset #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] pub struct Integer { + /// The value, without any suffix modification pub value: i64, + /// A provided suffix, if any. pub suffix: Option, } @@ -598,8 +600,11 @@ impl TryFrom> for IntegerSuffix { /// foreground or background color. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)] pub struct Color { + /// A provided foreground color pub foreground: Option, + /// A provided background color pub background: Option, + /// A potentially empty list of text attributes pub attributes: Vec, }