1use axum::response::{Html, IntoResponse, Response};
9
10pub trait RenderAdapter: Send + Sync {
12 fn render_to_html(&self) -> String;
14}
15
16#[derive(Clone, Debug, PartialEq, Eq)]
18pub struct HtmlAdapter(pub String);
19
20impl IntoResponse for HtmlAdapter {
21 fn into_response(self) -> Response {
22 Html(self.0).into_response()
23 }
24}
25
26#[derive(Clone, Debug, PartialEq, Eq)]
28pub struct PicoAdapter(pub String);
29
30impl IntoResponse for PicoAdapter {
31 fn into_response(self) -> Response {
32 Html(self.0).into_response()
33 }
34}
35
36pub type TopcoatAdapter = PicoAdapter;
38
39#[derive(Clone, Debug, PartialEq, Eq)]
41pub struct TemplateAdapter(pub String);
42
43impl IntoResponse for TemplateAdapter {
44 fn into_response(self) -> Response {
45 Html(self.0).into_response()
46 }
47}
48
49#[derive(Clone, Debug, PartialEq, Eq)]
51pub struct LiveViewAdapter<T> {
52 pub view: T,
54}
55
56impl<T: std::fmt::Display> LiveViewAdapter<T> {
57 pub fn new(view: T) -> Self {
59 Self { view }
60 }
61}
62
63impl<T: std::fmt::Display> IntoResponse for LiveViewAdapter<T> {
64 fn into_response(self) -> Response {
65 Html(self.view.to_string()).into_response()
66 }
67}
68
69#[derive(Clone, Debug, PartialEq, Eq)]
71pub struct WasmIslandAdapter<T> {
72 pub component: T,
74}
75
76impl<T: std::fmt::Display> WasmIslandAdapter<T> {
77 pub fn new(component: T) -> Self {
79 Self { component }
80 }
81}
82
83impl<T: std::fmt::Display> IntoResponse for WasmIslandAdapter<T> {
84 fn into_response(self) -> Response {
85 Html(self.component.to_string()).into_response()
86 }
87}
88
89pub type LeptosAdapter<T> = LiveViewAdapter<T>;
91
92pub type DioxusAdapter<T> = WasmIslandAdapter<T>;