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
Fields
value: &'a str
The lexical form.
A simple literal without datatype or language form.
LanguageTaggedString
Typed
A literal with an explicit datatype
Trait Implementations
Performs the conversion.
Return the “value” of this term, possibly split in two substrings. The second part might only be non-empty if this term is an IRI reference. Read more
Return the datatype IRI of this term if it is a literal. Read more
Return the language tag of this term if it is a language-tagged literal. Read more
This method ensures that all implementations of TTerm
can be turned into a trait object. Read more
Return the “value” of this term, which depends on its kind: Read more
All terms are absolute, except for: Read more
Auto Trait Implementations
impl<'a> RefUnwindSafe for Literal<'a>
impl<'a> UnwindSafe for Literal<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
Try to copy this IRI into another type.