LiteralRef

Struct LiteralRef 

Source
pub struct LiteralRef<'a>(/* private fields */);
Expand description

A borrowed RDF literal.

The default string formatter is returning an N-Triples, Turtle, and SPARQL compatible representation:

use oxirs_core::model::literal::LiteralRef;
use oxirs_core::vocab::xsd;

assert_eq!(
    "\"foo\\nbar\"",
    LiteralRef::new_simple_literal("foo\nbar").to_string()
);

assert_eq!(
    r#""1999-01-01"^^<http://www.w3.org/2001/XMLSchema#date>"#,
    LiteralRef::new_typed_literal("1999-01-01", xsd::DATE.as_ref()).to_string()
);

Implementations§

Source§

impl<'a> LiteralRef<'a>

Source

pub const fn new_simple_literal(value: &'a str) -> Self

Builds an RDF simple literal.

Source

pub const fn new(value: &'a str) -> Self

Creates a new literal reference (alias for compatibility)

Source

pub fn new_typed_literal( value: &'a str, datatype: impl Into<NamedNodeRef<'a>>, ) -> Self

Builds an RDF literal with a datatype.

Source

pub fn new_typed(value: &'a str, datatype: NamedNodeRef<'a>) -> Self

Creates a new typed literal reference (alias for compatibility)

Source

pub const fn new_language_tagged_literal_unchecked( value: &'a str, language: &'a str, ) -> Self

Builds an RDF language-tagged string.

It is the responsibility of the caller to check that language is valid BCP47 language tag, and is lowercase.

Literal::new_language_tagged_literal() is a safe version of this constructor and should be used for untrusted data.

Source

pub const fn new_lang(value: &'a str, language: &'a str) -> Self

Creates a new language-tagged literal reference (alias for compatibility)

Source

pub const fn value(self) -> &'a str

The literal lexical form

Source

pub const fn language(self) -> Option<&'a str>

The literal language tag if it is a language-tagged string.

Language tags are defined by the BCP47. They are normalized to lowercase by this implementation.

Source

pub fn datatype(self) -> NamedNodeRef<'a>

The literal datatype.

The datatype of language-tagged string is always rdf:langString. The datatype of simple literals is xsd:string.

Source

pub const fn is_plain(self) -> bool

👎Deprecated since 0.3.0: Plain literal concept is removed in RDF 1.1

Checks if this literal could be seen as an RDF 1.0 plain literal.

It returns true if the literal is a language-tagged string or has the datatype xsd:string.

Source

pub fn into_owned(self) -> Literal

Source

pub fn to_owned(&self) -> Literal

Converts to an owned Literal (alias for compatibility)

Trait Implementations§

Source§

impl<'a> Clone for LiteralRef<'a>

Source§

fn clone(&self) -> LiteralRef<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for LiteralRef<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LiteralRef<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Literal> for LiteralRef<'a>

Source§

fn from(node: &'a Literal) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for LiteralRef<'a>

Source§

fn from(value: &'a str) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<LiteralRef<'a>> for Literal

Source§

fn from(node: LiteralRef<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> Hash for LiteralRef<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq<Literal> for LiteralRef<'_>

Source§

fn eq(&self, other: &Literal) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<LiteralRef<'_>> for Literal

Source§

fn eq(&self, other: &LiteralRef<'_>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq for LiteralRef<'a>

Source§

fn eq(&self, other: &LiteralRef<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> RdfTerm for LiteralRef<'a>

Source§

fn as_str(&self) -> &str

Returns the string representation of this term
Source§

fn is_literal(&self) -> bool

Returns true if this is a literal
Source§

fn is_named_node(&self) -> bool

Returns true if this is a named node (IRI)
Source§

fn is_blank_node(&self) -> bool

Returns true if this is a blank node
Source§

fn is_variable(&self) -> bool

Returns true if this is a variable
Source§

fn is_quoted_triple(&self) -> bool

Returns true if this is a quoted triple (RDF-star)
Source§

impl<'a> Copy for LiteralRef<'a>

Source§

impl<'a> Eq for LiteralRef<'a>

Source§

impl<'a> StructuralPartialEq for LiteralRef<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for LiteralRef<'a>

§

impl<'a> RefUnwindSafe for LiteralRef<'a>

§

impl<'a> Send for LiteralRef<'a>

§

impl<'a> Sync for LiteralRef<'a>

§

impl<'a> Unpin for LiteralRef<'a>

§

impl<'a> UnwindSafe for LiteralRef<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,