[][src]Struct interledger_service_util::ExchangeRateService

pub struct ExchangeRateService<S, O, A> { /* fields omitted */ }

Exchange Rates Service

Responsible for getting the exchange rates for the two assets in the outgoing request (request.from.asset_code, request.to.asset_code). Requires a ExchangeRateStore

Methods

impl<S, O, A> ExchangeRateService<S, O, A> where
    S: AddressStore + ExchangeRateStore,
    O: OutgoingService<A>,
    A: Account
[src]

pub fn new(spread: f64, store: S, next: O) -> Self[src]

Trait Implementations

impl<S: Clone, O: Clone, A: Clone> Clone for ExchangeRateService<S, O, A>[src]

impl<S, O, A> OutgoingService<A> for ExchangeRateService<S, O, A> where
    S: AddressStore + ExchangeRateStore + Clone + Send + Sync + 'static,
    O: OutgoingService<A> + Send + Clone + 'static,
    A: Account + Sync + 'static, 
[src]

type Future = BoxedIlpFuture

fn send_request(
    &mut self,
    request: OutgoingRequest<A>
) -> Box<dyn Future<Item = Fulfill, Error = Reject> + Send>
[src]

On send request:

  1. If the prepare packet's amount is 0, it just forwards
  2. Retrieves the exchange rate from the store (the store independently is responsible for polling the rates)
    • return reject if the call to the store fails
  3. Calculates the exchange rate AND scales it up/down depending on how many decimals each asset requires
  4. Updates the amount in the prepare packet and forwards it

Auto Trait Implementations

impl<S, O, A> Send for ExchangeRateService<S, O, A> where
    A: Send,
    O: Send,
    S: Send

impl<S, O, A> Sync for ExchangeRateService<S, O, A> where
    A: Sync,
    O: Sync,
    S: Sync

impl<S, O, A> Unpin for ExchangeRateService<S, O, A> where
    A: Unpin,
    O: Unpin,
    S: Unpin

impl<S, O, A> UnwindSafe for ExchangeRateService<S, O, A> where
    A: UnwindSafe,
    O: UnwindSafe,
    S: UnwindSafe

impl<S, O, A> RefUnwindSafe for ExchangeRateService<S, O, A> where
    A: RefUnwindSafe,
    O: RefUnwindSafe,
    S: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err