chore: simplify liveview abstraction

This commit is contained in:
Jonathan Kelley committed 2022-12-15 18:46:59 -08:00
1 parent 44dde38c63
commit 7790d2c065
8 files changed
+142 -82

No files matched your search

+27 -20
View File
@@ -1,3 +1,30 @@
pub mod adapters {
#[cfg(feature = "warp")]
pub mod warp_adapter;
#[cfg(feature = "axum")]
pub mod axum_adapter;
#[cfg(feature = "salvo")]
pub mod salvo_adapter;
}
pub mod pool;
use futures_util::{SinkExt, StreamExt};
pub use pool::*;
pub trait WebsocketTx: SinkExt<String, Error = LiveViewError> {}
impl<T> WebsocketTx for T where T: SinkExt<String, Error = LiveViewError> {}
pub trait WebsocketRx: StreamExt<Item = Result<String, LiveViewError>> {}
impl<T> WebsocketRx for T where T: StreamExt<Item = Result<String, LiveViewError>> {}
#[derive(Debug, thiserror::Error)]
pub enum LiveViewError {
#[error("warp error")]
SendingFailed,
}
use dioxus_interpreter_js::INTERPRETER_JS;
static MAIN_JS: &str = include_str!("./main.js");
@@ -13,23 +40,3 @@ pub fn interpreter_glue(url: &str) -> String {
"#
)
}
pub mod adapters {
#[cfg(feature = "warp")]
pub mod warp_adapter;
#[cfg(feature = "axum")]
pub mod axum_adapter;
#[cfg(feature = "salvo")]
pub mod salvo_adapter;
}
pub mod pool;
pub use pool::*;
#[derive(Debug, thiserror::Error)]
pub enum LiveViewError {
#[error("Connection Failed")]
Warp(#[from] warp::Error),
}