| Crates.io | tiltflake |
| lib.rs | tiltflake |
| version | 0.2.1 |
| created_at | 2025-04-08 19:16:00.146395+00 |
| updated_at | 2025-04-09 17:00:01.186872+00 |
| description | Tiltflake is a distributed database that uses the flake algorithm to generate unique IDs. |
| homepage | |
| repository | https://github.com/t1ltxz-gxd/tiltflake |
| max_upload_size | |
| id | 1625847 |
| size | 94,522 |
A strict, deterministic, and time-traveling Snowflake ID generator for Rust — supports timewalk generation from SystemTime, DateTime
Add the following to your Cargo.toml file:
[dependencies]
tiltflake = {version = "*", features = ["serde"]}
use tiltflake::Tiltflake;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let generator = Tiltflake::builder().build(); // Default machine_id is 1 and epoch is Unix
let id = generator.generate_from_rfc3339("2025-04-08T12:00:00Z", 0)?;
println!("Snowflake ID: {}", id);
let (dt, machine_id, seq) = generator.parse(id);
println!(
"Parsed: {}, machine_id={}, sequence={}",
dt, machine_id, seq
);
Ok(())
}
use chrono::{TimeZone, Utc};
use tiltflake::{EpochType, Tiltflake};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let epoch = EpochType::Custom(
Utc.with_ymd_and_hms(2020, 1, 1, 0, 0, 0).single().unwrap(),
);
let generator = Tiltflake::builder()
.with_epoch(epoch)
.with_machine_id(1)
.build();
let id = generator.generate_from_rfc3339("2025-04-08T12:00:00Z", 0)?;
println!("Snowflake ID: {}", id);
let (dt, machine_id, seq) = generator.parse(id);
println!(
"Parsed: {}, machine_id={}, sequence={}",
dt, machine_id, seq
);
Ok(())
}
use tiltflake::{EpochType, Tiltflake};
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let generator = Tiltflake::builder()
.with_machine_id(1)
.with_epoch(EpochType::Discord)
.build();
let id = generator.generate_from_rfc3339("2025-04-08T12:00:00Z", 0)?;
println!("Snowflake ID: {}", id);
let (dt, machine_id, seq) = generator.parse(id);
println!(
"Parsed: {}, machine_id={}, sequence={}",
dt, machine_id, seq
);
Ok(())
}
examples folder.Contributions are what make the open source community an amazing place to learn, be inspired, and create. Any contributions you make are greatly appreciated.
git clone https://github.com/t1ltxz-gxd/tiltflake.gitgit checkout -b feat-smth-amazinggit add .git commit -m 'feat: add some amazing feature'
fix, feat, docs, style, refactor, perf, test, chore prefixes.git push origin feat-smth-amazingReleased with ❤️ by Tilt.