1.Oh,the crate doc should have some questions.The bytes mod in https://docs.rs/molecule/0.7.1/molecule/ links to https://docs.rs/bytes/1.0.1/bytes/index.html.
2.If serde-rs is not good enough,why not use derive macro directly,which is more user friendly, instead? In fact,I really don’t like to install a tool to generate code. And, molecule crate seems not be able to generate code for enum.
p.s. serde-rs is a serderialize and deserialize frame,which just provide serderialize attributes.It may not change serialize logic.
First, molecule is a blockchain side-project.
So, we have to consider requirements for blockchain first.
-
why not use derive macro directly
-
Personally, I prefer to proc-macros.
-
We want to see the generated code by eyes, proc-macros hide the codes.
-
The schema files are for all languages, not only for rust.
Therefore, we don’t want to:
-
Put the schemas in rust source code.
-
Or make two copies: one in schemas files, another in rust source code.
If you were Java developers, do you want to read Rust code for the schemas?
Then you have to learn serde-rs.
-
In fact,I really don’t like to install a tool to generate code.
Try putting them in build.rs. Here is an example.
-
molecule crate seems not be able to generate code for enum.
If you mean a type alias for numbers, yes. But we have union.
-
serde-rs is a serderialize and deserialize frame,which just provide serderialize attributes.It may not change serialize logic.
How could you guarantee? Have you read the whole code of it? No one never writes bugs.
I like serde-rs but it’s too complicated. We can’t afford the risk.
p.s. If you don’t like last reason, it’s OK, but I think the first reason is enough.
1 Like
Thanks for your reply.It’s enough.