Struct hyperid::HyperId[][src]

pub struct HyperId { /* fields omitted */ }
Expand description

Id generator. Every instance create different generator.

use hyperid::HyperId;
let mut hyperid = HyperId::default();

let id = hyperid.generate();
let id2 = hyperid.generate();

assert_ne!(id, id2);

let id = hyperid.get();
let id2 = hyperid.get();

assert_eq!(id, id2);

Implementations

Create a new HyperId instance

use hyperid::HyperId;
let mut hyperid = HyperId::new();

Create a new HyperId instance starting from a given id

use hyperid::{HyperId, Id};
let bytes = vec![0; 17];
let id = Id::from_bytes(bytes).unwrap();
let hyperid = HyperId::from_id(id);
let id = hyperid.get();
assert_eq!(vec![0; 17], id.into_bytes());

Return the latest generated Id

use hyperid::HyperId;
let mut hyperid = HyperId::new();
let id1 = hyperid.get();
let id2 = hyperid.get();
assert_eq!(id1, id2);

Generate the Id and returns it

use hyperid::HyperId;
let mut hyperid = HyperId::new();
let id1 = hyperid.get();
let id2 = hyperid.generate();
assert_ne!(id1, id2);

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.