use crate::effect::boxed::BoxedEffect;
use crate::effect::ext::EffectExt;
#[deprecated(
since = "0.11.0",
note = "Use `impl Effect<...>` for zero-cost or `BoxedEffect` for type erasure"
)]
pub type LegacyEffect<T, E, Env> = BoxedEffect<T, E, Env>;
#[deprecated(since = "0.11.0", note = "Use `pure()` and `fail()` functions instead")]
pub trait LegacyConstructors<T, E, Env>: Sized {
fn legacy_pure(value: T) -> BoxedEffect<T, E, Env>
where
T: Send + 'static,
E: Send + 'static,
Env: Clone + Send + Sync + 'static;
fn legacy_fail(error: E) -> BoxedEffect<T, E, Env>
where
T: Send + 'static,
E: Send + 'static,
Env: Clone + Send + Sync + 'static;
}
#[allow(deprecated)]
impl<T, E, Env> LegacyConstructors<T, E, Env> for BoxedEffect<T, E, Env> {
fn legacy_pure(value: T) -> BoxedEffect<T, E, Env>
where
T: Send + 'static,
E: Send + 'static,
Env: Clone + Send + Sync + 'static,
{
crate::effect::constructors::pure(value).boxed()
}
fn legacy_fail(error: E) -> BoxedEffect<T, E, Env>
where
T: Send + 'static,
E: Send + 'static,
Env: Clone + Send + Sync + 'static,
{
crate::effect::constructors::fail(error).boxed()
}
}
#[allow(async_fn_in_trait)]
pub trait RunStandalone: crate::effect::trait_def::Effect<Env = ()> {
async fn run_standalone(self) -> Result<Self::Output, Self::Error>;
}
impl<E: crate::effect::trait_def::Effect<Env = ()>> RunStandalone for E {
async fn run_standalone(self) -> Result<Self::Output, Self::Error> {
self.run(&()).await
}
}