cgp_handler/components/
handler.rs

1use core::marker::PhantomData;
2
3use cgp_core::component::UseDelegate;
4use cgp_core::prelude::*;
5
6#[cgp_component {
7    provider: Handler,
8    derive_delegate: [
9        UseDelegate<Code>,
10        UseInputDelegate<Input>,
11    ],
12}]
13#[async_trait]
14pub trait CanHandle<Code: Send, Input: Send>: HasAsyncErrorType {
15    type Output: Send;
16
17    async fn handle(
18        &self,
19        _tag: PhantomData<Code>,
20        input: Input,
21    ) -> Result<Self::Output, Self::Error>;
22}
23
24pub struct UseInputDelegate<Components>(pub PhantomData<Components>);