pub enum Term {
NamedNode(NamedNode),
BlankNode(BlankNode),
Literal(Literal),
Variable(Variable),
QuotedTriple(Box<QuotedTriple>),
}
Expand description
Union type for all RDF terms
This enum can hold any type of RDF term and is used when the specific type is not known at compile time. It supports the full RDF 1.2 specification including RDF-star quoted triples.
§Examples
use oxirs_core::model::{Term, NamedNode, Literal, BlankNode, Variable};
// Create different types of terms
let named_node = Term::NamedNode(NamedNode::new("http://example.org/resource").unwrap());
let literal = Term::Literal(Literal::new("Hello World"));
let blank_node = Term::BlankNode(BlankNode::new("b1").unwrap());
let variable = Term::Variable(Variable::new("x").unwrap());
// Check term types
assert!(named_node.is_named_node());
assert!(literal.is_literal());
assert!(blank_node.is_blank_node());
assert!(variable.is_variable());
§Variants
Variants§
NamedNode(NamedNode)
A named node (IRI reference)
Represents a resource identified by an IRI according to RFC 3987. Used for subjects, predicates, and objects in RDF triples.
BlankNode(BlankNode)
A blank node (anonymous resource)
Represents an anonymous resource that can be used as a subject or object but not as a predicate. Blank nodes have local scope within a graph.
Literal(Literal)
A literal value
Represents a data value with an optional datatype and language tag. Can only be used as objects in RDF triples.
Variable(Variable)
A query variable
Represents a variable in SPARQL queries or graph patterns. Variables are prefixed with ‘?’ or ‘$’ in SPARQL syntax.
QuotedTriple(Box<QuotedTriple>)
A quoted triple (RDF-star)
Represents a triple that can itself be used as a subject or object in another triple, enabling statement-level metadata.
Implementations§
Source§impl Term
impl Term
Sourcepub fn is_named_node(&self) -> bool
pub fn is_named_node(&self) -> bool
Returns true
if this term is a named node (IRI reference)
§Examples
use oxirs_core::model::{Term, NamedNode, Literal};
let named_node = Term::NamedNode(NamedNode::new("http://example.org/resource").unwrap());
let literal = Term::Literal(Literal::new("Hello"));
assert!(named_node.is_named_node());
assert!(!literal.is_named_node());
Sourcepub fn is_blank_node(&self) -> bool
pub fn is_blank_node(&self) -> bool
Returns true
if this term is a blank node
§Examples
use oxirs_core::model::{Term, BlankNode, Literal};
let blank_node = Term::BlankNode(BlankNode::new("b1").unwrap());
let literal = Term::Literal(Literal::new("Hello"));
assert!(blank_node.is_blank_node());
assert!(!literal.is_blank_node());
Sourcepub fn is_literal(&self) -> bool
pub fn is_literal(&self) -> bool
Returns true
if this term is a literal value
§Examples
use oxirs_core::model::{Term, NamedNode, Literal};
let literal = Term::Literal(Literal::new("Hello"));
let named_node = Term::NamedNode(NamedNode::new("http://example.org/resource").unwrap());
assert!(literal.is_literal());
assert!(!named_node.is_literal());
Sourcepub fn is_variable(&self) -> bool
pub fn is_variable(&self) -> bool
Returns true
if this term is a query variable
§Examples
use oxirs_core::model::{Term, Variable, Literal};
let variable = Term::Variable(Variable::new("x").unwrap());
let literal = Term::Literal(Literal::new("Hello"));
assert!(variable.is_variable());
assert!(!literal.is_variable());
Sourcepub fn is_quoted_triple(&self) -> bool
pub fn is_quoted_triple(&self) -> bool
Returns true
if this term is a quoted triple (RDF-star)
§Examples
use oxirs_core::model::{Term, Literal};
let literal = Term::Literal(Literal::new("Hello"));
assert!(!literal.is_quoted_triple());
// Note: Creating QuotedTriple examples requires more complex setup
Sourcepub fn as_named_node(&self) -> Option<&NamedNode>
pub fn as_named_node(&self) -> Option<&NamedNode>
Returns the named node if this term is a named node
Sourcepub fn as_blank_node(&self) -> Option<&BlankNode>
pub fn as_blank_node(&self) -> Option<&BlankNode>
Returns the blank node if this term is a blank node
Sourcepub fn as_literal(&self) -> Option<&Literal>
pub fn as_literal(&self) -> Option<&Literal>
Returns the literal if this term is a literal
Sourcepub fn as_variable(&self) -> Option<&Variable>
pub fn as_variable(&self) -> Option<&Variable>
Returns the variable if this term is a variable
Sourcepub fn as_quoted_triple(&self) -> Option<&QuotedTriple>
pub fn as_quoted_triple(&self) -> Option<&QuotedTriple>
Returns the quoted triple if this term is a quoted triple
Sourcepub fn from_subject(subject: &Subject) -> Term
pub fn from_subject(subject: &Subject) -> Term
Convert a Subject to a Term
Sourcepub fn from_predicate(predicate: &Predicate) -> Term
pub fn from_predicate(predicate: &Predicate) -> Term
Convert a Predicate to a Term
Sourcepub fn from_object(object: &Object) -> Term
pub fn from_object(object: &Object) -> Term
Convert an Object to a Term
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Term
impl<'de> Deserialize<'de> for Term
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<GroundTerm> for Term
impl From<GroundTerm> for Term
Source§fn from(term: GroundTerm) -> Self
fn from(term: GroundTerm) -> Self
Source§impl From<NamedOrBlankNode> for Term
impl From<NamedOrBlankNode> for Term
Source§fn from(node: NamedOrBlankNode) -> Self
fn from(node: NamedOrBlankNode) -> Self
Source§impl Ord for Term
impl Ord for Term
Source§impl PartialOrd for Term
impl PartialOrd for Term
Source§impl RdfTerm for Term
impl RdfTerm for Term
Source§fn is_named_node(&self) -> bool
fn is_named_node(&self) -> bool
Source§fn is_blank_node(&self) -> bool
fn is_blank_node(&self) -> bool
Source§fn is_literal(&self) -> bool
fn is_literal(&self) -> bool
Source§fn is_variable(&self) -> bool
fn is_variable(&self) -> bool
Source§fn is_quoted_triple(&self) -> bool
fn is_quoted_triple(&self) -> bool
Source§impl TryFrom<Term> for GroundTerm
impl TryFrom<Term> for GroundTerm
Source§impl ZeroCopySerialize for Term
impl ZeroCopySerialize for Term
Source§fn serialized_size(&self) -> usize
fn serialized_size(&self) -> usize
Source§fn serialize_to_bytes(&self, buf: &mut BytesMut)
fn serialize_to_bytes(&self, buf: &mut BytesMut)
impl Eq for Term
impl StructuralPartialEq for Term
Auto Trait Implementations§
impl Freeze for Term
impl RefUnwindSafe for Term
impl Send for Term
impl Sync for Term
impl Unpin for Term
impl UnwindSafe for Term
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.