Diffstat (limited to 'src/build/builders/core/struct.rs')
-rw-r--r--src/build/builders/core/struct.rs91
1 files changed, 35 insertions, 56 deletions
diff --git a/src/build/builders/core/struct.rs b/src/build/builders/core/struct.rs
index 7e8d854..d1889b3 100644
--- a/src/build/builders/core/struct.rs
+++ b/src/build/builders/core/struct.rs
@@ -202,49 +202,30 @@ where
.map(|(_, value)| value)
.into_erased()
}
- StructMode::Map => {
- todo!()
- }
+ StructMode::Map => E::ready((self, scope))
+ .r#loop(|(this, scope)| {
+ let visitor = FieldVisitor::<I, M, E> {
+ builders: &mut this.builders,
+ marker: None,
+ _marker: Default::default(),
+ };
+
+ E::ready((scope, visitor))
+ .as_ctx(|(scope, visitor)| {
+ let scope: &mut DynSequenceScope<'_, '_, _> = scope;
+
+ scope.next(DynVisitor(visitor)).into_erased()
+ })
+ .map(|(_, result)| match result {
+ Flow::Continue => ControlFlow::Continue(()),
+ Flow::Err => ControlFlow::Break(VisitResult::Control(Flow::Err)),
+ Flow::Done => ControlFlow::Break(VisitResult::Control(Flow::Done)),
+ })
+ .into_erased()
+ })
+ .map(|(_, value)| value)
+ .into_erased(),
}
-
- // match self.mode {
- // StructMode::Tuple => E::wrap(async {
- // let mut index = 0;
- //
- // // For each index based marker.
- // while let Some(marker) = I::marker_from_index(index) {
- // // Select the visitor for this field.
- // let visitor = I::as_visitor(marker, &mut self.builders);
- //
- // // Get the next value in the sequence.
- // match scope.next(visitor).await {
- // Flow::Continue => {}
- // Flow::Err => return VisitResult::Control(Flow::Err),
- // Flow::Done => break,
- // }
- //
- // // Move to the next field.
- // index += 1;
- // }
- //
- // VisitResult::Control(Flow::Done)
- // }),
- // StructMode::Map => E::wrap(async {
- // loop {
- // let mut visitor = FieldVisitor::<I, M, E> {
- // builders: &mut self.builders,
- // marker: None,
- // _marker: Default::default(),
- // };
- //
- // match scope.next(DynVisitor(&mut visitor)).await {
- // Flow::Continue => {}
- // Flow::Err => return VisitResult::Control(Flow::Err),
- // Flow::Done => return VisitResult::Control(Flow::Done),
- // }
- // }
- // }),
- // }
}
}
@@ -282,20 +263,18 @@ where
_key: tags::Key,
walker: DynWalkerObjSafe<'b, 'ctx, E>,
) -> ErasedEffective<'c, VisitResult<DynWalkerObjSafe<'b, 'ctx, E>>, E> {
- todo!()
- // E::wrap(async {
- // let mut visitor = NameVisitor::<I, M, E> {
- // field_marker: None,
- // _marker: Default::default(),
- // };
- //
- // let flow = walker.walk(DynVisitor(&mut visitor)).await;
- //
- // self.marker = visitor.field_marker;
- //
- // // We are expecting the value of the field to be given next.
- // flow.to_continue().into()
- // })
+ let visitor = NameVisitor::<I, M, E> {
+ field_marker: None,
+ _marker: Default::default(),
+ };
+
+ E::ready((self, visitor, walker))
+ .as_ctx(|(_, visitor, walker)| walker.walk(DynVisitor(visitor)).into_erased())
+ .map(|((this, visitor, _), flow)| {
+ this.marker = visitor.field_marker;
+ flow.to_continue().into()
+ })
+ .into_erased()
}
}