use sdivi_snapshot::snapshot::SNAPSHOT_VERSION;
use serde::{Deserialize, Serialize};
const CATALOG_ENTRIES: &[(&str, &str)] = &[
(
"async_patterns",
"Code constructs that implement or leverage asynchronous execution — \
e.g., `.await` expressions on `Future` values and `async fn` definitions.",
),
(
"error_handling",
"Code constructs that propagate, transform, or handle error conditions — \
e.g., the `?` operator (`try_expression`) and `match` arms that dispatch \
on `Result` or `Option` variants.",
),
(
"resource_management",
"Code constructs that allocate, release, or manage system or heap resources — \
e.g., macro invocations such as `drop!`, `vec!`, or standard I/O macros.",
),
(
"state_management",
"Code constructs that capture, transform, or share mutable or shared state — \
e.g., closures that close over mutable bindings or shared references.",
),
(
"type_assertions",
"Code constructs that assert or coerce between types at compile or runtime — \
e.g., `as` casts (`as_expression`) and language-specific type-cast expressions.",
),
];
pub const CATEGORIES: &[&str] = &[
CATALOG_ENTRIES[0].0,
CATALOG_ENTRIES[1].0,
CATALOG_ENTRIES[2].0,
CATALOG_ENTRIES[3].0,
CATALOG_ENTRIES[4].0,
];
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CategoryInfo {
pub name: String,
pub description: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CategoryCatalog {
pub schema_version: String,
pub categories: Vec<CategoryInfo>,
}
pub fn list_categories() -> CategoryCatalog {
CategoryCatalog {
schema_version: SNAPSHOT_VERSION.to_string(),
categories: CATALOG_ENTRIES
.iter()
.map(|(name, desc)| CategoryInfo {
name: name.to_string(),
description: desc.to_string(),
})
.collect(),
}
}