[−][src]Struct ulid_generator_rs::ULID
This struct is ULID.
Implementations
impl ULID
[src]
implements for ULID.
#[must_use]pub fn new(value: u128) -> Self
[src]
The Constructor for ULID.
Example
ULID::new()
is used to create a ULID instance, but usually ULIDGenerator is used.
use ulid_generator_rs::{ULID, ULIDGenerator}; let ulid: ULID = ULID::new(1945530789360716160560926739305506752); // Use `ULIDGenerator::generate` as follows let ulid: ULID = ULIDGenerator::new().generate().unwrap();
#[must_use]pub const fn most_significant_bits(&self) -> u64
[src]
Most significant bits.
Example
use ulid_generator_rs::{ULIDGenerator, ULID}; let ulid: ULID = ULIDGenerator::new().generate().unwrap(); let m: u64 = ulid.most_significant_bits();
#[must_use]pub const fn least_significant_bits(&self) -> u64
[src]
Least significant bits.
Example
use ulid_generator_rs::{ULIDGenerator, ULID}; let ulid: ULID = ULIDGenerator::new().generate().unwrap(); let l: u64 = ulid.least_significant_bits();
#[must_use]pub const fn to_epoch_milli_as_long(&self) -> i64
[src]
Converts a ULID to a epoch time as milli seconds.
Example
use ulid_generator_rs::{ULIDGenerator, ULID}; let ulid: ULID = ULIDGenerator::new().generate().unwrap(); let epoch: i64 = ulid.to_epoch_milli_as_long();
#[must_use]pub fn to_date_time(&self) -> DateTime<Local>
[src]
Converts a ULID to a DateTime<Local>
Example
use ulid_generator_rs::{ULIDGenerator, ULID}; use chrono::{Local, DateTime}; let ulid: ULID = ULIDGenerator::new().generate().unwrap(); let date_time: DateTime<Local> = ulid.to_date_time();
#[must_use]pub fn to_byte_array(&self, endian: Endian) -> Vec<u8>
[src]
Converts a ULID to a byte array.
endian
a Endian of byte array
Example
use ulid_generator_rs::{ULIDGenerator, ULID, Endian}; let ulid: ULID = ULIDGenerator::new().generate().unwrap(); let ba: Vec<u8> = ulid.to_byte_array(Endian::BE);
pub fn parse_from_byte_array(
byte_array: Vec<u8>,
endian: Endian
) -> Result<Self, ULIDError>
[src]
byte_array: Vec<u8>,
endian: Endian
) -> Result<Self, ULIDError>
Parse a byte array as ULID.
byte_array
a byte array as ULID.
endian
a Endian of byte_array
.
Example
use ulid_generator_rs::{ULIDGenerator, ULID, Endian}; let ulid: ULID = ULIDGenerator::new().generate().unwrap(); let ba: Vec<u8> = ulid.to_byte_array(Endian::BE); let ulid: ULID = ULID::parse_from_byte_array(ba, Endian::BE).unwrap();
Trait Implementations
impl Clone for ULID
[src]
impl Debug for ULID
[src]
impl Display for ULID
[src]
impl From<(u64, u64)> for ULID
[src]
pub fn from((most_significant_bits, least_significant_bits): (u64, u64)) -> Self
[src]
use ulid_generator_rs::ULID; let ulid: ULID = (105449255778666307, 1874305465861347464).into();
impl From<u128> for ULID
[src]
pub fn from(value: u128) -> Self
[src]
use ulid_generator_rs::ULID; let ulid: ULID = 1945530789360716160560926739305506752.into();
impl FromStr for ULID
[src]
type Err = ULIDError
The associated error which can be returned from parsing.
pub fn from_str(ulid_str: &str) -> Result<Self, Self::Err>
[src]
use ulid_generator_rs::ULID; let ulid: ULID = "01ETGRM6448X1HM0PYWG2KT648".parse::<ULID>().unwrap();
impl PartialEq<ULID> for ULID
[src]
impl PartialOrd<ULID> for ULID
[src]
pub fn partial_cmp(&self, other: &ULID) -> Option<Ordering>
[src]
pub fn lt(&self, other: &ULID) -> bool
[src]
pub fn le(&self, other: &ULID) -> bool
[src]
pub fn gt(&self, other: &ULID) -> bool
[src]
pub fn ge(&self, other: &ULID) -> bool
[src]
impl StructuralPartialEq for ULID
[src]
impl TryFrom<Vec<u8, Global>> for ULID
[src]
type Error = ULIDError
The type returned in the event of a conversion error.
pub fn try_from(value: Vec<u8>) -> Result<Self, Self::Error>
[src]
use ulid_generator_rs::{ULID, Endian}; use std::convert::TryInto; let ulid: ULID = 1945530789360716160560926739305506752.into(); let bytes: Vec<u8> = ulid.to_byte_array(Endian::BE); let ulid: ULID = bytes.try_into().unwrap();
Auto Trait Implementations
impl RefUnwindSafe for ULID
[src]
impl Send for ULID
[src]
impl Sync for ULID
[src]
impl Unpin for ULID
[src]
impl UnwindSafe for ULID
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,