Skip to content

Add dicebear-styles Rust crate#1

Closed
FlorianKoerner wants to merge 1 commit into
mainfrom
rust-port
Closed

Add dicebear-styles Rust crate#1
FlorianKoerner wants to merge 1 commit into
mainfrom
rust-port

Conversation

@FlorianKoerner

Copy link
Copy Markdown
Member

Ships the 37 DiceBear avatar style definitions as a data-only Rust crate (dicebear-styles), mirroring how the npm/Composer/PyPI packages distribute the same pure JSON. No rendering or avatar-generation logic.

What's added (rust/)

  • build.rs scans src/*.json and generates, in sorted order: a STYLES embed table (include_str!), a NAMES list, and one typed accessor fn per style. Names are derived from disk, never hand-listed.
  • src/lib.rs public API:
    • get(name) -> Option<&'static str> (binary search over the sorted table)
    • names() -> &'static [&'static str]
    • parsed(name) -> Option<serde_json::Value>
    • per-style fns (e.g. adventurer(), big_ears_neutral())
  • Cargo.toml — minimal data crate, edition 2021, single dep serde_json.
  • README.md — Rust-consumer usage matching the repo tone.
  • .gitignore: ignore rust/target and rust/Cargo.lock.

Tests

cargo build + cargo test pass (clean rebuild verified). cargo fmt --check and cargo clippy -- -D warnings are clean. Tests assert exactly 37 styles, every definition is non-empty valid JSON, names are sorted/unique, and typed accessors match get().

Ship the 37 avatar style definitions as embedded JSON data via a
data-only Rust crate, mirroring the npm/Composer/PyPI packages.

- build.rs scans src/*.json and generates a sorted embed table plus a
  typed accessor per style, so names are derived from disk, never
  hand-listed.
- Public API: get(name), names(), parsed(name) and per-style fns.
- Tests assert exactly 37 styles, every definition is non-empty valid
  JSON, names are sorted/unique, and accessors match get().
@FlorianKoerner
FlorianKoerner deleted the rust-port branch June 7, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant