cgp_component/traits/has_provider.rs
1/**
2 This trait is used by the blanket implementations of CGP consumer traits to
3 forward the implementation to the `CgpProvider` type, which impements the
4 corresponding provider trait.
5
6 The `HasCgpProvider` trait is automatically implemented by `#[cgp_context]`
7 when defining a context type, together with the generated provider struct.
8
9 Typically, the `CgpProvider` would contain provider implementation mapping
10 through `delegate_component!` macro to implement the corresponding provider
11 traits. However, it is also possible to implement context-specific provider
12 traits on the `CgpProvider` type directly.
13
14 ## Example
15
16 Given the following context definition:
17
18 ```rust,ignore
19 #[cgp_context(MyContextComponents)]
20 pub struct MyContext {
21 ...
22 }
23 ```
24
25 The following would be generated:
26
27 ```rust,ignore
28 pub struct MyContextComponents;
29
30 impl HasCgpProvider for MyContext {
31 type CgpProvider = MyContextComponents;
32 }
33 ```
34*/
35pub trait HasCgpProvider {
36 type CgpProvider;
37}