pub struct EUID(/* private fields */);Expand description
Extendable Universally Unique Identifier or EUID contains two main components: header and random number.
Binary layout (Big Endian):
0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Timestamp High |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Timestamp Low | N Bit Random + Ops Ext Data |Ext Len|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Random |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Random |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Implementations§
Source§impl EUID
A Standard implementation of EUID.
impl EUID
A Standard implementation of EUID.
Sourcepub fn create() -> Option<EUID>
pub fn create() -> Option<EUID>
Create random EUID. None will returns if the EUID is created after Friday, December 12, 3084 12:41:28.831 PM (UTC).
Example:
use euid::EUID;
let euid: EUID = EUID::create().unwrap_or_default();
println!("{}", euid); // with check-mod.
println!("{}", euid.encode(true)); // with check-mod.
println!("{}", euid.encode(false)); // without check-mod.Sourcepub fn create_with_extension(extension: u16) -> Option<EUID>
pub fn create_with_extension(extension: u16) -> Option<EUID>
Create random EUID with attachable data (max 15 bit). None will returns if the EUID is created after Friday, December 12, 3084 12:41:28.831 PM (UTC) or the extenstion (user attached data) is more then 15 bits.
Example:
use euid::EUID;
let euid: EUID = EUID::create_with_extension(1).unwrap_or_default();
println!("{}", euid); // with check-mod.
println!("{}", euid.encode(true)); // with check-mod.
println!("{}", euid.encode(false)); // without check-mod.
let overflowed_euid: Option<EUID> = EUID::create_with_extension(32768);
assert_eq!(None, overflowed_euid);Sourcepub fn extension(&self) -> Option<u16>
pub fn extension(&self) -> Option<u16>
Returns user attached data (extension), or None if no attached data.
Trait Implementations§
Source§impl Ord for EUID
impl Ord for EUID
Source§impl PartialOrd for EUID
impl PartialOrd for EUID
impl Copy for EUID
impl Eq for EUID
Auto Trait Implementations§
impl Freeze for EUID
impl RefUnwindSafe for EUID
impl Send for EUID
impl Sync for EUID
impl Unpin for EUID
impl UnwindSafe for EUID
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