Diffstat (limited to 'src/walk/walkers/serde/deserializer.rs')
| -rw-r--r-- | src/walk/walkers/serde/deserializer.rs | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/src/walk/walkers/serde/deserializer.rs b/src/walk/walkers/serde/deserializer.rs index 4537e07..a37b4fb 100644 --- a/src/walk/walkers/serde/deserializer.rs +++ b/src/walk/walkers/serde/deserializer.rs @@ -1,10 +1,11 @@ use crate::walk::walkers::core::noop::NoopWalker; use effectful::{ - bound::{Dynamic, No}, - effective::Effective, - environment::{DynBind, EnvConfig, Environment, NativeForm}, + bound::{Dynamic, No, SsBound}, + effective::{Effective, Canonical}, + environment::{Environment}, higher_ranked::{Rank1, WithLt}, SendSync, + DynBind, }; use serde::{ de::{DeserializeSeed, MapAccess}, @@ -101,21 +102,21 @@ where impl<'ctx, T, E: Environment> Walker<'ctx, E> for DeserializerWalker<'ctx, T, E> where T: Deserializer<'ctx>, - E: EnvConfig<NeedSend = No, NeedSync = No>, + E: SsBound<NeedSend = No, NeedSync = No>, { type Error = DeserializerWalkerError<'ctx, T>; type Output = (); - fn walk<'visitor: 'effect, 'effect>( + fn walk<'visitor: 'effect, 'lt: 'effect, 'effect>( self, - visitor: DynVisitor<'visitor, 'ctx, E>, - ) -> NativeForm<'effect, Result<Self::Output, Self::Error>, E> + visitor: DynVisitor<'visitor, 'lt, 'ctx, E>, + ) -> Canonical<'effect, Result<Self::Output, Self::Error>, E> where Self: 'effect, { E::value((self, visitor)) - .update((), |_, (this, visitor)| { + .update_map((), |_, (this, visitor)| { // Serde deserializers usually prefer that a hint method is called rather than _any. // As such we need to ask the visitor for a hint first. request_hint::<E>(visitor.cast(), DynWalker(this)) @@ -139,7 +140,7 @@ where } } -impl<'ctx, T, E> AnyTrait<'ctx> for DeserializerWalker<'ctx, T, E> +impl<'lt, 'ctx: 'lt, T: 'lt, E> AnyTrait<'lt, 'ctx> for DeserializerWalker<'ctx, T, E> where T: Deserializer<'ctx>, E: Environment<NeedSend = No, NeedSync = No>, @@ -169,7 +170,7 @@ where impl<'ctx, T, E: Environment> DeserializerWalker<'ctx, T, E> where T: Deserializer<'ctx>, - E: EnvConfig<NeedSend = No, NeedSync = No>, + E: SsBound<NeedSend = No, NeedSync = No>, { #[allow(clippy::type_complexity)] fn call_deserialize<'this: 'e, 'e, Cap>( @@ -179,10 +180,10 @@ where Cap, T, ) -> Result< - NativeForm<'e, (Option<VisitorError<'ctx, T>>, VisitResult), E, (&'ctx (), Cap)>, + Canonical<'e, (Option<VisitorError<'ctx, T>>, VisitResult), E, (&'ctx (), Cap)>, T::Error, >, - ) -> NativeForm<'e, VisitResult, E> + ) -> Canonical<'e, VisitResult, E> where 'ctx: 'this, Cap: DynBind<E> + 'e, @@ -230,18 +231,18 @@ macro_rules! impl_hints { $(impl<$ctx, $T, $E: Environment> Hint<$ctx, type_name::Raised<'static, $ctx, $proto>> for DeserializerWalker<$ctx, $T, $E> where $T: Deserializer<$ctx>, - $E: EnvConfig<NeedSend = No, NeedSync = No> + $E: SsBound<NeedSend = No, NeedSync = No> { - fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>( + fn hint<'this: 'e, 'visitor: 'e, 'lt: 'e, 'hint: 'e, 'e>( &'this mut self, - visitor: DynVisitorWith<'visitor, $ctx, type_name::Raised<'static, $ctx, $proto>>, + visitor: DynVisitorWith<'visitor, 'lt, $ctx, type_name::Raised<'static, $ctx, $proto>>, _hint: WithLt<'hint, <type_name::Raised<'static, $ctx, $proto> as HintMeta>::Hint>, - ) -> NativeForm<'e, VisitResult, $E> + ) -> Canonical<'e, VisitResult, $E> where $ctx: 'this + 'visitor + 'hint + 'e, { $E::value((self, visitor)) - .update((), |_, (this, visitor)| { + .update_map((), |_, (this, visitor)| { this.call_deserialize(visitor, move |visitor, deserializer| { let x = deserializer.$method(Visitor::<$T, $E>::new(visitor.cast(), stringify!($type))); x.map(|x| x.cast()) @@ -255,7 +256,7 @@ macro_rules! impl_hints { fn known<'a>( &'a mut self, _hint: &'a WithLt<'a, <type_name::Raised<'static, $ctx, $proto> as HintMeta>::Hint>, - ) -> NativeForm<'a, Result<WithLt<'a, <type_name::Raised<'static, $ctx, $proto> as HintMeta>::Known>, ()>, $E> + ) -> Canonical<'a, Result<WithLt<'a, <type_name::Raised<'static, $ctx, $proto> as HintMeta>::Known>, ()>, $E> where WithLt<'a, <type_name::Raised<'static, $ctx, $proto> as HintMeta>::Known>: DynBind<$E> { @@ -295,17 +296,18 @@ impl<'ctx, T, E: Environment> for DeserializerWalker<'ctx, T, E> where T: Deserializer<'ctx>, - E: EnvConfig<NeedSend = No, NeedSync = No>, + E: SsBound<NeedSend = No, NeedSync = No>, { - fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>( + fn hint<'this: 'e, 'visitor: 'e, 'lt: 'e, 'hint: 'e, 'e>( &'this mut self, _visitor: DynVisitorWith< 'visitor, + 'lt, 'ctx, type_name::Raised<'static, 'ctx, dyn Tag<'ctx, tags::Map, E>>, >, _hint: TagHint<tags::Map>, - ) -> NativeForm<'e, VisitResult, E> + ) -> Canonical<'e, VisitResult, E> where 'ctx: 'this + 'visitor + 'hint + 'e, { @@ -318,7 +320,7 @@ where fn known<'a>( &'a mut self, _hint: &'a WithLt<'a, Rank1<TagHint<tags::Map>>>, - ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, E> + ) -> Canonical<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, E> where WithLt<'a, Rank1<TagKnown>>: DynBind<E>, { @@ -351,20 +353,20 @@ where } #[derive(SendSync)] -struct Visitor<'temp, 'ctx, T, E: Environment> +struct Visitor<'temp, 'lt, 'ctx, T, E: Environment> where T: Deserializer<'ctx>, { wanted: &'static str, - visitor: DynVisitor<'temp, 'ctx, E>, + visitor: DynVisitor<'temp, 'lt, 'ctx, E>, _marker: Marker<(T, E)>, } -impl<'temp, 'ctx, T, E: Environment> Visitor<'temp, 'ctx, T, E> +impl<'temp, 'lt, 'ctx, T, E: Environment> Visitor<'temp, 'lt, 'ctx, T, E> where T: Deserializer<'ctx>, { - pub fn new(visitor: DynVisitor<'temp, 'ctx, E>, wanted: &'static str) -> Self { + pub fn new(visitor: DynVisitor<'temp, 'lt, 'ctx, E>, wanted: &'static str) -> Self { Self { wanted, visitor, @@ -399,12 +401,12 @@ macro_rules! impl_visits { }; } -impl<'temp, 'ctx, T: Deserializer<'ctx> + 'temp, E: Environment> serde::de::Visitor<'ctx> - for Visitor<'temp, 'ctx, T, E> +impl<'temp, 'lt, 'ctx, T: Deserializer<'ctx> + 'temp, E: Environment> serde::de::Visitor<'ctx> + for Visitor<'temp, 'lt, 'ctx, T, E> where - E: EnvConfig<NeedSend = No, NeedSync = No>, + E: SsBound<NeedSend = No, NeedSync = No>, { - type Value = NativeForm<'temp, (Option<VisitorError<'ctx, T>>, VisitResult), E>; + type Value = Canonical<'temp, (Option<VisitorError<'ctx, T>>, VisitResult), E>; fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { formatter.write_str(self.wanted) @@ -444,9 +446,9 @@ where where A: MapAccess<'ctx>, { - E::value((self, MapScope { map: Dynamic(map) })).update((), |_, (this, scope)| { + E::value((self, MapScope { map: Dynamic(map) })).update_map((), |_, (this, scope)| { // Need to notify the visitor we are doing a map instead of just a sequence. - visit_tag::<tags::Map, E, _>(TagConst, this.visitor.cast(), NoopWalker::new()); + let x = visit_tag::<tags::Map, E, _>(TagConst, this.visitor.cast(), NoopWalker::new()).wait(); visit_sequence(this.visitor.cast(), scope).cast() }); @@ -462,17 +464,17 @@ struct MapScope<A> { impl<'ctx, A, E: Environment> SequenceScope<'ctx, E> for MapScope<A> where - E: EnvConfig<NeedSend = No, NeedSync = No>, + E: SsBound<NeedSend = No, NeedSync = No>, A: MapAccess<'ctx>, { - fn size_hint(&mut self) -> NativeForm<'_, (usize, Option<usize>), E> { + fn size_hint(&mut self) -> Canonical<'_, (usize, Option<usize>), E> { E::value((0, self.map.0.size_hint())).cast() } - fn next<'a: 'c, 'b: 'c, 'c>( + fn next<'a: 'c, 'd: 'c, 'b: 'c, 'c>( &'a mut self, - mut visitor: DynVisitor<'b, 'ctx, E>, - ) -> NativeForm<'c, Flow, E> + mut visitor: DynVisitor<'b, 'd, 'ctx, E>, + ) -> Canonical<'c, Flow, E> where 'ctx: 'c + 'a + 'b, { @@ -502,13 +504,13 @@ where } } -struct KeyDeserialize<'a, 'ctx, E: Environment> { - visitor: DynVisitor<'a, 'ctx, E>, +struct KeyDeserialize<'a, 'lt, 'ctx, E: Environment> { + visitor: DynVisitor<'a, 'lt, 'ctx, E>, } -impl<'a, 'ctx: 'a, E: Environment> DeserializeSeed<'ctx> for KeyDeserialize<'a, 'ctx, E> +impl<'a, 'lt, 'ctx: 'a, E: Environment> DeserializeSeed<'ctx> for KeyDeserialize<'a, 'lt, 'ctx, E> where - E: EnvConfig<NeedSend = No, NeedSync = No>, + E: SsBound<NeedSend = No, NeedSync = No>, { type Value = (); @@ -536,13 +538,13 @@ where } } -struct ValueDeserialize<'a, 'ctx, E: Environment> { - visitor: DynVisitor<'a, 'ctx, E>, +struct ValueDeserialize<'a, 'lt, 'ctx, E: Environment> { + visitor: DynVisitor<'a, 'lt, 'ctx, E>, } -impl<'a, 'ctx, E: Environment> DeserializeSeed<'ctx> for ValueDeserialize<'a, 'ctx, E> +impl<'a, 'lt, 'ctx, E: Environment> DeserializeSeed<'ctx> for ValueDeserialize<'a, 'lt, 'ctx, E> where - E: EnvConfig<NeedSend = No, NeedSync = No>, + E: SsBound<NeedSend = No, NeedSync = No>, { type Value = (); |