Expand description
§Commons
Shared Rust utilities and common patterns for the Sebastien Rousseau ecosystem.
This crate provides reusable components, traits, and utilities used across multiple Rust projects in the ecosystem.
§Features
config- Configuration file loading and management (TOML)error- Common error types and Result aliaseslogging- Near-lock-free structured logging enginetime- Date/time utilities and formattingcollections- Extended collection utilities (LRU cache)validation- Input validation utilitiesretry- Retry logic with backoff strategiesid- ID generation (timestamp, random, UUID-like)env- Environment variable helpersfs- Cross-platform filesystem utilities
§Quick Start
use commons::prelude::*;
// Use the LRU cache
let mut cache = LruCache::new(100);
cache.insert("key", "value");§Feature Flags
Enable only what you need:
[dependencies]
commons = { version = "0.0.3", default-features = false, features = ["error", "time"] }Modules§
- collections
collections - Specialized data structures and collection utilities.
- config
config - Configuration management utilities.
- counter
counter - Portable monotonic counters for targets without 64-bit atomics.
A monotonic
u64counter that works without 64-bit atomics. - env
env - Environment variable utilities.
- error
error - Common error types and handling utilities.
- fs
fs - Cross-platform filesystem utilities.
- id
id - ID generation utilities.
- logging
logging - Near-lock-free structured logging engine.
- prelude
- Prelude module for convenient imports.
- retry
retry - Retry logic with configurable backoff strategies.
- time
time - Time handling and duration utilities.
- validation
validation - Input validation utilities.
Macros§
- logger
logging - Create a logger for the current module.
- logging_
mcp_ notify logging - Emit an MCP-formatted state transition notification.
- logging_
span idandlogging - Execute a block within an OTLP-tagged span.
- logging_
time_ it logging - Measure wall-clock latency of a block and emit a Logfmt metric.
Constants§
- VERSION
- Crate version.
Functions§
- version
- Returns the crate version.