cgp_handler/providers/
return_input.rs1use cgp_core::prelude::*;
2
3use crate::{
4 AsyncComputer, AsyncComputerComponent, Computer, ComputerComponent, Handler, HandlerComponent,
5 TryComputer, TryComputerComponent,
6};
7
8pub struct ReturnInput;
9
10#[cgp_provider]
11impl<Context, Code, Input> Computer<Context, Code, Input> for ReturnInput {
12 type Output = Input;
13
14 fn compute(_context: &Context, _code: PhantomData<Code>, input: Input) -> Self::Output {
15 input
16 }
17}
18
19#[cgp_provider]
20impl<Context, Code, Input> TryComputer<Context, Code, Input> for ReturnInput
21where
22 Context: HasErrorType,
23{
24 type Output = Input;
25
26 fn try_compute(
27 _context: &Context,
28 _code: PhantomData<Code>,
29 input: Input,
30 ) -> Result<Self::Output, Context::Error> {
31 Ok(input)
32 }
33}
34
35#[cgp_provider]
36impl<Context, Code, Input> AsyncComputer<Context, Code, Input> for ReturnInput {
37 type Output = Input;
38
39 async fn compute_async(
40 _context: &Context,
41 _code: PhantomData<Code>,
42 input: Input,
43 ) -> Self::Output {
44 input
45 }
46}
47
48#[cgp_provider]
49impl<Context, Code, Input> Handler<Context, Code, Input> for ReturnInput
50where
51 Context: HasErrorType,
52{
53 type Output = Input;
54
55 async fn handle(
56 _context: &Context,
57 _code: PhantomData<Code>,
58 input: Input,
59 ) -> Result<Self::Output, Context::Error> {
60 Ok(input)
61 }
62}