use serde::{de::DeserializeOwned, Deserialize, Serialize};
pub trait Req: Serialize + DeserializeOwned {
type Response: Serialize + DeserializeOwned;
fn path(&self) -> String;
const METHOD: &'static str;
}
pub trait REST: Serialize + DeserializeOwned {
type Index;
fn path() -> String;
}
#[derive(Clone, Serialize, Deserialize)]
#[cfg_attr(target_family = "wasm", derive(tsify_next::Tsify))]
#[cfg_attr(
target_family = "wasm",
tsify(into_wasm_abi, from_wasm_abi, large_number_types_as_bigints)
)]
pub struct SignUp {
pub user: String,
pub pass: String,
}
impl Req for SignUp {
type Response = ();
fn path(&self) -> String {
"/api/auth/signup".into()
}
const METHOD: &'static str = "POST";
}
#[derive(Clone, Serialize, Deserialize)]
#[cfg_attr(target_family = "wasm", derive(tsify_next::Tsify))]
#[cfg_attr(
target_family = "wasm",
tsify(into_wasm_abi, from_wasm_abi, large_number_types_as_bigints)
)]
pub struct Enroll(pub String);
#[derive(Clone, Serialize, Deserialize)]
#[cfg_attr(target_family = "wasm", derive(tsify_next::Tsify))]
#[cfg_attr(
target_family = "wasm",
tsify(
into_wasm_abi,
from_wasm_abi,
missing_as_null,
large_number_types_as_bigints
)
)]
pub struct Message {
#[cfg(target_family = "wasm")] pub time: f64,
#[cfg(not(target_family = "wasm"))]
pub time: u64,
pub sender: Option<String>,
pub content: String,
pub html: bool,
}
#[derive(Clone, Serialize, Deserialize)]
#[cfg_attr(target_family = "wasm", derive(tsify_next::Tsify))]
#[cfg_attr(
target_family = "wasm",
tsify(into_wasm_abi, from_wasm_abi, large_number_types_as_bigints)
)]
pub struct EditPass(pub String);
impl Req for EditPass {
type Response = ();
fn path(&self) -> String {
"/api/auth/pass".into()
}
const METHOD: &'static str = "POST";
}