use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "export", derive(tsify::Tsify))]
#[cfg_attr(feature = "export", tsify(into_wasm_abi, from_wasm_abi))]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Replay {
pub content: String, pub encoding: String, }
#[cfg_attr(feature = "export", derive(tsify::Tsify))]
#[cfg_attr(feature = "export", tsify(into_wasm_abi, from_wasm_abi))]
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GetReplayParamsRaw {
pub k: Option<String>, pub b: Option<String>, pub u: Option<String>, pub m: Option<u8>, pub s: Option<String>, pub t: Option<String>, pub mods: Option<u32>, }
#[cfg_attr(feature = "export", derive(tsify::Tsify))]
#[cfg_attr(feature = "export", tsify(into_wasm_abi, from_wasm_abi))]
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GetReplayParams {
pub api_key: Option<String>, pub beatmap_id: Option<String>, pub user: Option<String>, pub mode: Option<u8>, pub score_id: Option<String>, pub typee: Option<String>, pub mods: Option<u32>, }
impl GetReplayParams {
pub fn api_key(mut self, api_key: String) -> Self {
self.api_key = Some(api_key);
self
}
pub fn beatmap_id(mut self, beatmap_id: String) -> Self {
self.beatmap_id = Some(beatmap_id);
self
}
pub fn user(mut self, user: String) -> Self {
self.user = Some(user);
self
}
pub fn mode(mut self, mode: u8) -> Self {
self.mode = Some(mode);
self
}
pub fn score_id(mut self, score_id: String) -> Self {
self.score_id = Some(score_id);
self
}
pub fn typee(mut self, typee: String) -> Self {
self.typee = Some(typee);
self
}
pub fn mods(mut self, mods: u32) -> Self {
self.mods = Some(mods);
self
}
pub fn build_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(ref api_key) = self.api_key {
params.push(("k".to_string(), api_key.clone()));
}
if let Some(ref beatmap_id) = self.beatmap_id {
params.push(("b".to_string(), beatmap_id.clone()));
}
if let Some(ref user) = self.user {
params.push(("u".to_string(), user.clone()));
}
if let Some(ref mode) = self.mode {
params.push(("m".to_string(), mode.to_string()));
}
if let Some(ref score_id) = self.score_id {
params.push(("s".to_string(), score_id.clone()));
}
if let Some(ref typee) = self.typee {
params.push(("type".to_string(), typee.clone()));
}
if let Some(ref mods) = self.mods {
params.push(("mods".to_string(), mods.to_string()));
}
params
}
pub fn to_raw(&self) -> GetReplayParamsRaw {
GetReplayParamsRaw {
k: self.api_key.clone(),
b: self.beatmap_id.clone(),
u: self.user.clone(),
m: self.mode,
s: self.score_id.clone(),
t: self.typee.clone(),
mods: self.mods,
}
}
}
impl GetReplayParamsRaw {
pub fn k(mut self, api_key: String) -> Self {
self.k = Some(api_key);
self
}
pub fn b(mut self, beatmap_id: String) -> Self {
self.b = Some(beatmap_id);
self
}
pub fn u(mut self, user: String) -> Self {
self.u = Some(user);
self
}
pub fn m(mut self, mode: u8) -> Self {
self.m = Some(mode);
self
}
pub fn s(mut self, score_id: String) -> Self {
self.s = Some(score_id);
self
}
pub fn t(mut self, typee: String) -> Self {
self.t = Some(typee);
self
}
pub fn mods(mut self, mods: u32) -> Self {
self.mods = Some(mods);
self
}
pub fn build_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(ref api_key) = self.k {
params.push(("k".to_string(), api_key.clone()));
}
if let Some(ref beatmap_id) = self.b {
params.push(("b".to_string(), beatmap_id.clone()));
}
if let Some(ref user) = self.u {
params.push(("u".to_string(), user.clone()));
}
if let Some(ref mode) = self.m {
params.push(("m".to_string(), mode.to_string()));
}
if let Some(ref score_id) = self.s {
params.push(("s".to_string(), score_id.clone()));
}
if let Some(ref typee) = self.t {
params.push(("type".to_string(), typee.clone()));
}
if let Some(ref mods) = self.mods {
params.push(("mods".to_string(), mods.to_string()));
}
params
}
}