rosetta-uuid
A wrapper implementation of UUID providing binary diesel bindings for SQLite and PostgreSQL, and redis serialization support.
Features
This crate provides a Uuid wrapper type that implements various traits based on enabled features:
diesel: Enables Diesel integration.postgres: Enables binaryUuidsupport for PostgreSQL.sqlite: Enables binaryUuidsupport for SQLite (stored as BLOB).
redis: EnablesToRedisArgsandFromRedisValuefor easy Redis storage and retrieval.serde: Enables serialization and deserialization via Serde.
Platform Support
- Wasm: Verified support for
wasm32-unknown-unknownwithuuidv4 and v7 generation.
Usage
Add this to your Cargo.toml. Select the features matching your database or storage requirements.
[]
= { = "0.1", = ["diesel", "postgres", "redis", "serde"] }
Example
use Uuid;
use FromStr;
// Create a new random UUID (v4)
let id = new_v4;
// Create a new timestamp-based UUID (v7) with the current UTC timestamp
let id_v7 = utc_v7;
// Parse from string
let parsed = from_str.unwrap;
// Access underlying uuid::Uuid methods via Deref
println!;
To use the functions made available by this crate as a SQLite registered function, you can use:
Traits
The Uuid type implements:
FromStrDisplay,DebugDeref,DerefMut(touuid::Uuid)AsRef<[u8; 16]>,AsRef<uuid::Uuid>From<uuid::Uuid>,Into<uuid::Uuid>From<[u8; 16]>,Into<[u8; 16]>Default(returns nil UUID)