| ... | @@ -75,6 +75,10 @@ pub fn BinValue(comptime max_len: usize) type { | ... | @@ -75,6 +75,10 @@ pub fn BinValue(comptime max_len: usize) type { |
| 75 | /// | 75 | /// |
| 76 | /// Other fields will also be deserialized from the function parameters section. | 76 | /// Other fields will also be deserialized from the function parameters section. |
| 77 | pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult { | 77 | pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult { |
| | 78 | if (@hasField(HashResult, version_param_name)) { |
| | 79 | @compileError("Field name '" ++ version_param_name ++ "'' is reserved for the algorithm version"); |
| | 80 | } |
| | 81 | |
| 78 | var out = mem.zeroes(HashResult); | 82 | var out = mem.zeroes(HashResult); |
| 79 | var it = mem.splitScalar(u8, str, fields_delimiter_scalar); | 83 | var it = mem.splitScalar(u8, str, fields_delimiter_scalar); |
| 80 | var set_fields: usize = 0; | 84 | var set_fields: usize = 0; |
| ... | @@ -198,6 +202,11 @@ pub fn calcSize(params: anytype) usize { | ... | @@ -198,6 +202,11 @@ pub fn calcSize(params: anytype) usize { |
| 198 | | 202 | |
| 199 | fn serializeTo(params: anytype, out: anytype) !void { | 203 | fn serializeTo(params: anytype, out: anytype) !void { |
| 200 | const HashResult = @TypeOf(params); | 204 | const HashResult = @TypeOf(params); |
| | 205 | |
| | 206 | if (@hasField(HashResult, version_param_name)) { |
| | 207 | @compileError("Field name '" ++ version_param_name ++ "'' is reserved for the algorithm version"); |
| | 208 | } |
| | 209 | |
| 201 | try out.writeAll(fields_delimiter); | 210 | try out.writeAll(fields_delimiter); |
| 202 | try out.writeAll(params.alg_id); | 211 | try out.writeAll(params.alg_id); |
| 203 | | 212 | |