use crate::cdk::candid::CandidType;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum BuildNetwork {
#[serde(rename = "ic")]
Ic,
#[serde(rename = "local")]
Local,
}
impl BuildNetwork {
#[must_use]
pub(crate) fn parse(value: &str) -> Option<Self> {
match value {
"ic" => Some(Self::Ic),
"local" => Some(Self::Local),
_ => None,
}
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Ic => "ic",
Self::Local => "local",
}
}
}
impl Display for BuildNetwork {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}