pub struct SpendLedger { /* private fields */ }Implementations§
Source§impl SpendLedger
impl SpendLedger
pub fn new(data_dir: &str, exchange_rate: Option<ExchangeRateConfig>) -> Self
pub fn new_postgres( pool: PgPool, exchange_rate: Option<ExchangeRateConfig>, ) -> Self
Sourcepub fn take_fx_stale_warning(&self) -> bool
pub fn take_fx_stale_warning(&self) -> bool
Returns true (once) if a stale FX quote was used since last check.
Sourcepub async fn add_limit(
&self,
limit: &mut SpendLimit,
) -> Result<String, PayError>
pub async fn add_limit( &self, limit: &mut SpendLimit, ) -> Result<String, PayError>
Add a single spend limit rule. Generates and assigns a rule_id, returns it.
Sourcepub async fn remove_limit(&self, _rule_id: &str) -> Result<(), PayError>
pub async fn remove_limit(&self, _rule_id: &str) -> Result<(), PayError>
Remove a spend limit rule by its rule_id.
Sourcepub async fn set_limits(&self, limits: &[SpendLimit]) -> Result<(), PayError>
pub async fn set_limits(&self, limits: &[SpendLimit]) -> Result<(), PayError>
Replace all spend limits (used by config patch / pipe mode).
Sourcepub async fn get_status(&self) -> Result<Vec<SpendLimitStatus>, PayError>
pub async fn get_status(&self) -> Result<Vec<SpendLimitStatus>, PayError>
Compute current status for all limits.
Sourcepub async fn reserve(
&self,
op_id: &str,
ctx: &SpendContext,
) -> Result<u64, PayError>
pub async fn reserve( &self, op_id: &str, ctx: &SpendContext, ) -> Result<u64, PayError>
Reserve spend against all matching limits, returns reservation id.
pub async fn confirm(&self, _reservation_id: u64) -> Result<(), PayError>
pub async fn cancel(&self, _reservation_id: u64) -> Result<(), PayError>
Auto Trait Implementations§
impl !Freeze for SpendLedger
impl !RefUnwindSafe for SpendLedger
impl Send for SpendLedger
impl Sync for SpendLedger
impl Unpin for SpendLedger
impl UnsafeUnpin for SpendLedger
impl !UnwindSafe for SpendLedger
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request