Skip to main content

edda_types/
admin.rs

1//! What the services' admin APIs answer (see `edda_server::admin`): what
2//! they deleted and took in, and each one's part of a campaign as it's
3//! exported, to keep or to move to another server (the auth service's is
4//! `edda_auth::protocol::AuthExport`).
5
6use serde::{Deserialize, Serialize};
7
8/// `DELETE /admin/campaigns/{id}`: how many of the campaign's things a
9/// service deleted (characters, combats, monsters and texts, or devices).
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
11#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
12pub struct Deleted {
13    pub deleted: u64,
14}
15
16/// `PUT /admin/campaigns/{id}/import`: how many of the campaign's things a
17/// service took in.
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
19#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
20pub struct Imported {
21    pub imported: u64,
22}
23
24/// The character service's part of a campaign, as exported and imported:
25/// `GET`/`PUT /admin/campaigns/{id}/export|import`.
26#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
27#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
28pub struct CharactersExport {
29    pub characters: Vec<crate::Character>,
30}
31
32/// The combat service's part of a campaign: its combats, log and all, and
33/// its planned encounters.
34#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
35#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
36pub struct CombatExport {
37    pub combats: Vec<ExportedCombat>,
38    pub encounters: Vec<crate::encounter::Encounter>,
39}
40
41/// A combat as exported: everything else about it follows from its log.
42#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
43#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
44pub struct ExportedCombat {
45    pub id: uuid::Uuid,
46    pub log: Vec<crate::combat::LoggedEvent>,
47    /// The commands it has run, and whose device sent them, so resent ones
48    /// are still recognised and each device undoes only its own.
49    pub commands: Vec<SentCommand>,
50    /// How far its hit points have reached the character sheets.
51    #[serde(default, skip_serializing_if = "Option::is_none")]
52    pub hp_synced: Option<u64>,
53}
54
55/// A command a combat has run, and the key of the device that sent it.
56#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
57#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
58pub struct SentCommand {
59    pub id: uuid::Uuid,
60    #[serde(default, skip_serializing_if = "Option::is_none")]
61    pub sender: Option<String>,
62}
63
64/// The monster service's part of a campaign: its own monsters, spells and
65/// conditions.
66#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
67#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
68pub struct MonstersExport {
69    pub monsters: Vec<crate::monster::Monster>,
70    pub spells: Vec<crate::rules_text::Entry<crate::rules_text::SpellText>>,
71    pub conditions: Vec<crate::rules_text::Entry<crate::rules_text::ConditionText>>,
72}