███████╗ █████╗ ██╗ ██╗ █████╗ ████████╗
╚══███╔╝██╔══██╗██║ ██╔╝██╔══██╗╚══██╔══╝
███╔╝ ███████║█████╔╝ ███████║ ██║
███╔╝ ██╔══██║██╔═██╗ ██╔══██║ ██║
███████╗██║ ██║██║ ██╗██║ ██║ ██║
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
Zakat
Rust library for Islamic Zakat calculation. Uses rust_decimal for precision.
Features
- Gold, Silver, Business, Agriculture, Livestock, Mining & Rikaz
- Stocks, Mutual Funds, Crypto (as liquid assets)
- Professional Income (Gross/Net)
- Zakat Fitrah
- Configurable Nisab thresholds
- Portfolio aggregation
- Asset Labeling (e.g., "Main Store", "Crypto Wallet")
- Input Sanitization (Rejects negative values)
- Flexible Configuration (Env Vars, JSON, Fluent Builder)
- Fiqh Compliance (Jewelry exemptions, Madhab-specific rules)
- Detailed Reporting (Livestock in-kind details, metadata support)
Install
[]
= "0.3.0"
= "1.39"
= { = "1.0", = ["derive"] }
= "1.0"
Usage
Business Zakat
Note: You can pass standard Rust types (
i32,f64,&str) directly to all constructors. There is no need to manually convert toDecimalor use thedec!()macro anymore.
use ;
use ;
Portfolio
use ;
use PreciousMetals;
use ;
use ;
use dec;
Configuration
use ;
// Load from Environment Variables (ZAKAT_GOLD_PRICE, etc.)
let config = from_env?;
// Or load from JSON
let config = try_from_json?;
// Or using Value Builder
let config = builder
.gold_price
.silver_price
.madhab
.build?;
Advanced Assets (Jewelry & Livestock)
use ;
use ;
// Personal Jewelry (Exempt in Shafi/Maliki, Payable in Hanafi)
let necklace = new?
.with_usage
.with_label;
// Livestock Reporting
let prices = builder
.sheep_price
.cow_price
.camel_price
.build?;
let camels = new;
let result = camels.calculate_zakat?;
if result.is_payable
Custom Nisab
use ZakatConfig;
let config = new?
.with_gold_nisab
.with_agriculture_nisab;
Modules
| Module | Nisab |
|---|---|
maal::precious_metals |
85g Gold / 595g Silver |
maal::business |
85g Gold |
maal::income |
85g Gold |
maal::investments |
85g Gold |
maal::agriculture |
653 kg |
maal::livestock |
Count-based |
maal::mining |
Rikaz: None / Mines: 85g Gold |
fitrah |
N/A |
Contributing
- Add tests
- Use
rust_decimal - Run
cargo test
Support
"Those who spend their wealth in the cause of Allah..." — Al-Baqarah 2:262
License
MIT