diff options
Diffstat (limited to 'vendor/gix-config-value/src/types.rs')
-rw-r--r-- | vendor/gix-config-value/src/types.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/vendor/gix-config-value/src/types.rs b/vendor/gix-config-value/src/types.rs new file mode 100644 index 000000000..ac3911dfd --- /dev/null +++ b/vendor/gix-config-value/src/types.rs @@ -0,0 +1,48 @@ +use crate::{color, integer}; + +/// Any value that may contain a foreground color, background color, a +/// collection of color (text) modifiers, or a combination of any of the +/// aforementioned values, like `red` or `brightgreen`. +/// +/// Note that `gix-config` allows color values to simply be a collection of +/// [`color::Attribute`]s, and does not require a [`color::Name`] for either the +/// foreground or background color. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)] +pub struct Color { + /// A provided foreground color + pub foreground: Option<color::Name>, + /// A provided background color + pub background: Option<color::Name>, + /// A potentially empty set of text attributes + pub attributes: color::Attribute, +} + +/// Any value that can be interpreted as an integer. +/// +/// This supports any numeric value that can fit in a [`i64`], excluding the +/// suffix. The suffix is parsed separately from the value itself, so if you +/// wish to obtain the true value of the integer, you must account for the +/// suffix after fetching the value. [`integer::Suffix`] provides +/// [`bitwise_offset()`][integer::Suffix::bitwise_offset] to help with the +/// math, or [to_decimal()][Integer::to_decimal()] for obtaining a usable value in one step. +#[derive(Default, 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<integer::Suffix>, +} + +/// Any value that can be interpreted as a boolean. +#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] +#[allow(missing_docs)] +pub struct Boolean(pub bool); + +/// Any value that can be interpreted as a path to a resource on disk. +/// +/// Git represents file paths as byte arrays, modeled here as owned or borrowed byte sequences. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] +pub struct Path<'a> { + /// The path string, un-interpolated + pub value: std::borrow::Cow<'a, bstr::BStr>, +} |