Add dicebear-styles Rust crate#1
Closed
FlorianKoerner wants to merge 1 commit into
Closed
Conversation
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().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.rsscanssrc/*.jsonand generates, in sorted order: aSTYLESembed table (include_str!), aNAMESlist, and one typed accessor fn per style. Names are derived from disk, never hand-listed.src/lib.rspublic API:get(name) -> Option<&'static str>(binary search over the sorted table)names() -> &'static [&'static str]parsed(name) -> Option<serde_json::Value>adventurer(),big_ears_neutral())Cargo.toml— minimal data crate, edition 2021, single depserde_json.README.md— Rust-consumer usage matching the repo tone..gitignore: ignorerust/targetandrust/Cargo.lock.Tests
cargo build+cargo testpass (clean rebuild verified).cargo fmt --checkandcargo clippy -- -D warningsare clean. Tests assert exactly 37 styles, every definition is non-empty valid JSON, names are sorted/unique, and typed accessors matchget().