### Install readable-code-english Crate Source: https://crates.io/crates/readable-code-english Add the readable-code-english crate to your Cargo project dependencies. ```bash cargo add readable-code-english ``` -------------------------------- ### Generate Basic English-like Code Source: https://crates.io/crates/readable-code-english Use the `word` builder to create a code with a specified length of pseudo-words, dashes, and digits. ```rust use readable_code_english::word; let code = word(4).dash().digits(4).build(); // "mivo-4821" ``` -------------------------------- ### word(length) -> EnglishBuilder Source: https://crates.io/crates/readable-code-english/0.1.2 The primary fluent API for generating codes. It returns a builder with a pseudo-word already added, allowing for chaining of methods like `dash()`, `digits()`, `add()`, and `build()` to construct the final code string. Uses a secure default random source. ```APIDOC ## `word(length)` ### Description Generates a code starting with a pseudo-word of the specified length. This method returns a builder object that allows for further customization through chaining. ### Method Signature `word(length: usize) -> EnglishBuilder` ### Parameters * **length** (usize) - Required - The desired length of the initial pseudo-word. ### Builder Methods * `dash()`: Appends a dash separator. * `digits(length)` / `nums(length)`: Appends a sequence of digits of the specified length. * `add(value)`: Appends a custom string value. * `build()`: Finalizes the code generation and returns the complete `String`. ### Usage Example ```rust use readable_code_english::word; let code = word(4).dash().digits(4).build(); // Example output: "mivo-4821" let code = word(4).dash().word(8).dash().digits(4).build(); // Example output: "teva-pifoluna-7520" ``` ``` -------------------------------- ### word_with(length, rng) -> EnglishBuilder Source: https://crates.io/crates/readable-code-english/0.1.2 Provides the same fluent API as `word()` but allows the caller to supply a custom random number generator (`rng`). This is useful for creating deterministic and reproducible code outputs. ```APIDOC ## `word_with(length, rng)` ### Description Offers the fluent API for code generation, similar to `word()`, but accepts a user-provided random source (`rng`). This enables deterministic code generation for testing or reproducibility. ### Method Signature `word_with(length: usize, rng: R) -> EnglishBuilder` where `R: RandomSource` ### Parameters * **length** (usize) - Required - The desired length of the initial pseudo-word. * **rng** (R) - Required - An instance of a type implementing `RandomSource` for generating random numbers. ### Builder Methods (Same as `word()`: `dash()`, `digits()`, `add()`, `build()`) ### Usage Example ```rust use readable_code_english::word_with; use readable_code_core::SplitMix64; let mut rng = SplitMix64::new(1); let code = word_with(4, &mut rng).dash().digits(4).build(); // Example output: "fupo-1738" (with a specific seed) ``` ``` -------------------------------- ### Generate Deterministic English-like Code Source: https://crates.io/crates/readable-code-english Utilize `word_with` and a specific random source (e.g., `SplitMix64`) for reproducible code generation. ```rust use readable_code_english::word_with; use readable_code_core::SplitMix64; let code = word_with(4, SplitMix64::new(1)).dash().digits(4).build(); ``` -------------------------------- ### word(length) -> EnglishBuilder Source: https://crates.io/crates/readable-code-english The primary fluent API for generating codes using the secure default random source. It returns a builder with one pseudo-word added, allowing for further chaining of methods like `dash()`, `digits()`, `add()`, and `build()`. ```APIDOC ## `word(length) -> EnglishBuilder` ### Description Primary fluent API using the secure default random source. Returns a builder with one pseudo-word already added, so you can keep chaining. ### Builder Methods - `word(length)`: Adds a pseudo-word of the specified length. - `dash()`: Adds a dash separator. - `digits(length)` / `nums(length)`: Adds a sequence of digits of the specified length. - `add(value)`: Adds a custom value. - `build()`: Finalizes the chain and returns the generated code as a `String`. ``` -------------------------------- ### word_with(length, rng) -> EnglishBuilder Source: https://crates.io/crates/readable-code-english A fluent API that allows the use of a caller-supplied random source (`rng`). This is useful for generating deterministic and reproducible output by providing a specific random number generator. ```APIDOC ## `word_with(length, rng) -> EnglishBuilder` ### Description Same fluent API with a caller-supplied `RandomSource` — use for deterministic, reproducible output. ### Parameters - `length` (usize): The desired length of the pseudo-word. - `rng` (R): A mutable reference to a type implementing the `RandomSource` trait. ### Builder Methods (Same as `word` method: `word(length)`, `dash()`, `digits(length)` / `nums(length)`, `add(value)`, `build()`) ``` -------------------------------- ### eng_word(length, rng) -> String Source: https://crates.io/crates/readable-code-english A lower-level helper function that generates and returns a single pseudo-word as a plain `String`. It takes a mutable reference to a random source, allowing for interleaved draws from the same source. ```APIDOC ## `eng_word(length, rng) -> String` ### Description Lower-level helper that returns a plain `String` for one pseudo-word, with no builder chain. Use it when you want to drop a generated word into your own composition. ### Parameters - `length` (usize): The desired length of the pseudo-word. - `rng` (&mut R): A mutable reference to a type implementing the `RandomSource` trait. It borrows the random source mutably, allowing for interleaved draws from one source. ``` -------------------------------- ### Generate Single English Pseudo-word Source: https://crates.io/crates/readable-code-english Use the `eng_word` helper for generating a single pseudo-word, useful for custom composition. It allows mutable borrowing of the random source. ```rust use readable_code_core::{code, OsRandom}; use readable_code_english::eng_word; let mut rng = OsRandom::new(); let token = eng_word(4, &mut rng); // "mivo" let out = code(OsRandom::new()).add(eng_word(6, &mut OsRandom::new())).dash().digits(4).build(); ``` -------------------------------- ### Generate Complex English-like Code Source: https://crates.io/crates/readable-code-english Chain multiple `word`, `dash`, and `digits` calls to construct more elaborate codes. ```rust use readable_code_english::word; let code = word(4).dash().word(8).dash().digits(4).build(); // "teva-pifoluna-7520" ``` -------------------------------- ### eng_word(length, rng) -> String Source: https://crates.io/crates/readable-code-english/0.1.2 A lower-level function that directly generates a single pseudo-word of the specified length. It returns a plain `String` and mutably borrows the random source, allowing for interleaved generation from a single source. ```APIDOC ## `eng_word(length, rng)` ### Description A utility function to generate a single English-like pseudo-word of a given length. It returns the word as a `String` and requires a mutable reference to a random source. ### Method Signature `eng_word(length: usize, rng: &mut R) -> String` where `R: RandomSource` ### Parameters * **length** (usize) - Required - The desired length of the pseudo-word. * **rng** (&mut R) - Required - A mutable reference to a random source implementing `RandomSource`. ### Return Value * `String` - A pronounceable pseudo-word. ### Usage Example ```rust use readable_code_core::{code, OsRandom}; use readable_code_english::eng_word; let mut rng = OsRandom::new(); let token = eng_word(4, &mut rng); // "mivo" // Can be used within other code generation contexts: let out = code(OsRandom::new()).add(eng_word(6, &mut OsRandom::new())).dash().digits(4).build(); // Example output: "ranepu-1234" ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.