trazaeo 0.5.4

Open-source provenance SDK and specification for verifiable EO and climate data workflows
Documentation
use crate::utils::TransformRecord;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TransformActionDeclaration {
    pub action_name: String,
    pub implementation_ref: String,
    pub implementation_version: String,
}

pub fn declare_transform_action(
    action_name: &str,
    implementation_ref: &str,
    implementation_version: &str,
) -> TransformActionDeclaration {
    TransformActionDeclaration {
        action_name: action_name.to_string(),
        implementation_ref: implementation_ref.to_string(),
        implementation_version: implementation_version.to_string(),
    }
}

pub fn log_transform(record: &TransformRecord) {
    log::debug!("logged {:?}", record);
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::utils::{DGGSCell, Hash, TransformRecord};

    #[test]
    fn declare_transform_action_records_external_implementation() {
        let action =
            declare_transform_action("nc_to_zarr", "container://pipeline/nc2zarr", "v1.2.0");
        assert_eq!(action.action_name, "nc_to_zarr");
        assert_eq!(action.implementation_ref, "container://pipeline/nc2zarr");
        assert_eq!(action.implementation_version, "v1.2.0");
    }

    #[test]
    fn log_transform_does_not_panic() {
        let record = TransformRecord {
            step: "decode".to_string(),
            params: serde_json::json!({"mode": "test"}),
            in_hash: Hash([1u8; 32]),
            out_hash: Hash([2u8; 32]),
            cell: DGGSCell { id: 42 },
        };
        log_transform(&record);
    }
}