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>
impl<'a> LiteralRef<'a>
Sourcepub const fn new_simple_literal(value: &'a str) -> Self
pub const fn new_simple_literal(value: &'a str) -> Self
Builds an RDF simple literal.
Sourcepub const fn new(value: &'a str) -> Self
pub const fn new(value: &'a str) -> Self
Creates a new literal reference (alias for compatibility)
Sourcepub fn new_typed_literal(
value: &'a str,
datatype: impl Into<NamedNodeRef<'a>>,
) -> Self
pub fn new_typed_literal( value: &'a str, datatype: impl Into<NamedNodeRef<'a>>, ) -> Self
Sourcepub fn new_typed(value: &'a str, datatype: NamedNodeRef<'a>) -> Self
pub fn new_typed(value: &'a str, datatype: NamedNodeRef<'a>) -> Self
Creates a new typed literal reference (alias for compatibility)
Sourcepub const fn new_language_tagged_literal_unchecked(
value: &'a str,
language: &'a str,
) -> Self
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.
Sourcepub const fn new_lang(value: &'a str, language: &'a str) -> Self
pub const fn new_lang(value: &'a str, language: &'a str) -> Self
Creates a new language-tagged literal reference (alias for compatibility)
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 fn datatype(self) -> NamedNodeRef<'a>
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.
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§impl<'a> From<&'a str> for LiteralRef<'a>
impl<'a> From<&'a str> for LiteralRef<'a>
Source§impl<'a> From<LiteralRef<'a>> for Literal
impl<'a> From<LiteralRef<'a>> for Literal
Source§fn from(node: LiteralRef<'a>) -> Self
fn from(node: LiteralRef<'a>) -> Self
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<'a> RdfTerm for LiteralRef<'a>
impl<'a> RdfTerm for LiteralRef<'a>
Source§fn is_literal(&self) -> bool
fn is_literal(&self) -> bool
Source§fn is_named_node(&self) -> bool
fn is_named_node(&self) -> bool
Source§fn is_blank_node(&self) -> bool
fn is_blank_node(&self) -> bool
Source§fn is_variable(&self) -> bool
fn is_variable(&self) -> bool
Source§fn is_quoted_triple(&self) -> bool
fn is_quoted_triple(&self) -> bool
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> 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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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.