pub trait BaseMoney:
Sized
+ Debug
+ Display
+ Clone
+ PartialOrd
+ PartialEq
+ FromStr {
Show 20 methods
// Required methods
fn currency(&self) -> Currency;
fn amount(&self) -> Decimal;
fn round(self) -> Self;
// Provided methods
fn name(&self) -> &str { ... }
fn symbol(&self) -> &str { ... }
fn code(&self) -> &str { ... }
fn numeric_code(&self) -> i32 { ... }
fn minor_unit(&self) -> u16 { ... }
fn minor_amount(&self) -> MoneyResult<i128> { ... }
fn thousand_separator(&self) -> &'static str { ... }
fn decimal_separator(&self) -> &'static str { ... }
fn is_zero(&self) -> bool { ... }
fn is_positive(&self) -> bool { ... }
fn is_negative(&self) -> bool { ... }
fn format_code(&self) -> String { ... }
fn format_symbol(&self) -> String { ... }
fn format_code_minor(&self) -> MoneyResult<String> { ... }
fn format_symbol_minor(&self) -> MoneyResult<String> { ... }
fn display(&self) -> String { ... }
fn countries(&self) -> Option<Vec<Country>> { ... }
}Expand description
BaseMoney is the base trait for dealing with money type.
Required Methods§
Provided Methods§
Sourcefn numeric_code(&self) -> i32
fn numeric_code(&self) -> i32
Get currency ISO 4217 numeric code
Sourcefn minor_unit(&self) -> u16
fn minor_unit(&self) -> u16
Get money minor unit
Sourcefn minor_amount(&self) -> MoneyResult<i128>
fn minor_amount(&self) -> MoneyResult<i128>
Get money amount in its smallest unit
Sourcefn thousand_separator(&self) -> &'static str
fn thousand_separator(&self) -> &'static str
Get money thousands separator
Sourcefn decimal_separator(&self) -> &'static str
fn decimal_separator(&self) -> &'static str
Get money decimal separator
Sourcefn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Check if sign is +
Sourcefn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Check if sign is -
Sourcefn format_code(&self) -> String
fn format_code(&self) -> String
Format money with code along with thousands and decimal separators. Example: USD 1,234.45
Sourcefn format_symbol(&self) -> String
fn format_symbol(&self) -> String
Format money with symbol along with thousands and decimal separators. Example: $1,234.45
Sourcefn format_code_minor(&self) -> MoneyResult<String>
fn format_code_minor(&self) -> MoneyResult<String>
Format money with code in the smallest unit along with thousands separators.
Example USD 1,234.45 –> USD 123,445 ¢
If the currency has no minor unit symbol, it defaults to “minor”.
You can set the minor unit symbol in Currency type’s setter.
Sourcefn format_symbol_minor(&self) -> MoneyResult<String>
fn format_symbol_minor(&self) -> MoneyResult<String>
Format money with code in the smallest unit along with thousands separators.
Example $1,234.45 –> $123,445 ¢
If the currency has no minor unit symbol, it defaults to “minor”.
You can set the minor unit symbol in Currency type’s setter.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.