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 methods
fn bytes(&self, value: f64, unit: ByteUnit) -> String { ... }
fn offset_minutes(&self, _utc_ms: f64) -> i32 { ... }
}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§
Sourcefn bytes(&self, value: f64, unit: ByteUnit) -> String
fn bytes(&self, value: f64, unit: ByteUnit) -> String
A byte size (value already in unit, ≤ 1 fraction digit), like
Intl.NumberFormat(locale, {style: "unit", unitDisplay: "short"}).
The default: the number through Self::number + the English
short unit (byte, kB, MB, GB).
Sourcefn offset_minutes(&self, _utc_ms: f64) -> i32
fn offset_minutes(&self, _utc_ms: f64) -> i32
VAPP-191: the surface (team) zone’s UTC offset in minutes at an
instant, for the expression date maths (crate::cel). Default UTC.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".