[PR #2231] [MERGED] refactor the Resource data structure #2890

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

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/2231
Author: @japaric
Created: 6/7/2024
Status: Merged
Merged: 6/11/2024
Merged by: @bluejekyll

Base: mainHead: ja-refactor-resource


📝 Commits (1)

  • 869ee36 refactor the Resource data structure

📊 Changes

55 files changed (+1021 additions, -1457 deletions)

View changed files

📝 bin/tests/named_tests.rs (+2 -2)
📝 bin/tests/server_harness/mod.rs (+3 -3)
📝 crates/client/src/client/async_client.rs (+5 -4)
📝 crates/client/src/lib.rs (+2 -2)
📝 crates/proto/src/h2/h2_client_stream.rs (+7 -13)
📝 crates/proto/src/h3/h3_client_stream.rs (+7 -13)
📝 crates/proto/src/op/edns.rs (+5 -11)
📝 crates/proto/src/op/message.rs (+6 -6)
📝 crates/proto/src/op/update_message.rs (+8 -11)
📝 crates/proto/src/rr/dnssec/rdata/tsig.rs (+13 -13)
📝 crates/proto/src/rr/dnssec/signer.rs (+76 -113)
📝 crates/proto/src/rr/dnssec/tbs.rs (+2 -8)
📝 crates/proto/src/rr/dnssec/tsig.rs (+1 -1)
📝 crates/proto/src/rr/mod.rs (+5 -0)
crates/proto/src/rr/rdata/update.rs (+1 -0)
📝 crates/proto/src/rr/record_data.rs (+11 -0)
📝 crates/proto/src/rr/resource.rs (+58 -165)
📝 crates/proto/src/rr/rr_set.rs (+115 -132)
📝 crates/proto/src/serialize/txt/rdata_parsers/svcb.rs (+1 -6)
📝 crates/proto/src/serialize/txt/zone.rs (+11 -14)

...and 35 more files

📄 Description

the rr_type field has been removed. this eliminates the possibility of setting rdata to a type that does not match rr_type. as a consequence, the set_record_type has also been removed

the record_type of the Resource is now derived from what's stored in the rdata field

rdata is no longer an Option. rdata = None was being used to represent update records. an Update variant has been added to the RData enum. this variant is used to represent update records, which have RDLENGTH set to 0.

the Resource::{default,new} constructors have been removed. they felt error prone as in most cases one wants to set the rdata and name fields since they have no sensible defaults. all uses of those constructors now use the pre-existing from_rdata constructor

the Resource::with constructor has also been removed. it was pretty similar to from_rdata but initialized rr_type and not rdata. all uses of Record::with has been changed to from_rdata

closes #2211


🔄 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/2231 **Author:** [@japaric](https://github.com/japaric) **Created:** 6/7/2024 **Status:** ✅ Merged **Merged:** 6/11/2024 **Merged by:** [@bluejekyll](https://github.com/bluejekyll) **Base:** `main` ← **Head:** `ja-refactor-resource` --- ### 📝 Commits (1) - [`869ee36`](https://github.com/hickory-dns/hickory-dns/commit/869ee364789c99ef3f0bbb312f2a14bd8147c957) refactor the `Resource` data structure ### 📊 Changes **55 files changed** (+1021 additions, -1457 deletions) <details> <summary>View changed files</summary> 📝 `bin/tests/named_tests.rs` (+2 -2) 📝 `bin/tests/server_harness/mod.rs` (+3 -3) 📝 `crates/client/src/client/async_client.rs` (+5 -4) 📝 `crates/client/src/lib.rs` (+2 -2) 📝 `crates/proto/src/h2/h2_client_stream.rs` (+7 -13) 📝 `crates/proto/src/h3/h3_client_stream.rs` (+7 -13) 📝 `crates/proto/src/op/edns.rs` (+5 -11) 📝 `crates/proto/src/op/message.rs` (+6 -6) 📝 `crates/proto/src/op/update_message.rs` (+8 -11) 📝 `crates/proto/src/rr/dnssec/rdata/tsig.rs` (+13 -13) 📝 `crates/proto/src/rr/dnssec/signer.rs` (+76 -113) 📝 `crates/proto/src/rr/dnssec/tbs.rs` (+2 -8) 📝 `crates/proto/src/rr/dnssec/tsig.rs` (+1 -1) 📝 `crates/proto/src/rr/mod.rs` (+5 -0) ➕ `crates/proto/src/rr/rdata/update.rs` (+1 -0) 📝 `crates/proto/src/rr/record_data.rs` (+11 -0) 📝 `crates/proto/src/rr/resource.rs` (+58 -165) 📝 `crates/proto/src/rr/rr_set.rs` (+115 -132) 📝 `crates/proto/src/serialize/txt/rdata_parsers/svcb.rs` (+1 -6) 📝 `crates/proto/src/serialize/txt/zone.rs` (+11 -14) _...and 35 more files_ </details> ### 📄 Description the `rr_type` field has been removed. this eliminates the possibility of setting `rdata` to a type that does not match `rr_type`. as a consequence, the `set_record_type` has also been removed the `record_type` of the `Resource` is now derived from what's stored in the `rdata` field `rdata` is no longer an `Option`. `rdata = None` was being used to represent update records. an `Update` variant has been added to the `RData` enum. this variant is used to represent update records, which have RDLENGTH set to 0. the `Resource::{default,new}` constructors have been removed. they felt error prone as in most cases one wants to set the `rdata` and `name` fields since they have no sensible defaults. all uses of those constructors now use the pre-existing `from_rdata` constructor the `Resource::with` constructor has also been removed. it was pretty similar to `from_rdata` but initialized `rr_type` and not `rdata`. all uses of `Record::with` has been changed to `from_rdata` closes #2211 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 11:13:53 +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#2890
No description provided.