Diffstat (limited to 'src/walk/walkers/core/struct.rs')
| -rw-r--r-- | src/walk/walkers/core/struct.rs | 104 |
1 files changed, 51 insertions, 53 deletions
diff --git a/src/walk/walkers/core/struct.rs b/src/walk/walkers/core/struct.rs index c6a2c8f..21f48bd 100644 --- a/src/walk/walkers/core/struct.rs +++ b/src/walk/walkers/core/struct.rs @@ -1,18 +1,16 @@ use core::any::TypeId; use crate::{ - any::BorrowedStatic, + any::{BorrowedStatic, BorrowedStaticHrt}, any_trait, effect::{Effect, Future}, hkt::Marker, never::Never, protocol::{ visitor::{ - visit_recoverable, visit_request_hint, visit_sequence, visit_tag, visit_value, - DynRecoverable, DynSequence, DynTag, DynValue, RecoverableScope, SequenceKnown, - SequenceScope, TagConst, TagDyn, TagError, TagHint, TagKnown, ValueKnown, VisitResult, + visit_recoverable, visit_request_hint, visit_sequence, visit_tag, visit_value, RecoverableKnown, RecoverableProto, RecoverableScope, SequenceKnown, SequenceProto, SequenceScope, TagConst, TagDyn, TagError, TagHint, TagKnown, TagProto, ValueKnown, ValueProto, VisitResult }, - walker::hint::{DynHint, HintMeta}, + walker::hint::{HintMeta, HintProto}, walker::hint::{Hint, Known}, Visitor, }, @@ -136,22 +134,22 @@ where any_trait! { impl['ctx, T, I, M, E] StructWalker<'ctx, T, I, M, E> = [ - DynHint<'ctx, DynRecoverable<'ctx, E>, E>, - DynHint<'ctx, DynSequence<'ctx, E>, E>, - DynHint<'ctx, DynValue<'ctx, BorrowedStatic<'ctx, T>, E>, E>, - DynHint<'ctx, DynTag<'ctx, TagDyn, E>, E>, - DynHint<'ctx, DynTag<'ctx, TagConst<{ TAG_TYPE_ID.to_int() }>, E>, E>, - DynHint<'ctx, DynTag<'ctx, TagConst<{ TAG_STRUCT.to_int() }>, E>, E>, - DynHint<'ctx, DynTag<'ctx, TagConst<{ TAG_MAP.to_int() }>, E>, E>, - DynHint<'ctx, DynTag<'ctx, TagConst<{ TAG_TYPE_NAME.to_int() }>, E>, E>, - DynHint<'ctx, DynTag<'ctx, TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>, E>, + HintProto<RecoverableProto<E>, E>, + HintProto<SequenceProto<E>, E>, + HintProto<ValueProto<BorrowedStaticHrt<T>, E>, E>, + HintProto<TagProto<TagDyn, E>, E>, + HintProto<TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>, E>, + HintProto<TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>, E>, + HintProto<TagProto<TagConst<{ TAG_MAP.to_int() }>, E>, E>, + HintProto<TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>, E>, + HintProto<TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>, E>, ] where E: Effect, T: Sync + 'static, I: StructTypeInfo<'ctx, M, T = T> } -impl<'ctx, T, I, M, E> Hint<'ctx, DynRecoverable<'ctx, E>, E> for StructWalker<'ctx, T, I, M, E> +impl<'ctx, T, I, M, E> Hint<'ctx, RecoverableProto<E>, E> for StructWalker<'ctx, T, I, M, E> where E: Effect, I: StructTypeInfo<'ctx, M, T = T>, @@ -160,7 +158,7 @@ where fn hint<'a>( &'a mut self, visitor: Visitor<'a, 'ctx>, - _hint: <DynRecoverable<'ctx, E> as HintMeta<'ctx>>::Hint, + _hint: <RecoverableProto<E> as HintMeta<'ctx>>::Hint, ) -> Future<'a, Flow, E> { E::map( visit_recoverable::<E>(visitor, self), @@ -173,13 +171,13 @@ where fn known<'a>( &'a mut self, - _hint: &'a <DynRecoverable<'ctx, E> as HintMeta<'ctx>>::Hint, - ) -> Future<'a, Result<Known<'a, 'ctx, DynRecoverable<'ctx, E>>, ()>, E> { - E::ready(Ok(())) + _hint: &'a <RecoverableProto<E> as HintMeta<'ctx>>::Hint, + ) -> Future<'a, Result<Known<'a, 'ctx, RecoverableProto<E>>, ()>, E> { + E::ready(Ok(RecoverableKnown)) } } -impl<'ctx, T, I, M, E> Hint<'ctx, DynTag<'ctx, TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>, E> +impl<'ctx, T, I, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>, E> for StructWalker<'ctx, T, I, M, E> where E: Effect, @@ -189,7 +187,7 @@ where fn hint<'a>( &'a mut self, visitor: Visitor<'a, 'ctx>, - _hint: <DynTag<'ctx, TagConst<{ TAG_FIELD_NAMES.to_int() }>, E> as HintMeta<'ctx>>::Hint, + _hint: <TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E> as HintMeta<'ctx>>::Hint, ) -> Future<'a, Flow, E> { E::map( visit_tag::<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E, _>( @@ -210,12 +208,12 @@ where fn known<'a>( &'a mut self, - _hint: &'a <DynTag<'ctx, TagConst<{ TAG_FIELD_NAMES.to_int() }>, E> as HintMeta< + _hint: &'a <TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E> as HintMeta< 'ctx, >>::Hint, ) -> Future< 'a, - Result<Known<'a, 'ctx, DynTag<'ctx, TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>, ()>, + Result<Known<'a, 'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>, ()>, E, > { E::ready(Ok(TagKnown { @@ -224,7 +222,7 @@ where } } -impl<'ctx, T, I, M, E> Hint<'ctx, DynTag<'ctx, TagConst<{ TAG_TYPE_NAME.to_int() }>, E>, E> +impl<'ctx, T, I, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>, E> for StructWalker<'ctx, T, I, M, E> where E: Effect, @@ -234,7 +232,7 @@ where fn hint<'a>( &'a mut self, visitor: Visitor<'a, 'ctx>, - _hint: <DynTag<'ctx, TagConst<{ TAG_TYPE_NAME.to_int() }>, E> as HintMeta<'ctx>>::Hint, + _hint: <TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E> as HintMeta<'ctx>>::Hint, ) -> Future<'a, Flow, E> { E::map( visit_tag::<TagConst<{ TAG_TYPE_NAME.to_int() }>, E, _>( @@ -255,10 +253,10 @@ where fn known<'a>( &'a mut self, - _hint: &'a <DynTag<'ctx, TagConst<{ TAG_TYPE_NAME.to_int() }>, E> as HintMeta<'ctx>>::Hint, + _hint: &'a <TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E> as HintMeta<'ctx>>::Hint, ) -> Future< 'a, - Result<Known<'a, 'ctx, DynTag<'ctx, TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>, ()>, + Result<Known<'a, 'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>, ()>, E, > { E::ready(Ok(TagKnown { @@ -267,7 +265,7 @@ where } } -impl<'ctx, T, I, M, E> Hint<'ctx, DynTag<'ctx, TagConst<{ TAG_MAP.to_int() }>, E>, E> +impl<'ctx, T, I, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>, E> for StructWalker<'ctx, T, I, M, E> where E: Effect, @@ -277,7 +275,7 @@ where fn hint<'a>( &'a mut self, visitor: Visitor<'a, 'ctx>, - _hint: <DynTag<'ctx, TagConst<{ TAG_MAP.to_int() }>, E> as HintMeta<'ctx>>::Hint, + _hint: <TagProto<TagConst<{ TAG_MAP.to_int() }>, E> as HintMeta<'ctx>>::Hint, ) -> Future<'a, Flow, E> { E::map( visit_tag::<TagConst<{ TAG_MAP.to_int() }>, E, _>(TagConst, visitor, NoopWalker::new()), @@ -294,8 +292,8 @@ where fn known<'a>( &'a mut self, - _hint: &'a <DynTag<'ctx, TagConst<{ TAG_MAP.to_int() }>, E> as HintMeta<'ctx>>::Hint, - ) -> Future<'a, Result<Known<'a, 'ctx, DynTag<'ctx, TagConst<{ TAG_MAP.to_int() }>, E>>, ()>, E> + _hint: &'a <TagProto<TagConst<{ TAG_MAP.to_int() }>, E> as HintMeta<'ctx>>::Hint, + ) -> Future<'a, Result<Known<'a, 'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>, ()>, E> { E::ready(Ok(TagKnown { kind_available: Some(true), @@ -303,7 +301,7 @@ where } } -impl<'ctx, T, I, M, E> Hint<'ctx, DynTag<'ctx, TagConst<{ TAG_STRUCT.to_int() }>, E>, E> +impl<'ctx, T, I, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>, E> for StructWalker<'ctx, T, I, M, E> where E: Effect, @@ -313,7 +311,7 @@ where fn hint<'a>( &'a mut self, visitor: Visitor<'a, 'ctx>, - _hint: <DynTag<'ctx, TagConst<{ TAG_STRUCT.to_int() }>, E> as HintMeta<'ctx>>::Hint, + _hint: <TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E> as HintMeta<'ctx>>::Hint, ) -> Future<'a, Flow, E> { E::map( visit_tag::<TagConst<{ TAG_STRUCT.to_int() }>, E, _>( @@ -334,10 +332,10 @@ where fn known<'a>( &'a mut self, - _hint: &'a <DynTag<'ctx, TagConst<{ TAG_STRUCT.to_int() }>, E> as HintMeta<'ctx>>::Hint, + _hint: &'a <TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E> as HintMeta<'ctx>>::Hint, ) -> Future< 'a, - Result<Known<'a, 'ctx, DynTag<'ctx, TagConst<{ TAG_STRUCT.to_int() }>, E>>, ()>, + Result<Known<'a, 'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>, ()>, E, > { E::ready(Ok(TagKnown { @@ -346,7 +344,7 @@ where } } -impl<'ctx, T, I, M, E> Hint<'ctx, DynTag<'ctx, TagConst<{ TAG_TYPE_ID.to_int() }>, E>, E> +impl<'ctx, T, I, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>, E> for StructWalker<'ctx, T, I, M, E> where E: Effect, @@ -356,7 +354,7 @@ where fn hint<'a>( &'a mut self, visitor: Visitor<'a, 'ctx>, - _hint: <DynTag<'ctx, TagConst<{ TAG_TYPE_ID.to_int() }>, E> as HintMeta<'ctx>>::Hint, + _hint: <TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E> as HintMeta<'ctx>>::Hint, ) -> Future<'a, Flow, E> { E::map( visit_tag::<TagConst<{ TAG_TYPE_ID.to_int() }>, E, _>( @@ -377,10 +375,10 @@ where fn known<'a>( &'a mut self, - _hint: &'a <DynTag<'ctx, TagConst<{ TAG_TYPE_ID.to_int() }>, E> as HintMeta<'ctx>>::Hint, + _hint: &'a <TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E> as HintMeta<'ctx>>::Hint, ) -> Future< 'a, - Result<Known<'a, 'ctx, DynTag<'ctx, TagConst<{ TAG_TYPE_ID.to_int() }>, E>>, ()>, + Result<Known<'a, 'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>, ()>, E, > { E::ready(Ok(TagKnown { @@ -389,7 +387,7 @@ where } } -impl<'ctx, T, I, M, E> Hint<'ctx, DynTag<'ctx, TagDyn, E>, E> for StructWalker<'ctx, T, I, M, E> +impl<'ctx, T, I, M, E> Hint<'ctx, TagProto<TagDyn, E>, E> for StructWalker<'ctx, T, I, M, E> where E: Effect, I: StructTypeInfo<'ctx, M>, @@ -398,23 +396,23 @@ where fn hint<'a>( &'a mut self, visitor: Visitor<'a, 'ctx>, - hint: <DynTag<'ctx, TagDyn, E> as HintMeta<'ctx>>::Hint, + hint: <TagProto<TagDyn, E> as HintMeta<'ctx>>::Hint, ) -> Future<'a, Flow, E> { match hint.kind.0 { crate::TAG_TYPE_ID => Hint::< 'ctx, - DynTag<'ctx, TagConst<{ TAG_TYPE_ID.to_int() }>, E>, + TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>, E, >::hint(self, visitor, TagHint { kind: TagConst }), crate::TAG_STRUCT => { - Hint::<'ctx, DynTag<'ctx, TagConst<{ TAG_STRUCT.to_int() }>, E>, E>::hint( + Hint::<'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>, E>::hint( self, visitor, TagHint { kind: TagConst }, ) } crate::TAG_MAP => { - Hint::<'ctx, DynTag<'ctx, TagConst<{ TAG_MAP.to_int() }>, E>, E>::hint( + Hint::<'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>, E>::hint( self, visitor, TagHint { kind: TagConst }, @@ -422,12 +420,12 @@ where } crate::TAG_TYPE_NAME => Hint::< 'ctx, - DynTag<'ctx, TagConst<{ TAG_TYPE_NAME.to_int() }>, E>, + TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>, E, >::hint(self, visitor, TagHint { kind: TagConst }), crate::TAG_FIELD_NAMES => Hint::< 'ctx, - DynTag<'ctx, TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>, + TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>, E, >::hint(self, visitor, TagHint { kind: TagConst }), _ => E::ready(Flow::Continue), @@ -436,8 +434,8 @@ where fn known<'a>( &'a mut self, - hint: &'a <DynTag<'ctx, TagDyn, E> as HintMeta<'ctx>>::Hint, - ) -> Future<'a, Result<Known<'a, 'ctx, DynTag<'ctx, TagDyn, E>>, ()>, E> { + hint: &'a <TagProto<TagDyn, E> as HintMeta<'ctx>>::Hint, + ) -> Future<'a, Result<Known<'a, 'ctx, TagProto<TagDyn, E>>, ()>, E> { E::ready(match hint.kind { TagDyn(crate::TAG_TYPE_ID) | TagDyn(crate::TAG_STRUCT) => Ok(TagKnown { kind_available: Some(true), @@ -449,7 +447,7 @@ where } } -impl<'ctx, T, I, M, E> Hint<'ctx, DynValue<'ctx, BorrowedStatic<'ctx, T>, E>, E> +impl<'ctx, T, I, M, E> Hint<'ctx, ValueProto<BorrowedStaticHrt<T>, E>, E> for StructWalker<'ctx, T, I, M, E> where E: Effect, @@ -471,7 +469,7 @@ where } } -impl<'ctx, T, I, M, E> Hint<'ctx, DynSequence<'ctx, E>, E> for StructWalker<'ctx, T, I, M, E> +impl<'ctx, T, I, M, E> Hint<'ctx, SequenceProto<E>, E> for StructWalker<'ctx, T, I, M, E> where E: Effect, I: StructTypeInfo<'ctx, M, T = T>, @@ -480,7 +478,7 @@ where fn hint<'a>( &'a mut self, visitor: Visitor<'a, 'ctx>, - _hint: <DynSequence<'ctx, E> as HintMeta<'ctx>>::Hint, + _hint: <SequenceProto<E> as HintMeta<'ctx>>::Hint, ) -> Future<'a, Flow, E> { E::map(visit_sequence::<E>(visitor, self), |status| match status { VisitResult::Skipped(_) => Flow::Continue, @@ -490,8 +488,8 @@ where fn known<'a>( &'a mut self, - _hint: &'a <DynSequence<'ctx, E> as HintMeta<'ctx>>::Hint, - ) -> Future<'a, Result<Known<'a, 'ctx, DynSequence<'ctx, E>>, ()>, E> { + _hint: &'a <SequenceProto<E> as HintMeta<'ctx>>::Hint, + ) -> Future<'a, Result<Known<'a, 'ctx, SequenceProto<E>>, ()>, E> { let len = I::FIELDS.len(); E::ready(Ok(SequenceKnown { |