Skip to main content

sim_lib_skill/
citizen.rs

1use sim_citizen_derive::Citizen;
2use sim_kernel::{CapabilityName, Symbol};
3
4/// Serializable `skill/Card` projection of a [`SkillCard`].
5///
6/// Where [`SkillCard`] is a shape-bearing runtime handle, this descriptor is a
7/// plain citizen value carrying only the serializable metadata, suitable for
8/// transport across the runtime boundary.
9///
10/// [`SkillCard`]: crate::SkillCard
11#[derive(Clone, Debug, PartialEq, Citizen)]
12#[citizen(symbol = "skill/Card", version = 1)]
13pub struct SkillCardDescriptor {
14    /// Stable string identifier for the skill.
15    pub id: String,
16    /// Symbol the skill is registered and called under.
17    pub symbol: Symbol,
18    /// Human-readable title.
19    pub title: String,
20    /// Human-readable description.
21    pub description: String,
22    /// Symbols naming the roles the skill plays.
23    pub roles: Vec<Symbol>,
24    /// Capabilities a caller must hold to invoke the skill.
25    pub capabilities: Vec<CapabilityName>,
26    /// Identifier of the transport that runs the skill.
27    pub transport_id: String,
28    /// Kind of the transport.
29    pub transport_kind: String,
30    /// Operation name the transport dispatches.
31    pub operation: String,
32}
33
34impl Default for SkillCardDescriptor {
35    fn default() -> Self {
36        Self {
37            id: "citizen-skill".to_owned(),
38            symbol: Symbol::qualified("skill", "citizen-skill"),
39            title: "Citizen Skill".to_owned(),
40            description: "Citizen fixture skill descriptor".to_owned(),
41            roles: vec![Symbol::new("tool")],
42            capabilities: vec![CapabilityName::new("skill.call.citizen-skill")],
43            transport_id: "fixture".to_owned(),
44            transport_kind: "fixture".to_owned(),
45            operation: "citizen-skill".to_owned(),
46        }
47    }
48}
49
50/// Returns the class symbol (`skill/Card`) for [`SkillCardDescriptor`].
51pub fn skill_card_descriptor_class_symbol() -> Symbol {
52    Symbol::qualified("skill", "Card")
53}