strong_id
Strongly typed IDs which optionally satisfy the TypeID specification.
A StrongId is any type which implements StrongId<T: Id>
.
The Id
trait is implemented for u8
, u16
, u32
, u64
, u128
, usize
and when the "uuid"
feature is enabled,
Uuid
.
With default-features = false
and the typeid
feature enabled, StrongID will follow the TypeID specification.
StrongID is verified against the TypeID spec with the typeid workflow every 6 hours.
```rust use strong_id::{prefix, DynamicStrongId};
let userid = DynamicStrongId::
let userid = "user0343".parse::
```rust use strong_id::{prefix, DynamicStrongId};
let id = DynamicStrongId::
let id = "0343".parse::
```rust use strong_id::{prefix, DynamicStrongId};
let userid = DynamicStrongId::
let userid = "user01h536gfwffx2rm6pa0xg63337"
.parse::
```rust use strong_id::{prefix, DynamicStrongId};
let id = DynamicStrongId::
let id = "01h536gfwffx2rm6pa0xg63337"
.parse::
```rust use strongid::strongid;
strong_id!(pub struct UserId(u16 => "user"));
let userid = UserId::from(3203); println!("{}", userid); // user_0343
let userid = "user0343".parse::
```rust use strongid::strongid;
strong_id!(pub struct Id(u16));
let id = Id::from(3203); println!("{}", id); // user_0343
let id = "0343".parse::
```rust use strongid::{stronguuid, StrongUuid};
stronguuid!(pub struct UserId(pub Uuid => "user"));
// stronguuid!(struct UserId(Uuid => "user"));
/*
strong_id! {
#[derive(StrongUuid)]
pub struct UserId(pub Uuid => "user")
}
*/
let userid = UserId::nowv7(); println!("{}", userid); // user01h536z8abez196j2nzz06y8c8
let userid = "user01h536z8abez196j2nzz06y8c8".parse::
```rust use strongid::{stronguuid, StrongUuid};
stronguuid!(pub struct Id(pub Uuid));
// stronguuid!(struct Id(Uuid));
/*
strong_id! {
#[derive(StrongUuid)]
pub struct Id(pub Uuid)
}
*/
let id = Id::now_v7(); println!("{}", id); // 01h5372sq2egxb6ps3taq7p6np
let id = "01h5372sq2egxb6ps3taq7p6np".parse::
delimited
- Enables underscore delimited prefixes. On by default.serde
- Enables serde support in code generation.uuid
- Enable uuid functionality.
uuid-v1
- corresponds with uuid "v1" featureuuid-v3
- corresponds with uuid "v3" featureuuid-v4
- corresponds with uuid "v4" featureuuid-v5
- corresponds with uuid "v5" featureuuid-v6
- corresponds with uuid "v6" featureuuid-v7
- corresponds with uuid "v7" featureuuid-v8
- corresponds with uuid "v8" featuretypeid
- Enable features which satisfy the TypeId specification.