pub struct NodeConstraint(pub u64);
Expand description
Constraint on allowed node types, as a set of node types.
Tuple Fields§
§0: u64
Implementations§
Source§impl NodeConstraint
impl NodeConstraint
Sourcepub fn matches(&self, node_type: NodeType) -> bool
pub fn matches(&self, node_type: NodeType) -> bool
§Examples
let only_dirs: NodeConstraint = "dir".parse().unwrap();
let history_nodes: NodeConstraint = "rel,rev".parse().unwrap();
let all_nodes: NodeConstraint = "*".parse().unwrap();
assert!(only_dirs.matches(NodeType::Directory));
assert!(!only_dirs.matches(NodeType::Content));
assert!(history_nodes.matches(NodeType::Release));
assert!(history_nodes.matches(NodeType::Revision));
assert!(!history_nodes.matches(NodeType::Origin));
for node_type in NodeType::all() {
assert!(all_nodes.matches(node_type));
}
pub fn to_vec(&self) -> Vec<NodeType>
Trait Implementations§
Source§impl Clone for NodeConstraint
impl Clone for NodeConstraint
Source§fn clone(&self) -> NodeConstraint
fn clone(&self) -> NodeConstraint
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for NodeConstraint
impl Debug for NodeConstraint
Source§impl Default for NodeConstraint
impl Default for NodeConstraint
Source§impl Display for NodeConstraint
impl Display for NodeConstraint
Source§impl FromStr for NodeConstraint
impl FromStr for NodeConstraint
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
§Examples
assert_eq!("*".parse::<NodeConstraint>(), Ok(NodeConstraint(0b111111)));
assert_eq!("rel".parse::<NodeConstraint>(), Ok(NodeConstraint(0b001000)));
assert_eq!("dir,cnt".parse::<NodeConstraint>(), Ok(NodeConstraint(0b000011)));
assert!(matches!("xyz".parse::<NodeConstraint>(), Err(_)));
Source§impl PartialEq for NodeConstraint
impl PartialEq for NodeConstraint
impl Copy for NodeConstraint
impl StructuralPartialEq for NodeConstraint
Auto Trait Implementations§
impl Freeze for NodeConstraint
impl RefUnwindSafe for NodeConstraint
impl Send for NodeConstraint
impl Sync for NodeConstraint
impl Unpin for NodeConstraint
impl UnwindSafe for NodeConstraint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> UpcastableFrom<T> for T
impl<T> UpcastableFrom<T> for T
Source§fn upcast_from(value: T) -> T
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.
Source§impl<T> UpcastableFrom<T> for T
impl<T> UpcastableFrom<T> for T
Source§fn upcast_from(value: T) -> T
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.