1pub mod json;
2pub mod text;
3
4pub use json::{emit_json_error, emit_json_result, emit_json_results, emit_json_results_with_meta};
5
6pub fn format_item_id(item_id: i64) -> String {
7 format!("itm_{item_id:08}")
8}
9
10pub fn parse_item_id(raw: &str) -> Option<i64> {
11 let trimmed = raw.trim();
12 if trimmed.is_empty() {
13 return None;
14 }
15
16 if let Some(suffix) = trimmed.strip_prefix("itm_") {
17 let parsed = suffix.parse::<i64>().ok()?;
18 return (parsed > 0).then_some(parsed);
19 }
20
21 let parsed = trimmed.parse::<i64>().ok()?;
22 (parsed > 0).then_some(parsed)
23}