Skip to main content

Value

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>

Returns this value as a string slice.

Source

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

Returns the literal and its type, if this is a typed literal value.

Source

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

Returns the @type IRI of this value, if it is a typed literal with one.

Source

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

Sets the @type IRI of a typed literal value, returning the type it replaced.

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

Source

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

Replaces the @type IRI of a typed literal value with the result of f.

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

Source

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

Returns the value as a boolean, if it is a literal holding one.

Source

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

Returns the value as a number, if it is a literal holding one.

Source

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

Returns the @type of the value, if it has one.

JSON literal values report TypeRef::Json; language-tagged strings have no type and report None.

Source

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

Returns the @language of the value.

Returns None if the value is not a language-tagged string, or is one carrying only a @direction.

Source

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

Returns the @direction of the value.

Returns None if the value is not a language-tagged string, or is one carrying only a @language.

Source

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

Returns an iterator over the entries of the JSON representation of the value object.

Source

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

Puts the literal held by this value object into canonical form, using the given buffer to render numbers.

Source

pub fn canonicalize(&mut self)

Puts the literal held by this value object into canonical form.

Source

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

Rewrites the @type IRI of the value, if it has one, with the given function.

Trait Implementations§

Source§

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

Source§

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

Borrows the object as a value, node or list reference.
Source§

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

Returns the identifier (@id) of the object, if it is a node object with one.
Source§

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

Returns the language tag of this value, if it carries one.
Source§

fn is_value(&self) -> bool

Checks whether the object is a value object.
Source§

fn is_node(&self) -> bool

Checks whether the object is a node object.
Source§

fn is_graph(&self) -> bool

Checks whether the object is a graph object (a node object with a @graph entry).
Source§

fn is_list(&self) -> bool

Checks whether the object is a list object.
Source§

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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: Eq> Eq for Value<T>

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

Converts this value into JSON, resolving the identifiers it holds against the given vocabulary. Read more
Source§

impl<T, I: Interpretation> LinkedData<I> for Value<T>
where T: LinkedDataResource<I>,

Source§

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

Visit the RDF dataset represented by this type.
Source§

impl<T, I: Interpretation> LinkedDataGraph<I> for Value<T>
where T: LinkedDataResource<I>,

Source§

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

Visits the subjects of the graph represented by this value.
Source§

impl<T, I: Interpretation> LinkedDataPredicateObjects<I> for Value<T>
where T: LinkedDataResource<I>,

Source§

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

Visits the objects this predicate points at.
Source§

impl<T, I: Interpretation> LinkedDataResource<I> for Value<T>
where T: LinkedDataResource<I>,

Source§

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

Returns the interpretation of this resource, inserting it into interpretation if required.
Source§

fn lexical_representation<'a>( &'a self, interpretation: &'a mut I, ) -> Option<CowRdfTerm<'a>>

Returns the lexical term representing this resource, if any.
Source§

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

Returns the interpretation to use when this resource appears as a reference rather than as a subject with properties.
Source§

impl<T, I: Interpretation> LinkedDataSubject<I> for Value<T>
where T: LinkedDataResource<I>,

Source§

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

Visits the properties of the subject represented by this value.
Source§

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

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

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

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

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

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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: PartialEq> StructuralPartialEq for Value<T>

Auto Trait Implementations§

§

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

§

impl<T> RefUnwindSafe for Value<T>

§

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

§

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

§

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

§

impl<T> UnsafeUnpin for Value<T>
where Option<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Value<T>
where Option<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> 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> BorrowUnordered for T

Source§

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

Views this value as an Unordered reference.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Checks if self is equivalent to key.
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> 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: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

type Error = !

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

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