Struct rdf_store_rs::Literal

source ·
pub struct Literal {
    pub data_type: DataType,
    literal_value: LiteralValue,
}
Expand description

Literals are used for values such as strings, numbers, and dates. It consists of a DataType and a LiteralValue.

(See also RDF 1.1 Concepts and Abstract Syntax).

A literal in an RDF graph consists of two or three elements:

  1. a lexical form, being a Unicode string, which SHOULD be in Normal Form C

  2. a datatype IRI, being an IRI identifying a datatype that determines how the lexical form maps to a literal value,

  3. and if and only if the datatype IRI is http://www.w3.org/1999/02/22-rdf-syntax-ns#langString, a non-empty language tag as defined by BCP47. The language tag MUST be well-formed according to section 2.2.9 of BCP47.

Fields§

§data_type: DataType§literal_value: LiteralValue

Implementations§

source§

impl Literal

source

pub fn as_term(&self) -> Term

source

pub fn as_iri(&self) -> Option<Iri<'_>>

source

pub fn as_local_name(&self) -> Option<String>

source

pub fn as_str(&self) -> Option<&str>

source

pub fn as_string(&self) -> Option<String>

source

pub fn as_boolean(&self) -> Option<bool>

source

pub fn as_signed_long(&self) -> Option<i64>

source

pub fn as_unsigned_long(&self) -> Option<u64>

source

pub fn as_date(&self) -> Option<NaiveDate>

source

pub fn as_date_time(&self) -> Option<&DateTime<Utc>>

source

pub fn as_decimal(&self) -> Option<&str>

source

pub fn as_duration(&self) -> Option<&str>

source

pub fn from_type_and_c_buffer( data_type: DataType, buffer: &[u8] ) -> Result<Option<Literal>, RDFStoreError>

source

pub fn from_type_and_buffer( data_type: DataType, buffer: &str, id_base_iri: Option<&IriBuf> ) -> Result<Option<Literal>, RDFStoreError>

source

fn date_from_str(buffer: &str) -> Result<Option<Literal>, RDFStoreError>

source

pub fn from_iri(iri: &Iri<'_>) -> Result<Self, RDFStoreError>

source

pub fn new_plain_literal_string(str: &str) -> Result<Self, RDFStoreError>

source

pub fn new_plain_literal_boolean(boolean: bool) -> Result<Self, RDFStoreError>

source

pub fn new_string_with_datatype( str: &str, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn new_date_with_datatype( date: NaiveDate, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn new_date_time_with_datatype( date_time: DateTime<Utc>, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn new_decimal_with_datatype( str: &str, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn new_duration_with_datatype( str: &str, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn new_iri_from_string_with_datatype( iri_string: &str, data_type: DataType, id_base_iri: Option<&IriBuf> ) -> Result<Self, RDFStoreError>

source

pub fn new_iri_reference_from_str(iri: &str) -> Result<Self, RDFStoreError>

source

pub fn new_iri_with_datatype( iri: &Iri<'_>, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn new_blank_node_with_datatype( id: &str, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn new_boolean(boolean: bool) -> Result<Self, RDFStoreError>

source

pub fn new_boolean_from_string( boolean_string: &str ) -> Result<Self, RDFStoreError>

source

pub fn new_boolean_from_string_with_datatype( boolean_string: &str, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn new_boolean_with_datatype( boolean: bool, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn new_signed_integer(signed_integer: i64) -> Result<Self, RDFStoreError>

source

pub fn new_signed_integer_with_datatype( signed_integer: i64, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn new_unsigned_integer( unsigned_integer: u64 ) -> Result<Self, RDFStoreError>

source

pub fn new_unsigned_integer_with_datatype( unsigned_integer: u64, data_type: DataType ) -> Result<Self, RDFStoreError>

source

pub fn display_turtle<'a, 'b>(&'a self) -> impl Display + 'a + 'b
where 'a: 'b,

source

pub fn display_json<'a, 'b>(&'a self) -> impl Display + 'a + 'b
where 'a: 'b,

source

pub fn as_url_display(&self) -> LiteralUrlDisplay<'_>

source

pub fn as_id_url_display<'a>( &'a self, id_base_iri: &'a IriBuf ) -> LiteralIdUrlDisplay<'_>

source

pub fn is_id_iri(&self, id_base_iri: &IriBuf) -> bool

Is the given Literal an IRI whose base is the given IRI?

source

pub fn as_id(&self, id_base_iri: &IriBuf) -> &str

Trait Implementations§

source§

impl Clone for Literal

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Literal

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Literal

source§

fn default() -> Literal

Returns the “default value” for a type. Read more
source§

impl Display for Literal

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&str> for Literal

source§

fn from(value: &str) -> Self

Converts to this type from the input type.
source§

impl From<Literal> for Term

source§

fn from(value: Literal) -> Self

Converts to this type from the input type.
source§

impl FromStr for Literal

§

type Err = RDFStoreError

The associated error which can be returned from parsing.
source§

fn from_str(str: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Literal

source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Literal

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Literal

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T> ToStringFallible for T
where T: Display,

§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more