generate random ids in new
parent
e90e83c310
commit
16e0487833
|
@ -14,3 +14,4 @@ serde = { version = "1.0.71", features = ["rc", ] }
|
|||
serde_derive = "1.0.71"
|
||||
serde_json = { version = "1.0", features = ["raw_value",] }
|
||||
smallvec = { version = "^1.5.0", features = ["serde", ] }
|
||||
uuid = { version = "0.8", features = ["serde", "v4"] }
|
||||
|
|
|
@ -108,9 +108,10 @@ impl<OBJ> core::fmt::Display for Id<OBJ> {
|
|||
}
|
||||
|
||||
impl<OBJ> Id<OBJ> {
|
||||
pub fn new() -> Self {
|
||||
fn new_with_prefix(prefix: &str) -> Self {
|
||||
let id = uuid::Uuid::new_v4().to_string();
|
||||
Self {
|
||||
inner: String::new(),
|
||||
inner: String::from(prefix) + &id,
|
||||
_ph: PhantomData,
|
||||
}
|
||||
}
|
||||
|
@ -128,6 +129,12 @@ impl<OBJ> Id<OBJ> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Id<Account> {
|
||||
pub fn new() -> Self {
|
||||
Self::new_with_prefix("A")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
#[serde(transparent)]
|
||||
pub struct State<OBJ> {
|
||||
|
|
Loading…
Reference in New Issue