Skip to main content

HostChargeTargetStore

Trait HostChargeTargetStore 

Source
pub trait HostChargeTargetStore: Send + Sync {
    // Required methods
    fn preflight_target<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        connection: &'life1 mut PgConnection,
        reservation: &'life2 HostChargeTargetReservation,
    ) -> Pin<Box<dyn Future<Output = Result<HostChargeReservationDecision, HostChargeTargetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn reserve_target<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        connection: &'life1 mut PgConnection,
        reservation: &'life2 HostChargeTargetReservation,
    ) -> Pin<Box<dyn Future<Output = Result<HostChargeReservationDecision, HostChargeTargetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn ensure_submission_admitted<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        connection: &'life1 mut PgConnection,
        admission: &'life2 HostChargeSubmissionAdmission,
    ) -> Pin<Box<dyn Future<Output = Result<HostChargeSubmissionDecision, HostChargeTargetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn apply_transition<'life0, 'life1, 'async_trait>(
        &'life0 self,
        connection: &'life1 mut PgConnection,
        transition: HostChargeTargetTransition,
    ) -> Pin<Box<dyn Future<Output = Result<HostChargeTargetTransitionOutcome, HostChargeTargetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Host-owned target extension composed into shared ledger transactions.

Implementations must use only the supplied connection. Reservation and submission lock the target before calling host_charge_ledger_admission.

Required Methods§

Source

fn preflight_target<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, connection: &'life1 mut PgConnection, reservation: &'life2 HostChargeTargetReservation, ) -> Pin<Box<dyn Future<Output = Result<HostChargeReservationDecision, HostChargeTargetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Locks and snapshots the target for replay/conflict preflight without changing host business state.

A same-mode prepared replay invokes this callback again so its current economics can be compared with the durable attempt. Terminal replay and a prepared replay owned by another deployment mode skip it. When the target is already claimed by the same idempotency key, return HostChargeReservationDecision::IdempotentContender with its current snapshot; the ledger still validates that snapshot.

Source

fn reserve_target<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, connection: &'life1 mut PgConnection, reservation: &'life2 HostChargeTargetReservation, ) -> Pin<Box<dyn Future<Output = Result<HostChargeReservationDecision, HostChargeTargetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn ensure_submission_admitted<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, connection: &'life1 mut PgConnection, admission: &'life2 HostChargeSubmissionAdmission, ) -> Pin<Box<dyn Future<Output = Result<HostChargeSubmissionDecision, HostChargeTargetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Revalidates the target immediately before provider submission.

This callback must be repeat-safe for the same attempt. A transient control-plane failure can prove that the provider mutation was not contacted, restore the canonical attempt to prepared state, and invoke admission again on a same-key retry. Implementations should return the same admitted snapshot while the target and expected charge are unchanged and produce no additional observable side effect: do not increment counters or append duplicate audit rows. One-shot paid/failed business transitions belong in Self::apply_transition.

Source

fn apply_transition<'life0, 'life1, 'async_trait>( &'life0 self, connection: &'life1 mut PgConnection, transition: HostChargeTargetTransition, ) -> Pin<Box<dyn Future<Output = Result<HostChargeTargetTransitionOutcome, HostChargeTargetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Applies one repeat-safe business transition keyed by its attempt.

Return HostChargeTargetTransitionOutcome::ExactReplay when the same transition was already applied. In particular, syrup_rail::HostChargeTargetTransitionKind::ReleasedBeforeSubmission releases a claimed target after a determinate pre-submission failure and must not be interpreted as a card decline.

Application and reconciliation transactions ordinarily commit only when this callback returns Applied or ExactReplay. One canonical replay exception preserves the target-before-attempt lock order: if a Paid callback returns StaleTarget or Unchanged and the subsequently locked attempt is already approved, Syrup Rail returns that approved attempt. This permits a later reversal to remain monotonic; implementations must never move a reversed target back to paid. Other persistent refusals intentionally leave the canonical attempt unresolved and require the host to repair or explicitly reconcile its target state before retrying cleanup.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§