Diffstat (limited to 'src/effect/blocking.rs')
| -rw-r--r-- | src/effect/blocking.rs | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/src/effect/blocking.rs b/src/effect/blocking.rs new file mode 100644 index 0000000..ea97477 --- /dev/null +++ b/src/effect/blocking.rs @@ -0,0 +1,164 @@ +use super::*; + +pub enum Blocking {} + +pub struct Value<T>(pub T); + +impl Effect for Blocking { + type Erased<T> = Value<T>; + + type Ready<T> = Value<T>; + + fn ready<T>(value: T) -> Self::Ready<T> { + todo!() + } + + type FromFuture<F> = Value<F::Output> + where + F: Future; + + fn from_future<F>() -> Self::FromFuture<F> + where + F: Future, + { + todo!() + } +} + +impl<U> Effective for Value<U> { + type Effect = Blocking; + + type Output = U; + + type IntoFuture = core::future::Ready<U>; + + fn into_future(self) -> Self::IntoFuture { + todo!() + } + + type Loop<T, V, F> = Value<T> + where + F: for<'a> FnMut(&'a mut Self::Output) -> EffectiveT<'a, V, ControlFlow<T>, Self::Effect>, + V: EffectiveHrt<ControlFlow<T>, Self::Effect>; + + fn r#loop<T, V, F>(self, cb: F) -> Self::Loop<T, V, F> + where + F: for<'a> FnMut(&'a mut Self::Output) -> EffectiveT<'a, V, ControlFlow<T>, Self::Effect>, + V: EffectiveHrt<ControlFlow<T>, Self::Effect>, + { + todo!() + } + + type Map<T, F> = Value<T> + where + F: FnOnce(Self::Output) -> T; + + fn map<T, F>(self, cb: F) -> Self::Map<T, F> + where + F: FnOnce(Self::Output) -> T, + { + todo!() + } + + type Then<T, V, F> = Value<T> + where + F: FnOnce(Self::Output) -> V, + V: Effective<Output = T, Effect = Self::Effect>; + + fn then<T, V, F>(self, cb: F) -> Self::Then<T, V, F> + where + F: FnOnce(Self::Output) -> V, + V: Effective<Output = T, Effect = Self::Effect>, + { + todo!() + } + + type AsCtx<T, V, F> = Value<T> + where + F: for<'a> FnOnce(&'a mut Self::Output) -> EffectiveT<'a, V, T, Self::Effect>, + V: EffectiveHrt<T, Self::Effect>; + + fn as_ctx<T, V, F>(self, cb: F) -> Self::AsCtx<T, V, F> + where + F: for<'a> FnOnce(&'a mut Self::Output) -> EffectiveT<'a, V, T, Self::Effect>, + V: EffectiveHrt<T, Self::Effect>, + { + todo!() + } +} + +impl Join for Blocking { + type Effect = Self; + + type Two<T0, T1> = Value<(T0::Output, T1::Output)> + where + T0: Effective<Effect = Self::Effect>, + T1: Effective<Effect = Self::Effect>; + + type Three<T0, T1, T2> = Value<(T0::Output, T1::Output, T2::Output)> + where + T0: Effective<Effect = Self::Effect>, + T1: Effective<Effect = Self::Effect>, + T2: Effective<Effect = Self::Effect>; + + fn two<T0, T1, F0, F1>(cb: (F0, F1)) -> Self::Two<T0, T1> + where + T0: Effective<Effect = Self::Effect>, + T1: Effective<Effect = Self::Effect>, + F0: FnOnce() -> T0, + F1: FnOnce() -> T1, + { + todo!() + } + + fn three<T0, T1, T2, F0, F1, F2>(effectives: (F0, F1, F2)) -> Self::Three<T0, T1, T2> + where + T0: Effective<Effect = Self::Effect>, + T1: Effective<Effect = Self::Effect>, + T2: Effective<Effect = Self::Effect>, + F0: FnOnce() -> T0, + F1: FnOnce() -> T1, + F2: FnOnce() -> T2, + { + todo!() + } +} + +impl TryJoin for Blocking { + type Effect = Self; + + type Two<Err, V0, V1, T0, T1> = Value<Result<(T0, T1), Err>> + where + V0: Effective<Output = Result<T0, Err>, Effect = Self::Effect>, + V1: Effective<Output = Result<T1, Err>, Effect = Self::Effect>; + + type Three<Err, V0, V1, V2, T0, T1, T2> = Value<Result<(T0, T1, T2), Err>> + where + V0: Effective<Output = Result<T0, Err>, Effect = Self::Effect>, + V1: Effective<Output = Result<T1, Err>, Effect = Self::Effect>, + V2: Effective<Output = Result<T2, Err>, Effect = Self::Effect>; + + fn two<Err, T0, T1, V0, V1, F0, F1>(cb: (F0, F1)) -> Self::Two<Err, V0, V1, T0, T1> + where + V0: Effective<Output = Result<T0, Err>, Effect = Self::Effect>, + V1: Effective<Output = Result<T1, Err>, Effect = Self::Effect>, + F0: FnOnce() -> T0, + F1: FnOnce() -> T1, + { + todo!() + } + + fn three<Err, T0, T1, T2, V0, V1, V2, F0, F1, F2>( + cb: (F0, F1, F2), + ) -> Self::Three<Err, V0, V1, V2, T0, T1, T2> + where + V0: Effective<Output = Result<T0, Err>, Effect = Self::Effect>, + V1: Effective<Output = Result<T1, Err>, Effect = Self::Effect>, + V2: Effective<Output = Result<T2, Err>, Effect = Self::Effect>, + F0: FnOnce() -> T0, + F1: FnOnce() -> T1, + F2: FnOnce() -> T2, + { + todo!() + } +} |