cgp_handler/providers/
promote.rs1use core::marker::PhantomData;
2
3use cgp_core::prelude::*;
4
5use crate::{Computer, Handler, HandlerComponent};
6
7#[cgp_new_provider]
8impl<Context, Code, Input, Output, Provider> Handler<Context, Code, Input> for Promote<Provider>
9where
10 Context: HasAsyncErrorType,
11 Provider: Computer<Context, Code, Input, Output = Output>,
12 Code: Send,
13 Input: Send,
14 Output: Send,
15{
16 type Output = Output;
17
18 async fn handle(
19 context: &Context,
20 tag: PhantomData<Code>,
21 input: Input,
22 ) -> Result<Output, Context::Error> {
23 Ok(Provider::compute(context, tag, input))
24 }
25}
26
27#[cgp_new_provider]
28impl<Context, Code, Input, Output, Provider> Handler<Context, Code, Input> for TryPromote<Provider>
29where
30 Context: HasAsyncErrorType,
31 Provider: Computer<Context, Code, Input, Output = Result<Output, Context::Error>>,
32 Code: Send,
33 Input: Send,
34 Output: Send,
35{
36 type Output = Output;
37
38 async fn handle(
39 context: &Context,
40 tag: PhantomData<Code>,
41 input: Input,
42 ) -> Result<Output, Context::Error> {
43 Provider::compute(context, tag, input)
44 }
45}