1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#[cfg(any(not(feature = "mock"), feature = "no-mock"))]
mod wasm;
#[cfg(any(not(feature = "mock"), feature = "no-mock"))]
pub use wasm::*;
use tea_actorx_core::{
error::{Error, Result},
ActorId,
};
use tea_codec::{
errorx::Scope,
serde::handle::{Handle, HandleList, Handles, Request},
};
pub type CallingCx = Option<ActorId>;
#[derive(Default, Clone)]
pub struct NoCallingCxWrapper<T>(pub T);
struct AutoTraitWrapper<T>(T);
auto trait NotSliceU8 {}
impl !NotSliceU8 for AutoTraitWrapper<&[u8]> {}
impl<Req, T> Handle<CallingCx, Req> for NoCallingCxWrapper<T>
where
T: Handle<(), Req>,
Req: Request,
AutoTraitWrapper<Req>: NotSliceU8,
{
async fn handle(
self,
req: Req,
_: CallingCx,
) -> Result<<Req as Request>::Response, Error<impl Scope>> {
self.0.handle(req, ()).await
}
}
impl<T> Handles<CallingCx> for NoCallingCxWrapper<T>
where
T: Handles<()>,
T::List: HandleList<Self, CallingCx>,
{
type List = T::List;
}