euv_ui/component/router/select/impl.rs
1use super::*;
2
3/// Inherent implementation of [`NestedRouteConfig`].
4impl NestedRouteConfig {
5 /// Creates a new nested route configuration.
6 ///
7 /// # Arguments
8 ///
9 /// - `P` - The route path, converted into the stored `String`.
10 /// - `F` - The component closure.
11 /// - `Vec<NestedRouteConfig>` - The child routes.
12 pub fn new<P, F>(path: P, component: F, children: Vec<NestedRouteConfig>) -> Self
13 where
14 P: Into<String>,
15 F: Fn() -> VirtualNode + 'static,
16 {
17 Self {
18 path: path.into(),
19 component: Rc::new(component),
20 children,
21 }
22 }
23
24 /// Returns the component closure.
25 ///
26 /// # Returns
27 ///
28 /// - `Rc<dyn Fn() -> VirtualNode>` - A shared closure producing the route's component node.
29 pub fn component(&self) -> Rc<dyn Fn() -> VirtualNode> {
30 self.get_component().clone()
31 }
32
33 /// Returns the child routes.
34 ///
35 /// # Returns
36 ///
37 /// - `&[NestedRouteConfig]` - Slice of all child route configs.
38 pub fn children(&self) -> &[NestedRouteConfig] {
39 self.get_children()
40 }
41}