Skip to main content

nil_payload/request/
user.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use bon::Builder;
5use nil_core::player::PlayerId;
6use nil_crypto::password::Password;
7use serde::{Deserialize, Serialize};
8
9#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
10#[serde(rename_all = "camelCase")]
11#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
12#[cfg_attr(feature = "typescript", ts(export))]
13pub struct CreateUserRequest {
14  #[builder(into)]
15  pub player: PlayerId,
16  #[builder(into)]
17  pub password: Password,
18}
19
20#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
21#[serde(rename_all = "camelCase")]
22#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
23#[cfg_attr(feature = "typescript", ts(export))]
24pub struct UserExistsRequest {
25  #[builder(into)]
26  pub user: PlayerId,
27}
28
29impl<T> From<T> for UserExistsRequest
30where
31  T: Into<PlayerId>,
32{
33  fn from(value: T) -> Self {
34    Self::builder().user(value).build()
35  }
36}