Skip to main content

Crate jpzip

Crate jpzip 

Source
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.
JpzipClient
The jpzip SDK entry point.
JpzipClientBuilder
Builder for JpzipClient.
Meta
Contents of /meta.json.
Town
One element of ZipcodeEntry::towns.
ZipcodeEntry
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_meta on a lazily-initialized default client.
is_valid_zipcode
Returns true iff s matches ^\d{7}$.
lookup
Shortcut for JpzipClient::lookup on a lazily-initialized default client.
lookup_all
Shortcut for JpzipClient::lookup_all on a lazily-initialized default client.
lookup_group
Shortcut for JpzipClient::lookup_group on a lazily-initialized default client.
preload
Shortcut for JpzipClient::preload on a lazily-initialized default client.

Type Aliases§

SpecMismatchCallback
Callback invoked once when the CDN’s spec_version does not match SPEC_VERSION.
ZipcodeDict
On-the-wire shape of /g/*.json and /p/*.json.