[][src]Struct snowflake::SnowflakeIdGenerator

pub struct SnowflakeIdGenerator { /* fields omitted */ }

The SnowflakeIdGenerator type is snowflake algorithm wrapper.

Implementations

impl SnowflakeIdGenerator[src]

pub fn new(machine_id: i32, node_id: i32) -> SnowflakeIdGenerator[src]

Constructs a new SnowflakeIdGenerator. Please make sure that machine_id and node_id is small than 32(2^5);

Examples

use snowflake::SnowflakeIdGenerator;

let id_generator = SnowflakeIdGenerator::new(1, 1);

pub fn real_time_generate(&mut self) -> i64[src]

The real_time_generate keep id generate time is eq call method time.

Examples

use snowflake::SnowflakeIdGenerator;

let mut id_generator = SnowflakeIdGenerator::new(1, 1);
id_generator.real_time_generate();

pub fn generate(&mut self) -> i64[src]

The basic guarantee time punctuality.

Examples

use snowflake::SnowflakeIdGenerator;

let mut id_generator = SnowflakeIdGenerator::new(1, 1);
id_generator.generate();

pub fn lazy_generate(&mut self) -> i64[src]

The lazy generate.

Examples

use snowflake::SnowflakeIdGenerator;

let mut id_generator = SnowflakeIdGenerator::new(1, 1);
id_generator.lazy_generate();

Trait Implementations

impl Clone for SnowflakeIdGenerator[src]

impl Copy for SnowflakeIdGenerator[src]

impl Debug for SnowflakeIdGenerator[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.