pub struct Ulid(/* private fields */);Available on crate feature
ulid only.Expand description
A 128-bit ULID.
§Example
use id_forge::ulid::Ulid;
let id = Ulid::new();
assert_eq!(id.to_string().len(), 26);Implementations§
Source§impl Ulid
impl Ulid
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new ULID with the current time.
In 0.1.0 this is a placeholder. The real implementation
lands in 0.9.x.
Examples found in repository?
examples/basic.rs (line 12)
7fn main() {
8 let v4 = Uuid::v4();
9 println!("UUID v4: {v4} (version={})", v4.version());
10 println!("UUID v7: {}", Uuid::v7());
11 println!("UUID nil: {}", Uuid::nil());
12 println!("ULID: {}", Ulid::new());
13
14 let gen = Snowflake::new(1);
15 println!("Snowflake: {}", gen.next_id());
16
17 println!("NanoID 21: {}", nanoid::generate());
18 println!("NanoID 8: {}", nanoid::with_length(8));
19
20 let round_tripped = Uuid::parse_str(&v4.to_string()).unwrap();
21 assert_eq!(v4, round_tripped);
22}Trait Implementations§
impl Copy for Ulid
impl Eq for Ulid
impl StructuralPartialEq for Ulid
Auto Trait Implementations§
impl Freeze for Ulid
impl RefUnwindSafe for Ulid
impl Send for Ulid
impl Sync for Ulid
impl Unpin for Ulid
impl UnsafeUnpin for Ulid
impl UnwindSafe for Ulid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more