Skip to content

Commit

Permalink
add some missing methods/trait bounds (#318)
Browse files Browse the repository at this point in the history
This PR:
* adds a missing ?Sized bound on Message::is_answer,
* adds MessageBuilder::as_target,
* impls FreezeBuilder for StaticCompressor.
  • Loading branch information
xofyarg authored May 30, 2024
1 parent 7ebfcf3 commit 57f3475
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/base/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ impl<Octs: Octets + ?Sized> Message<Octs> {
/// The method checks whether the ID fields of the headers are the same,
/// whether the QR flag is set in this message, and whether the questions
/// are the same.
pub fn is_answer<Other: Octets>(&self, query: &Message<Other>) -> bool {
pub fn is_answer<Other: Octets + ?Sized>(
&self,
query: &Message<Other>,
) -> bool {
if !self.header().qr()
|| self.header().id() != query.header().id()
|| self.header_counts().qdcount()
Expand Down
13 changes: 13 additions & 0 deletions src/base/message_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,11 @@ impl<'a, Target: Composer + ?Sized> OptBuilder<'a, Target> {
let start = self.start;
OptHeader::for_record_slice_mut(&mut self.target.as_mut()[start..])
}

/// Returns a reference to the underlying octets builder.
pub fn as_target(&self) -> &Target {
self.target
}
}

//------------ StreamTarget --------------------------------------------------
Expand Down Expand Up @@ -2050,6 +2055,14 @@ impl<Target: Truncate> Truncate for StaticCompressor<Target> {
}
}

impl<Target: FreezeBuilder> FreezeBuilder for StaticCompressor<Target> {
type Octets = Target::Octets;

fn freeze(self) -> Self::Octets {
self.target.freeze()
}
}

//------------ TreeCompressor ------------------------------------------------

/// A domain name compressor that uses a tree.
Expand Down

0 comments on commit 57f3475

Please sign in to comment.