[][src]Struct oxigraph::model::Literal

pub struct Literal(_);

An owned RDF literal

The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation:

use oxigraph::model::Literal;
use oxigraph::model::vocab::xsd;

assert_eq!(
    "\"foo\\nbar\"",
    Literal::new_simple_literal("foo\nbar").to_string()
);

assert_eq!(
    "\"1999-01-01\"^^<http://www.w3.org/2001/XMLSchema#date>",
    Literal::new_typed_literal("1999-01-01", xsd::DATE).to_string()
);

assert_eq!(
    "\"foo\"@en",
    Literal::new_language_tagged_literal("foo", "en")?.to_string()
);

Implementations

impl Literal[src]

pub fn new_simple_literal(value: impl Into<String>) -> Self[src]

Builds an RDF simple literal

pub fn new_typed_literal(
    value: impl Into<String>,
    datatype: impl Into<NamedNode>
) -> Self
[src]

Builds an RDF literal with a datatype

pub fn new_language_tagged_literal(
    value: impl Into<String>,
    language: impl Into<String>
) -> Result<Self, LanguageTagParseError>
[src]

Builds an RDF language-tagged string

pub fn new_language_tagged_literal_unchecked(
    value: impl Into<String>,
    language: impl Into<String>
) -> Self
[src]

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.

new_language_tagged_literal is a safe version of this constructor and should be used for untrusted data.

pub fn value(&self) -> &str[src]

The literal lexical form

pub fn language(&self) -> Option<&str>[src]

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.

pub fn datatype(&self) -> NamedNodeRef<'_>[src]

The literal datatype.

The datatype of language-tagged string is always rdf:langString. The datatype of simple literals is xsd:string.

pub fn is_plain(&self) -> bool[src]

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 as_ref(&self) -> LiteralRef<'_>[src]

pub fn destruct(self) -> (String, Option<NamedNode>, Option<String>)[src]

Extract components from this literal

Trait Implementations

impl Clone for Literal[src]

impl Debug for Literal[src]

impl Display for Literal[src]

impl Eq for Literal[src]

impl<'a> From<&'a Literal> for LiteralRef<'a>[src]

impl<'a> From<&'a Literal> for TermRef<'a>[src]

impl<'a> From<&'a str> for Literal[src]

impl<'a> From<Cow<'a, str>> for Literal[src]

impl From<Literal> for Term[src]

impl<'a> From<LiteralRef<'a>> for Literal[src]

impl From<String> for Literal[src]

impl From<bool> for Literal[src]

impl From<f32> for Literal[src]

impl From<f64> for Literal[src]

impl From<i128> for Literal[src]

impl From<i16> for Literal[src]

impl From<i32> for Literal[src]

impl From<i64> for Literal[src]

impl From<u16> for Literal[src]

impl From<u32> for Literal[src]

impl From<u64> for Literal[src]

impl Hash for Literal[src]

impl PartialEq<Literal> for Literal[src]

impl<'_> PartialEq<Literal> for LiteralRef<'_>[src]

impl<'_> PartialEq<LiteralRef<'_>> for Literal[src]

impl StructuralEq for Literal[src]

impl StructuralPartialEq for Literal[src]

impl TTerm for Literal[src]

impl TryCopyTerm for Literal[src]

type Error = SophiaToOxigraphConversionError

The error type produced when failing to copy a given term

Auto Trait Implementations

impl RefUnwindSafe for Literal

impl Send for Literal

impl Sync for Literal

impl Unpin for Literal

impl UnwindSafe for Literal

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CopiableTerm for T where
    T: TTerm + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<U> TermMatcher for U where
    U: TTerm + ?Sized
[src]

type Term = U

Type of TTerm used internally by this matcher.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,