Skip to main content

Crate mf2_host_web

Crate mf2_host_web 

Source
Expand description

mf2-host-web — the Host of mf2-runtime in the browser (wasm32-unknown-unknown, its only target): NFC through String.prototype.normalize and the shortest round-trip text of a float through Number.prototype .toString, both via js-sys, so the wasm carries no normalization tables and no float-printing code.

Dates and numbers (intl) come as more hosts, not as more methods of HOST: a host method is linked whenever its host is (it is in the Host vtable), so a date or number method on HOST would cost every client that has the feature on, dates or numbers or not. An application names the host its corpus needs (mf2-build picks it):

StaticFeatureAdds
HOST—NFC, float text
ZONES_HOSTtime-zonesHost::zone_offset from the browser’s zone data (datetime-icu clients: named zones)
INTL_HOSTdatetime-intlthat, and Host::format_date_time through Intl.DateTimeFormat
NUMBERS_HOST, IntlNumbers(&host)intlnumbers through Intl.NumberFormat and Intl.PluralRules (Host::numbers) over another host

§The user guide

The Rust MF2 book is the user guide: how the crates fit together, web and native applications, the command line, and what 2.x promises. An application reaches this crate through mf2, as mf2::host_web (feature host-web).

Structs§

IntlNumbersintl
A host with numbers through Intl (feature intl): the number methods here, every other method from the host it wraps — crate::HOST, or a date host (IntlNumbers(&INTL_HOST) for a corpus with dates under datetime-intl). Its own static, like the date hosts, so a client that formats no numbers names a host without this glue (B1′). It forwards each Host method; a method added to the trait later must be forwarded here too.
IntlWebHostdatetime-intl
The browser host with dates through Intl.DateTimeFormat and zone offsets from the browser’s zone data (datetime-intl).
WebHost
The browser host.
ZonesWebHosttime-zones
The browser host with time-zone offsets from the browser’s zone data.

Statics§

HOST
The browser host, for mf2_runtime::FormatContext::new.
INTL_HOSTdatetime-intl
IntlWebHost, for mf2_runtime::FormatContext::new.
NUMBERS_HOSTintl
IntlNumbers over crate::HOST, for mf2_runtime::FormatContext::new.
ZONES_HOSTtime-zones
ZonesWebHost, for mf2_runtime::FormatContext::new.