Diffstat (limited to 'src/walk/walkers/core/struct.rs')
| -rw-r--r-- | src/walk/walkers/core/struct.rs | 125 |
1 files changed, 59 insertions, 66 deletions
diff --git a/src/walk/walkers/core/struct.rs b/src/walk/walkers/core/struct.rs index fc4607a..d98043d 100644 --- a/src/walk/walkers/core/struct.rs +++ b/src/walk/walkers/core/struct.rs @@ -8,15 +8,16 @@ use crate::{ never::Never, protocol::{ visitor::{ - visit_request_hint, visit_sequence, visit_tag, visit_value, EffectiveVisitExt as _, - RecoverableKnown, RecoverableProto, RecoverableScope, SequenceKnown, SequenceProto, - SequenceScope, TagConst, TagDyn, TagError, TagHint, TagKnown, TagProto, ValueKnown, - ValueProto, VisitResult, + request_hint, tags, visit_sequence, visit_tag, visit_value, EffectiveVisitExt as _, + Recoverable, RecoverableKnown, RecoverableProto, RecoverableScope, Sequence, + SequenceKnown, SequenceProto, SequenceScope, Tag, TagConst, TagDyn, TagError, TagKnown, + TagProto, Value, ValueKnown, ValueProto, VisitResult, }, walker::hint::{Hint, HintMeta, HintProto, MetaHint, MetaKnown}, DynVisitor, DynWalker, }, - Flow, Status, WalkerTypes, TAG_FIELD_NAMES, TAG_MAP, TAG_STRUCT, TAG_TYPE_ID, TAG_TYPE_NAME, + DynWalkerAdapter, Flow, Status, WalkerTypes, TAG_FIELD_NAMES, TAG_MAP, TAG_STRUCT, TAG_TYPE_ID, + TAG_TYPE_NAME, }; use super::{noop::NoopWalker, value::ValueWalker}; @@ -190,7 +191,7 @@ where #[inline(always)] fn hint<'this, 'visitor, 'hint, 'e>( &'this mut self, - _visitor: DynVisitor<'visitor, 'ctx>, + _visitor: &'visitor mut (dyn Recoverable<'ctx, E> + Send + Sync), _hint: MetaHint<'hint, 'ctx, RecoverableProto<E>>, ) -> ErasedEffective<'e, Flow, E> where @@ -224,7 +225,7 @@ where #[inline(always)] fn hint<'this, 'visitor, 'hint, 'e>( &'this mut self, - _visitor: DynVisitor<'visitor, 'ctx>, + _visitor: &'visitor mut (dyn Tag<'ctx, tags::FieldNames, E> + Send + Sync), _hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>, ) -> ErasedEffective<'e, Flow, E> where @@ -272,7 +273,7 @@ where #[inline(always)] fn hint<'this, 'visitor, 'hint, 'e>( &'this mut self, - _visitor: DynVisitor<'visitor, 'ctx>, + _visitor: &'visitor mut (dyn Tag<'ctx, tags::TypeName, E> + Send + Sync), _hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>, ) -> ErasedEffective<'e, Flow, E> where @@ -320,7 +321,7 @@ where #[inline(always)] fn hint<'this, 'visitor, 'hint, 'e>( &'this mut self, - _visitor: DynVisitor<'visitor, 'ctx>, + _visitor: &'visitor mut (dyn Tag<'ctx, tags::Map, E> + Send + Sync), _hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>, ) -> ErasedEffective<'e, Flow, E> where @@ -364,30 +365,20 @@ where #[inline(always)] fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>( &'this mut self, - visitor: DynVisitor<'visitor, 'ctx>, + visitor: &'visitor mut (dyn Tag<'ctx, tags::Struct, E> + Send + Sync), _hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>, ) -> ErasedEffective<'e, Flow, E> where 'ctx: 'this + 'visitor + 'hint + 'e, { E::as_ctx( - (self, visitor), + (visitor, DynWalkerAdapter::new(NoopWalker::new())), #[inline(always)] - |(this, visitor)| { - visit_tag::<TagConst<{ TAG_STRUCT.to_int() }>, E, _>( - TagConst, - visitor.cast(), - NoopWalker::new(), - ) - .map(|status| match status { - Err(err) => { - this.error = Some(StructWalkErrorKind::Tag(err)); - Flow::Err - } - Ok(VisitResult::Skipped(_)) => Flow::Continue, - Ok(VisitResult::Control(flow)) => flow, - }) - .cast() + |(visitor, noop_walker)| { + visitor + .visit(TagConst, noop_walker) + .map(|status| status.to_flow().unwrap_or(Flow::Continue)) + .cast() }, ) .remove_ctx() @@ -418,7 +409,7 @@ where #[inline(always)] fn hint<'this, 'visitor, 'hint, 'e>( &'this mut self, - _visitor: DynVisitor<'visitor, 'ctx>, + _visitor: &'visitor mut (dyn Tag<'ctx, tags::TypeId, E> + Send + Sync), _hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>, ) -> ErasedEffective<'e, Flow, E> where @@ -466,45 +457,46 @@ where #[inline(always)] fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>( &'this mut self, - visitor: DynVisitor<'visitor, 'ctx>, - hint: MetaHint<'hint, 'ctx, TagProto<TagDyn, E>>, + _visitor: &'visitor mut (dyn Tag<'ctx, TagDyn, E> + Send + Sync), + _hint: MetaHint<'hint, 'ctx, TagProto<TagDyn, E>>, ) -> ErasedEffective<'e, Flow, E> where 'ctx: 'this + 'visitor + 'hint + 'e, { - match hint.kind.0 { - crate::TAG_TYPE_ID => { - Hint::<'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>::hint( - self, - visitor, - TagHint { kind: TagConst }, - ) - } - crate::TAG_STRUCT => { - Hint::<'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>::hint( - self, - visitor, - TagHint { kind: TagConst }, - ) - } - crate::TAG_MAP => Hint::<'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>::hint( - self, - visitor, - TagHint { kind: TagConst }, - ), - crate::TAG_TYPE_NAME => { - Hint::<'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>::hint( - self, - visitor, - TagHint { kind: TagConst }, - ) - } - crate::TAG_FIELD_NAMES => Hint::< - 'ctx, - TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>, - >::hint(self, visitor, TagHint { kind: TagConst }), - _ => E::ready(Flow::Continue), - } + todo!() + // match hint.kind.0 { + // crate::TAG_TYPE_ID => { + // Hint::<'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>::hint( + // self, + // visitor, + // TagHint { kind: TagConst }, + // ) + // } + // crate::TAG_STRUCT => { + // Hint::<'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>::hint( + // self, + // visitor, + // TagHint { kind: TagConst }, + // ) + // } + // crate::TAG_MAP => Hint::<'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>::hint( + // self, + // visitor, + // TagHint { kind: TagConst }, + // ), + // crate::TAG_TYPE_NAME => { + // Hint::<'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>::hint( + // self, + // visitor, + // TagHint { kind: TagConst }, + // ) + // } + // crate::TAG_FIELD_NAMES => Hint::< + // 'ctx, + // TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>, + // >::hint(self, visitor, TagHint { kind: TagConst }), + // _ => E::ready(Flow::Continue), + // } } #[inline(always)] @@ -533,7 +525,7 @@ where #[inline(always)] fn hint<'this, 'visitor, 'hint, 'e>( &'this mut self, - _visitor: DynVisitor<'visitor, 'ctx>, + _visitor: &'visitor mut (dyn Value<'ctx, BorrowedStaticHrt<I::T>, E> + Send + Sync), _hint: MetaHint<'hint, 'ctx, ValueProto<BorrowedStaticHrt<I::T>, E>>, ) -> ErasedEffective<'e, Flow, E> where @@ -567,14 +559,15 @@ where fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>( &'this mut self, - visitor: DynVisitor<'visitor, 'ctx>, + visitor: &'visitor mut (dyn Sequence<'ctx, E> + Send + Sync), _hint: MetaHint<'hint, 'ctx, SequenceProto<E>>, ) -> ErasedEffective<'e, Flow, E> where 'ctx: 'this + 'visitor + 'hint + 'e, { E::as_ctx_map((self, visitor), |(this, visitor)| { - visit_sequence::<E>(visitor.cast(), *this) + visitor + .visit(*this) .map(|status| match status { VisitResult::Skipped(_) => Flow::Continue, VisitResult::Control(flow) => flow, @@ -661,7 +654,7 @@ where self.index = 0; E::as_ctx((self, visitor), |(this, visitor)| { - visit_request_hint::<E>(visitor.cast(), DynWalker(*this)) + request_hint::<E>(visitor.cast(), DynWalker(*this)) .map(VisitResult::unit_skipped) .cast() }) |