yew_router_nested/
alias.rs

1/// Generates a module named `router_state` containing aliases to common structures within
2/// yew_router that deal with operating with Route and its state values as well as functions for
3/// rendering routes.
4///
5/// Because they should be the same across a given application,
6/// its a handy way to make sure that every type that could be needed is generated.
7///
8/// This macro is used to generate aliases for the state type of `()` within yew_router.
9/// Instead of doing these yourself, use this macro if you need to store state in the browser.
10///
11/// # Example
12/// ```
13/// # use yew_router::define_router_state;
14/// define_router_state!(Option<String>);
15/// use router_state::Route; // alias to Route<Option<String>>
16/// # fn main() {}
17/// ```
18#[macro_export]
19macro_rules! define_router_state {
20    ($StateT:ty) => {
21        define_router_state!($StateT, stringify!($StateT));
22    };
23    ($StateT:ty, $StateName:expr) => {
24        #[doc = "A set of aliases to commonly used structures and functions used for routing."]
25        mod router_state {
26
27            #[doc = "The state that can be stored by the router service."]
28            pub type State = $StateT;
29
30            #[doc = "Alias to [Route<"]
31            #[doc = $StateName]
32            #[doc = ">](route/struct.Route.html)."]
33            pub type Route = $crate::route::Route<$StateT>;
34
35            #[doc = "Alias to [RouteService<"]
36            #[doc = $StateName]
37            #[doc = ">](route_service/struct.RouteService.html)."]
38            pub type RouteService = $crate::service::RouteService<$StateT>;
39
40            #[cfg(feature = "agent")]
41            #[doc = "Alias to [RouteAgent<"]
42            #[doc = $StateName]
43            #[doc = ">](agent/struct.RouteAgent.html)."]
44            pub type RouteAgent = $crate::agent::RouteAgent<$StateT>;
45
46            #[cfg(feature = "agent")]
47            #[doc = "Alias to [RouteAgentBridge<"]
48            #[doc = $StateName]
49            #[doc = ">](agent/bridge/struct.RouteAgentBridge.html)`."]
50            pub type RouteAgentBridge = $crate::agent::RouteAgentBridge<$StateT>;
51
52            #[cfg(feature = "agent")]
53            #[doc = "Alias to [RouteAgentDispatcher<"]
54            #[doc = $StateName]
55            #[doc = ">](agent/struct.RouteAgentDispatcher.html)`."]
56            pub type RouteAgentDispatcher = $crate::agent::RouteAgentDispatcher<$StateT>;
57
58            #[allow(deprecated)]
59            #[deprecated(note = "Has been renamed to RouterAnchor")]
60            #[cfg(feature = "components")]
61            #[doc = "Alias to [RouterLink<"]
62            #[doc = $StateName]
63            #[doc = ">](components/struct.RouterLink.html)`."]
64            pub type RouterLink = $crate::components::RouterLink<$StateT>;
65
66            #[cfg(feature = "components")]
67            #[doc = "Alias to [RouterAnchor<"]
68            #[doc = $StateName]
69            #[doc = ">](components/struct.RouterAnchor.html)`."]
70            pub type RouterAnchor = $crate::components::RouterAnchor<$StateT>;
71
72            #[cfg(feature = "components")]
73            #[doc = "Alias to [RouterButton<"]
74            #[doc = $StateName]
75            #[doc = ">](components/struct.RouterButton.html)`."]
76            pub type RouterButton = $crate::components::RouterButton<$StateT>;
77
78            #[cfg(feature = "router")]
79            #[doc = "Alias to [Router<"]
80            #[doc = $StateName]
81            #[doc = ">](router/router/struct.Router.html)."]
82            pub type Router<SW> = $crate::router::Router<$StateT, SW>;
83        }
84    };
85}