Skip to main content

auric_runtime/
router.rs

1use crate::RouteDef;
2use std::sync::Arc;
3use web_sys::window;
4
5#[derive(Clone)]
6pub struct Router {
7    #[allow(unused)]
8    router: Arc<actix_router::Router<RouteDef>>,
9}
10
11impl Default for Router {
12    fn default() -> Self {
13        let builder = actix_router::Router::build();
14        let router = Arc::new(builder.finish());
15        Self { router }
16    }
17}
18
19impl Router {
20    pub fn new() -> Self {
21        Self::default()
22    }
23
24    pub fn init(&self) -> anyhow::Result<()> {
25        // Find route for href
26        let _href = window()
27            .and_then(|win| win.location().href().ok())
28            .expect("Could not access window location");
29        // TODO
30
31        // Enter route
32        // TODO
33
34        // Done
35        web_sys::console::log_1(&"Initialized router".into());
36        Ok(())
37    }
38}