dpp-domain 0.22.0

EU Digital Product Passport domain types, port traits, and per-field disclosure policy
Documentation
//! [`GhostRegistrySync`] — a no-op registry sync for development.

use async_trait::async_trait;
use uuid::Uuid;

use crate::error::dpp::DppError;
use crate::ports::registry_sync::{
    RegistrationRequest, RegistryRecord, RegistrySyncPort, SubmissionAcknowledgement,
    SubmissionReport,
};

/// No-op implementation for use before a deployment is enrolled with the EU
/// Central Registry.
///
/// Accepts every submission under a placeholder correlation identifier and
/// knows of no submission or record afterwards: nothing was sent, so there is
/// nothing to report on, and answering `Processing` would keep a caller polling
/// a registry that does not exist.
pub struct GhostRegistrySync;

#[async_trait]
impl RegistrySyncPort for GhostRegistrySync {
    async fn register(
        &self,
        _request: RegistrationRequest,
    ) -> Result<SubmissionAcknowledgement, DppError> {
        Ok(SubmissionAcknowledgement::Accepted {
            correlation_id: format!("GHOST-CORR-{}", Uuid::now_v7()),
        })
    }

    async fn check_submission(&self, correlation_id: &str) -> Result<SubmissionReport, DppError> {
        Err(DppError::NotFound(format!(
            "ghost registry has no submission {correlation_id}"
        )))
    }

    async fn check_status(&self, registration_id: &str) -> Result<RegistryRecord, DppError> {
        Err(DppError::NotFound(format!(
            "ghost registry has no record {registration_id}"
        )))
    }

    async fn notify_transfer(
        &self,
        record: &crate::transfer::TransferRecord,
        _registration_id: &str,
    ) -> Result<RegistryRecord, DppError> {
        Err(DppError::NotFound(format!(
            "ghost registry has no record for {}",
            record.passport_id
        )))
    }
}