diesel-ulid
Ulid mapping for diesel-rs and . This crate contains custom mapping for the Ulid implementation from rusty-ulid to diesel::sql_types::Uuid. With this adapter you can use these types in Diesel and tokio_postgres as regular Postgres UUID type.
Import
cargo add diesel-ulid
or add:
diesel-ulid = 0.3.1
to your Cargo.toml. While this crate was iniated for diesel-rs it can also be used with the rust-postgres driver. You can use the postgres or diesel feature to enable the corresponding adapter.
Usage
This is an adaptation of the Getting started section from diesel-rs.
Assuming you have the following schema.rs file:
table!
you could use diesel-ulid as follows:
use *;
use DieselUlid as Ulid;
The Postgres UUID will be automatically mapped to a corresponding Ulid and vice-versa. This works because UUID and Ulid are both represented as 16 byte (128 bit) data struct.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Licensing
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.