joyful 0.1.0

Generate delightful, random word combinations - Rust port of the joyful TypeScript library
Documentation
//! Word lists and categories used for generation.
//!
//! This module provides access to curated word lists organized by category,
//! which are used to generate delightful word combinations.
//!
//! # Word Categories
//!
//! The library includes words from diverse categories including:
//! - Adjectives and colors (used as prefixes)
//! - Animals, nature, space
//! - Art, music, literature
//! - Fashion, food, professions
//! - History, mythology, science
//! - Sports, transportation, architecture
//!
//! All word lists are loaded lazily from embedded JSON files.

use std::sync::LazyLock;

static ADJECTIVES: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/adjectives.json")).unwrap());

static ANIMALS: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/animals.json")).unwrap());

static ARCHITECTURE: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/architecture.json")).unwrap());

static ART: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/art.json")).unwrap());

static COLORS: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/colors.json")).unwrap());

static EMOTIONS: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/emotions.json")).unwrap());

static FASHION: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/fashion.json")).unwrap());

static FOOD: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/food.json")).unwrap());

static HISTORY: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/history.json")).unwrap());

static LITERATURE: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/literature.json")).unwrap());

static MUSIC: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/music.json")).unwrap());

static MYTHOLOGY: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/mythology.json")).unwrap());

static NATURE: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/nature.json")).unwrap());

static PROFESSIONS: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/professions.json")).unwrap());

static SCIENCE: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/science.json")).unwrap());

static SPACE: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/space.json")).unwrap());

static SPORTS: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/sports.json")).unwrap());

static TRANSPORTATION: LazyLock<Vec<String>> =
    LazyLock::new(|| serde_json::from_str(include_str!("./data/transportation.json")).unwrap());

/// Combined list of prefix words (adjectives and colors).
///
/// These words are used as the first segment in generated strings.
/// They're chosen to be memorable and evocative.
///
/// Lazily initialized from embedded JSON data files.
pub static PREFIXES: LazyLock<Vec<String>> = LazyLock::new(|| {
    let mut accumulator: Vec<String> = Vec::new();

    accumulator.append(&mut ADJECTIVES.to_vec());
    accumulator.append(&mut COLORS.to_vec());

    accumulator
});

/// Combined list of all category words.
///
/// This includes words from all categories (animals, nature, professions, etc.)
/// and is used for selecting subsequent segments after the prefix.
///
/// Lazily initialized from embedded JSON data files.
pub static CATEGORIES: LazyLock<Vec<String>> = LazyLock::new(|| {
    let mut accumulator: Vec<String> = Vec::new();

    accumulator.append(&mut ANIMALS.to_vec());
    accumulator.append(&mut ARCHITECTURE.to_vec());
    accumulator.append(&mut ART.to_vec());
    accumulator.append(&mut EMOTIONS.to_vec());
    accumulator.append(&mut FASHION.to_vec());
    accumulator.append(&mut FOOD.to_vec());
    accumulator.append(&mut HISTORY.to_vec());
    accumulator.append(&mut LITERATURE.to_vec());
    accumulator.append(&mut MUSIC.to_vec());
    accumulator.append(&mut MYTHOLOGY.to_vec());
    accumulator.append(&mut NATURE.to_vec());
    accumulator.append(&mut PROFESSIONS.to_vec());
    accumulator.append(&mut SCIENCE.to_vec());
    accumulator.append(&mut SPACE.to_vec());
    accumulator.append(&mut SPORTS.to_vec());
    accumulator.append(&mut TRANSPORTATION.to_vec());

    accumulator
});

/// Maximum number of segments that can be requested.
///
/// This is calculated as the total number of unique words available
/// (categories + prefixes), since the generator guarantees word uniqueness
/// within each generated string.
pub static MAX_SEGMENTS: LazyLock<usize> = LazyLock::new(|| CATEGORIES.len() + PREFIXES.len());