turbonss/lib/validate.zig
Motiejus Jakštys a8b45911aa weekend changes
- move main.zig to it's own package, create lib/
- rename AllSections to DB, remove intermediate tuples
- iovec does not allocate
- remove error{Overflow} from almost everywhere
2022-03-23 12:01:13 +02:00

16 lines
387 B
Zig

const std = @import("std");
pub fn downCast(comptime T: type, n: u64) error{InvalidRecord}!T {
return std.math.cast(T, n) catch |err| switch (err) {
error.Overflow => {
return error.InvalidRecord;
},
};
}
pub fn utf8(s: []const u8) error{InvalidRecord}!void {
if (!std.unicode.utf8ValidateSlice(s)) {
return error.InvalidRecord;
}
}