Skip to main content

cgp_dispatch/providers/matchers/
match_with_field_handlers.rs

1use cgp_core::prelude::*;
2use cgp_handler::{
3    AsyncComputerComponent, AsyncComputerRefComponent, ComputerComponent, ComputerRefComponent,
4    HandlerComponent, HandlerRefComponent, PromoteRef, TryComputerComponent,
5    TryComputerRefComponent, UseInputDelegate,
6};
7
8use crate::providers::matchers::to_field_handlers::{HasFieldHandlers, MapExtractFieldAndHandle};
9use crate::{HandleFieldValue, MatchWithHandlers, MatchWithHandlersMut, MatchWithHandlersRef};
10
11pub type MatchWithFieldHandlers<Provider = UseContext> =
12    UseInputDelegate<MatchWithFieldHandlersInputs<Provider>>;
13
14pub type MatchWithValueHandlers<Provider = UseContext> =
15    UseInputDelegate<MatchWithFieldHandlersInputs<HandleFieldValue<Provider>>>;
16
17pub struct MatchWithFieldHandlersRef<Provider = UseContext>(pub PhantomData<Provider>);
18
19pub struct MatchWithValueHandlersRef<Provider = UseContext>(pub PhantomData<Provider>);
20
21pub struct MatchWithValueHandlersMut<Provider = UseContext>(pub PhantomData<Provider>);
22
23delegate_components! {
24    <Provider>
25    MatchWithFieldHandlersRef<Provider> {
26        [
27            ComputerComponent,
28            TryComputerComponent,
29            AsyncComputerComponent,
30            HandlerComponent,
31        ]:
32            UseInputDelegate<MatchWithFieldHandlersInputsRef<Provider>>,
33        [
34            ComputerRefComponent,
35            TryComputerRefComponent,
36            AsyncComputerRefComponent,
37            HandlerRefComponent,
38        ]:
39            PromoteRef<UseInputDelegate<MatchWithFieldHandlersInputsRef<PromoteRef<Provider>>>>,
40    }
41}
42
43delegate_components! {
44    <Provider>
45    MatchWithValueHandlersRef<Provider> {
46        [
47            ComputerComponent,
48            TryComputerComponent,
49            AsyncComputerComponent,
50            HandlerComponent,
51        ]:
52            UseInputDelegate<MatchWithFieldHandlersInputsRef<HandleFieldValue<Provider>>>,
53        [
54            ComputerRefComponent,
55            TryComputerRefComponent,
56            AsyncComputerRefComponent,
57            HandlerRefComponent,
58        ]:
59            PromoteRef<UseInputDelegate<MatchWithFieldHandlersInputsRef<HandleFieldValue<PromoteRef<Provider>>>>>,
60    }
61}
62
63delegate_components! {
64    <Provider>
65    MatchWithValueHandlersMut<Provider> {
66        [
67            ComputerComponent,
68            TryComputerComponent,
69            AsyncComputerComponent,
70            HandlerComponent,
71        ]:
72            UseInputDelegate<MatchWithFieldHandlersInputsMut<HandleFieldValue<Provider>>>,
73        [
74            ComputerRefComponent,
75            TryComputerRefComponent,
76            AsyncComputerRefComponent,
77            HandlerRefComponent,
78        ]:
79            PromoteRef<UseInputDelegate<MatchWithFieldHandlersInputsMut<HandleFieldValue<PromoteRef<Provider>>>>>,
80    }
81}
82
83delegate_components! {
84    <Input: HasFieldHandlers<MapExtractFieldAndHandle<Provider>>, Provider>
85    new MatchWithFieldHandlersInputs<Provider> {
86        Input: MatchWithHandlers<Input::Handlers>
87    }
88}
89
90delegate_components! {
91    <Input: HasFieldHandlers<MapExtractFieldAndHandle<Provider>>, Provider>
92    new MatchWithFieldHandlersInputsRef<Provider> {
93        <'a> &'a Input:
94            MatchWithHandlersRef<Input::Handlers>,
95    }
96}
97
98delegate_components! {
99    <Input: HasFieldHandlers<MapExtractFieldAndHandle<Provider>>, Provider>
100    new MatchWithFieldHandlersInputsMut<Provider> {
101        <'a> &'a mut Input:
102            MatchWithHandlersMut<Input::Handlers>
103    }
104}