Skip to main content

Crate tzf_rs

Crate tzf_rs 

Source
Expand description

Fast timezone finder for Rust: convert (longitude, latitude) coordinates to timezone names, offline.

Version 2 is protobuf-free: the data source is the TZF embedded binary format (.tzb) shipped by tzf-dist, and two finder mechanisms consume it:

  • DefaultFinder — the recommended general-purpose finder. Expands the file’s geometry into materialized polygons at load time and answers most queries from the FUZZY preindex tiles, falling back to exact point-in-polygon for boundary cases.
  • EmbeddedFinder — the low-memory finder. Queries the .tzb bytes in place (no expansion; roughly the file size plus a small open-time index of chunk skip blocks and per-group latitude stripes, ~100 KB on lite), with the same FUZZY fast path. Queries are slower than DefaultFinder; results are identical.
use tzf_rs::DefaultFinder;

let finder = DefaultFinder::new();
assert_eq!("Asia/Shanghai", finder.get_tz_name(116.3883, 39.9289));

Creating a finder is expensive — build one and share it (e.g. via std::sync::LazyLock).

Structs§

BoundaryFileexport-geojson
DefaultFinder
The recommended finder: FUZZY preindex fast path over materialized polygon geometry, loaded from a .tzb file.
EmbeddedFinder
The low-memory finder: queries TZF embedded binary (.tzb) bytes in place, without expanding the geometry. Total footprint is roughly the file itself (the bundled lite data is ~4 MB) plus the timezone names and a 16-bytes-per-16-chunks skip table built while validating the file at open (~6 KB for lite, ~20 KB for full at the encoder’s default 256-point chunks).
FeatureItemexport-geojson
GeometryDefineexport-geojson
PropertiesDefineexport-geojson

Enums§

Error
Errors reported by the .tzb reader.

Functions§

deg2num
deg2num is used to convert longitude, latitude to Slippy map tilenames under specific zoom level.

Type Aliases§

MultiPolygonCoordinatesexport-geojson
PolygonCoordinatesexport-geojson