Skip to main content

sim_lib_discrete_graph/
cards.rs

1//! Browse/help card content for the graph family, as kernel-free static data.
2//!
3//! These descriptors are the single source of truth for the graph Cards. The
4//! facade crate registers them into the runtime; keeping them here as plain data
5//! preserves the boundary (this crate never depends on the kernel).
6
7/// A browse/help card descriptor for one discrete family or operation group.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub struct CardSpec {
10    /// Stable card key (for example `discrete/graph`).
11    pub key: &'static str,
12    /// One-line summary.
13    pub summary: &'static str,
14    /// Operation names exposed by this family.
15    pub operations: &'static [&'static str],
16    /// Data forms / value types this family deals in.
17    pub data_forms: &'static [&'static str],
18    /// Known limits and capability needs, in prose.
19    pub limits: &'static str,
20}
21
22/// The graph family cards available so far.
23pub fn graph_cards() -> &'static [CardSpec] {
24    const CARDS: &[CardSpec] = &[CardSpec {
25        key: "discrete/graph",
26        summary: "Weighted graphs with traversal and connectivity.",
27        operations: &[
28            "bfs",
29            "dfs",
30            "connected-components",
31            "weakly-connected-components",
32            "strongly-connected-components",
33        ],
34        data_forms: &["graph", "edge"],
35        limits: "Node identity is index-based; multiedges and self-loops are \
36                 representable. Connectivity validates endpoints and fails closed \
37                 on out-of-range nodes.",
38    }];
39    CARDS
40}
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn graph_card_is_present_and_ascii() {
48        let cards = graph_cards();
49        assert_eq!(cards.len(), 1);
50        assert_eq!(cards[0].key, "discrete/graph");
51        assert!(cards[0].summary.is_ascii());
52    }
53}