[PR #2147] [MERGED] feat: add setter methods for Message struct to improve configurability #2841

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

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/2147
Author: @situ2001
Created: 2/16/2024
Status: Merged
Merged: 3/2/2024
Merged by: @bluejekyll

Base: mainHead: feat/add-setter-for-message-struct


📝 Commits (4)

  • 519f6a0 feat: add setter methods for Message struct to improve configurability
  • 56706c7 chore: add comments
  • 4015c77 test: Header count setting
  • 3fdf35d fix: not returning the result of a let binding from a block

📊 Changes

1 file changed (+87 additions, -1 deletions)

View changed files

📝 crates/proto/src/op/message.rs (+87 -1)

📄 Description

I've added several set_**_count methods to the Message struct to simplify the process of setting the count fields within the Header of a mutable Message instance before encoding it into binary format. Previously, to achieve this, I had to:

  1. Get a cloned header from the Message.
  2. Set the count on the cloned header.
  3. Set the modified header back as the Message's header.

Here is how I do in my production code.

let mut msg = Message::new();

// Ignored code part: init and add `Query` to `Message`
msg.add_query(q);

let mut header = msg.header().clone();
header.set_query_count(1);
msg.set_header(header);

🔄 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/2147 **Author:** [@situ2001](https://github.com/situ2001) **Created:** 2/16/2024 **Status:** ✅ Merged **Merged:** 3/2/2024 **Merged by:** [@bluejekyll](https://github.com/bluejekyll) **Base:** `main` ← **Head:** `feat/add-setter-for-message-struct` --- ### 📝 Commits (4) - [`519f6a0`](https://github.com/hickory-dns/hickory-dns/commit/519f6a0ba1b901b8fa0e828be65c0e53f407d747) feat: add setter methods for Message struct to improve configurability - [`56706c7`](https://github.com/hickory-dns/hickory-dns/commit/56706c77ec75eed77fe20951f432a5a14bbb9c24) chore: add comments - [`4015c77`](https://github.com/hickory-dns/hickory-dns/commit/4015c7754bce16f2826bb7db0217a872bafcd8bd) test: Header count setting - [`3fdf35d`](https://github.com/hickory-dns/hickory-dns/commit/3fdf35da18870557a9d186b63869eb68523aad31) fix: not returning the result of a `let` binding from a block ### 📊 Changes **1 file changed** (+87 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/proto/src/op/message.rs` (+87 -1) </details> ### 📄 Description I've added several `set_**_count` methods to the `Message` struct to simplify the process of setting the count fields within the `Header` of a mutable `Message` instance before encoding it into binary format. Previously, to achieve this, I had to: 1. Get a cloned header from the Message. 2. Set the count on the cloned header. 3. Set the modified header back as the Message's header. Here is how I do in my production code. ```rust let mut msg = Message::new(); // Ignored code part: init and add `Query` to `Message` msg.add_query(q); let mut header = msg.header().clone(); header.set_query_count(1); msg.set_header(header); ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 11:11:10 +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#2841
No description provided.