[GH-ISSUE #1266] Inconsistent function signatures for ServerFuture::register_* #636

Closed
opened 2026-03-15 23:34:20 +03:00 by kerem · 1 comment
Owner

Originally created by @jonasbb on GitHub (Oct 26, 2020).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1266

I noticed that some register_* functions on ServerFuture have inconsistent type signatures regarding their error value. Namely, the UDP functions do not return a Result, but can panic, whereas the TCP ones return a Result where not necessary.

UDP:

This one does not have any error it could return.
github.com/bluejekyll/trust-dns@1b8f865066/crates/server/src/server/server_future.rs (L53-L54)

This one panics instead of returning a result.
github.com/bluejekyll/trust-dns@1b8f865066/crates/server/src/server/server_future.rs (L96-L99)

TCP:

This one returns a result but it can never return an error.
github.com/bluejekyll/trust-dns@1b8f865066/crates/server/src/server/server_future.rs (L113-L117)

This one is ok.
github.com/bluejekyll/trust-dns@1b8f865066/crates/server/src/server/server_future.rs (L196-L202)

I haven't checked how the TLS versions are.
It seems weird to panic in the UDP case but return a result for TCP.
I would expect to only return a result if an error could occur or, to keep the function signatures closer aligned, always return a result.

Originally created by @jonasbb on GitHub (Oct 26, 2020). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1266 I noticed that some `register_*` functions on `ServerFuture` have inconsistent type signatures regarding their error value. Namely, the UDP functions do not return a `Result`, but can panic, whereas the TCP ones return a `Result` where not necessary. UDP: This one does not have any error it could return. https://github.com/bluejekyll/trust-dns/blob/1b8f865066418fa80ada2f19bbb99c07e45caa6d/crates/server/src/server/server_future.rs#L53-L54 This one panics instead of returning a result. https://github.com/bluejekyll/trust-dns/blob/1b8f865066418fa80ada2f19bbb99c07e45caa6d/crates/server/src/server/server_future.rs#L96-L99 TCP: This one returns a result but it can never return an error. https://github.com/bluejekyll/trust-dns/blob/1b8f865066418fa80ada2f19bbb99c07e45caa6d/crates/server/src/server/server_future.rs#L113-L117 This one is ok. https://github.com/bluejekyll/trust-dns/blob/1b8f865066418fa80ada2f19bbb99c07e45caa6d/crates/server/src/server/server_future.rs#L196-L202 I haven't checked how the TLS versions are. It seems weird to panic in the UDP case but return a result for TCP. I would expect to only return a result if an error could occur or, to keep the function signatures closer aligned, always return a result.
kerem closed this issue 2026-03-15 23:34:25 +03:00
Author
Owner

@djc commented on GitHub (Oct 27, 2020):

Fair enough, see #1267. I think I prefer being precise about what errors may be returned over being consistent.

<!-- gh-comment-id:717127317 --> @djc commented on GitHub (Oct 27, 2020): Fair enough, see #1267. I think I prefer being precise about what errors may be returned over being consistent.
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#636
No description provided.