Skip to main content

canic_core/ids/
app.rs

1//! Module: ids::app
2//!
3//! Responsibility: identify one checked-in App definition.
4//! Does not own: live Fleet identity, deployment labels, or filesystem paths.
5//! Boundary: configuration validation admits the wrapped source name before use.
6
7use serde::{Deserialize, Serialize};
8use std::fmt;
9
10///
11/// AppId
12///
13/// Immutable source identity declared by `[app].name`.
14///
15
16#[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
17#[serde(transparent)]
18pub struct AppId(String);
19
20impl AppId {
21    #[must_use]
22    pub const fn owned(value: String) -> Self {
23        Self(value)
24    }
25
26    #[must_use]
27    pub const fn as_str(&self) -> &str {
28        self.0.as_str()
29    }
30}
31
32impl AsRef<str> for AppId {
33    fn as_ref(&self) -> &str {
34        self.as_str()
35    }
36}
37
38impl fmt::Display for AppId {
39    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
40        formatter.write_str(self.as_str())
41    }
42}
43
44impl From<&str> for AppId {
45    fn from(value: &str) -> Self {
46        Self(value.to_string())
47    }
48}
49
50impl From<String> for AppId {
51    fn from(value: String) -> Self {
52        Self::owned(value)
53    }
54}