Skip to main content

mars_schema/
visibility.rs

1//! Whether an effectful package item (a hook or an MCP server) crosses a package boundary.
2
3/// `local` (the default) stays with the package that declares it; `exported` reaches its
4/// dependents.
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
6pub enum Visibility {
7    #[default]
8    Local,
9    Exported,
10}
11
12impl Visibility {
13    /// The authored spelling, or `None` for anything else; the caller decides how loud that is.
14    pub fn parse(value: &str) -> Option<Self> {
15        match value {
16            "local" => Some(Self::Local),
17            "exported" => Some(Self::Exported),
18            _ => None,
19        }
20    }
21
22    pub fn as_str(self) -> &'static str {
23        match self {
24            Self::Local => "local",
25            Self::Exported => "exported",
26        }
27    }
28}