ggen-graph 26.6.11

Deterministic graph module for ggen
Documentation
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// Represents a PROV-JSON document structure containing entities, activities, agents, and their relations.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
pub struct ProvDocument {
    /// The list of entities defined in the PROV document.
    pub entities: Vec<ProvEntity>,
    /// The list of activities defined in the PROV document.
    pub activities: Vec<ProvActivity>,
    /// The list of agents defined in the PROV document.
    pub agents: Vec<ProvAgent>,
    /// The list of generations representing entities generated by activities.
    pub generations: Vec<ProvGeneration>,
    /// The list of usages representing entities used by activities.
    pub usages: Vec<ProvUsage>,
    /// The list of derivations representing entities derived from other entities.
    pub derivations: Vec<ProvDerivation>,
}

impl ProvDocument {
    /// Creates a new empty `ProvDocument`.
    pub fn new() -> Self {
        Self::default()
    }
}

/// Represents a PROV Entity.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ProvEntity {
    /// The unique identifier of the entity.
    pub id: String,
    /// Attributes associated with the entity.
    pub attributes: HashMap<String, String>,
}

/// Represents a PROV Activity.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ProvActivity {
    /// The unique identifier of the activity.
    pub id: String,
    /// The optional start time of the activity.
    pub start_time: Option<chrono::DateTime<chrono::Utc>>,
    /// The optional end time of the activity.
    pub end_time: Option<chrono::DateTime<chrono::Utc>>,
    /// Attributes associated with the activity.
    pub attributes: HashMap<String, String>,
}

/// Represents a PROV Agent.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ProvAgent {
    /// The unique identifier of the agent.
    pub id: String,
    /// Attributes associated with the agent.
    pub attributes: HashMap<String, String>,
}

/// Represents a PROV Generation relationship (Entity wasGeneratedBy Activity).
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ProvGeneration {
    /// The identifier of the generated entity.
    pub entity: String,
    /// The identifier of the generating activity.
    pub activity: String,
}

/// Represents a PROV Usage relationship (Activity used Entity).
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ProvUsage {
    /// The identifier of the using activity.
    pub activity: String,
    /// The identifier of the used entity.
    pub entity: String,
}

/// Represents a PROV Derivation relationship (Entity wasDerivedFrom Entity).
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ProvDerivation {
    /// The identifier of the derived entity.
    pub generated_entity: String,
    /// The identifier of the entity it was derived from.
    pub used_entity: String,
}