pub struct UniqueId(/* private fields */);
Expand description
A UniqueId that can be used within a database. Is not cryptographically secure and could be bruteforced.
Contains 10bytes
- 0..5 are seconds since the UNIX_EPOCH
- 5..10 are random
Implementations§
Source§impl UniqueId
impl UniqueId
pub fn new() -> Self
Sourcepub const fn from_raw(inner: [u8; 10]) -> Self
pub const fn from_raw(inner: [u8; 10]) -> Self
This creates a unique id with it’s raw content making it able to be called in a const context.
pub fn from_slice_unchecked(slice: &[u8]) -> Self
pub fn to_b64(&self) -> String
Sourcepub fn parse_from_b64<T>(b64: T) -> Result<Self, DecodeError>
pub fn parse_from_b64<T>(b64: T) -> Result<Self, DecodeError>
If the string is not 14 bytes long returns InvalidLength
pub fn from_bytes(bytes: [u8; 10]) -> Self
pub fn into_bytes(self) -> [u8; 10]
pub fn since_unix_secs(&self) -> u64
pub fn as_slice(&self) -> &[u8] ⓘ
Trait Implementations§
Source§impl ColumnType for UniqueId
impl ColumnType for UniqueId
fn column_kind() -> ColumnKind
fn to_data(&self) -> ColumnData<'_>
fn from_data(data: ColumnData<'_>) -> Result<Self, FromDataError>
Source§impl<'de> Deserialize<'de> for UniqueId
impl<'de> Deserialize<'de> for UniqueId
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for UniqueId
impl Eq for UniqueId
impl StructuralPartialEq for UniqueId
Auto Trait Implementations§
impl Freeze for UniqueId
impl RefUnwindSafe for UniqueId
impl Send for UniqueId
impl Sync for UniqueId
impl Unpin for UniqueId
impl UnwindSafe for UniqueId
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