Skip to main content

dope_sys/engine/
shutdown.rs

1use std::convert::Infallible;
2
3use crate::{engine::Buffer, io::Retry, memory, ring::map};
4
5/// Ends the native reactor and its receive projection as one lifetime.
6pub trait Shutdown: Buffer + Sized {
7    type State: Cleanup;
8
9    fn try_shutdown(self, context: Self::Context) -> Result<(), Self::State>;
10}
11
12/// Retains every resource needed to retry the exact failed shutdown phase.
13pub trait Cleanup: Retry<Failure: Into<Failure<Self::Error>>> {
14    type Error;
15
16    fn failure(&self) -> Failure<Self::Error>;
17}
18
19/// Exact failure from the reactor or its retained receive storage.
20#[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}