pub struct Triple {
pub subject: Subject,
pub predicate: NamedNode,
pub object: Term,
}
Expand description
An owned RDF triple.
The default string formatter is returning an N-Triples, Turtle, and SPARQL compatible representation:
use oxrdf::{NamedNode, Triple};
assert_eq!(
"<http://example.com/s> <http://example.com/p> <http://example.com/o>",
Triple {
subject: NamedNode::new("http://example.com/s")?.into(),
predicate: NamedNode::new("http://example.com/p")?,
object: NamedNode::new("http://example.com/o")?.into(),
}
.to_string()
);
Fields§
§subject: Subject
The subject of this triple.
predicate: NamedNode
The predicate of this triple.
object: Term
The object of this triple.
Implementations§
Source§impl Triple
impl Triple
Sourcepub fn new(
subject: impl Into<Subject>,
predicate: impl Into<NamedNode>,
object: impl Into<Term>,
) -> Triple
pub fn new( subject: impl Into<Subject>, predicate: impl Into<NamedNode>, object: impl Into<Term>, ) -> Triple
Builds an RDF triple.
Sourcepub fn from_terms(
subject: impl Into<Term>,
predicate: impl Into<Term>,
object: impl Into<Term>,
) -> Result<Triple, TryFromTermError>
pub fn from_terms( subject: impl Into<Term>, predicate: impl Into<Term>, object: impl Into<Term>, ) -> Result<Triple, TryFromTermError>
Builds an RDF triple from Term
s.
Returns a TryFromTermError
error if the generated triple would be ill-formed.
Sourcepub fn in_graph(self, graph_name: impl Into<GraphName>) -> Quad
pub fn in_graph(self, graph_name: impl Into<GraphName>) -> Quad
Encodes that this triple is in an RDF dataset.
pub fn as_ref(&self) -> TripleRef<'_>
Trait Implementations§
Source§impl From<Triple> for TriplePattern
impl From<Triple> for TriplePattern
Source§impl FromStr for Triple
impl FromStr for Triple
Source§fn from_str(s: &str) -> Result<Triple, <Triple as FromStr>::Err>
fn from_str(s: &str) -> Result<Triple, <Triple as FromStr>::Err>
Parses a triple from its NTriples serialization
use oxrdf::{BlankNode, Literal, NamedNode, Triple};
use std::str::FromStr;
assert_eq!(
Triple::from_str("_:a <http://example.com/p> \"o\" .")?,
Triple::new(
BlankNode::new("a")?,
NamedNode::new("http://example.com/p")?,
Literal::new_simple_literal("o")
)
);
Source§type Err = TermParseError
type Err = TermParseError
The associated error which can be returned from parsing.
Source§impl TryFrom<Triple> for GroundTriple
impl TryFrom<Triple> for GroundTriple
Source§impl TryFrom<TriplePattern> for Triple
impl TryFrom<TriplePattern> for Triple
impl Eq for Triple
impl StructuralPartialEq for Triple
Auto Trait Implementations§
impl Freeze for Triple
impl RefUnwindSafe for Triple
impl Send for Triple
impl Sync for Triple
impl Unpin for Triple
impl UnwindSafe for Triple
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