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/// Owned by ids and consumed by build-network config and access checks.
14///
15
16#[derive(Clone, Copy, Debug, Eq, PartialEq)]
17pub enum BuildNetwork {
18 Ic,
19 Local,
20}
21
22impl BuildNetwork {
23 /// Return the stable build-network label.
24 #[must_use]
25 pub const fn as_str(self) -> &'static str {
26 match self {
27 Self::Ic => "ic",
28 Self::Local => "local",
29 }
30 }
31}
32
33impl Display for BuildNetwork {
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 f.write_str(self.as_str())
36 }
37}