Struct idgenerator::options::IdGeneratorOptions
source · [−]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_len
should 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
sourceimpl 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
sourceimpl Clone for IdGeneratorOptions
impl Clone for IdGeneratorOptions
sourcefn clone(&self) -> IdGeneratorOptions
fn clone(&self) -> IdGeneratorOptions
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for IdGeneratorOptions
impl Debug for IdGeneratorOptions
sourceimpl Default for IdGeneratorOptions
impl Default for IdGeneratorOptions
sourcefn default() -> IdGeneratorOptions
fn default() -> IdGeneratorOptions
Returns the “default value” for a type. Read more
sourceimpl PartialEq<IdGeneratorOptions> for IdGeneratorOptions
impl PartialEq<IdGeneratorOptions> for IdGeneratorOptions
sourcefn eq(&self, other: &IdGeneratorOptions) -> bool
fn eq(&self, other: &IdGeneratorOptions) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &IdGeneratorOptions) -> bool
fn ne(&self, other: &IdGeneratorOptions) -> bool
This method tests for !=
.
impl StructuralPartialEq for IdGeneratorOptions
Auto Trait Implementations
impl RefUnwindSafe for IdGeneratorOptions
impl Send for IdGeneratorOptions
impl Sync for IdGeneratorOptions
impl Unpin for IdGeneratorOptions
impl UnwindSafe for IdGeneratorOptions
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more