Skip to main content

mars_schema/
item.rs

1//! Package item vocabulary.
2
3use serde::{Deserialize, Serialize};
4use std::fmt;
5
6#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
7#[serde(rename_all = "kebab-case")]
8pub enum ItemKind {
9    Agent,
10    Skill,
11    Hook,
12    McpServer,
13    BootstrapDoc,
14}
15
16impl fmt::Display for ItemKind {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        f.write_str(match self {
19            Self::Agent => "agent",
20            Self::Skill => "skill",
21            Self::Hook => "hook",
22            Self::McpServer => "mcp-server",
23            Self::BootstrapDoc => "bootstrap-doc",
24        })
25    }
26}
27
28/// The kinds of file a package's definitions are: what `mars-schema` selects, prepares and
29/// reads, as opposed to the binary's wider [`ItemKind`].
30#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
31#[serde(rename_all = "lowercase")]
32pub enum DefinitionKind {
33    Agent,
34    Skill,
35}
36
37impl From<DefinitionKind> for ItemKind {
38    fn from(kind: DefinitionKind) -> Self {
39        match kind {
40            DefinitionKind::Agent => Self::Agent,
41            DefinitionKind::Skill => Self::Skill,
42        }
43    }
44}
45
46impl fmt::Display for DefinitionKind {
47    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
48        ItemKind::from(*self).fmt(f)
49    }
50}