Skip to main content

Triple

Trait Triple 

Source
pub trait Triple<S, P, O>:
    Debug
    + Clone
    + Display
where S: Subject, P: Iri, O: Term,
{ // Required methods fn new(subj: impl Into<S>, pred: impl Into<P>, obj: impl Into<O>) -> Self; fn subj(&self) -> &S; fn pred(&self) -> &P; fn obj(&self) -> &O; fn into_components(self) -> (S, P, O); // Provided methods fn into_subject(self) -> S { ... } fn into_predicate(self) -> P { ... } fn into_object(self) -> O { ... } }
Expand description

Represents an RDF triple.

An RDF triple consists of three components: a subject, a predicate, and an object.

§Type Parameters

  • S - The subject type, which must implement Subject
  • P - The predicate type, which must implement Iri
  • O - The object type, which must implement Term

Required Methods§

Source

fn new(subj: impl Into<S>, pred: impl Into<P>, obj: impl Into<O>) -> Self

Constructs a new RDF triple from the given components.

§Parameters
  • subj - The subject of the triple, convertible to type S
  • pred - The predicate of the triple, convertible to type P
  • obj - The object of the triple, convertible to type O
Source

fn subj(&self) -> &S

Returns a reference to the subject of this triple.

Source

fn pred(&self) -> &P

Returns a reference to the predicate of this triple.

Source

fn obj(&self) -> &O

Returns a reference to the object of this triple.

Source

fn into_components(self) -> (S, P, O)

Consumes the triple and returns its components as a tuple.

This method takes ownership of the triple and returns (subject, predicate, object), allowing you to extract the individual components without cloning.

Provided Methods§

Source

fn into_subject(self) -> S

Consumes the triple and returns only the subject.

Source

fn into_predicate(self) -> P

Consumes the triple and returns only the predicate.

Source

fn into_object(self) -> O

Consumes the triple and returns only the object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Triple<NamedOrBlankNode, NamedNode, Term> for Triple

Implements the Triple trait for OxTriple.

Provides construction, field access, and decomposition for RDF triples consisting of subject, predicate, and object.

Source§

fn new( subj: impl Into<OxSubject>, pred: impl Into<OxNamedNode>, obj: impl Into<OxTerm>, ) -> Self

Creates a new RDF triple from subject, predicate, and object.

§Parameters
  • subj: The subject (IRI or blank node)
  • pred: The predicate (IRI/named node)
  • obj: The object (IRI, blank node, literal, or quoted triple)
Source§

fn subj(&self) -> &OxSubject

Returns a reference to the subject of this triple.

Source§

fn pred(&self) -> &OxNamedNode

Returns a reference to the predicate of this triple.

Source§

fn obj(&self) -> &OxTerm

Returns a reference to the object of this triple.

Source§

fn into_components(self) -> (OxSubject, OxNamedNode, OxTerm)

Consumes the triple and returns its components.

This method is useful when you need owned values rather than references, avoiding additional clones.

Implementors§