joyful 0.1.0

Generate delightful, random word combinations - Rust port of the joyful TypeScript library
Documentation
  • Coverage
  • 94.12%
    16 out of 17 items documented3 out of 4 items with examples
  • Size
  • Source code size: 77.26 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.37 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 29s Average build duration of successful builds.
  • all releases: 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rawnly

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

[dependencies]
joyful = "0.1.0"

Usage

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

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