| ... | ... | @@ -56,13 +56,16 @@ pub const ULID = struct { |
| 56 | 56 | pub const readField = parse; |
| 57 | 57 | pub const bindField = toString; |
| 58 | 58 | |
| 59 | | pub fn format(self: ULID, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { |
| 60 | | _ = fmt; |
| 61 | | _ = options; |
| 62 | | |
| 59 | pub fn bytes(self: ULID) [26]u8 { |
| 63 | 60 | var buf: [26]u8 = undefined; |
| 64 | 61 | base32.formatInt(u48, self.timestamp, buf[0..10]); |
| 65 | 62 | base32.formatInt(u80, self.randomnes, buf[10..26]); |
| 66 | | try writer.writeAll(&buf); |
| 63 | return buf; |
| 64 | } |
| 65 | |
| 66 | pub fn format(self: ULID, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { |
| 67 | _ = fmt; |
| 68 | _ = options; |
| 69 | try writer.writeAll(&self.bytes()); |
| 67 | 70 | } |
| 68 | 71 | }; |