dioxus_liveview/adapters/
mod.rs

1use std::future::Future;
2
3use dioxus_core::{Element, VirtualDom};
4
5#[cfg(feature = "axum")]
6pub mod axum_adapter;
7#[cfg(feature = "axum")]
8pub use axum_adapter::*;
9
10/// A trait for servers that can be used to host a LiveView app.
11pub trait LiveviewRouter {
12    /// Create a new router.
13    fn create_default_liveview_router() -> Self;
14
15    /// Add a liveview route to the server from a component
16    fn with_app(self, route: &str, app: fn() -> Element) -> Self
17    where
18        Self: Sized,
19    {
20        self.with_virtual_dom(route, move || VirtualDom::new(app))
21    }
22
23    /// Add a liveview route to the server from a virtual dom.
24    fn with_virtual_dom(
25        self,
26        route: &str,
27        app: impl Fn() -> VirtualDom + Send + Sync + 'static,
28    ) -> Self;
29
30    /// Start the server on an address.
31    fn start(self, address: impl Into<std::net::SocketAddr>) -> impl Future<Output = ()>;
32}