rrefactor

This commit is contained in:
2025-03-16 08:02:29 +01:00
parent 3b1068a3a8
commit 4796e4fe82
37 changed files with 896 additions and 115 deletions

View File

@@ -13,6 +13,8 @@ pub fn encode[T](obj T) ![]u8 {
$if field.typ is string {
// $(string_expr) produces an identifier
d.add_string(obj.$(field.name).str())
} $else $if field.typ is bool {
d.add_bool(bool(obj.$(field.name)))
} $else $if field.typ is int {
d.add_int(int(obj.$(field.name)))
} $else $if field.typ is u8 {
@@ -70,6 +72,8 @@ pub fn decode[T](data []u8) !T {
$if field.typ is string {
// $(string_expr) produces an identifier
result.$(field.name) = d.get_string()!
} $else $if field.typ is bool {
result.$(field.name) = d.get_bool()!
} $else $if field.typ is int {
result.$(field.name) = d.get_int()!
} $else $if field.typ is u8 {