dope_sys/engine/
shutdown.rs1use std::convert::Infallible;
2
3use crate::{engine::Buffer, io::Retry, memory, ring::map};
4
5pub trait Shutdown: Buffer + Sized {
7 type State: Cleanup;
8
9 fn try_shutdown(self, context: Self::Context) -> Result<(), Self::State>;
10}
11
12pub trait Cleanup: Retry<Failure: Into<Failure<Self::Error>>> {
14 type Error;
15
16 fn failure(&self) -> Failure<Self::Error>;
17}
18
19#[derive(Debug, Eq, PartialEq)]
21pub enum Failure<E> {
22 Backend(map::Storage<E>),
23 Context(memory::Error),
24}
25
26impl Cleanup for Infallible {
27 type Error = Infallible;
28
29 fn failure(&self) -> Failure<Self::Error> {
30 match *self {}
31 }
32}
33
34impl<E> From<Infallible> for Failure<E> {
35 fn from(value: Infallible) -> Self {
36 match value {}
37 }
38}