pub struct WithTypespace<'a, T: ?Sized> { /* private fields */ }
Expand description

Adds a Typespace context atop of a borrowed type.

Implementations§

source§

impl<'a> WithTypespace<'a, ProductType>

source

pub fn elements(&self) -> ElementsWithTypespace<'a>

source

pub fn with_values<I: IntoIterator<Item = &'a AlgebraicValue>>( &self, vals: I ) -> ElementValuesWithType<'a, I::IntoIter>

source§

impl<'a> WithTypespace<'a, ProductTypeElement>

source§

impl<T: ResolveRefs> WithTypespace<'_, T>

source

pub fn resolve_refs(self) -> Option<T::Output>

source§

impl<'a, T: ?Sized> WithTypespace<'a, T>

source

pub const fn new(typespace: &'a Typespace, ty: &'a T) -> Self

Wraps ty in a context combined with the typespace.

source

pub const fn ty(&self) -> &'a T

Returns the object that the context was created with.

source

pub const fn typespace(&self) -> &'a Typespace

Returns the typespace context.

source

pub fn with<'b, U>(&self, ty: &'b U) -> WithTypespace<'b, U>
where 'a: 'b,

Reuses the typespace we already have and returns ty: U wrapped with it.

source

pub fn with_value<'b, V: Value<Type = T>>( &self, val: &'b V ) -> ValueWithType<'b, V>
where 'a: 'b,

Wraps val with the type and typespace context in self.

source

pub fn resolve(&self, r: AlgebraicTypeRef) -> WithTypespace<'a, AlgebraicType>

Returns the AlgebraicType that r resolves to in the context of our Typespace.

Panics if r is not known by our Typespace.

source

pub fn map<U: ?Sized>( &self, f: impl FnOnce(&'a T) -> &'a U ) -> WithTypespace<'a, U>

Maps the object we’ve wrapped from &T -> &U in our context.

This can be used to e.g., project fields and through a structure. This provides an implementation of functor mapping for WithTypespace.

Trait Implementations§

source§

impl<T: ?Sized> Clone for WithTypespace<'_, T>

source§

fn clone(&self) -> Self

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<'a, T: Debug + ?Sized> Debug for WithTypespace<'a, T>

source§

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

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

impl<'de> DeserializeSeed<'de> for WithTypespace<'_, AlgebraicType>

§

type Output = AlgebraicValue

The type produced by using this seed.
source§

fn deserialize<D: Deserializer<'de>>( self, de: D ) -> Result<Self::Output, D::Error>

Equivalent to the more common Deserialize::deserialize associated function, except with some initial piece of data (the seed self) passed in.
source§

impl<'de> DeserializeSeed<'de> for WithTypespace<'_, ArrayType>

§

type Output = ArrayValue

The type produced by using this seed.
source§

fn deserialize<D: Deserializer<'de>>( self, deserializer: D ) -> Result<Self::Output, D::Error>

Equivalent to the more common Deserialize::deserialize associated function, except with some initial piece of data (the seed self) passed in.
source§

impl<'de> DeserializeSeed<'de> for WithTypespace<'_, MapType>

§

type Output = BTreeMap<AlgebraicValue, AlgebraicValue>

The type produced by using this seed.
source§

fn deserialize<D: Deserializer<'de>>( self, deserializer: D ) -> Result<Self::Output, D::Error>

Equivalent to the more common Deserialize::deserialize associated function, except with some initial piece of data (the seed self) passed in.
source§

impl<'de> DeserializeSeed<'de> for WithTypespace<'_, ProductType>

§

type Output = ProductValue

The type produced by using this seed.
source§

fn deserialize<D: Deserializer<'de>>( self, deserializer: D ) -> Result<Self::Output, D::Error>

Equivalent to the more common Deserialize::deserialize associated function, except with some initial piece of data (the seed self) passed in.
source§

impl<'de> DeserializeSeed<'de> for WithTypespace<'_, SumType>

§

type Output = SumValue

The type produced by using this seed.
source§

fn deserialize<D: Deserializer<'de>>( self, deserializer: D ) -> Result<Self::Output, D::Error>

Equivalent to the more common Deserialize::deserialize associated function, except with some initial piece of data (the seed self) passed in.
source§

impl<'a> IntoIterator for WithTypespace<'a, ProductType>

§

type Item = WithTypespace<'a, ProductTypeElement>

The type of the elements being iterated over.
§

type IntoIter = IterWithTypespace<'a, Iter<'a, ProductTypeElement>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'de> ProductVisitor<'de> for WithTypespace<'_, ProductType>

§

type Output = ProductValue

The resulting product.
source§

fn product_name(&self) -> Option<&str>

Returns the name of the product, if any.
source§

fn product_len(&self) -> usize

Returns the length of the product.
source§

fn visit_seq_product<A: SeqProductAccess<'de>>( self, tup: A ) -> Result<Self::Output, A::Error>

The input contains an unnamed product.
source§

fn visit_named_product<A: NamedProductAccess<'de>>( self, tup: A ) -> Result<Self::Output, A::Error>

The input contains a named product.
source§

fn product_kind(&self) -> ProductKind

Returns the kind of the product.
source§

impl<'de> SumVisitor<'de> for WithTypespace<'_, SumType>

§

type Output = SumValue

The resulting sum.
source§

fn sum_name(&self) -> Option<&str>

Returns the name of the sum, if any.
source§

fn is_option(&self) -> bool

Returns whether an option is expected. Read more
source§

fn visit_sum<A: SumAccess<'de>>(self, data: A) -> Result<Self::Output, A::Error>

Drives the deserialization of a sum value. Read more
source§

impl VariantVisitor for WithTypespace<'_, SumType>

§

type Output = u8

The result of identifying a variant, e.g., some index type.
source§

fn variant_names(&self, names: &mut dyn ValidNames)

Provides the visitor the chance to add valid names into names.
source§

fn visit_tag<E: Error>(self, tag: u8) -> Result<Self::Output, E>

Identify the variant based on tag.
source§

fn visit_name<E: Error>(self, name: &str) -> Result<Self::Output, E>

Identify the variant based on name.
source§

impl<T: ?Sized> Copy for WithTypespace<'_, T>

Auto Trait Implementations§

§

impl<'a, T: ?Sized> RefUnwindSafe for WithTypespace<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T: ?Sized> Send for WithTypespace<'a, T>
where T: Sync,

§

impl<'a, T: ?Sized> Sync for WithTypespace<'a, T>
where T: Sync,

§

impl<'a, T: ?Sized> Unpin for WithTypespace<'a, T>

§

impl<'a, T: ?Sized> UnwindSafe for WithTypespace<'a, T>
where T: RefUnwindSafe,

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

source§

fn from(t: T) -> T

Returns the argument unchanged.

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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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, U> TryFrom<U> for T
where 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> TryInto<U> for T
where 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> 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