# 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](https://github.com/fvitale/joyful) TypeScript library.
## Installation
```toml
[dependencies]
joyful = "0.1.0"
```
## Usage
```rust
use joyful::{joyful, Options};
// Default: 2 segments with "-" separator
joyful(Options::default()).unwrap(); // "amber-fox"
// Custom segments
joyful(Options {
segments: 3,
..Default::default()
}).unwrap(); // "golden-marble-cathedral"
// Custom separator
joyful(Options {
segments: 3,
separator: '_',
..Default::default()
}).unwrap(); // "swift_northern_lights"
// With max length constraint
joyful(Options {
max_length: Some(20),
..Default::default()
}).unwrap(); // "tan-elk"
```
## API
### `joyful(options: Options) -> Result<String, ValidationError>`
Returns a randomly generated string or an error if constraints cannot be satisfied.
### `Options`
| `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
| 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](https://github.com/fvitale/joyful) by Federico Vitale
- Based on [friendly-words](https://github.com/glitchdotcom/friendly-words) by Glitch, with curated word lists and additional categories
## License
ISC