Skip to content

Commit

Permalink
Merge pull request #1 from t3hmrman/feat/add-output-as-bytes
Browse files Browse the repository at this point in the history
feat: support outputting bytes
  • Loading branch information
jedisct1 authored Oct 30, 2023
2 parents 88afaf5 + dc879f8 commit aeda91a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ impl UUIDv6 {
}
}

/// Return the next UUIDv6 string
pub fn create(&mut self) -> String {
/// Return the next bytes UUIDv6 as bytes
pub fn create_bytes(&mut self) -> [u8; 16] {
let mut buf = [0u8; 16];
let ts = self.ts;
buf[0..8].copy_from_slice(&(ts << 4).to_be_bytes());
Expand All @@ -80,6 +80,12 @@ impl UUIDv6 {

buf[10..].copy_from_slice(&self.node.node_id);

return buf;
}

/// Return the next UUIDv6 string
pub fn create(&mut self) -> String {
let buf = self.create_bytes();
let mut out = [0u8; 4 + 32];
out[8] = b'-';
out[13] = b'-';
Expand Down

0 comments on commit aeda91a

Please sign in to comment.