road-runner-common 0.31.0

Shared Rust utilities for exchange ecosystem backend services.
Documentation
//! Read port for cex-policy governance records.
//!
//! Application code (a [`crate::governance::GovernanceHandler`], a ruleset
//! apply service) depends on this trait, not on the gRPC client, so it can be
//! tested against an in-memory fake that fails the way cex-policy does.
//! [`crate::governance::PolicyGovernanceClient`] is the production adapter.

use async_trait::async_trait;

use super::client::{GovernanceProposal, GovernanceRootAction};
use super::error::PolicyFetchError;

/// Read side of cex-policy's internal API used by governance consumers.
///
/// Both methods share one contract: `Ok(None)` only when cex-policy answered
/// `NOT_FOUND`; any failure to get an answer is `Err` and must hold the event
/// that triggered the read (see [`PolicyFetchError`]).
#[async_trait]
pub trait GovernanceRecordSource: Send + Sync {
    /// Fetch a proposal (payload included) by id.
    async fn fetch_proposal(
        &self,
        proposal_id: &str,
    ) -> Result<Option<GovernanceProposal>, PolicyFetchError>;

    /// Fetch an applied root action (payload included, unverified) by id.
    async fn fetch_root_action(
        &self,
        action_id: &str,
    ) -> Result<Option<GovernanceRootAction>, PolicyFetchError>;
}