canic_core/ids/build_network/
mod.rs1use crate::cdk::candid::CandidType;
8use serde::{Deserialize, Serialize};
9use std::fmt::{self, Display};
10
11#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
19pub enum BuildNetwork {
20 #[serde(rename = "ic")]
21 Ic,
22 #[serde(rename = "local")]
23 Local,
24}
25
26impl BuildNetwork {
27 #[must_use]
29 pub(crate) fn parse(value: &str) -> Option<Self> {
30 match value {
31 "ic" => Some(Self::Ic),
32 "local" => Some(Self::Local),
33 _ => None,
34 }
35 }
36
37 #[must_use]
39 pub const fn as_str(self) -> &'static str {
40 match self {
41 Self::Ic => "ic",
42 Self::Local => "local",
43 }
44 }
45}
46
47impl Display for BuildNetwork {
48 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
49 f.write_str(self.as_str())
50 }
51}