1#[cfg(feature = "serde")]
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4use strum::{AsRefStr, EnumString};
5use time::OffsetDateTime;
6use url::Url;
7
8use crate::Hateoas;
9
10#[cfg(feature = "serde")]
11use super::utils;
12
13#[cfg_attr(
14 feature = "serde",
15 derive(Serialize, Deserialize),
16 serde(rename_all = "SCREAMING_SNAKE_CASE")
17)]
18#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, AsRefStr, EnumString)]
19#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
20#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
21pub enum BandType {
22 Transmit,
23 Receive,
24}
25
26#[cfg_attr(
27 feature = "serde",
28 derive(Serialize, Deserialize),
29 serde(rename_all = "SCREAMING_SNAKE_CASE")
30)]
31#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, AsRefStr, EnumString)]
32#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
33#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
34pub enum IoHardware {
35 Modem,
36 Fep,
37 Cortex,
38 Recorder,
39 #[strum(default)]
40 #[cfg_attr(feature = "serde", serde(untagged))]
41 Other(String),
42}
43
44#[cfg_attr(
45 feature = "serde",
46 derive(Serialize, Deserialize),
47 serde(rename_all = "camelCase")
48)]
49#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
50#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
51pub struct IoConfiguration {
52 #[cfg_attr(feature = "serde", serde(default))]
53 pub start_hex_pattern: Option<String>,
54 #[cfg_attr(feature = "serde", serde(default))]
55 pub end_hex_pattern: Option<String>,
56 pub strip_pattern: bool,
57 #[cfg_attr(feature = "serde", serde(default))]
58 pub io_hardware: Option<IoHardware>,
59}
60
61#[cfg_attr(
62 feature = "serde",
63 derive(Serialize, Deserialize),
64 serde(rename_all = "camelCase")
65)]
66#[derive(Debug, Clone, PartialEq)]
67#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
68pub struct Band {
69 #[cfg_attr(feature = "serde", serde(with = "time::serde::iso8601"))]
70 pub created: OffsetDateTime,
71 #[cfg_attr(
72 feature = "serde",
73 serde(default, with = "time::serde::iso8601::option")
74 )]
75 pub modified: Option<OffsetDateTime>,
76 pub name: String,
77 #[cfg_attr(feature = "serde", serde(rename = "type", default))]
78 pub typ: Option<BandType>,
79 pub frequency_mghz: f64,
80 pub default_band_width_mghz: f64,
81 pub io_configuration: IoConfiguration,
82 #[cfg_attr(feature = "serde", serde(default))]
83 pub manual_transmit_control: Option<bool>,
84 #[cfg_attr(feature = "serde", serde(default))]
85 pub account_name: Option<String>,
86 #[cfg_attr(
87 feature = "serde",
88 serde(rename = "_links", with = "utils::links::serde", default)
89 )]
90 pub links: HashMap<String, Url>,
91}
92
93impl Hateoas for Band {
94 fn get_links(&self) -> &HashMap<String, url::Url> {
95 &self.links
96 }
97
98 fn get_links_mut(&mut self) -> &mut HashMap<String, url::Url> {
99 &mut self.links
100 }
101}