Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Generate A ksuid For A Specific Date And Time In Rust

I use truncated KSUIDs as IDs for content on my site. The shortcut I use to make a new posts adds them automatically. Older ones sometimes don't have them but generally have a date in the metadata. KSUIDs are sortable by date and while I don't use them specifically for that purpose I do like the idea of keeping them in order when possible.

This is the Rust process I use to make a new KSUID for a specific date.

Code

use svix_ksuid::*;
use time::macros::datetime;

fn main() {
    let raw_ksuid = Ksuid::new(Some(datetime!(2017-02-01 12:12:01 UTC)), None);
    let ksuid_string = raw_ksuid.to_string();
    println!("{}", ksuid_string);
}