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 oxrdf::LiteralRef;
use oxrdf::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).to_string()
);
Implementations§
Source§impl<'a> LiteralRef<'a>
impl<'a> LiteralRef<'a>
Sourcepub const fn new_simple_literal(value: &'a str) -> LiteralRef<'a>
pub const fn new_simple_literal(value: &'a str) -> LiteralRef<'a>
Builds an RDF simple literal.
Sourcepub fn new_typed_literal(
value: &'a str,
datatype: impl Into<NamedNodeRef<'a>>,
) -> LiteralRef<'a>
pub fn new_typed_literal( value: &'a str, datatype: impl Into<NamedNodeRef<'a>>, ) -> LiteralRef<'a>
Sourcepub const fn new_language_tagged_literal_unchecked(
value: &'a str,
language: &'a str,
) -> LiteralRef<'a>
pub const fn new_language_tagged_literal_unchecked( value: &'a str, language: &'a str, ) -> LiteralRef<'a>
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.
Sourcepub const fn value(self) -> &'a str
pub const fn value(self) -> &'a str
The literal lexical form
Sourcepub const fn language(self) -> Option<&'a str>
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.
Sourcepub const fn datatype(self) -> NamedNodeRef<'a>
pub const 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.
Sourcepub const fn is_plain(self) -> bool
👎Deprecated since 0.3.0: Plain literal concept is removed in RDF 1.1
pub const fn is_plain(self) -> bool
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.
pub fn into_owned(self) -> Literal
Trait Implementations§
Source§impl<'a> Clone for LiteralRef<'a>
impl<'a> Clone for LiteralRef<'a>
Source§fn clone(&self) -> LiteralRef<'a>
fn clone(&self) -> LiteralRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a> Debug for LiteralRef<'a>
impl<'a> Debug for LiteralRef<'a>
Source§impl Display for LiteralRef<'_>
impl Display for LiteralRef<'_>
Source§impl<'a> From<&'a Literal> for LiteralRef<'a>
impl<'a> From<&'a Literal> for LiteralRef<'a>
Source§fn from(node: &'a Literal) -> LiteralRef<'a>
fn from(node: &'a Literal) -> LiteralRef<'a>
Source§impl<'a> From<&'a str> for LiteralRef<'a>
impl<'a> From<&'a str> for LiteralRef<'a>
Source§fn from(value: &'a str) -> LiteralRef<'a>
fn from(value: &'a str) -> LiteralRef<'a>
Source§impl From<LiteralRef<'_>> for PlainTermScalar
impl From<LiteralRef<'_>> for PlainTermScalar
Source§fn from(term: LiteralRef<'_>) -> PlainTermScalar
fn from(term: LiteralRef<'_>) -> PlainTermScalar
Source§impl From<LiteralRef<'_>> for Term
impl From<LiteralRef<'_>> for Term
Source§fn from(literal: LiteralRef<'_>) -> Term
fn from(literal: LiteralRef<'_>) -> Term
Source§impl<'a> From<LiteralRef<'a>> for Literal
impl<'a> From<LiteralRef<'a>> for Literal
Source§fn from(node: LiteralRef<'a>) -> Literal
fn from(node: LiteralRef<'a>) -> Literal
Source§impl<'a> From<LiteralRef<'a>> for TermRef<'a>
impl<'a> From<LiteralRef<'a>> for TermRef<'a>
Source§fn from(literal: LiteralRef<'a>) -> TermRef<'a>
fn from(literal: LiteralRef<'a>) -> TermRef<'a>
Source§impl<'a> Hash for LiteralRef<'a>
impl<'a> Hash for LiteralRef<'a>
Source§impl PartialEq<Literal> for LiteralRef<'_>
impl PartialEq<Literal> for LiteralRef<'_>
Source§impl PartialEq<LiteralRef<'_>> for Literal
impl PartialEq<LiteralRef<'_>> for Literal
Source§impl<'a> PartialEq for LiteralRef<'a>
impl<'a> PartialEq for LiteralRef<'a>
Source§impl<'data> TryFrom<LiteralRef<'data>> for TypedValueRef<'data>
impl<'data> TryFrom<LiteralRef<'data>> for TypedValueRef<'data>
Source§type Error = TermToTypedValueError
type Error = TermToTypedValueError
Source§fn try_from(
value: LiteralRef<'data>,
) -> Result<TypedValueRef<'data>, <TypedValueRef<'data> as TryFrom<LiteralRef<'data>>>::Error>
fn try_from( value: LiteralRef<'data>, ) -> Result<TypedValueRef<'data>, <TypedValueRef<'data> as TryFrom<LiteralRef<'data>>>::Error>
impl<'a> Copy for LiteralRef<'a>
impl<'a> Eq for LiteralRef<'a>
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> 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> 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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