Skip to main content

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::{
9    natural_sort_ids, parse_scg, parse_scg_result, serialize_scg, serialize_scg_pipeline,
10    PipelineNodeAttrs, ScgEdgeAttrs, ScgParseResult, ScgPipeline,
11};
12
13/// Supported file formats
14#[derive(Debug, Clone, Copy, PartialEq)]
15pub enum Format {
16    /// Legacy JSON format
17    Json,
18    /// SCUD Graph format (.scg)
19    Scg,
20}
21
22impl Format {
23    pub fn from_extension(ext: &str) -> Option<Self> {
24        match ext.to_lowercase().as_str() {
25            "json" => Some(Format::Json),
26            "scg" => Some(Format::Scg),
27            _ => None,
28        }
29    }
30
31    pub fn extension(&self) -> &'static str {
32        match self {
33            Format::Json => "json",
34            Format::Scg => "scg",
35        }
36    }
37}