pub enum Value<T = IriBuf, M = ()> {
    Literal(Literal, Option<T>),
    LangString(LangString),
    Json(Meta<Value<M>, M>),
}
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(Meta<Value<M>, M>)

JSON literal value.

Implementations§

source§

impl<T, M> Value<T, M>

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<LenientLanguageTag<'_>>

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, M>

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.

Trait Implementations§

source§

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

source§

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

source§

fn id_entry<'a>(&'a self) -> Option<&'a Entry<Id<T, B>, M>>where M: 'a,

source§

fn id<'a>(&'a self) -> Option<&'a Meta<Id<T, B>, M>>where M: 'a,

source§

fn language<'a>(&'a self) -> Option<LenientLanguageTag<'_>>where T: 'a, B: 'a, M: '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, M: Clone> Clone for Value<T, M>

source§

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

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<T, B, M> From<Value<T, M>> for Object<T, B, M>

source§

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

Converts to this type from the input type.
source§

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

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

source§

fn into_json_meta_with(self, meta: M, vocabulary: &N) -> Meta<Value<M>, M>

source§

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

source§

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

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

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

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

source§

fn eq(&self, other: &Value<T, M>) -> 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<T: PartialOrd, M: PartialOrd> PartialOrd<Value<T, M>> for Value<T, M>

source§

fn partial_cmp(&self, other: &Value<T, M>) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: Hash, M> StrippedHash for Value<T, M>

source§

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

source§

impl<T: Ord, M> StrippedOrd for Value<T, M>

source§

fn stripped_cmp(&self, other: &Self) -> Ordering

source§

impl<T: PartialEq<T>, M, __M> StrippedPartialEq<Value<T, __M>> for Value<T, M>

source§

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

source§

impl<T: PartialOrd<T>, M, __M> StrippedPartialOrd<Value<T, __M>> for Value<T, M>

source§

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

source§

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

source§

impl<T: Eq, M> StrippedEq for Value<T, M>

source§

impl<T, M> StructuralEq for Value<T, M>

source§

impl<T, M> StructuralPartialEq for Value<T, M>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

impl<T> Any for Twhere 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 Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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§

fn unordered(&self) -> &Unordered<T>

§

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

§

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

source§

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

source§

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

source§

impl<Q, K> Equivalent<K> for Qwhere 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 Qwhere 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<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 Twhere 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 Twhere U: FromWithContext<T, C>,

source§

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

source§

impl<T> ToOwned for Twhere 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> ToOwned for T

§

type Owned = T

source§

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

§

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 Twhere 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.
source§

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

§

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 Twhere T: ?Sized,

source§

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

source§

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