Skip to content

Commit

Permalink
add mut Edns, deprecate set_option
Browse files Browse the repository at this point in the history
  • Loading branch information
leshow committed Jan 20, 2021
1 parent 636a371 commit 47f3f68
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions crates/proto/src/op/edns.rs
Expand Up @@ -115,14 +115,10 @@ impl Edns {
}

/// Set the specified EDNS option
#[deprecated(note = "Please use options_mut() to modify")]
pub fn set_option(&mut self, option: EdnsOption) {
self.options.insert(option);
}

/// Remove the option specified by the `EdnsCode`
pub fn remove_option(&mut self, option: EdnsCode) {
self.options.remove(option);
}
}

impl<'a> From<&'a Record> for Edns {
Expand Down Expand Up @@ -236,11 +232,7 @@ fn test_encode_decode() {
assert_eq!(edns.rcode_high(), edns_decode.rcode_high());
assert_eq!(edns.options(), edns_decode.options());

// remove option
edns.remove_option(EdnsCode::DAU);
assert!(edns.option(EdnsCode::DAU).is_none());

// re-insert and remove r using mut
// re-insert and remove using mut
edns.options_mut()
.insert(EdnsOption::DAU(SupportedAlgorithms::all()));
edns.options_mut().remove(EdnsCode::DAU);
Expand Down

0 comments on commit 47f3f68

Please sign in to comment.