So I guess this is gonna be the 3rd MessagePack library here GitHub - uyha/mzg: A MessagePack library for Zig
Thanks for sharing! Welcome to the message pack club!
Yeah I don’t think any of us have settled on a good way for customizations yet, and I didn’t even figure out how to correctly use the writer interface.
Also the writer interface is expected to change soon.
The way I did customizations was to generate a type for the value passed for serialization, which honestly was bad since it’s almost impossible for the user to figure out what options there are.
Yeah I don’t think any of us have settled on a good way for customizations yet
For customization, I just followed strictly the way that std.json
does it. What surprised me the most was the adapters since I did not originally plan for it. They just kinda fell off the sky when I saw that I can simply check for mzgPack
/mzgUnpack
at the very beginning. I was originally planning to wrap containers like std.ArrayList
in a struct like
fn ArrayAdapter(comptime T: type) type {
return struct {
container: std.ArrayList(T),
// More details
};
};
but then the users have to access the data like adapter.container.items
which I did not like at all, and with the current approach, they wrap the containers themselves and the containers get modified directly, which I like very much.
and I didn’t even figure out how to correctly use the writer interface.
I’m not sure how to use it correctly also, so I just settled on using only the writeAll
function, so that if something changes, I can change it easily.