[PR #2877] [MERGED] feat(resolver): add a ResolverBuilder::with_options() method #3394

Closed
opened 2026-03-16 11:41:11 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/2877
Author: @cratelyn
Created: 3/20/2025
Status: Merged
Merged: 4/3/2025
Merged by: @djc

Base: mainHead: add-with-options-method-to-resolver-builder


📝 Commits (2)

  • 807aabf feat(resolver): add a ResolverBuilder::with_options() method
  • 508a87b review(resolver): add note about registry defaults

📊 Changes

1 file changed (+13 additions, -0 deletions)

View changed files

📝 crates/resolver/src/resolver.rs (+13 -0)

📄 Description

this commit introduces a new method to hickory-resolver's Builder structure.

in the v0.24 release, users of the DNS lookup Resolver could provide configuration (ResolverConfig) and and options (ResolverOpts) to the Resolver::new(..) constructor.

as of the v0.25 release, builders are now acquired by calling Resolver::builder(), Resolver::builder_tokio(), or Resolver::builder_with_config()

these can be used to provide a P-typed connection provider, and the resolver configuration. there is not however, a way for callers to set the resolver options without assigning options via Resolver::options_mut().

this requires binding the builder to a temporary variable however, resulting in code shaped approximately like so:

let mut builder = hickory_resolver::Resolver::builder_tokio();
*builder.options_mut() = opts;
let dns = builder.build();

this commit adds a with_options() method, so that a dns resolver can be constructed using builder-style api calls.

let dns = hickory_resolver::Resolver::builder_tokio()
    .with_options(opts)
    .build();

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/2877 **Author:** [@cratelyn](https://github.com/cratelyn) **Created:** 3/20/2025 **Status:** ✅ Merged **Merged:** 4/3/2025 **Merged by:** [@djc](https://github.com/djc) **Base:** `main` ← **Head:** `add-with-options-method-to-resolver-builder` --- ### 📝 Commits (2) - [`807aabf`](https://github.com/hickory-dns/hickory-dns/commit/807aabfaceee2a3acee78671076846c9eb8a515e) feat(resolver): add a `ResolverBuilder::with_options()` method - [`508a87b`](https://github.com/hickory-dns/hickory-dns/commit/508a87b344278811533bbdf37c83d63544f52437) review(resolver): add note about registry defaults ### 📊 Changes **1 file changed** (+13 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/resolver/src/resolver.rs` (+13 -0) </details> ### 📄 Description this commit introduces a new method to `hickory-resolver`'s `Builder` structure. in the v0.24 release, users of the DNS lookup `Resolver` could provide configuration (`ResolverConfig`) and and options (`ResolverOpts`) to the `Resolver::new(..)` constructor. as of the v0.25 release, builders are now acquired by calling `Resolver::builder()`, `Resolver::builder_tokio()`, or `Resolver::builder_with_config()` these can be used to provide a `P`-typed connection provider, and the resolver configuration. there is not however, a way for callers to set the resolver options without assigning options via `Resolver::options_mut()`. this requires binding the builder to a temporary variable however, resulting in code shaped approximately like so: ```rust let mut builder = hickory_resolver::Resolver::builder_tokio(); *builder.options_mut() = opts; let dns = builder.build(); ``` this commit adds a `with_options()` method, so that a dns resolver can be constructed using builder-style api calls. ```rust let dns = hickory_resolver::Resolver::builder_tokio() .with_options(opts) .build(); ``` * https://github.com/hickory-dns/hickory-dns/pull/2830 * https://docs.rs/hickory-resolver/0.24.4/hickory_resolver/struct.Resolver.html#method.new * https://docs.rs/hickory-resolver/latest/hickory_resolver/struct.ResolverBuilder.html#method.options_mut * https://docs.rs/hickory-resolver/latest/hickory_resolver/struct.Resolver.html#method.builder_with_config --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 11:41:11 +03:00
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#3394
No description provided.