Skip to main content

IdGeneratorOptions

Struct IdGeneratorOptions 

Source
#[repr(C)]
pub struct IdGeneratorOptions { pub Method: u8, pub BaseTime: i64, pub WorkerId: u32, pub WorkerIdBitLength: u8, pub SeqBitLength: u8, pub MaxSeqNumber: u32, pub MinSeqNumber: u32, pub TopOverCostCount: u32, }

Fields§

§Method: u8

雪花计算方法,(1-漂移算法|2-传统算法),默认1

§BaseTime: i64

基础时间(ms单位),不能超过当前系统时间

§WorkerId: u32

必须由外部设定,最大值 2^WorkerIdBitLength-1

§WorkerIdBitLength: u8

默认值6,取值范围 [1, 15](要求:序列数位长+机器码位长不超过22)

§SeqBitLength: u8

默认值6,取值范围 [3, 21](要求:序列数位长+机器码位长不超过22)

§MaxSeqNumber: u32

设置范围 [MinSeqNumber, 2^SeqBitLength-1],默认值0,表示最大序列数取最大值(2^SeqBitLength-1])

§MinSeqNumber: u32

默认值5,取值范围 [5, MaxSeqNumber],每毫秒的前5个序列数对应编号0-4是保留位,其中1-4是时间回拨相应预留位,0是手工新值预留位

§TopOverCostCount: u32

最大漂移次数(含),默认2000,推荐范围 500-20000(与计算能力有关)

Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.