Skip to content

Commit ef3de5a

Browse files
committed
Add NsecRdata setters and update examples
1 parent 5888468 commit ef3de5a

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

src/message/rdata/nsec_rdata.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl NsecRdata{
3030
/// Returns the next_domain_name of the `NsecRdata`.
3131
/// # Example
3232
/// ```
33-
/// let nsec_rdata = NsecRdata::new(String::from("www.example.com"), vec![Rtype::A, Rtype::NS]);
33+
/// let nsec_rdata = NsecRdata::new(DomainName::new_from_str("example.com"), vec![Rtype::A, Rtype::NS]);
3434
/// assert_eq!(nsec_rdata.get_next_domain_name().get_name(), String::from("www.example.com"));
3535
/// ```
3636
pub fn get_next_domain_name(&self) -> DomainName {
@@ -40,10 +40,36 @@ impl NsecRdata{
4040
/// Returns the type_bit_maps of the `NsecRdata`.
4141
/// # Example
4242
/// ```
43-
/// let nsec_rdata = NsecRdata::new(String::from("www.example.com"), vec![Rtype::A, Rtype::NS]);
43+
/// let nsec_rdata = NsecRdata::new(DomainName::new_from_str("example.com"), vec![Rtype::A, Rtype::NS]);
4444
/// assert_eq!(nsec_rdata.get_type_bit_maps(), vec![Rtype::A, Rtype::NS]);
4545
/// ```
4646
pub fn get_type_bit_maps(&self) -> Vec<Rtype> {
4747
self.type_bit_maps.clone()
4848
}
49+
}
50+
51+
impl NsecRdata{
52+
/// Setters
53+
54+
/// Set the next_domain_name of the `NsecRdata`.
55+
/// # Example
56+
/// ```
57+
/// let mut nsec_rdata = NsecRdata::new(DomainName::new_from_str("example.com"), vec![Rtype::A, Rtype::NS]);
58+
/// nsec_rdata.set_next_domain_name(DomainName::new_from_str("www.example2.com"));
59+
/// assert_eq!(nsec_rdata.get_next_domain_name().get_name(), String::from("www.example2.com"));
60+
/// ```
61+
pub fn set_next_domain_name(&mut self, next_domain_name: DomainName) {
62+
self.next_domain_name = next_domain_name;
63+
}
64+
65+
/// Set the type_bit_maps of the `NsecRdata`.
66+
/// # Example
67+
/// ```
68+
/// let mut nsec_rdata = NsecRdata::new(DomainName::new_from_str("example.com"), vec![Rtype::A, Rtype::NS]);
69+
/// nsec_rdata.set_type_bit_maps(vec![Rtype::A, Rtype::NS, Rtype::CNAME]);
70+
/// assert_eq!(nsec_rdata.get_type_bit_maps(), vec![Rtype::A, Rtype::NS, Rtype::CNAME]);
71+
/// ```
72+
pub fn set_type_bit_maps(&mut self, type_bit_maps: Vec<Rtype>) {
73+
self.type_bit_maps = type_bit_maps;
74+
}
4975
}

0 commit comments

Comments
 (0)