ens-normalize-rs
Rust implementation of ENS normalization, ported from
@adraffy/ens-normalize.
The crates.io package is named ens-normalize, which imports as
ens_normalize.
The crate embeds the same upstream derived data (spec.json and nf.json) and
tests against the upstream validation corpus from @adraffy/ens-normalize
1.11.1 (Unicode 17.0.0, CLDR 47).
use ens_normalize;
let name = ens_normalize?;
assert_eq!;
# Ok::
Core API:
ens_normalize(name) -> Result<String>ens_beautify(name) -> Result<String>ens_normalize_fragment(fragment, decompose) -> Result<String>ens_split(name, preserve_emoji) -> Vec<Label>ens_tokenize(name) -> Vec<Token>nfc(cps)andnfd(cps)using the embedded Unicode data
Verification
The Rust tests reuse the upstream fixture files in tests/fixtures.
For the JS/WASM compatibility harness, install wasm-pack and run:
Benchmarks
To compare against ens-normalize.js after running cargo bench:
ENS_NORMALIZE_JS_DIR=/path/to/ens-normalize.js
Updating Upstream Data
To refresh from ens-normalize.js:
The script runs the upstream JS test suite, copies the derived data and fixtures into this repo, then runs the Rust tests.