canic_core/ids/network.rs
1//! Module: ids::network
2//!
3//! Responsibility: build network identifiers.
4//! Does not own: environment detection or deployment selection.
5//! Boundary: exposes the network label a canister believes it runs under.
6
7use std::fmt::{self, Display};
8
9///
10/// BuildNetwork
11///
12/// Identifies the environment the canister believes it runs in.
13///
14
15#[derive(Clone, Copy, Debug, Eq, PartialEq)]
16pub enum BuildNetwork {
17 Ic,
18 Local,
19}
20
21impl BuildNetwork {
22 #[must_use]
23 pub const fn as_str(self) -> &'static str {
24 match self {
25 Self::Ic => "ic",
26 Self::Local => "local",
27 }
28 }
29}
30
31impl Display for BuildNetwork {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 f.write_str(self.as_str())
34 }
35}