pub struct IdGeneratorOptions {
pub method: Option<u8>,
pub base_time: Option<i64>,
pub worker_id: Option<u32>,
pub worker_id_bit_len: Option<u8>,
pub seq_bit_len: Option<u8>,
pub max_seq_num: Option<u32>,
pub min_seq_num: Option<u32>,
pub top_over_cost_count: Option<u32>,
}Expand description
Options for CoreIdGenerator
§Parameters
method: 1 means snowflake with shift.base_time: base time of the snowflake algorithm, in milliseconds, can not exceed the current system time.worker_id: should be decided externally, smaller than2^worker_id_bit_len-1.worker_id_bit_len: the bit length of worker_id, default to 8, in range [1, 15].worker_id_bit_len + seq_bit_lenshould be less than 22.seq_bit_len: the bit length of sequence, default to 8, in range [3, 21].max_seq_num: set the range of [min_seq_num, 2^seq_bit_len-1], default to 0 meaning2^seq_bit_len-1.min_seq_num: default to 5, range [5, max_seq_num], reserved for manually value and time turned back.top_over_cost_count: max shift count(included), default to 2000, recommended range is [500, 20000] (associated with computing ability).
Fields§
§method: Option<u8>Snowflake 1 for shift
base_time: Option<i64>base time (in milliseconds), can not exceed the current system time
worker_id: Option<u32>should be decided externally, smaller than 2^worker_id_bit_len-1
worker_id_bit_len: Option<u8>worker_id_bit_len + seq_bit_len should be less than 22
default to 8, in range [1, 15]
seq_bit_len: Option<u8>default to 8, in range [3, 21]
max_seq_num: Option<u32>set the range of [min_seq_num, 2^seq_bit_len-1], default to 0 meaning 2^seq_bit_len-1
min_seq_num: Option<u32>default to 5, range [5, max_seq_num], reserved for manually value and time turned back
top_over_cost_count: Option<u32>max shift count(included), default to 2000, recommended range is [500, 20000] (associated with computing ability)
Implementations§
Source§impl IdGeneratorOptions
impl IdGeneratorOptions
pub fn new() -> Self
pub fn method(self, method: u8) -> Self
pub fn base_time(self, base_time: i64) -> Self
pub fn worker_id(self, worker_id: u32) -> Self
pub fn worker_id_bit_len(self, worker_id_bit_len: u8) -> Self
pub fn seq_bit_len(self, seq_bit_len: u8) -> Self
pub fn max_seq_num(self, max_seq_num: u32) -> Self
pub fn min_seq_num(self, min_seq_num: u32) -> Self
pub fn top_over_cost_count(self, top_over_cost_count: u32) -> Self
Trait Implementations§
Source§impl Clone for IdGeneratorOptions
impl Clone for IdGeneratorOptions
Source§fn clone(&self) -> IdGeneratorOptions
fn clone(&self) -> IdGeneratorOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IdGeneratorOptions
impl Debug for IdGeneratorOptions
Source§impl Default for IdGeneratorOptions
impl Default for IdGeneratorOptions
Source§fn default() -> IdGeneratorOptions
fn default() -> IdGeneratorOptions
Returns the “default value” for a type. Read more
Source§impl PartialEq for IdGeneratorOptions
impl PartialEq for IdGeneratorOptions
impl StructuralPartialEq for IdGeneratorOptions
Auto Trait Implementations§
impl Freeze for IdGeneratorOptions
impl RefUnwindSafe for IdGeneratorOptions
impl Send for IdGeneratorOptions
impl Sync for IdGeneratorOptions
impl Unpin for IdGeneratorOptions
impl UnwindSafe for IdGeneratorOptions
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