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 Extend<Triple> for Graph
impl Extend<Triple> for Graph
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = Triple>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = Triple>,
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl Extend<Triple> for GraphViewMut<'_>
impl Extend<Triple> for GraphViewMut<'_>
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = Triple>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = Triple>,
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<'a> From<&'a Triple> for SubjectRef<'a>
impl<'a> From<&'a Triple> for SubjectRef<'a>
Source§fn from(node: &'a Triple) -> SubjectRef<'a>
fn from(node: &'a Triple) -> SubjectRef<'a>
Converts to this type from the input type.
Source§impl FromIterator<Triple> for Graph
impl FromIterator<Triple> for Graph
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<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