Struct oxrdf::LiteralRef
source · pub struct LiteralRef<'a>(_);
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!(
"\"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 fn new_simple_literal(value: &'a str) -> Self
pub fn new_simple_literal(value: &'a str) -> Self
Builds an RDF simple literal.
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_language_tagged_literal_unchecked(
value: &'a str,
language: &'a str
) -> Self
pub 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 fn value(self) -> &'a str
pub fn value(self) -> &'a str
The literal lexical form
sourcepub fn language(self) -> Option<&'a str>
pub 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 fn is_plain(self) -> bool
pub 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 From<LiteralRef<'_>> for Term
impl From<LiteralRef<'_>> for Term
source§fn from(literal: LiteralRef<'_>) -> Self
fn from(literal: LiteralRef<'_>) -> Self
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> From<LiteralRef<'a>> for TermRef<'a>
impl<'a> From<LiteralRef<'a>> for TermRef<'a>
source§fn from(literal: LiteralRef<'a>) -> Self
fn from(literal: 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§fn eq(&self, other: &LiteralRef<'_>) -> bool
fn eq(&self, other: &LiteralRef<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> PartialEq<LiteralRef<'a>> for LiteralRef<'a>
impl<'a> PartialEq<LiteralRef<'a>> for LiteralRef<'a>
source§fn eq(&self, other: &LiteralRef<'a>) -> bool
fn eq(&self, other: &LiteralRef<'a>) -> bool
self
and other
values to be equal, and is used
by ==
.