Crate uniqer_rs

Crate uniqer_rs 

Source
Expand description

§Uniqer

uniqer_rs is a lightweight and easy-to-use Rust library for generating various types of unique identifiers. It provides a simple builder-pattern API for creating random alphanumeric, numeric, and alphabetic IDs, as well as standard UUIDs (v1, v4, and v7).

§Features

  • Generate random alphanumeric IDs with default or custom length.
  • Generate random numeric-only IDs.
  • Generate random alphabetic-only IDs.
  • Generate Version 1 (time-based), Version 4 (random), and Version 7 (time-based, sortable) UUIDs.
  • Simple, intuitive builder API: Uniqer::new().method() or Uniqer::new().with_length(16).method().
  • Built-in validation to ensure a minimum ID length, reducing collision probability.

§Quick Start

use uniqer_rs::{Uniqer, UniqerError};

fn main() -> Result<(), UniqerError> {
    // Generate a 12-character alphanumeric ID (default length)
    let id = Uniqer::new().unique_id()?;
    println!("Generated Alphanumeric ID: {}", id);

    // Generate a 16-character alphanumeric ID (custom length)
    let long_id = Uniqer::new().with_length(16).unique_id()?;
    println!("Generated Long ID: {}", long_id);

    // Generate a UUID v4
    let uuid = Uniqer::new().uuidv4()?;
    println!("Generated UUID v4: {}", uuid);

    Ok(())
}

Structs§

Uniqer
A builder struct for generating various types of unique identifiers.

Enums§

UniqerError
Represents errors that can occur during ID generation.