persistent websocket

This commit is contained in:
2023-06-13 11:27:00 +02:00
parent 70d99b0c6b
commit 78999174ab
18 changed files with 334 additions and 309 deletions

View File

@@ -2,6 +2,26 @@ use serde::Deserialize;
use serde::Serialize;
pub type WebSocketMessage = State;
pub type RestResponse<T> = Result<T, RestError>;
#[derive(thiserror::Error, Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[error("{error}")]
pub struct RestError {
pub error: String,
}
impl RestError {
pub fn new(err: impl Into<String>) -> Self {
Self { error: err.into() }
}
}
impl<T> From<T> for RestError
where
T: Into<String>,
{
fn from(value: T) -> Self {
RestError::new(value)
}
}
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct State {