Crate yeast_rs[][src]

Expand description

yeast-rs is a rust implementation for the yeast JS package.

yeast is a tiny but linear growing unique id generator.


    let id :String = yeast().to_string();


Using the function:

    let first_id :Yeast = yeast();
    let second_id :Yeast = yeast();
    let third_id :Yeast = yeast();

    // Based on the same timestamp but different values
    assert_ne!(first_id.to_string(), second_id.to_string());
    assert_eq!(first_id.timestamp_millis(), second_id.timestamp_millis());

    // Different Timestamps
    assert_ne!(first_id.timestamp_millis(), third_id.timestamp_millis());

    // Can be converted back
    let third_id_converted: Yeast = third_id.to_string().try_into().unwrap();
    assert_eq!(third_id_converted.timestamp_millis(), third_id.timestamp_millis());

Cargo features

This crate provides these cargo features:

  • async-std-runtime: include an async version of yeast built on the async-std runtime.
  • tokio-runtime: include an async version of yeast built on the tokio runtime.


support for the async-std runtime

support for the tokio runtime


A unique id, based on timestamp.


Returns a A unique id.