joyful-rs
Generate delightful, random word combinations for your Rust app — perfect for project names, usernames, or unique identifiers.
Note: This is a Rust port of the original joyful TypeScript library.
Installation
[]
= "0.1.0"
Usage
use ;
// Default: 2 segments with "-" separator
joyful.unwrap; // "amber-fox"
// Custom segments
joyful.unwrap; // "golden-marble-cathedral"
// Custom separator
joyful.unwrap; // "swift_northern_lights"
// With max length constraint
joyful.unwrap; // "tan-elk"
API
joyful(options: Options) -> Result<String, ValidationError>
Returns a randomly generated string or an error if constraints cannot be satisfied.
Options
| Field | Type | Default | Description |
|---|---|---|---|
segments |
usize |
2 |
Number of words to generate |
separator |
char |
'-' |
Character between words |
max_length |
Option<usize> |
None |
Maximum length of the returned string |
When max_length is set, words are intelligently selected to fit within the constraint. Returns ValidationError::LengthConstraintImpossible if the limit is too short to produce a valid result.
Word Categories
The first word is always a prefix (adjective or color). Subsequent words are drawn from:
animals, architecture, art, emotions, fashion, food, history, literature, music, mythology, nature, professions, science, space, sports, transportation
Permutations
| Segments | Combinations |
|---|---|
| 2 | 700,295 |
| 3 | 2,160,410,075 |
| 4 | 6,664,865,081,375 |
| 5 | 20,561,108,776,041,876 |
Credits
- Rust port by Federico Vitale
- Original TypeScript library: joyful by Federico Vitale
- Based on friendly-words by Glitch, with curated word lists and additional categories
License
ISC