Expand description
Exact ISO 4217 money with compile-time currency identity.
Money<USD> and Money<IDR> are different types, so
cross-currency arithmetic is a compile error. Addition and subtraction are
exact. Division returns a Division and requires a named residue decision
before releasing its quotient.
§Start here
use kamu_money_core::{Money, iso::USD};
let whole = Money::<USD>::try_from_major(10)?;
let parts = whole.allocate(&[1, 1, 1])?;
assert_eq!(Money::<USD>::try_sum(parts)?, whole);The crate root holds the common path. Browse deeper only when needed:
localeandtextown display and canonical text;errorsgroups narrow operation errors;advancedexposes raw-unit kernels, domain constants, residue internals, and stable hashing;- feature-gated
wireandadaptersexpose boundary integrations.
§What this crate is not
It represents amounts. It does not model tax, accounting rules, or FX policy, and exactness
does not stand in for any of them: an amount this crate can hold and carry without error is
still only as right as the decision that produced it. Each type states its own guarantees
beside the things it deliberately does not guarantee — start with Money and Rate.
Re-exports§
pub use errors::MoneyError;pub use iso::Iso4217;
Modules§
- adapters
- Optional database integrations.
- advanced
- Raw-unit and persistence surfaces for specialist integrations.
- errors
- Narrow errors, grouped by the operation that can return them.
- iso
- ISO 4217 currency identity. One register, three consumers.
- locale
- Locale-aware display: symbol, grouping, and a minimum fraction width.
- text
- The canonical text form:
"<ISO> <amount>", one trim rule, one parser. - wire
serde - Serde wire formats.
Macros§
Structs§
- Division
- A quotient and residue that must be resolved together.
- Money
- A monetary quantity:
unitscounts10^-18of a currency unit. - Rate
- A directed FX rate: how many
Quoteunits oneBaseunit buys. - Residue
- Canonical units moved by a rounding operation.
- Split
Parts - The lazy half of
Money::split, returned byMoney::split.
Enums§
- Rounding
- How to resolve a division that does not divide evenly.
Traits§
- Static
Currency - A currency, known at compile time. Implemented by the generated ISO register, never by hand — and enforced, not requested: the crate-private sealing supertrait is unnameable downstream.