pub trait Formatter: Send + Sync {
// Required methods
fn locale(&self) -> String;
fn number(&self, value: f64, options: NumberOptions) -> String;
fn currency(&self, value: f64, code: &str, options: NumberOptions) -> String;
fn percent(&self, value: f64, decimals: Option<u32>) -> String;
fn date(&self, value: DateValue, options: &DateOptions) -> String;
fn relative_time(&self, value: i64, unit: RelativeUnit) -> String;
fn plural(&self, value: f64) -> PluralCategory;
// Provided method
fn bytes(&self, value: f64, unit: ByteUnit) -> String { ... }
}Expand description
What a host supplies per surface (in SurfaceSettings.locale and its
own time zone). The core parses date values and picks the relative unit;
the formatter localizes. EnglishFormatter is the default.
Required Methods§
fn number(&self, value: f64, options: NumberOptions) -> String
Sourcefn currency(&self, value: f64, code: &str, options: NumberOptions) -> String
fn currency(&self, value: f64, code: &str, options: NumberOptions) -> String
code = an upper-case ISO 4217 code.
fn date(&self, value: DateValue, options: &DateOptions) -> String
Sourcefn relative_time(&self, value: i64, unit: RelativeUnit) -> String
fn relative_time(&self, value: i64, unit: RelativeUnit) -> String
value units relative to now (negative = past), truncated by the core.
fn plural(&self, value: f64) -> PluralCategory
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".