prefix_id

All the magic from nanoid but with a prefix

Inspired by nanoid

Docs.rs docs Crates.io version Download
## Installation ```shell cargo add prefix_id ``` ## Usage ```rust create_id!(MyEntityId, "id"); let id = MyEntityId::new(); // => "id_1234567890avjfwdnfvqdp" // then you can use the impl methods id.as_str(); // => "id_1234567890avjfwdnfvqdp" let my_string: String = id.into(); // you can also validate/convert it from string let str = "id_1234567890avjfwdnfvqdp"; let id = MyEntityId::from_str(str).unwrap(); // you can optionally set the feature `serde` flag to serialize/deserialize let serialized = serde_json::to_string(&id).unwrap(); let deserialized = serde_json::from_str::(&serialized).unwrap(); ``` ## License Licensed under Apache License, Version 2.0