yew_router_nested/
lib.rs

1#![recursion_limit = "128"]
2//! Provides routing faculties for the Yew web framework.
3//!
4//! ## Contents
5//! This crate consists of multiple types, some independently useful on their own,
6//! that are used together to facilitate routing within the Yew framework.
7//! Among them are:
8//! * RouteService - Hooks into the History API and listens to `PopStateEvent`s to respond to users
9//!   clicking the back/forwards buttons.
10//! * RouteAgent - A singleton agent that owns a RouteService that provides an easy place for other
11//!   components and agents to hook into it.
12//! * Switch - A trait/derive macro that allows specification of how enums or structs can be constructed
13//! from Routes.
14//! * Router - A component connected to the RouteAgent, and is capable of resolving Routes to
15//! Switch implementors, so you can use them to render Html.
16//! * Route - A struct containing an the route string and state.
17//! * RouteButton & RouteLink - Wrapper components around buttons and anchor tags respectively that
18//!   allow users to change the route.
19//!
20//! ## State and Aliases
21//! Because the History API allows you to store data along with a route string,
22//! most types have at type parameter that allows you to specify which type is being stored.
23//! As this behavior is uncommon, aliases using the unit type (`()`) are provided to remove the
24//! need to specify the storage type you likely aren't using.
25//!
26//! If you want to store state using the history API, it is recommended that you generate your own
27//! aliases using the `define_router_state` macro.
28//! Give it a typename, and it will generate a module containing aliases and functions useful for
29//! routing. If you specify your own router_state aliases and functions, you will want to disable
30//! the `unit_alias` feature to prevent the default `()` aliases from showing up in the prelude.
31//!
32//! ## Features
33//! This crate has some feature-flags that allow you to not include some parts in your compilation.
34//! * "default" - Everything is included by default.
35//! * "core" - The fully feature complete ("router", "components", "matchers"), but without
36//!   unit_alias.
37//! * "unit_alias" - If enabled, a module will be added to the route and expanded within the prelude
38//! for aliases of Router types to their `()` variants.
39//! * "router" - If enabled, the Router component and its dependent infrastructure (including
40//!   "agent") will be included.
41//! * "agent" - If enabled, the RouteAgent and its associated types will be included.
42//! * "components" - If enabled, the accessory components will be made available.
43
44#![deny(
45    missing_docs,
46    missing_debug_implementations,
47    missing_copy_implementations,
48    trivial_casts,
49    trivial_numeric_casts,
50    unsafe_code,
51    unstable_features,
52    unused_qualifications
53)]
54// This will break the project at some point, but it will break yew as well.
55// It can be dealt with at the same time.
56#![allow(macro_expanded_macro_exports_accessed_by_absolute_paths)]
57
58pub use yew_router_route_parser;
59
60#[macro_use]
61mod alias;
62
63#[cfg(feature = "service")]
64pub mod service;
65
66#[cfg(feature = "agent")]
67pub mod agent;
68
69pub mod route;
70
71#[cfg(feature = "components")]
72pub mod components;
73
74#[cfg(feature = "router")]
75pub mod router;
76
77/// Prelude module that can be imported when working with the yew_router
78pub mod prelude {
79    pub use super::matcher::Captures;
80
81    #[cfg(feature = "service")]
82    pub use crate::route::RouteState;
83    #[cfg(feature = "service")]
84    pub use crate::service::RouteService;
85
86    #[cfg(feature = "agent")]
87    pub use crate::agent::RouteAgent;
88    #[cfg(feature = "agent")]
89    pub use crate::agent::RouteAgentBridge;
90    #[cfg(feature = "agent")]
91    pub use crate::agent::RouteAgentDispatcher;
92
93    #[cfg(feature = "components")]
94    pub use crate::components::RouterAnchor;
95    #[cfg(feature = "components")]
96    pub use crate::components::RouterButton;
97
98    #[cfg(feature = "router")]
99    pub use crate::router::Router;
100
101    #[cfg(feature = "router")]
102    pub use crate::router::RouterState;
103
104    pub use crate::{
105        route::Route,
106        switch::{Routable, Switch},
107    };
108    pub use yew_router_macro::Switch;
109}
110
111pub use alias::*;
112
113pub mod matcher;
114
115pub use matcher::Captures;
116
117#[cfg(feature = "service")]
118pub use crate::route::RouteState;
119#[cfg(feature = "router")]
120pub use crate::router::RouterState;
121
122pub mod switch;
123pub use switch::Switch;
124pub use yew_router_macro::Switch;