Expand description
§jpzip
Rust SDK for the jpzip Japanese postal-code dataset. The SDK fetches normalized JSON from the CDN, keeps a per-prefix in-memory LRU, and optionally backs that with a user-supplied persistent cache.
use jpzip::JpzipClient;
let client = JpzipClient::new();
if let Some(entry) = client.lookup("2310017").await? {
println!("{} {}", entry.prefecture, entry.city);
}Structs§
- Endpoints
- Endpoint template block of
/meta.json. - Jpzip
Client - The jpzip SDK entry point.
- Jpzip
Client Builder - Builder for
JpzipClient. - Meta
- Contents of
/meta.json. - Town
- One element of
ZipcodeEntry::towns. - Zipcode
Entry - One logical entry as published by the CDN.
Enums§
- Error
- Errors returned by the jpzip SDK.
Constants§
- DEFAULT_
BASE_ URL - Production CDN origin.
- SPEC_
VERSION - The jpzip protocol version this SDK targets.
Traits§
- Cache
- User-supplied L2 persistent cache. Implementations decide their own TTL, eviction, and backend (file, KV, Redis, IndexedDB, …).
Functions§
- get_
meta - Shortcut for
JpzipClient::get_metaon a lazily-initialized default client. - is_
valid_ zipcode - Returns true iff
smatches^\d{7}$. - lookup
- Shortcut for
JpzipClient::lookupon a lazily-initialized default client. - lookup_
all - Shortcut for
JpzipClient::lookup_allon a lazily-initialized default client. - lookup_
group - Shortcut for
JpzipClient::lookup_groupon a lazily-initialized default client. - preload
- Shortcut for
JpzipClient::preloadon a lazily-initialized default client.
Type Aliases§
- Spec
Mismatch Callback - Callback invoked once when the CDN’s
spec_versiondoes not matchSPEC_VERSION. - Zipcode
Dict - On-the-wire shape of
/g/*.jsonand/p/*.json.