-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: serde
serialization/deserialization support
#20
Conversation
Provides an optional feature to support `serde` for serializing and deserializing `NetworkInterface`, `Addr`, `V4IfAddr`, `V6IfAddr`. Resolves: #19
Cargo.toml
Outdated
@@ -13,6 +13,7 @@ readme = "README.md" | |||
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |||
[dependencies] | |||
serde = { version = "1.0.144", features = ["derive"], optional = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general when adding serde
we try to avoid including the derive
feature as it's lead to slower compile time. See this this section about derive in clap documentation about this.
Without the derive
feature, we have to impl Serialize
by hand. I think we can just copy and paste the code generated by the #[derive(Serialize)
] macro. To see the generated code we can use cargo expand.
There are many example of crate that add a serde feature without the derive, for instance Uuid or the time crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestions! I agree with you, let me apply changes and get back to you.
4251293
to
3c4661c
Compare
26be3a1
to
2263d58
Compare
@Tudyx sorry about the delay! I just pushed tests for serialization. |
Seems great to me so far, well done |
@EstebanBorai Any update on this? Really need this feature. The current release doesn't seem to support serialize or deserialize. |
Hi @HuakunShen! I have not worked on this for a while. The goal was to speed up compile times by implementing the trait manually over using I think we can merge your PR and work on this later as an optimization. Thanks so much! |
Provides an optional feature to support
serde
for serializingand deserializing
NetworkInterface
,Addr
,V4IfAddr
,V6IfAddr
.Resolves: #19