| @@ -10,7 +10,7 @@ pub use git_glob as glob; · 9 unmodified lines |
| 10 | /// The state an attribute can be in, referencing the value. | 10 | /// The state an attribute can be in, referencing the value. |
| 11 | /// | 11 | /// |
| 12 | /// Note that this doesn't contain the name. | 12 | /// Note that this doesn't contain the name. |
| 13 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] | 13 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)] |
| 14 | #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] | 14 | #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] |
| 15 | pub enum StateRef<'a> { | 15 | pub enum StateRef<'a> { |
| 16 | /// The attribute is listed, or has the special value 'true' | 16 | /// The attribute is listed, or has the special value 'true' |
| @@ -37,7 +37,7 @@ pub enum State { · 20 unmodified lines |
| 37 | Unset, | 37 | Unset, |
| 38 | /// The attribute is set to the given value, which followed the `=` sign. | 38 | /// The attribute is set to the given value, which followed the `=` sign. |
| 39 | /// Note that values can be empty. | 39 | /// Note that values can be empty. |
| 40 | Value(CompactString), | 40 | Value(CompactString), // TODO: use `kstring`, maybe it gets a binary string soon |
| 41 | /// The attribute isn't mentioned with a given path or is explicitly set to `Unspecified` using the `!` sign. | 41 | /// The attribute isn't mentioned with a given path or is explicitly set to `Unspecified` using the `!` sign. |
| 42 | Unspecified, | 42 | Unspecified, |
| 43 | } | 43 | } |
| @@ -100,6 +100,22 @@ pub struct PatternMapping<T> { · 56 unmodified lines |
| 100 | pub sequence_number: usize, | 100 | pub sequence_number: usize, |
| 101 | } | 101 | } |
| 102 | | 102 | |
| | 103 | mod state { |
| | 104 | use crate::{State, StateRef}; |
| | 105 | use bstr::ByteSlice; |
| | 106 | |
| | 107 | impl<'a> From<StateRef<'a>> for State { |
| | 108 | fn from(s: StateRef<'a>) -> Self { |
| | 109 | match s { |
| | 110 | StateRef::Value(v) => State::Value(v.to_str().expect("no illformed unicode").into()), |
| | 111 | StateRef::Set => State::Set, |
| | 112 | StateRef::Unset => State::Unset, |
| | 113 | StateRef::Unspecified => State::Unspecified, |
| | 114 | } |
| | 115 | } |
| | 116 | } |
| | 117 | } |
| | 118 | |
| 103 | pub mod name { | 119 | pub mod name { |
| 104 | use bstr::BString; | 120 | use bstr::BString; |
| 105 | | 121 | |