65 releases

Uses new Rust 2024

new 0.3.1 May 11, 2026
0.2.0 Nov 10, 2025
0.1.64 Apr 17, 2025
0.1.62 Dec 11, 2024
0.1.11 Nov 29, 2023

#579 in WebAssembly

Download history 184/week @ 2026-01-22 270/week @ 2026-01-29 252/week @ 2026-02-05 145/week @ 2026-02-12 229/week @ 2026-02-19 204/week @ 2026-02-26 280/week @ 2026-03-05 369/week @ 2026-03-12 115/week @ 2026-03-19 215/week @ 2026-03-26 129/week @ 2026-04-02 138/week @ 2026-04-09 35/week @ 2026-04-16 353/week @ 2026-04-23 249/week @ 2026-04-30 1021/week @ 2026-05-07

1,696 downloads per month
Used in 3 crates

Custom license

35KB
738 lines

bomboni_common

Common utilities for the Bomboni library.

This crate provides essential utilities for building distributed systems and applications.

Features

  • Unique Identifiers: ULID-based sortable and unique ID generation supporting both random and worker-based approaches
  • UTC DateTime Handling: A UTC-focused datetime type
  • WASM Compatible: Full support for WebAssembly targets
  • Database Support: PostgreSQL and MySQL integration via optional features

Examples

Unique IDs

use bomboni_common::id::{Id, worker::WorkerIdGenerator};
use std::str::FromStr;

// Generate a random sortable ID
let id = Id::generate();
println!("ID: {}", id);

// Generate multiple IDs
let ids = Id::generate_multiple(5);
assert_eq!(ids.len(), 5);

// Parsing IDs
let id_str = "01ARZ3NDEKTSV4RRFFQ69G5FAV";
let id: Id = id_str.parse().unwrap();

// For distributed systems where each worker needs to generate unique IDs:
let mut g = WorkerIdGenerator::new(1);
let id = g.generate();
assert_ne!(g.generate(), id);

// Generating multiple IDs at once is more efficient:
let mut g = WorkerIdGenerator::new(1);
let ids = g.generate_multiple(3);
assert_eq!(ids.len(), 3);

UTC DateTime

use bomboni_common::date_time::UtcDateTime;

// Get the current time
let now = UtcDateTime::now();

// Create from Unix timestamp
let dt = UtcDateTime::from_seconds(1609459200).unwrap();
assert_eq!(dt.to_string(), "2021-01-01T00:00:00Z");

// Convert from string
let dt = "1970-01-01T00:00:01Z".parse::<UtcDateTime>().unwrap();
assert_eq!(dt.timestamp(), (1, 0));

Cargo Features

  • serde: Enable serialization with serde
  • tokio: Enable async APIs using tokio
  • chrono: Enable conversion with the chrono crate
  • wasm: Enable WebAssembly support
  • postgres: Enable PostgreSQL type conversions
  • mysql: Enable MySQL type conversions

Dependencies

~1–6MB
~108K SLoC