Adds utility functions to check RDF term type

pull/10/head
Tpt 7 years ago
parent 9994ffe645
commit 553386e354
  1. 38
      src/model/data.rs

@ -126,6 +126,20 @@ impl NamedOrBlankNode {
NamedOrBlankNode::BlankNode(node) => node.value(), 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 { impl fmt::Display for NamedOrBlankNode {
@ -166,6 +180,30 @@ impl Term {
Term::Literal(literal) => literal.value(), 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 { impl fmt::Display for Term {

Loading…
Cancel
Save