Skip to main content

nil_payload/
lib.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4#![cfg_attr(docsrs, feature(doc_cfg))]
5#![doc(html_favicon_url = "https://nil.dev.br/favicon.png")]
6
7pub mod battle;
8pub mod chat;
9pub mod cheat;
10pub mod city;
11pub mod continent;
12pub mod infrastructure;
13pub mod military;
14pub mod npc;
15pub mod player;
16pub mod ranking;
17pub mod report;
18pub mod round;
19pub mod user;
20pub mod world;
21
22use nil_core::player::PlayerId;
23use nil_core::world::config::WorldId;
24use nil_crypto::password::Password;
25use nil_server_types::Token;
26use serde::{Deserialize, Serialize};
27
28#[derive(Clone, Debug, Deserialize, Serialize)]
29#[serde(rename_all = "camelCase")]
30pub struct AuthorizeRequest {
31  pub player: PlayerId,
32  #[serde(default)]
33  pub password: Option<Password>,
34}
35
36#[derive(Clone, Debug, Deserialize, Serialize)]
37#[serde(rename_all = "camelCase")]
38pub struct ValidateTokenRequest {
39  pub token: Token,
40}
41
42impl<T> From<T> for ValidateTokenRequest
43where
44  T: AsRef<str>,
45{
46  fn from(token: T) -> Self {
47    Self { token: Token::new(token) }
48  }
49}
50
51#[derive(Clone, Debug, Deserialize)]
52#[serde(rename_all = "camelCase")]
53pub struct WebsocketQuery {
54  pub world_id: WorldId,
55  #[serde(default)]
56  pub world_password: Option<Password>,
57}