pub struct Id<K: IdKind> { /* private fields */ }Expand description
How a provider names one thing of kind K.
Opaque on purpose: Stripe issues pi_…, iyzico a 64-bit integer, PayTR
nothing at all, and nothing outside the adapter should read any of them.
Display writes the text alone, because that is what goes
into a request.
Two facts travel with the text. K is what the identifier names, and it is
checked by the compiler: a PaymentId cannot be passed where the token of
a hosted checkout form is wanted, however alike the two strings look.
Id::source is whose uniqueness it rests on — the provider’s, or
kasapay’s own composition of fields the caller sent.
use kasapay_core::{Id, IdKind, PaymentId};
struct Session;
impl IdKind for Session {
const NAMES: &'static str = "session";
}
fn refund(payment: &PaymentId) {
println!("{payment}");
}
// A session is not a payment, and this does not compile.
refund(&Id::<Session>::issued("tok-1"));Implementations§
Source§impl<K: IdKind> Id<K>
impl<K: IdKind> Id<K>
Sourcepub fn derived(
value: impl Into<Box<str>>,
from: &'static [&'static str],
) -> Self
pub fn derived( value: impl Into<Box<str>>, from: &'static [&'static str], ) -> Self
Wraps an identifier kasapay composed, naming the fields it came from.
For a provider that issues none of its own: PayTR names a payment by
the merchant_oid the merchant chose and sent. from is what the
value’s uniqueness actually rests on, and a caller reads it back
through Id::source.