Diffstat (limited to 'src/effect/async/shim.rs')
-rw-r--r--src/effect/async/shim.rs116
1 files changed, 0 insertions, 116 deletions
diff --git a/src/effect/async/shim.rs b/src/effect/async/shim.rs
deleted file mode 100644
index 484f49b..0000000
--- a/src/effect/async/shim.rs
+++ /dev/null
@@ -1,116 +0,0 @@
-use core::ops::ControlFlow;
-
-use futures::Future;
-
-use crate::effect::{Effective, ErasedEffective, Ss};
-
-use super::{Async, BoxOrReady, Map, Then};
-
-pub struct Shim<F> {
- future: F,
-}
-
-impl<F> Shim<F> {
- pub(super) fn new(future: F) -> Self {
- Self { future }
- }
-}
-
-impl<'lt, U: Ss + 'lt> Effective<'lt> for Shim<U>
-where
- U: Future,
- U::Output: Ss + 'lt,
-{
- fn into_erased<B>(self) -> ErasedEffective<'lt, Self::Output, Self::Effect, B> {
- BoxOrReady::Boxed(Box::pin(self.future))
- }
-
- type Effect = Async;
-
- type Output = U::Output;
-
- type IntoFuture = U;
-
- fn into_future(self) -> Self::IntoFuture {
- self.future
- }
-
- type Loop<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>
- = BoxOrReady<'a, (U::Output, T)>
- where
- F: for<'b> FnMut(&'b mut Self::Output) -> ErasedEffective<'b, ControlFlow<T>, Self::Effect, (&'b mut Self::Output, &'ctx ())>,
- 'lt: 'a;
-
- fn r#loop<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>(self, mut cb: F) -> Self::Loop<'ctx, 'a, T, F>
- where
- F: for<'b> FnMut(
- &'b mut Self::Output,
- ) -> ErasedEffective<
- 'b,
- ControlFlow<T>,
- Self::Effect,
- (&'b mut Self::Output, &'ctx ()),
- >,
- 'lt: 'a,
- {
- BoxOrReady::Boxed(Box::pin(async move {
- let mut this = self.into_future().await;
-
- loop {
- if let ControlFlow::Break(value) = cb(&mut this).into_future().await {
- return (this, value);
- }
- }
- }))
- }
-
- type Map<'a, T: Ss + 'a, F: Ss + 'a>
- = Map<U, F>
- where
- F: FnOnce(Self::Output) -> T,
- 'lt: 'a;
-
- fn map<'a, T: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::Map<'a, T, F>
- where
- F: FnOnce(Self::Output) -> T,
- 'lt: 'a,
- {
- Map::new(self.future, cb)
- }
-
- type Then<'a, T: Ss + 'a, V: Ss + 'a, F: Ss + 'a>
- = Then<'a, U, F, V>
- where
- F: FnOnce(Self::Output) -> V,
- V: Effective<'a, Output = T, Effect = Self::Effect>,
- 'lt: 'a;
-
- fn then<'a, T: Ss + 'a, V: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::Then<'a, T, V, F>
- where
- F: FnOnce(Self::Output) -> V,
- V: Effective<'a, Output = T, Effect = Self::Effect>,
- 'lt: 'a,
- {
- Then::new(self.future, cb)
- }
-
- type AsCtx<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>
- = BoxOrReady<'a, (Self::Output, T)>
- where
- F: for<'b> FnOnce(&'b mut Self::Output) -> ErasedEffective<'b, T, Self::Effect>,
- 'lt: 'a;
-
- fn as_ctx<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::AsCtx<'ctx, 'a, T, F>
- where
- F: for<'b> FnOnce(&'b mut Self::Output) -> ErasedEffective<'b, T, Self::Effect>,
- 'lt: 'a,
- {
- BoxOrReady::Boxed(Box::pin(async {
- let mut this = self.future.await;
-
- let result = cb(&mut this).into_future().await;
-
- (this, result)
- }))
- }
-}