diff --git a/src/model/data.rs b/src/model/data.rs index b9dbc750..887ffc70 100644 --- a/src/model/data.rs +++ b/src/model/data.rs @@ -126,6 +126,20 @@ impl NamedOrBlankNode { NamedOrBlankNode::BlankNode(node) => node.value(), } } + + pub fn is_named_node(&self) -> bool { + match self { + NamedOrBlankNode::NamedNode(_) => true, + NamedOrBlankNode::BlankNode(_) => false, + } + } + + pub fn is_blank_node(&self) -> bool { + match self { + NamedOrBlankNode::NamedNode(_) => false, + NamedOrBlankNode::BlankNode(_) => true, + } + } } impl fmt::Display for NamedOrBlankNode { @@ -166,6 +180,30 @@ impl Term { Term::Literal(literal) => literal.value(), } } + + pub fn is_named_node(&self) -> bool { + match self { + Term::NamedNode(_) => true, + Term::BlankNode(_) => false, + Term::Literal(_) => false, + } + } + + pub fn is_blank_node(&self) -> bool { + match self { + Term::NamedNode(_) => false, + Term::BlankNode(_) => true, + Term::Literal(_) => false, + } + } + + pub fn is_literal(&self) -> bool { + match self { + Term::NamedNode(_) => false, + Term::BlankNode(_) => false, + Term::Literal(_) => true, + } + } } impl fmt::Display for Term {