CurrencyPlugin

Trait CurrencyPlugin 

Source
pub trait CurrencyPlugin: Send + Sync {
    // Required methods
    fn code(&self) -> &str;
    fn symbol(&self) -> &str;
    fn name(&self) -> &str;
    fn decimals(&self) -> u8;
    fn meta(&self) -> &PluginMeta;
    fn rate(&self) -> Option<(f64, String)>;
}
Expand description

Trait for currency plugins that provide exchange rates.

Required Methods§

Source

fn code(&self) -> &str

Currency code (e.g., “BTC”, “ETH”).

Source

fn symbol(&self) -> &str

Currency symbol (e.g., “₿”, “Ξ”).

Source

fn name(&self) -> &str

Currency name (e.g., “Bitcoin”, “Ethereum”).

Source

fn decimals(&self) -> u8

Number of decimal places.

Source

fn meta(&self) -> &PluginMeta

Plugin metadata.

Source

fn rate(&self) -> Option<(f64, String)>

Get current exchange rate.

Returns (rate, base_currency) where rate is how much 1 unit of this currency is worth in the base currency.

For example, for BTC returning (42000.0, "USD") means 1 BTC = 42000 USD.

Returns None if rate is unavailable.

Implementors§