Skip to content

Serde Deserialize+Serialize implementation#440

Open
rabbit-time wants to merge 3 commits intokeepsimple1:mainfrom
rabbit-time:main
Open

Serde Deserialize+Serialize implementation#440
rabbit-time wants to merge 3 commits intokeepsimple1:mainfrom
rabbit-time:main

Conversation

@rabbit-time
Copy link

This PR introduces a new feature flag: serde

I've implemented the Serialize and Deserialize traits using derive for ResolvedService and for all the local types which it contains.

Additionally, I've also written a basic test to accompany the changes and added serde_json as a development dependency.

If there is a benefit to providing serde support for types other than ResolvedService, please comment that.

Closes: #438

@rabbit-time
Copy link
Author

CI jobs are currently failing since clippy isn't being run with features enabled.

Line 1286 in ./src/service_info.rs:
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]

Copy link
Owner

@keepsimple1 keepsimple1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! One inline comment related to the CI error. And optional, if you have bandwidth, you can also add a new step in CI to run cargo clippy --tests --all-features -- -D warnings to cover the features (I think).

assert!(service_info.is_address_supported(&intf_loopback_v6));
}

#[test]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add #[cfg(feature = "serde")] here, which would also fix the CI error, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Deserialize/Serialize for mdns-sd types

2 participants