Skip to main content

koprogo_api/application/ports/
lien_notaire_repository.rs

1//! Port for persisting and looking up [`LienNotaire`] entities.
2//!
3//! #845 / ADR 0051. All methods return `Result<_, AppError>` natively — no
4//! `Result<_, String>` debt to migrate (CRITICAL.md #4).
5
6use crate::application::error::AppError;
7use crate::domain::entities::LienNotaire;
8use async_trait::async_trait;
9use uuid::Uuid;
10
11#[async_trait]
12pub trait LienNotaireRepository: Send + Sync {
13    /// Persist a freshly issued link.
14    async fn save(&self, lien: &LienNotaire) -> Result<(), AppError>;
15
16    /// Look up a link by its `token_hash` (already hashed by the caller).
17    /// Returns `Ok(None)` if no record matches.
18    async fn find_by_token_hash(&self, token_hash: &str) -> Result<Option<LienNotaire>, AppError>;
19
20    /// The most recently issued, non-revoked link for a given état daté —
21    /// what `renew`/`revoke` act on. May be expired: expiration is not
22    /// terminal, only revocation is (ADR 0051 — le renouvellement reste
23    /// possible après l'échéance).
24    async fn find_active_by_etat_date_id(
25        &self,
26        etat_date_id: Uuid,
27    ) -> Result<Option<LienNotaire>, AppError>;
28
29    /// Persist a mutated link (renewal or revocation).
30    async fn update(&self, lien: &LienNotaire) -> Result<(), AppError>;
31}