mm1_core/context/
linking.rs

1use std::future::Future;
2
3use mm1_address::address::Address;
4use mm1_proto_system as system;
5use mm1_proto_system::System;
6
7use crate::context::call::Call;
8
9pub trait Linking<Sys>:
10    Call<Sys, system::Link, Outcome = ()>
11    + Call<Sys, system::Unlink, Outcome = ()>
12    + Call<Sys, system::TrapExit, Outcome = ()>
13where
14    Sys: System,
15{
16    fn link(&mut self, peer: Address) -> impl Future<Output = ()> + Send
17    where
18        Sys: Default,
19    {
20        async move { self.call(Sys::default(), system::Link { peer }).await }
21    }
22
23    fn unlink(&mut self, peer: Address) -> impl Future<Output = ()> + Send
24    where
25        Sys: Default,
26    {
27        async move { self.call(Sys::default(), system::Unlink { peer }).await }
28    }
29
30    fn set_trap_exit(&mut self, enable: bool) -> impl Future<Output = ()> + Send
31    where
32        Sys: Default,
33    {
34        async move { self.call(Sys::default(), system::TrapExit { enable }).await }
35    }
36}
37
38impl<Sys, T> Linking<Sys> for T
39where
40    T: Call<Sys, system::Link, Outcome = ()>
41        + Call<Sys, system::Unlink, Outcome = ()>
42        + Call<Sys, system::TrapExit, Outcome = ()>,
43    Sys: System,
44{
45}