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:
-
a lexical form, being a Unicode string, which SHOULD be in Normal Form C
-
a datatype IRI, being an IRI identifying a datatype that determines how the lexical form maps to a literal value,
-
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
impl Literal
pub fn as_term(&self) -> Term
pub fn as_iri(&self) -> Option<Iri<'_>>
pub fn as_local_name(&self) -> Option<String>
pub fn as_str(&self) -> Option<&str>
pub fn as_string(&self) -> Option<String>
pub fn as_boolean(&self) -> Option<bool>
pub fn as_signed_long(&self) -> Option<i64>
pub fn as_unsigned_long(&self) -> Option<u64>
pub fn as_date(&self) -> Option<NaiveDate>
pub fn as_date_time(&self) -> Option<&DateTime<Utc>>
pub fn as_decimal(&self) -> Option<&str>
pub fn as_duration(&self) -> Option<&str>
pub fn from_type_and_c_buffer( data_type: DataType, buffer: &[u8] ) -> Result<Option<Literal>, RDFStoreError>
pub fn from_type_and_buffer( data_type: DataType, buffer: &str, id_base_iri: Option<&IriBuf> ) -> Result<Option<Literal>, RDFStoreError>
fn date_from_str(buffer: &str) -> Result<Option<Literal>, RDFStoreError>
pub fn from_iri(iri: &Iri<'_>) -> Result<Self, RDFStoreError>
pub fn new_plain_literal_string(str: &str) -> Result<Self, RDFStoreError>
pub fn new_plain_literal_boolean(boolean: bool) -> Result<Self, RDFStoreError>
pub fn new_string_with_datatype( str: &str, data_type: DataType ) -> Result<Self, RDFStoreError>
sourcepub fn new_date_with_datatype(
date: NaiveDate,
data_type: DataType
) -> Result<Self, RDFStoreError>
pub fn new_date_with_datatype( date: NaiveDate, data_type: DataType ) -> Result<Self, RDFStoreError>
Use this only for naive dates (see https://docs.rs/chrono/latest/chrono/naive/struct.NaiveDate.html)
pub fn new_date_time_with_datatype( date_time: DateTime<Utc>, data_type: DataType ) -> Result<Self, RDFStoreError>
pub fn new_decimal_with_datatype( str: &str, data_type: DataType ) -> Result<Self, RDFStoreError>
pub fn new_duration_with_datatype( str: &str, data_type: DataType ) -> Result<Self, RDFStoreError>
pub fn new_iri_from_string_with_datatype( iri_string: &str, data_type: DataType, id_base_iri: Option<&IriBuf> ) -> Result<Self, RDFStoreError>
pub fn new_iri_reference_from_str(iri: &str) -> Result<Self, RDFStoreError>
pub fn new_iri_with_datatype( iri: &Iri<'_>, data_type: DataType ) -> Result<Self, RDFStoreError>
pub fn new_blank_node_with_datatype( id: &str, data_type: DataType ) -> Result<Self, RDFStoreError>
pub fn new_boolean(boolean: bool) -> Result<Self, RDFStoreError>
pub fn new_boolean_from_string( boolean_string: &str ) -> Result<Self, RDFStoreError>
pub fn new_boolean_from_string_with_datatype( boolean_string: &str, data_type: DataType ) -> Result<Self, RDFStoreError>
pub fn new_boolean_with_datatype( boolean: bool, data_type: DataType ) -> Result<Self, RDFStoreError>
pub fn new_signed_integer(signed_integer: i64) -> Result<Self, RDFStoreError>
pub fn new_signed_integer_with_datatype( signed_integer: i64, data_type: DataType ) -> Result<Self, RDFStoreError>
pub fn new_unsigned_integer( unsigned_integer: u64 ) -> Result<Self, RDFStoreError>
pub fn new_unsigned_integer_with_datatype( unsigned_integer: u64, data_type: DataType ) -> Result<Self, RDFStoreError>
pub fn display_turtle<'a, 'b>(&'a self) -> impl Display + 'a + 'bwhere
'a: 'b,
pub fn display_json<'a, 'b>(&'a self) -> impl Display + 'a + 'bwhere
'a: 'b,
pub fn as_url_display(&self) -> LiteralUrlDisplay<'_>
pub fn as_id_url_display<'a>( &'a self, id_base_iri: &'a IriBuf ) -> LiteralIdUrlDisplay<'_>
sourcepub fn is_id_iri(&self, id_base_iri: &IriBuf) -> bool
pub fn is_id_iri(&self, id_base_iri: &IriBuf) -> bool
Is the given Literal an IRI whose base is the given IRI?
pub fn as_id(&self, id_base_iri: &IriBuf) -> &str
Trait Implementations§
source§impl PartialEq for Literal
impl PartialEq for Literal
impl Eq for Literal
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§
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.