#![allow(clippy::module_name_repetitions)]
use serde::{Deserialize, Serialize};
use strum::AsRefStr;
mod auth;
pub use auth::*;
mod friends;
pub use friends::*;
mod instances;
pub use instances::*;
mod users;
pub use users::*;
mod worlds;
pub use worlds::*;
#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Authenticating {
pub username: String,
pub password: String,
}
impl std::fmt::Debug for Authenticating {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Authenticating")
.field("username", &self.username)
.field("password", &"*****")
.finish()
}
}
impl racal::FromApiState<Self> for Authenticating {
fn from_state(state: &Self) -> &Self { state }
}
#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Authentication {
pub token: String,
pub second_factor_token: Option<String>,
}
impl std::fmt::Debug for Authentication {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Authentication")
.field("token", &"*****")
.field(
"second_factor_token",
match &self.second_factor_token {
Some(_) => &"Some(*****)",
None => &"None",
},
)
.finish()
}
}
impl racal::FromApiState<Self> for Authentication {
fn from_state(state: &Self) -> &Self { state }
}
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, AsRefStr,
)]
#[serde(rename_all = "camelCase")]
#[strum(serialize_all = "camelCase")]
pub enum Order {
Ascending,
Descending,
}
impl Default for Order {
fn default() -> Self { Self::Ascending }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
pub struct Pagination {
#[serde(rename = "n")]
pub limit: u8,
pub offset: u32,
}
impl Default for Pagination {
fn default() -> Self { Self { limit: 10, offset: 0 } }
}
impl Pagination {
fn to_query_str(&self) -> String {
format!("n={}&offset={}", self.limit, self.offset)
}
}