[GH-ISSUE #490] Add (optional) serde support for types in trust_dns_resolver::config #205

Closed
opened 2026-03-07 22:47:51 +03:00 by kerem · 6 comments
Owner

Originally created by @kingoflolz on GitHub (May 25, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/490

Hi,

I am building an application which will use trust-dns-resolver and I would like to have a config file where the user can specify which DNS server to use. Adding serde as an optional dependency and optionally deriving Serialize and Deserialize on the config types would make this much easier. Is this something that you would be interested in adding?

I would be happy to provide a PR for this.

Thanks

Originally created by @kingoflolz on GitHub (May 25, 2018). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/490 Hi, I am building an application which will use trust-dns-resolver and I would like to have a config file where the user can specify which DNS server to use. Adding serde as an optional dependency and optionally deriving Serialize and Deserialize on the config types would make this much easier. Is this something that you would be interested in adding? I would be happy to provide a PR for this. Thanks
kerem closed this issue 2026-03-07 22:47:56 +03:00
Author
Owner

@bluejekyll commented on GitHub (May 25, 2018):

I'd prefer to not pull a dependency on Serde right now, to be clear, we are trying to keep the number of dependencies in the Resolver limited so that it fits with various use cases where there is a desire to have a small set of dependencies, in fact there are probably many that we should be considering for removal.

It's possible this might work: https://serde.rs/remote-derive.html

Something along the lines of:

#[derive(Serialize, Deserialize)]
struct TrustDnsConfig(ResolverConfig);

See how far that gets you... If that's successful, we could add another crate for Serde derived configurations to help people in similar situations.

<!-- gh-comment-id:392133889 --> @bluejekyll commented on GitHub (May 25, 2018): I'd prefer to not pull a dependency on Serde right now, to be clear, we are trying to keep the number of dependencies in the Resolver limited so that it fits with various use cases where there is a desire to have a small set of dependencies, in fact there are probably many that we should be considering for removal. It's possible this might work: https://serde.rs/remote-derive.html Something along the lines of: ```rust #[derive(Serialize, Deserialize)] struct TrustDnsConfig(ResolverConfig); ``` See how far that gets you... If that's successful, we could add another crate for Serde derived configurations to help people in similar situations.
Author
Owner

@kingoflolz commented on GitHub (May 26, 2018):

@bluejekyll using remote derive should work, but I think it will be better to build serde support in so it would be more seamless. We can use a cargo feature to ensure there are no additional deps by default, and people who need it can opt into using serde.

<!-- gh-comment-id:392230197 --> @kingoflolz commented on GitHub (May 26, 2018): @bluejekyll using remote derive should work, but I think it will be better to build serde support in so it would be more seamless. We can use a cargo feature to ensure there are no additional deps by default, and people who need it can opt into using serde.
Author
Owner

@bluejekyll commented on GitHub (May 26, 2018):

@briansmith, I think you’d have the biggest concern here...

<!-- gh-comment-id:392230283 --> @bluejekyll commented on GitHub (May 26, 2018): @briansmith, I think you’d have the biggest concern here...
Author
Owner

@briansmith commented on GitHub (May 26, 2018):

@briansmith, I think you’d have the biggest concern here...

I don't have a good answer. If this were my project I would probably wouldn't do it, just due to lack of time to fully think through all the implications of doing it.

<!-- gh-comment-id:392282566 --> @briansmith commented on GitHub (May 26, 2018): > @briansmith, I think you’d have the biggest concern here... I don't have a good answer. If this were my project I would probably wouldn't do it, just due to lack of time to fully think through all the implications of doing it.
Author
Owner

@bluejekyll commented on GitHub (May 26, 2018):

Thanks, @briansmith.

@kingoflolz there is this issue: #483, which may be of interest. I think that might end up needing some serde derivable configs as well. I did add this to the server crate. My concern is that with the resolver we want to keep the dependencies slim as we want it to be able to be embedded in many different contexts, and config files would generally only be for binaries.

I suppose if we keep this as optional, and off by default, then that would be ok, though I am curious what it would look like to have a separate crate for this glue...

<!-- gh-comment-id:392291066 --> @bluejekyll commented on GitHub (May 26, 2018): Thanks, @briansmith. @kingoflolz there is this issue: #483, which may be of interest. I think that might end up needing some serde derivable configs as well. I did add this to the server crate. My concern is that with the resolver we want to keep the dependencies slim as we want it to be able to be embedded in many different contexts, and config files would generally only be for binaries. I suppose if we keep this as optional, and off by default, then that would be ok, though I am curious what it would look like to have a separate crate for this glue...
Author
Owner

@kingoflolz commented on GitHub (May 27, 2018):

@bluejekyll Thanks for your reply, I'll create a PR adding it as an optional feature to structs in trust-dns-resolver::conf::* (at least for now), and I'll make it off by default.

P.S. Serde provides external derives which alleviate most of the issue, however, they are less ergonomic to use (have to specify a #[serde(with = "")] every time its (de)/serialized)

<!-- gh-comment-id:392334737 --> @kingoflolz commented on GitHub (May 27, 2018): @bluejekyll Thanks for your reply, I'll create a PR adding it as an optional feature to structs in trust-dns-resolver::conf::* (at least for now), and I'll make it off by default. P.S. Serde provides external derives which alleviate most of the issue, however, they are less ergonomic to use (have to specify a #[serde(with = "")] every time its (de)/serialized)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#205
No description provided.