| Crates.io | zakat-providers |
| lib.rs | zakat-providers |
| version | 1.4.0 |
| created_at | 2026-01-03 04:16:44.986306+00 |
| updated_at | 2026-01-05 15:00:45.283214+00 |
| description | Live price fetching providers for Zakat calculations (Binance, etc.). |
| homepage | |
| repository | https://github.com/IRedDragonICY/zakatrs |
| max_upload_size | |
| id | 2019589 |
| size | 125,503 |
Live price fetching providers for Zakat calculations.
zakat-providers enables real-time metal pricing for accurate Nisab calculations:
| Platform | HTTP Client |
|---|---|
| Native (Linux, macOS, Windows) | reqwest |
| WebAssembly | gloo-net |
use zakat_providers::{PriceProvider, BinancePriceProvider, CachedPriceProvider};
// Create provider with 5-minute cache
let provider = CachedPriceProvider::new(
BinancePriceProvider::default(),
300, // TTL in seconds
);
// Fetch current prices
let prices = provider.get_prices().await?;
println!("Gold: ${}/gram", prices.gold_per_gram);
println!("Silver: ${}/gram", prices.silver_per_gram);
For testing or offline use:
use zakat_providers::{StaticPriceProvider, PriceProvider};
let provider = StaticPriceProvider::new(65.0, 0.80)?;
let prices = provider.get_prices().await?;
Implement the PriceProvider trait:
use zakat_providers::{PriceProvider, Prices};
use async_trait::async_trait;
struct MyProvider;
#[async_trait]
impl PriceProvider for MyProvider {
async fn get_prices(&self) -> Result<Prices, ZakatError> {
// Fetch from your data source
Ok(Prices::new(65.0, 0.80)?)
}
}
| Feature | Description |
|---|---|
live-pricing |
Enable live API calls (default) |
use zakat_providers::{NetworkConfig, BinancePriceProvider};
let config = NetworkConfig {
timeout_seconds: 30,
..Default::default()
};
let provider = BinancePriceProvider::new(&config);
MIT