1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#![allow(clippy::assign_op_pattern)]
use std::fmt;
use dataplane::derive::*;
#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]
#[cfg_attr(
feature = "use_serde",
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "camelCase")
)]
pub struct SpuGroupStatus {
pub resolution: SpuGroupStatusResolution,
pub reason: Option<String>,
}
impl fmt::Display for SpuGroupStatus {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:#?}", self.resolution)
}
}
impl SpuGroupStatus {
pub fn invalid(reason: String) -> Self {
Self {
resolution: SpuGroupStatusResolution::Invalid,
reason: Some(reason),
}
}
pub fn reserved() -> Self {
Self {
resolution: SpuGroupStatusResolution::Reserved,
..Default::default()
}
}
pub fn is_already_valid(&self) -> bool {
self.resolution == SpuGroupStatusResolution::Reserved
}
}
#[cfg_attr(feature = "use_serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Encode, Decode, Debug, Clone, PartialEq)]
pub enum SpuGroupStatusResolution {
Init,
Invalid,
Reserved,
}
impl Default for SpuGroupStatusResolution {
fn default() -> Self {
Self::Init
}
}
impl fmt::Display for SpuGroupStatusResolution {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Init => write!(f, "Init"),
Self::Invalid => write!(f, "Invalid"),
Self::Reserved => write!(f, "Reserved"),
}
}
}