lexa_framework/routing/interface.rs
1// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2// ┃ Copyright: (c) 2023, Mike 'PhiSyX' S. (https://github.com/PhiSyX) ┃
3// ┃ SPDX-License-Identifier: MPL-2.0 ┃
4// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
5// ┃ ┃
6// ┃ This Source Code Form is subject to the terms of the Mozilla Public ┃
7// ┃ License, v. 2.0. If a copy of the MPL was not distributed with this ┃
8// ┃ file, You can obtain one at https://mozilla.org/MPL/2.0/. ┃
9// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
10
11use super::RouteCollection;
12use crate::state;
13
14// --------- //
15// Interface //
16// --------- //
17
18pub trait RouterExt {
19 type State: state::StateInterface;
20
21 fn router(self) -> Self
22 where
23 Self: Sized,
24 {
25 self
26 }
27
28 fn routes() -> RouteCollection<Self::State>;
29
30 fn routes_with_state(
31 _: &crate::state::State<Self::State>,
32 ) -> RouteCollection<Self::State> {
33 Self::router_collection()
34 }
35
36 fn router_collection() -> RouteCollection<Self::State> {
37 RouteCollection::new()
38 }
39}