pub struct Sulid { /* private fields */ }Expand description
A “signed” ULID, whose “random” portion is generated by a cryptographic signature.
Implementations§
Source§impl Sulid
impl Sulid
Sourcepub fn sign(secret: &SigningKey, payload: UnsignedPayload) -> SignedPayload
pub fn sign(secret: &SigningKey, payload: UnsignedPayload) -> SignedPayload
Create a new sULID by signing a payload.
Returns a SignedPayload which includes the generated Sulid, as well
as the payload parts required to verify it.
The SignedPayload generated by this function is guaranteed to be valid. However,
to validate untrusted sULIDs, you can construct a SignedPayload and call its is_valid().
Sourcepub fn timestamp(&self) -> SystemTime
pub fn timestamp(&self) -> SystemTime
Gets the timestamp portion of the sULID from the first 48 bits.
pub fn to_bytes(&self) -> [u8; 16]
Trait Implementations§
impl Copy for Sulid
impl Eq for Sulid
Source§impl FromStr for Sulid
impl FromStr for Sulid
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Note: This only parses/deserializes an sULID from its string representation.
To verify that it has not been tampered with, check it using SignedPayload::is_valid()
Source§type Err = DecodeError
type Err = DecodeError
The associated error which can be returned from parsing.
Source§impl Ord for Sulid
impl Ord for Sulid
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Sulid
impl PartialOrd for Sulid
impl StructuralPartialEq for Sulid
Auto Trait Implementations§
impl Freeze for Sulid
impl RefUnwindSafe for Sulid
impl Send for Sulid
impl Sync for Sulid
impl Unpin for Sulid
impl UnsafeUnpin for Sulid
impl UnwindSafe for Sulid
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