pub enum Object {
Iri(IriS),
BlankNode(String),
Literal(ConcreteLiteral),
Triple {
subject: Box<IriOrBlankNode>,
predicate: IriS,
object: Box<Object>,
},
}Expand description
Represents an RDF object value in the object position of a triple.
In RDF, the object is the third component of a triple (subject-predicate-object) and can be one of four types:
- IRI: A resource identified by an Internationalized Resource Identifier
- Blank Node: An anonymous resource without a global identifier
- Literal: A concrete value (string, number, date, etc.) with optional datatype/language
- Triple (RDF-star): A quoted triple that can be nested as an object
Variants§
Iri(IriS)
An IRI (Internationalized Resource Identifier) representing a named resource.
BlankNode(String)
A blank node (anonymous resource) identified by a local label.
Literal(ConcreteLiteral)
A literal value with a datatype and optional language tag.
Triple
An RDF-star quoted triple that can be used as an object.
§Fields
subject: The subject of the nested triple (IRI or blank node)predicate: The predicate of the nested triple (IRI)object: The object of the nested triple (recursively an Object)
Implementations§
Source§impl Object
§Constructors methods
impl Object
§Constructors methods
Sourcepub fn literal(lit: ConcreteLiteral) -> Object
pub fn literal(lit: ConcreteLiteral) -> Object
Creates a literal object from a concrete literal value.
§Parameters
lit: The concrete literal to wrap as an object
Source§impl Object
§Accessors methods
impl Object
§Accessors methods
Sourcepub fn length(&self) -> usize
pub fn length(&self) -> usize
- For IRIs: the length of the IRI string
- For blank nodes: the length of the identifier
- For literals: the length of the lexical form
- For triples: the sum of all component lengths
Sourcepub fn numeric_value(&self) -> Option<NumericLiteral>
pub fn numeric_value(&self) -> Option<NumericLiteral>
Extracts the numeric value if this is a numeric literal.
§Returns
Some(NumericLiteral)if this is a numeric literal (integer, decimal, float, double)Noneif this is not a literal or not a numeric type
Source§impl Object
impl Object
Sourcepub fn parse(str: &str, base: Option<&str>) -> Result<Object, RDFError>
pub fn parse(str: &str, base: Option<&str>) -> Result<Object, RDFError>
§Parsing methods
Parses a string into an RDF object, with optional base IRI resolution.
This method attempts to parse:
- Blank nodes: strings starting with “_:”
- Literals: strings starting with ‘“’ (not yet implemented)
- IRIs: all other strings, resolved against the base if provided
§Parameters
str: The string to parsebase: Optional base IRI for resolving relative IRI references
§Errors
RDFError::ParsingIriif IRI parsing fails
Source§impl Object
§Formatting methods
impl Object
§Formatting methods
Sourcepub fn show_qualified(&self, prefixmap: &PrefixMap) -> String
pub fn show_qualified(&self, prefixmap: &PrefixMap) -> String
Formats this object using qualified names (prefixes) where possible.
This method produces a compact representation by replacing full IRIs with prefixed names (e.g., “rdf:type” instead of “http://www.w3.org/1999/02/22-rdf-syntax-ns#type”).
§Parameters
prefixmap: A prefix map containing IRI-to-prefix mappings
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Object
impl<'de> Deserialize<'de> for Object
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<ConcreteLiteral> for Object
Converts a ConcreteLiteral into an Object::Literal.
impl From<ConcreteLiteral> for Object
Converts a ConcreteLiteral into an Object::Literal.
This allows literals to be seamlessly used where objects are expected.
Source§fn from(lit: ConcreteLiteral) -> Self
fn from(lit: ConcreteLiteral) -> Self
Source§impl From<IriS> for Object
Converts an IriS into an Object::Iri.
impl From<IriS> for Object
Converts an IriS into an Object::Iri.
This allows IRIs to be seamlessly used where objects are expected.
Source§impl From<Object> for Term
Converts an Object into an oxrdf::Term.
impl From<Object> for Term
Converts an Object into an oxrdf::Term.
This enables interoperability with the oxrdf library by converting
the custom Object representation into oxrdf’s term type.
Source§impl Ord for Object
impl Ord for Object
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Implements total ordering for objects according to RDF semantics.
The ordering priority is: IRIs < Blank Nodes < Literals. Within each category, standard comparison applies:
- IRIs: lexicographic ordering of IRI strings
- Blank nodes: lexicographic ordering of identifiers
- Literals: ordering defined by
ConcreteLiteral::cmp
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Object
impl PartialOrd for Object
Source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Implements partial ordering for objects.
Since Object implements total ordering via Ord, this always returns
Some(ordering).
Source§impl TryFrom<Object> for IriOrBlankNode
Attempts to convert an Object into an IriOrBlankNode.
impl TryFrom<Object> for IriOrBlankNode
Attempts to convert an Object into an IriOrBlankNode.
This conversion succeeds only when the object is an IRI or blank node. It fails with an error if the object is a literal or triple, as these cannot be represented as resources.
§Errors
RDFError::ExpectedIriOrBlankNodeFoundLiteral: When attempting to convert a literal object. Literals cannot be subjects in standard RDF.RDFError::ExpectedIriOrBlankNodeFoundTriple: When attempting to convert an RDF-star triple object in a context where quoted triples are not supported.
Source§impl TryFrom<Object> for NamedOrBlankNode
Attempts to convert an Object into an oxrdf::NamedOrBlankNode.
impl TryFrom<Object> for NamedOrBlankNode
Attempts to convert an Object into an oxrdf::NamedOrBlankNode.
This conversion is used when an object appears in subject position (which can only be IRIs or blank nodes, not literals).
§Errors
Returns RDFError for objects that cannot be subjects (literals and triples).
Source§impl TryFrom<Term> for Object
Attempts to convert an oxrdf::Term into an Object.
impl TryFrom<Term> for Object
Attempts to convert an oxrdf::Term into an Object.
This enables interoperability with the oxrdf library by converting
oxrdf’s term type into the custom Object representation.
§Errors
Returns RDFError if the conversion fails (e.g., invalid literal format).
impl Eq for Object
impl StructuralPartialEq for Object
Auto Trait Implementations§
impl Freeze for Object
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnsafeUnpin for Object
impl UnwindSafe for Object
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<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> 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.