persistent websocket
This commit is contained in:
@@ -6,4 +6,5 @@ edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
serde.workspace = true
|
||||
thiserror = "1"
|
||||
uuid.workspace = true
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user