dpcs 0.6.0

Reference implementation of the Data Pipeline Contract Standard (DPCS)
Documentation
//! Contract reference model.

use serde::{Deserialize, Serialize};

use super::ExtensionMap;

/// Reference to an external contract artifact.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ContractReference {
    /// Stable reference identifier.
    pub id: String,
    /// Contract type (for example `odcs` or `dtcs`).
    #[serde(rename = "type")]
    pub reference_type: String,
    /// Location of the referenced contract.
    pub location: String,
    /// Optional version constraint.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub version: Option<String>,
    /// Extension fields.
    #[serde(default, flatten)]
    pub extensions: ExtensionMap,
}

impl ContractReference {
    /// Returns whether this reference has the given stable identifier.
    pub fn matches_id(&self, id: &str) -> bool {
        self.id == id
    }
}