Skip to main content

nil_core/
capital.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use crate::continent::coord::Coord;
5use serde::{Deserialize, Serialize};
6
7#[derive(Clone, Debug, Default, Deserialize, Serialize)]
8#[serde(rename_all = "camelCase")]
9#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
10pub struct Capital {
11  pub(crate) coord: Option<Coord>,
12}
13
14impl Capital {
15  #[inline]
16  pub fn new(coord: Coord) -> Self {
17    Self { coord: Some(coord) }
18  }
19
20  #[inline]
21  pub fn coord(&self) -> Option<Coord> {
22    self.coord
23  }
24}
25
26#[derive(Clone, Debug, Deserialize, Serialize)]
27#[serde(rename_all = "camelCase")]
28#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
29pub struct PublicCapital {
30  coord: Option<Coord>,
31}
32
33impl From<&Capital> for PublicCapital {
34  fn from(capital: &Capital) -> Self {
35    Self { coord: capital.coord }
36  }
37}