Skip to main content

trailcache_core/models/
organization.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4#[cfg_attr(feature = "ts", derive(ts_rs::TS))]
5#[cfg_attr(feature = "ts", ts(export))]
6pub struct Patrol {
7    #[serde(rename = "subUnitGuid")]
8    pub guid: Option<String>,
9    #[serde(rename = "subUnitName")]
10    pub name: String,
11    #[serde(rename = "memberCount")]
12    pub member_count: Option<i32>,
13    #[serde(rename = "patrolLeaderUserId")]
14    #[cfg_attr(feature = "ts", ts(type = "number | null"))]
15    pub patrol_leader_user_id: Option<i64>,
16    #[serde(rename = "patrolLeaderName")]
17    pub patrol_leader_name: Option<String>,
18}
19
20impl Patrol {
21    #[allow(dead_code)]
22    pub fn display_member_count(&self) -> String {
23        match self.member_count {
24            Some(count) => format!("{} members", count),
25            None => "Unknown".to_string(),
26        }
27    }
28}