Diffstat (limited to 'src/walk/walkers/core/struct.rs')
-rw-r--r--src/walk/walkers/core/struct.rs114
1 files changed, 58 insertions, 56 deletions
diff --git a/src/walk/walkers/core/struct.rs b/src/walk/walkers/core/struct.rs
index d6c8c4b..9dd5d68 100644
--- a/src/walk/walkers/core/struct.rs
+++ b/src/walk/walkers/core/struct.rs
@@ -3,7 +3,7 @@ use core::{any::TypeId, marker::PhantomData};
use crate::{
any::{AnyTrait, BorrowedStatic, BorrowedStaticHrt},
any_trait,
- effect::{Adapters, Effect, ObjSafe},
+ effect::{Effect, Effective, ErasedEffective},
hkt::Marker,
never::Never,
protocol::{
@@ -65,7 +65,7 @@ pub trait StructTypeInfo<'ctx, M>: 'static {
index: usize,
value: &'ctx Self::T,
visitor: DynVisitor<'a, 'ctx>,
- ) -> ObjSafe<'a, Result<Flow, Self::FieldError>, E>;
+ ) -> ErasedEffective<'a, Result<Flow, Self::FieldError>, E>;
}
#[derive(Debug, PartialEq, Clone, Copy)]
@@ -125,25 +125,22 @@ where
fn walk<'b: 'c, 'c>(
mut self,
mut visitor: DynVisitor<'b, 'ctx>,
- ) -> ObjSafe<'c, Result<Self::Output, Self::Error>, E>
+ ) -> ErasedEffective<'c, Result<Self::Output, Self::Error>, E>
where
Self: 'c,
{
E::ready((self, visitor))
- .as_ctx_for(
+ .as_ctx(
#[inline(always)]
- |(this, visitor), _| {
- (
- RecoverableScope::<'ctx, E>::new_walk::<'_, '_, '_>(this, visitor.cast()),
- PhantomData,
- )
+ |(this, visitor)| {
+ RecoverableScope::<'ctx, E>::new_walk::<'_, '_, '_>(this, visitor.cast()).into_erased()
},
)
.map(|((this, _), _)| match this.error {
Some(err) => Err(StructWalkError { kind: err }),
None => Ok(()),
})
- .into()
+ .into_erased()
// E::ready(self).as_ctx_for::<'ctx, '_>(|this, _| {
// (RecoverableScope::<'ctx, E>::new_walk::<'_, 'b, '_>(this, visitor), PhantomData)
@@ -190,7 +187,7 @@ where
&'a mut self,
visitor: DynVisitor<'a, 'ctx>,
_hint: <RecoverableProto<E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Flow, E> {
+ ) -> ErasedEffective<'a, Flow, E> {
todo!()
// E::map(
// visit_recoverable::<E>(visitor, self),
@@ -205,8 +202,8 @@ where
fn known<'a>(
&'a mut self,
_hint: &'a <RecoverableProto<E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Result<MetaKnown<'a, 'ctx, RecoverableProto<E>>, ()>, E> {
- E::ready(Ok(RecoverableKnown)).into()
+ ) -> ErasedEffective<'a, Result<MetaKnown<'a, 'ctx, RecoverableProto<E>>, ()>, E> {
+ E::ready(Ok(RecoverableKnown)).into_erased()
}
}
@@ -221,7 +218,7 @@ where
&'a mut self,
visitor: DynVisitor<'a, 'ctx>,
_hint: MetaHint<'a, 'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>,
- ) -> ObjSafe<'a, Flow, E> {
+ ) -> ErasedEffective<'a, Flow, E> {
todo!()
// E::map(
// visit_tag::<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E, _>(
@@ -244,7 +241,7 @@ where
fn known<'a>(
&'a mut self,
_hint: &'a MetaHint<'a, 'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>,
- ) -> ObjSafe<
+ ) -> ErasedEffective<
'a,
Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>, ()>,
E,
@@ -252,7 +249,7 @@ where
E::ready(Ok(TagKnown {
kind_available: Some(true),
}))
- .into()
+ .into_erased()
}
}
@@ -267,7 +264,7 @@ where
&'a mut self,
visitor: DynVisitor<'a, 'ctx>,
_hint: <TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Flow, E> {
+ ) -> ErasedEffective<'a, Flow, E> {
todo!()
// E::map(
// visit_tag::<TagConst<{ TAG_TYPE_NAME.to_int() }>, E, _>(
@@ -290,7 +287,7 @@ where
fn known<'a>(
&'a mut self,
_hint: &'a <TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E> as HintMeta>::Hint,
- ) -> ObjSafe<
+ ) -> ErasedEffective<
'a,
Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>, ()>,
E,
@@ -298,7 +295,7 @@ where
E::ready(Ok(TagKnown {
kind_available: Some(true),
}))
- .into()
+ .into_erased()
}
}
@@ -313,7 +310,7 @@ where
&'a mut self,
visitor: DynVisitor<'a, 'ctx>,
_hint: <TagProto<TagConst<{ TAG_MAP.to_int() }>, E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Flow, E> {
+ ) -> ErasedEffective<'a, Flow, E> {
todo!()
// E::map(
// visit_tag::<TagConst<{ TAG_MAP.to_int() }>, E, _>(TagConst, visitor, NoopWalker::new()),
@@ -332,12 +329,15 @@ where
fn known<'a>(
&'a mut self,
_hint: &'a <TagProto<TagConst<{ TAG_MAP.to_int() }>, E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>, ()>, E>
- {
+ ) -> ErasedEffective<
+ 'a,
+ Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>, ()>,
+ E,
+ > {
E::ready(Ok(TagKnown {
kind_available: Some(true),
}))
- .into()
+ .into_erased()
}
}
@@ -352,7 +352,7 @@ where
&'a mut self,
visitor: DynVisitor<'a, 'ctx>,
_hint: <TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Flow, E> {
+ ) -> ErasedEffective<'a, Flow, E> {
todo!()
// E::map(
// visit_tag::<TagConst<{ TAG_STRUCT.to_int() }>, E, _>(
@@ -375,7 +375,7 @@ where
fn known<'a>(
&'a mut self,
_hint: &'a <TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E> as HintMeta>::Hint,
- ) -> ObjSafe<
+ ) -> ErasedEffective<
'a,
Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>, ()>,
E,
@@ -383,7 +383,7 @@ where
E::ready(Ok(TagKnown {
kind_available: Some(true),
}))
- .into()
+ .into_erased()
}
}
@@ -399,7 +399,7 @@ where
&'a mut self,
visitor: DynVisitor<'a, 'ctx>,
_hint: <TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Flow, E> {
+ ) -> ErasedEffective<'a, Flow, E> {
todo!()
// E::map(
// visit_tag::<TagConst<{ TAG_TYPE_ID.to_int() }>, E, _>(
@@ -422,7 +422,7 @@ where
fn known<'a>(
&'a mut self,
_hint: &'a <TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E> as HintMeta>::Hint,
- ) -> ObjSafe<
+ ) -> ErasedEffective<
'a,
Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>, ()>,
E,
@@ -430,7 +430,7 @@ where
E::ready(Ok(TagKnown {
kind_available: Some(true),
}))
- .into()
+ .into_erased()
}
}
@@ -445,7 +445,7 @@ where
&'a mut self,
visitor: DynVisitor<'a, 'ctx>,
hint: <TagProto<TagDyn, E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Flow, E> {
+ ) -> ErasedEffective<'a, Flow, E> {
match hint.kind.0 {
crate::TAG_TYPE_ID => {
Hint::<'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>::hint(
@@ -477,7 +477,7 @@ where
'ctx,
TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>,
>::hint(self, visitor, TagHint { kind: TagConst }),
- _ => E::ready(Flow::Continue).into(),
+ _ => E::ready(Flow::Continue).into_erased(),
}
}
@@ -485,7 +485,7 @@ where
fn known<'a>(
&'a mut self,
hint: &'a <TagProto<TagDyn, E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Result<MetaKnown<'a, 'ctx, TagProto<TagDyn, E>>, ()>, E> {
+ ) -> ErasedEffective<'a, Result<MetaKnown<'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),
@@ -494,7 +494,7 @@ where
kind_available: Some(false),
}),
})
- .into()
+ .into_erased()
}
}
@@ -506,7 +506,11 @@ where
I::T: 'static,
{
#[inline(always)]
- fn hint<'a>(&'a mut self, visitor: DynVisitor<'a, 'ctx>, _hint: ()) -> ObjSafe<'a, Flow, E> {
+ fn hint<'a>(
+ &'a mut self,
+ visitor: DynVisitor<'a, 'ctx>,
+ _hint: (),
+ ) -> ErasedEffective<'a, Flow, E> {
todo!()
// E::map(
// visit_value::<_, E>(visitor, BorrowedStatic(self.value)),
@@ -521,8 +525,8 @@ where
fn known<'a>(
&'a mut self,
_hint: &'a (),
- ) -> ObjSafe<'a, Result<ValueKnown<'a, BorrowedStatic<'ctx, I::T>>, ()>, E> {
- E::ready(Ok(ValueKnown { preview: None })).into()
+ ) -> ErasedEffective<'a, Result<ValueKnown<'a, BorrowedStatic<'ctx, I::T>>, ()>, E> {
+ E::ready(Ok(ValueKnown { preview: None })).into_erased()
}
}
@@ -536,7 +540,7 @@ where
&'a mut self,
visitor: DynVisitor<'a, 'ctx>,
_hint: <SequenceProto<E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Flow, E> {
+ ) -> ErasedEffective<'a, Flow, E> {
todo!()
// E::map(visit_sequence::<E>(visitor, self), |status| match status {
// VisitResult::Skipped(_) => Flow::Continue,
@@ -548,13 +552,13 @@ where
fn known<'a>(
&'a mut self,
_hint: &'a <SequenceProto<E> as HintMeta>::Hint,
- ) -> ObjSafe<'a, Result<MetaKnown<'a, 'ctx, SequenceProto<E>>, ()>, E> {
+ ) -> ErasedEffective<'a, Result<MetaKnown<'a, 'ctx, SequenceProto<E>>, ()>, E> {
let len = I::FIELDS.len();
E::ready(Ok(SequenceKnown {
len: (len, Some(len)),
}))
- .into()
+ .into_erased()
}
}
@@ -564,16 +568,16 @@ where
I: StructTypeInfo<'ctx, M, S = S>,
{
#[inline(always)]
- fn size_hint(&mut self) -> ObjSafe<'_, (usize, Option<usize>), E> {
+ fn size_hint(&mut self) -> ErasedEffective<'_, (usize, Option<usize>), E> {
let len = I::FIELDS.len();
- E::ready((len, Some(len))).into()
+ E::ready((len, Some(len))).into_erased()
}
#[inline(always)]
- fn next<'a>(&'a mut self, visitor: DynVisitor<'a, 'ctx>) -> ObjSafe<'a, Flow, E> {
+ fn next<'a>(&'a mut self, visitor: DynVisitor<'a, 'ctx>) -> ErasedEffective<'a, Flow, E> {
if self.index >= I::FIELDS.len() {
- return E::ready(Flow::Done).into();
+ return E::ready(Flow::Done).into_erased();
}
let index = self.index;
@@ -588,7 +592,7 @@ where
Flow::Err
}
})
- .into()
+ .into_erased()
// E::map(
// I::walk_field::<E>(index, self.value, visitor),
@@ -614,18 +618,17 @@ where
fn new_walk<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
mut visitor: DynVisitor<'b, 'ctx>,
- ) -> ObjSafe<'c, Status, E> {
+ ) -> ErasedEffective<'c, Status, E> {
// Reset the errors to default state.
self.error = None;
// Reset the field index to the default.
self.index = 0;
- E::with(
- (self, visitor),
- #[inline(always)]
- |(this, visitor), _| {
- (
+ E::ready((self, visitor))
+ .as_ctx(
+ #[inline(always)]
+ |(this, visitor)| {
visit_sequence::<E>(visitor.cast(), *this)
.map(|result| {
match result {
@@ -636,12 +639,11 @@ where
Ok(())
})
- .into(),
- PhantomData,
- )
- },
- )
- .into()
+ .into_erased()
+ },
+ )
+ .map(|(_, value)| value)
+ .into_erased()
// E::wrap(async move {
// // // We should check if the visitor wants something specific.