use std::convert::Infallible;
use crate::{engine::Buffer, io::Retry, memory, ring::map};
pub trait Shutdown: Buffer + Sized {
type State: Cleanup;
fn try_shutdown(self, context: Self::Context) -> Result<(), Self::State>;
}
pub trait Cleanup: Retry<Failure: Into<Failure<Self::Error>>> {
type Error;
fn failure(&self) -> Failure<Self::Error>;
}
#[derive(Debug, Eq, PartialEq)]
pub enum Failure<E> {
Backend(map::Storage<E>),
Context(memory::Error),
}
impl Cleanup for Infallible {
type Error = Infallible;
fn failure(&self) -> Failure<Self::Error> {
match *self {}
}
}
impl<E> From<Infallible> for Failure<E> {
fn from(value: Infallible) -> Self {
match value {}
}
}