scud/formats/mod.rs
1//! Task graph serialization formats
2//!
3//! This module provides parsers and serializers for different
4//! task storage formats.
5
6mod scg;
7
8pub use scg::{natural_sort_ids, parse_scg, serialize_scg};
9
10/// Supported file formats
11#[derive(Debug, Clone, Copy, PartialEq)]
12pub enum Format {
13 /// Legacy JSON format
14 Json,
15 /// SCUD Graph format (.scg)
16 Scg,
17}
18
19impl Format {
20 pub fn from_extension(ext: &str) -> Option<Self> {
21 match ext.to_lowercase().as_str() {
22 "json" => Some(Format::Json),
23 "scg" => Some(Format::Scg),
24 _ => None,
25 }
26 }
27
28 pub fn extension(&self) -> &'static str {
29 match self {
30 Format::Json => "json",
31 Format::Scg => "scg",
32 }
33 }
34}