pub enum Literal<'a> {
Simple {
value: &'a str,
},
LanguageTaggedString {
value: &'a str,
language: &'a str,
},
Typed {
value: &'a str,
datatype: NamedNode<'a>,
},
}
Expand description
An RDF literal.
The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation.
The language tags should be lowercased as suggested by the RDF specification.
use rio_api::model::NamedNode;
use rio_api::model::Literal;
assert_eq!(
"\"foo\\nbar\"",
Literal::Simple { value: "foo\nbar" }.to_string()
);
assert_eq!(
"\"1999-01-01\"^^<http://www.w3.org/2001/XMLSchema#date>",
Literal::Typed { value: "1999-01-01", datatype: NamedNode {iri: "http://www.w3.org/2001/XMLSchema#date" }}.to_string()
);
assert_eq!(
"\"foo\"@en",
Literal::LanguageTaggedString { value: "foo", language: "en" }.to_string()
);
Variants§
Simple
A simple literal without datatype or language form.
Fields
§
value: &'a str
The lexical form.
LanguageTaggedString
Typed
A literal with an explicit datatype
Trait Implementations§
Source§impl<'a> From<Literal<'a>> for GeneralizedTerm<'a>
impl<'a> From<Literal<'a>> for GeneralizedTerm<'a>
Source§fn from(other: Literal<'a>) -> GeneralizedTerm<'a>
fn from(other: Literal<'a>) -> GeneralizedTerm<'a>
Converts to this type from the input type.
impl<'a> Copy for Literal<'a>
impl<'a> Eq for Literal<'a>
impl<'a> StructuralPartialEq for Literal<'a>
Auto Trait Implementations§
impl<'a> Freeze for Literal<'a>
impl<'a> RefUnwindSafe for Literal<'a>
impl<'a> Send for Literal<'a>
impl<'a> Sync for Literal<'a>
impl<'a> Unpin for Literal<'a>
impl<'a> UnwindSafe for Literal<'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
Mutably borrows from an owned value. Read more