| ... | @@ -36,7 +36,7 @@ pub const ULID = struct { | ... | @@ -36,7 +36,7 @@ pub const ULID = struct { |
| 36 | | 36 | |
| 37 | pub const BaseType = string; | 37 | pub const BaseType = string; |
| 38 | | 38 | |
| 39 | pub fn readField(alloc: *std.mem.Allocator, value: BaseType) !ULID { | 39 | pub fn parse(alloc: *std.mem.Allocator, value: BaseType) !ULID { |
| 40 | if (value.len != 26) return error.Ulid; | 40 | if (value.len != 26) return error.Ulid; |
| 41 | return ULID{ | 41 | return ULID{ |
| 42 | .timestamp = try std.math.cast(u48, try extras.sliceToInt(u50, u5, try base32.decode(alloc, value[0..10]))), | 42 | .timestamp = try std.math.cast(u48, try extras.sliceToInt(u50, u5, try base32.decode(alloc, value[0..10]))), |
| ... | @@ -44,15 +44,15 @@ pub const ULID = struct { | ... | @@ -44,15 +44,15 @@ pub const ULID = struct { |
| 44 | }; | 44 | }; |
| 45 | } | 45 | } |
| 46 | | 46 | |
| 47 | pub fn bindField(self: ULID, alloc: *std.mem.Allocator) !BaseType { | 47 | pub fn toString(self: ULID, alloc: *std.mem.Allocator) !BaseType { |
| 48 | var res = try std.ArrayList(u8).initCapacity(alloc, 26); | 48 | var res = try std.ArrayList(u8).initCapacity(alloc, 26); |
| 49 | defer res.deinit(); | 49 | defer res.deinit(); |
| 50 | try res.writer().print("{}", .{self}); | 50 | try res.writer().print("{}", .{self}); |
| 51 | return res.toOwnedSlice(); | 51 | return res.toOwnedSlice(); |
| 52 | } | 52 | } |
| 53 | | 53 | |
| 54 | pub const fromString = readField; | 54 | pub const readField = parse; |
| 55 | pub const toString = bindField; | 55 | pub const bindField = toString; |
| 56 | | 56 | |
| 57 | pub fn format(self: ULID, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { | 57 | pub fn format(self: ULID, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { |
| 58 | _ = fmt; | 58 | _ = fmt; |