use finchers_core::endpoint::{Context, Endpoint};
use finchers_core::{task, Error, Never};
pub fn abort<F, E>(f: F) -> Abort<F>
where
F: Fn(&mut Context) -> E + Send + Sync,
E: Into<Error> + Send,
{
Abort { f }
}
#[allow(missing_docs)]
#[derive(Copy, Clone, Debug)]
pub struct Abort<F> {
f: F,
}
impl<F, E> Endpoint for Abort<F>
where
F: Fn(&mut Context) -> E + Send + Sync,
E: Into<Error> + Send,
{
type Output = Never;
type Task = task::Abort<E>;
fn apply(&self, cx: &mut Context) -> Option<Self::Task> {
Some(task::abort((self.f)(cx)))
}
}