Enum Value

Source
pub enum Value<T = IriBuf> {
    Literal(Literal, Option<T>),
    LangString(LangString),
    Json(Value),
}
Expand description

Value object.

Either a typed literal value, or an internationalized language string.

Variants§

§

Literal(Literal, Option<T>)

Typed literal value.

§

LangString(LangString)

Language tagged string.

§

Json(Value)

JSON literal value.

Implementations§

Source§

impl<T> Value<T>

Source

pub fn null() -> Self

Creates a null value object.

Source

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

Source

pub fn as_literal(&self) -> Option<(&Literal, Option<&T>)>

Source

pub fn literal_type(&self) -> Option<&T>

Source

pub fn set_literal_type(&mut self, ty: Option<T>) -> Option<T>

Set the literal value type, and returns the old type.

Has no effect and return None if the value is not a literal value.

Source

pub fn map_literal_type<F: FnOnce(Option<T>) -> Option<T>>(&mut self, f: F)

Maps the literal value type.

Has no effect if the value is not a literal value.

Source

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

Source

pub fn as_number(&self) -> Option<&Number>

Source

pub fn typ(&self) -> Option<TypeRef<'_, T>>

Return the type of the value if any.

This will return Some(Type::Json) for JSON literal values.

Source

pub fn language(&self) -> Option<&LenientLangTag>

If the value is a language tagged string, return its associated language if any.

Returns None if the value is not a language tagged string.

Source

pub fn direction(&self) -> Option<Direction>

If the value is a language tagged string, return its associated direction if any.

Returns None if the value is not a language tagged string.

Source

pub fn entries(&self) -> Entries<'_, T>

Source

pub fn canonicalize_with(&mut self, buffer: &mut Buffer)

Puts this value object literal into canonical form using the given buffer.

The buffer is used to compute the canonical form of numbers.

Source

pub fn canonicalize(&mut self)

Puts this literal into canonical form.

Source

pub fn map_ids<U>(self, map_iri: impl FnOnce(T) -> U) -> Value<U>

Map the type IRI of this value, if any.

Trait Implementations§

Source§

impl<T, B> Any<T, B> for Value<T>

Source§

fn as_ref(&self) -> Ref<'_, T, B>

Source§

fn id(&self) -> Option<&Id<T, B>>

Source§

fn language<'a>(&'a self) -> Option<&'a LenientLangTag>
where T: 'a, B: 'a,

Source§

fn is_value(&self) -> bool

Source§

fn is_node(&self) -> bool

Source§

fn is_graph(&self) -> bool

Source§

fn is_list(&self) -> bool

Source§

impl<T: Clone> Clone for Value<T>

Source§

fn clone(&self) -> Value<T>

Returns a duplicate 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<T: Debug> Debug for Value<T>

Source§

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

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

impl<T, B> From<Value<T>> for Object<T, B>

Source§

fn from(value: Value<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Value<T>

Source§

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

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<T, N: IriVocabulary<Iri = T>> IntoJsonWithContext<N> for Value<T>

Source§

fn into_json_with(self, vocabulary: &N) -> Value

Source§

impl<V: Vocabulary, I: Interpretation> LinkedData<I, V> for Value<V::Iri>

Source§

fn visit<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
where S: Visitor<I, V>,

Visit the RDF dataset represented by this type.
Source§

impl<V: Vocabulary, I: Interpretation> LinkedDataGraph<I, V> for Value<V::Iri>

Source§

fn visit_graph<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
where S: GraphVisitor<I, V>,

Source§

impl<T, V: Vocabulary, I: Interpretation> LinkedDataPredicateObjects<I, V> for Value<T>

Source§

fn visit_objects<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
where S: PredicateObjectsVisitor<I, V>,

Source§

impl<V: Vocabulary, I: Interpretation> LinkedDataResource<I, V> for Value<V::Iri>

Source§

fn interpretation( &self, vocabulary: &mut V, _interpretation: &mut I, ) -> ResourceInterpretation<'_, I, V>

Source§

fn lexical_representation<'a>( &'a self, vocabulary: &'a mut V, interpretation: &'a mut I, ) -> Option<CowRdfTerm<'a, V>>
where I: ReverseTermInterpretation<Iri = <V as IriVocabulary>::Iri, BlankId = <V as BlankIdVocabulary>::BlankId, Literal = <V as LiteralVocabulary>::Literal>,

Source§

fn reference_interpretation( &self, vocabulary: &mut V, interpretation: &mut I, ) -> ResourceInterpretation<'_, I, V>

Source§

impl<T, V: Vocabulary, I: Interpretation> LinkedDataSubject<I, V> for Value<T>

Source§

fn visit_subject<S>(&self, visitor: S) -> Result<S::Ok, S::Error>
where S: SubjectVisitor<I, V>,

Source§

impl<T: Ord> Ord for Value<T>

Source§

fn cmp(&self, other: &Value<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq> PartialEq for Value<T>

Source§

fn eq(&self, other: &Value<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd for Value<T>

Source§

fn partial_cmp(&self, other: &Value<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Eq> Eq for Value<T>

Source§

impl<T> StructuralPartialEq for Value<T>

Auto Trait Implementations§

§

impl<T> Freeze for Value<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Value<T>
where T: RefUnwindSafe,

§

impl<T> Send for Value<T>
where T: Send,

§

impl<T> Sync for Value<T>
where T: Sync,

§

impl<T> Unpin for Value<T>
where T: Unpin,

§

impl<T> UnwindSafe for Value<T>
where T: UnwindSafe,

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> At for T

Source§

fn at<M>(self, metadata: M) -> Meta<T, M>

Wraps self inside a Meta<Self, M> using the given metadata. 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> BorrowStripped for T

Source§

fn stripped(&self) -> &Stripped<T>

Source§

impl<T> BorrowUnordered for T

Source§

impl<T> CallHasher for T
where T: Hash + ?Sized,

Source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, C> FromWithContext<T, C> for T

Source§

fn from_with(value: T, _context: &C) -> T

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.

Source§

impl<T, U, C> IntoWithContext<U, C> for T
where U: FromWithContext<T, C>,

Source§

fn into_with(self, context: &C) -> U

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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, C> TryFromWithContext<U, C> for T
where U: IntoWithContext<T, C>,

Source§

type Error = Infallible

Source§

fn try_from_with( value: U, context: &C, ) -> Result<T, <T as TryFromWithContext<U, C>>::Error>

Source§

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

Source§

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.
Source§

impl<T, U, C> TryIntoWithContext<U, C> for T
where U: TryFromWithContext<T, C>,

Source§

type Error = <U as TryFromWithContext<T, C>>::Error

Source§

fn try_into_with( self, context: &C, ) -> Result<U, <T as TryIntoWithContext<U, C>>::Error>

Source§

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

Source§

fn with<C>(&self, context: C) -> Contextual<&T, C>

Source§

fn into_with<C>(self, context: C) -> Contextual<T, C>