pub struct ProtocolCorrelator { /* private fields */ }payments only.Expand description
Cross-protocol correlator that routes ACP and AP2 adapters through the same canonical transaction ID and journal model.
The correlator enforces three rules:
- Both protocols share one canonical
TransactionIdper transaction. - Protocol-specific identifiers are correlated in
ProtocolRefswithout assuming they are interchangeable. - Direct protocol-to-protocol conversion is refused when it would lose semantics or accountability evidence.
Implementations§
Source§impl ProtocolCorrelator
impl ProtocolCorrelator
Sourcepub fn new(transaction_store: Arc<dyn TransactionStore>) -> ProtocolCorrelator
pub fn new(transaction_store: Arc<dyn TransactionStore>) -> ProtocolCorrelator
Creates a new correlator backed by the canonical transaction store.
Sourcepub async fn get_transaction(
&self,
lookup: TransactionLookup,
) -> Result<Option<TransactionRecord>, AdkError>
pub async fn get_transaction( &self, lookup: TransactionLookup, ) -> Result<Option<TransactionRecord>, AdkError>
Looks up a canonical transaction by its internal ID.
Sourcepub async fn find_by_acp_checkout_session_id(
&self,
session_identity: Option<AdkIdentity>,
acp_checkout_session_id: &str,
) -> Result<Option<TransactionRecord>, AdkError>
pub async fn find_by_acp_checkout_session_id( &self, session_identity: Option<AdkIdentity>, acp_checkout_session_id: &str, ) -> Result<Option<TransactionRecord>, AdkError>
Looks up a canonical transaction by an ACP checkout session ID.
Scans unresolved transactions for a matching protocol_refs.acp_checkout_session_id.
For production use, a dedicated index would be more efficient.
Sourcepub async fn find_by_ap2_mandate_id(
&self,
session_identity: Option<AdkIdentity>,
mandate_id: &str,
) -> Result<Option<TransactionRecord>, AdkError>
pub async fn find_by_ap2_mandate_id( &self, session_identity: Option<AdkIdentity>, mandate_id: &str, ) -> Result<Option<TransactionRecord>, AdkError>
Looks up a canonical transaction by an AP2 mandate ID (intent, cart, or payment).
Sourcepub fn attach_protocol_ref(
record: &mut TransactionRecord,
kind: ProtocolRefKind,
value: String,
) -> Result<(), PaymentsKernelError>
pub fn attach_protocol_ref( record: &mut TransactionRecord, kind: ProtocolRefKind, value: String, ) -> Result<(), PaymentsKernelError>
Attaches a protocol-specific reference to an existing transaction record.
This is the canonical way to correlate ACP and AP2 identifiers under one transaction. The correlator never overwrites an existing reference slot with a different value.
§Errors
Returns an error if the slot is already occupied by a different value.
Returns all protocol identifiers correlated to one canonical transaction.
Sourcepub fn contributing_protocols(record: &TransactionRecord) -> Vec<String>
pub fn contributing_protocols(record: &TransactionRecord) -> Vec<String>
Returns the set of protocol names that have contributed evidence to this transaction.
Sourcepub fn is_dual_protocol(record: &TransactionRecord) -> bool
pub fn is_dual_protocol(record: &TransactionRecord) -> bool
Returns true when both ACP and AP2 have contributed to this transaction.
Source§impl ProtocolCorrelator
Best-effort canonical projections where ACP or AP2 data can be mapped
safely without semantic loss.
impl ProtocolCorrelator
Best-effort canonical projections where ACP or AP2 data can be mapped safely without semantic loss.
These projections are intentionally one-directional: protocol data is projected into canonical kernel types. The kernel never projects canonical data back into a different protocol’s wire format because that would fabricate provenance.
Sourcepub fn project_acp_cart_to_canonical(
record: &TransactionRecord,
) -> ProjectionResult<Cart>
pub fn project_acp_cart_to_canonical( record: &TransactionRecord, ) -> ProjectionResult<Cart>
Projects an ACP cart (line items + totals) into the canonical cart model.
This projection is safe because ACP line items, totals, and currency map
directly to canonical Cart fields without losing structure.
Sourcepub fn project_ap2_cart_to_canonical(
record: &TransactionRecord,
) -> ProjectionResult<Cart>
pub fn project_ap2_cart_to_canonical( record: &TransactionRecord, ) -> ProjectionResult<Cart>
Projects an AP2 cart mandate’s payment details into the canonical cart model.
This projection is safe because AP2 PaymentRequest.details.displayItems
and total map to canonical CartLine and Cart.total without losing
the item-level structure.
Sourcepub fn project_order_to_canonical(
record: &TransactionRecord,
) -> ProjectionResult<OrderSnapshot>
pub fn project_order_to_canonical( record: &TransactionRecord, ) -> ProjectionResult<OrderSnapshot>
Projects ACP or AP2 order updates into the canonical order snapshot.
Both protocols produce order state that maps to the canonical
OrderSnapshot without semantic loss.
Sourcepub fn project_settlement_state(
record: &TransactionRecord,
) -> ProjectionResult<TransactionState>
pub fn project_settlement_state( record: &TransactionRecord, ) -> ProjectionResult<TransactionState>
Projects the canonical transaction state into a protocol-neutral settlement summary.
Both ACP order updates and AP2 payment receipts can update canonical settlement state, so this projection is safe in both directions.
Sourcepub fn project_fulfillment_to_canonical(
record: &TransactionRecord,
) -> ProjectionResult<FulfillmentSelection>
pub fn project_fulfillment_to_canonical( record: &TransactionRecord, ) -> ProjectionResult<FulfillmentSelection>
Projects the canonical fulfillment selection.
Both ACP fulfillment options and AP2 shipping options map to the
canonical FulfillmentSelection without semantic loss.
Sourcepub fn project_payment_method(
record: &TransactionRecord,
) -> ProjectionResult<PaymentMethodSelection>
pub fn project_payment_method( record: &TransactionRecord, ) -> ProjectionResult<PaymentMethodSelection>
Projects the canonical payment method selection.
Both ACP payment handlers and AP2 payment response method names map to
the canonical PaymentMethodSelection without semantic loss.
Source§impl ProtocolCorrelator
Guards against unsafe direct protocol-to-protocol conversions.
impl ProtocolCorrelator
Guards against unsafe direct protocol-to-protocol conversions.
The kernel mediates all cross-protocol operations. These guards return explicit errors when a direct ACP-to-AP2 or AP2-to-ACP conversion would lose semantics or accountability evidence.
Refuses direct conversion of an ACP delegated payment token to an AP2 user authorization credential.
ACP delegated payment tokens are scoped PSP credentials with merchant and amount constraints. AP2 user authorization artifacts are cryptographic proofs of user consent. Converting one to the other would fabricate provenance.
Refuses direct conversion of an AP2 signed user authorization to an ACP delegated payment token.
AP2 user authorization presentations prove user consent through cryptographic signatures. ACP delegated payment tokens are PSP-issued scoped credentials. Converting one to the other would lose the cryptographic accountability chain.
Sourcepub fn refuse_acp_session_to_ap2_mandate(
field: &str,
) -> Result<(), PaymentsKernelError>
pub fn refuse_acp_session_to_ap2_mandate( field: &str, ) -> Result<(), PaymentsKernelError>
Refuses direct conversion of ACP checkout session state to AP2 mandate state.
ACP checkout sessions are merchant-facing HTTP resources with server-managed lifecycle. AP2 mandates are signed authorization artifacts with explicit role separation. The state models are not equivalent.
Sourcepub fn refuse_ap2_mandate_to_acp_session(
field: &str,
) -> Result<(), PaymentsKernelError>
pub fn refuse_ap2_mandate_to_acp_session( field: &str, ) -> Result<(), PaymentsKernelError>
Refuses direct conversion of AP2 mandate state to ACP checkout session state.
AP2 mandates carry cryptographic authorization chains and role-separated provenance. ACP checkout sessions are server-managed merchant resources. Direct conversion would discard the mandate’s authorization evidence.
Sourcepub fn require_kernel_mediation(
record: &TransactionRecord,
source: ProtocolOrigin,
target: ProtocolOrigin,
operation: &str,
) -> Result<(), PaymentsKernelError>
pub fn require_kernel_mediation( record: &TransactionRecord, source: ProtocolOrigin, target: ProtocolOrigin, operation: &str, ) -> Result<(), PaymentsKernelError>
Validates that a cross-protocol operation goes through the kernel rather than attempting direct protocol-to-protocol transcoding.
Returns Ok(()) when the operation is kernel-mediated (both sides use
the canonical transaction). Returns an error when the caller attempts
to bypass the kernel.
Auto Trait Implementations§
impl !RefUnwindSafe for ProtocolCorrelator
impl !UnwindSafe for ProtocolCorrelator
impl Freeze for ProtocolCorrelator
impl Send for ProtocolCorrelator
impl Sync for ProtocolCorrelator
impl Unpin for ProtocolCorrelator
impl UnsafeUnpin for ProtocolCorrelator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.