nodex_core/model/
status.rs1use serde::{Deserialize, Serialize};
2use std::fmt;
3
4#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
6#[serde(transparent)]
7pub struct Status(String);
8
9impl Status {
10 pub fn new(s: impl Into<String>) -> Self {
11 Self(s.into())
12 }
13
14 pub fn as_str(&self) -> &str {
15 &self.0
16 }
17}
18
19impl fmt::Display for Status {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 f.write_str(&self.0)
22 }
23}
24
25impl Default for Status {
26 fn default() -> Self {
27 Self("active".to_string())
28 }
29}
30
31impl From<&str> for Status {
32 fn from(s: &str) -> Self {
33 Self(s.to_string())
34 }
35}