tree-type 0.4.5

Rust macros for creating type-safe filesystem tree structures
Documentation
#![allow(deprecated)]
#[cfg(feature = "serde")]
use tree_type::tree_type;

#[cfg(feature = "serde")]
tree_type! {
    TestRoot {
        config("config.toml"),
        data/ {
            file("data.txt")
        }
    }
}

#[cfg(feature = "serde")]
#[test]
fn test_serde_serialize_deserialize() {
    let root = TestRoot::new("/tmp/test").unwrap();

    // Serialize to JSON
    let json = serde_json::to_string(&root).expect("Failed to serialize");

    // Deserialize from JSON
    let deserialized: TestRoot = serde_json::from_str(&json).expect("Failed to deserialize");

    // Verify paths match
    assert_eq!(root.as_path(), deserialized.as_path());
}

#[cfg(feature = "serde")]
#[test]
fn test_serde_child_types() {
    let root = TestRoot::new("/tmp/test").unwrap();
    let config = root.config();
    let data = root.data();

    // Test file type serialization
    let config_json = serde_json::to_string(&config).expect("Failed to serialize file");
    let config_de: TestRootConfig =
        serde_json::from_str(&config_json).expect("Failed to deserialize file");
    assert_eq!(config.as_path(), config_de.as_path());

    // Test dir type serialization
    let data_json = serde_json::to_string(&data).expect("Failed to serialize dir");
    let data_de: TestRootData =
        serde_json::from_str(&data_json).expect("Failed to deserialize dir");
    assert_eq!(data.as_path(), data_de.as_path());
}