Skip to content

Commit

Permalink
Merge pull request #112 from NLnetLabs/owned-label-copy
Browse files Browse the repository at this point in the history
Add more traits impls to OwnedLabel.
  • Loading branch information
partim authored Oct 6, 2021
2 parents 40c4b65 + 3c8de67 commit 5d1dd6e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/base/name/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ impl fmt::Debug for Label {
//
// This keeps the label in wire format, so the first octet is the length
// octet, the remainder is the content.
#[derive(Clone, Copy)]
pub struct OwnedLabel([u8; 64]);

impl OwnedLabel {
Expand Down Expand Up @@ -534,6 +535,20 @@ impl hash::Hash for OwnedLabel {
}
}

//--- Display and Debug

impl fmt::Display for OwnedLabel {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.as_label().fmt(f)
}
}

impl fmt::Debug for OwnedLabel {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("OwnedLabel").field(&self.as_label()).finish()
}
}

//------------ SliceLabelsIter -----------------------------------------------

/// An iterator over the labels in an octets slice.
Expand Down

0 comments on commit 5d1dd6e

Please sign in to comment.