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 than 2^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 meaning 2^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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.