mm1_core/context/
fork.rs

1use mm1_common::errors::error_of::ErrorOf;
2use mm1_common::impl_error_kind;
3use mm1_proto::message;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6#[message(base_path = ::mm1_proto)]
7pub enum ForkErrorKind {
8    InternalError,
9    ResourceConstraint,
10}
11
12pub trait Fork: Sized + Send + 'static {
13    fn fork(&mut self) -> impl Future<Output = Result<Self, ErrorOf<ForkErrorKind>>> + Send;
14
15    fn run<F, Fut>(self, fun: F) -> impl Future<Output = ()> + Send
16    where
17        F: FnOnce(Self) -> Fut,
18        F: Send + 'static,
19        Fut: Future + Send + 'static;
20}
21
22impl_error_kind!(ForkErrorKind);