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() -> Value<T>

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>(&mut self, f: F)
where F: FnOnce(Option<T>) -> Option<T>,

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 for Value<T>
where T: Clone,

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 for Value<T>
where T: Debug,

Source§

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

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>) -> Object<T, B>

Converts to this type from the input type.
Source§

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

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

Source§

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

Source§

impl<V, I> LinkedData<I, V> for Value<<V as IriVocabulary>::Iri>

Source§

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

Visit the RDF dataset represented by this type.
Source§

impl<V, I> LinkedDataGraph<I, V> for Value<<V as IriVocabulary>::Iri>

Source§

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

Source§

impl<T, V, I> LinkedDataPredicateObjects<I, V> for Value<T>

Source§

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

Source§

impl<V, I> LinkedDataResource<I, V> for Value<<V as IriVocabulary>::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, I> LinkedDataSubject<I, V> for Value<T>

Source§

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

Source§

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

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 for Value<T>
where T: PartialEq,

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 for Value<T>
where T: PartialOrd,

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 for Value<T>
where T: Eq,

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<I, B, T> CompactIndexedFragment<I, B> for T
where T: Any<I, B>,

Source§

async fn compact_indexed_fragment<'a, N, L>( &'a self, vocabulary: &'a mut N, index: Option<&'a str>, active_context: &'a Context<I, B>, type_scoped_context: &'a Context<I, B>, active_property: Option<&'a str>, loader: &'a L, options: Options, ) -> Result<Value, Error>
where N: VocabularyMut<Iri = I, BlankId = B>, I: Clone + Hash + Eq, B: Clone + Hash + Eq, L: Loader,

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

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

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

Source§

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

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

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.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> ToOwned for T

Source§

type Owned = T

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>

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,