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