git_config_value/types.rs
1use crate::{color, integer};
2
3/// Any value that may contain a foreground color, background color, a
4/// collection of color (text) modifiers, or a combination of any of the
5/// aforementioned values, like `red` or `brightgreen`.
6///
7/// Note that `git-config` allows color values to simply be a collection of
8/// [`color::Attribute`]s, and does not require a [`color::Name`] for either the
9/// foreground or background color.
10#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
11pub struct Color {
12 /// A provided foreground color
13 pub foreground: Option<color::Name>,
14 /// A provided background color
15 pub background: Option<color::Name>,
16 /// A potentially empty set of text attributes
17 pub attributes: color::Attribute,
18}
19
20/// Any value that can be interpreted as an integer.
21///
22/// This supports any numeric value that can fit in a [`i64`], excluding the
23/// suffix. The suffix is parsed separately from the value itself, so if you
24/// wish to obtain the true value of the integer, you must account for the
25/// suffix after fetching the value. [`integer::Suffix`] provides
26/// [`bitwise_offset()`][integer::Suffix::bitwise_offset] to help with the
27/// math, or [to_decimal()][Integer::to_decimal()] for obtaining a usable value in one step.
28#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
29pub struct Integer {
30 /// The value, without any suffix modification
31 pub value: i64,
32 /// A provided suffix, if any.
33 pub suffix: Option<integer::Suffix>,
34}
35
36/// Any value that can be interpreted as a boolean.
37#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
38#[allow(missing_docs)]
39pub struct Boolean(pub bool);
40
41/// Any value that can be interpreted as a path to a resource on disk.
42///
43/// Git represents file paths as byte arrays, modeled here as owned or borrowed byte sequences.
44#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
45pub struct Path<'a> {
46 /// The path string, un-interpolated
47 pub value: std::borrow::Cow<'a, bstr::BStr>,
48}