Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion macros/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ impl ImplSkeleton {
}

GenericParam::Type(value) => {
types.push(value.clone());
types.push(TypeParam {
// Defaults are not allowed in 'impl' blocks.
eq_token: None,
default: None,
..value.clone()
});
Comment thread
mozzieongit marked this conversation as resolved.
let id = value.ident.clone();
let id = syn::TypePath {
qself: None,
Expand Down
12 changes: 6 additions & 6 deletions src/new/base/build/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl MessageBuilder<'_, '_> {
/// The message built thus far, mutably.
///
/// Compressed names in the message must not be modified here, as the name
/// compressor relies on them. Modifying them will break name compression
/// compressor relies on them. Modifying them will break name compression
/// and result in misformatted messages.
#[must_use]
pub fn message_mut(&mut self) -> &mut Message {
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<'b> MessageBuilder<'b, '_> {
///
/// The message will not be allowed to exceed the given size, in bytes.
/// Only the message header and contents are counted; the enclosing UDP
/// or TCP packet size is not considered. If the message already exceeds
/// or TCP packet size is not considered. If the message already exceeds
/// this size, a [`TruncationError`] is returned.
pub fn limit_to(&mut self, size: usize) -> Result<(), TruncationError> {
if 12 + self.offset <= size {
Expand Down Expand Up @@ -154,7 +154,7 @@ impl<'b> MessageBuilder<'b, '_> {
/// ## Errors
///
/// If the item cannot be appended (because it needs to come before items
/// already in the message), [`Misplaced`] is returned. If the item does
/// already in the message), [`Misplaced`] is returned. If the item does
/// not fit in the message buffer, [`Truncated`] is returned.
///
/// [`Misplaced`]: MessageBuildError::Misplaced
Expand Down Expand Up @@ -203,7 +203,7 @@ impl<'b> MessageBuilder<'b, '_> {
/// ## Errors
///
/// If the item cannot be appended (because it needs to come before items
/// already in the message), [`Misplaced`] is returned. If the item does
/// already in the message), [`Misplaced`] is returned. If the item does
/// not fit in the message buffer, [`Truncated`] is returned.
///
/// [`Misplaced`]: MessageBuildError::Misplaced
Expand All @@ -221,7 +221,7 @@ impl<'b> MessageBuilder<'b, '_> {
/// ## Errors
///
/// If the item cannot be appended (because it needs to come before items
/// already in the message), [`Misplaced`] is returned. If the item does
/// already in the message), [`Misplaced`] is returned. If the item does
/// not fit in the message buffer, [`Truncated`] is returned.
///
/// [`Misplaced`]: MessageBuildError::Misplaced
Expand All @@ -239,7 +239,7 @@ impl<'b> MessageBuilder<'b, '_> {
/// ## Errors
///
/// If the item cannot be appended (because it needs to come before items
/// already in the message), [`Misplaced`] is returned. If the item does
/// already in the message), [`Misplaced`] is returned. If the item does
/// not fit in the message buffer, [`Truncated`] is returned.
///
/// [`Misplaced`]: MessageBuildError::Misplaced
Expand Down
10 changes: 5 additions & 5 deletions src/new/base/build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Building DNS messages in the wire format.
//!
//! The [`wire`](super::wire) module provides basic serialization capability,
//! but it is not specialized to DNS messages. This module provides that
//! but it is not specialized to DNS messages. This module provides that
//! specialization within an ergonomic interface.
//!
//! The core of the high-level interface is [`MessageBuilder`]. It provides
//! The core of the high-level interface is [`MessageBuilder`]. It provides
//! the most intuitive methods for appending whole questions and records.
//!
//! ```
Expand Down Expand Up @@ -77,9 +77,9 @@ pub trait BuildInMessage {
///
/// ## Errors
///
/// Fails if the message buffer is too small to fit the object. Parts of
/// Fails if the message buffer is too small to fit the object. Parts of
/// the message buffer (anything after `start`) may have been modified,
/// but should not be considered part of the initialized message. The
/// but should not be considered part of the initialized message. The
/// caller should explicitly reset the name compressor to `start` to undo
/// the effects of this function.
fn build_in_message(
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<T: BuildInMessage> BuildInMessage for [T] {
/// Write a sequence of elements to a DNS message.
///
/// If an element cannot be written due to a truncation error, the whole
/// sequence is considered to have failed. For more nuanced behaviour on
/// sequence is considered to have failed. For more nuanced behaviour on
/// truncation, build each element manually.
fn build_in_message(
&self,
Expand Down
6 changes: 3 additions & 3 deletions src/new/base/charstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::{
pub struct CharStr {
/// The underlying octets.
///
/// This is at most 255 bytes. It does not include the length octet that
/// This is at most 255 bytes. It does not include the length octet that
/// precedes the character string when serialized in the wire format.
pub octets: [u8],
}
Expand Down Expand Up @@ -273,7 +273,7 @@ impl CharStrBuf {
pub fn wire_bytes(&self) -> &[u8] {
let ptr = self as *const _ as *const u8;
let len = self.len() + 1;
// SAFETY: 'Self' is 'repr(C)' and contains no padding. It can be
// SAFETY: 'Self' is 'repr(C)' and contains no padding. It can be
// interpreted as a 256-byte array.
unsafe { core::slice::from_raw_parts(ptr, len) }
}
Expand Down Expand Up @@ -430,7 +430,7 @@ impl fmt::Debug for CharStrBuf {

/// An error in parsing a [`CharStr`] from a string.
///
/// This can be returned by [`CharStrBuf::from_str()`]. It is not used when
/// This can be returned by [`CharStrBuf::from_str()`]. It is not used when
/// parsing character strings from the zonefile format, which uses a different
/// mechanism.
#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down
30 changes: 15 additions & 15 deletions src/new/base/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ impl Message {
/// # Safety
///
/// This method uses `pointer::offset()`: `self` must be "derived from a
/// pointer to some allocated object". There must be at least 12 bytes
/// between `self` and the end of that allocated object. A reference to
/// pointer to some allocated object". There must be at least 12 bytes
/// between `self` and the end of that allocated object. A reference to
/// `Message` will always result in a pointer satisfying this.
pub unsafe fn truncate_ptr(this: *mut Message, size: usize) -> *mut Self {
// Extract the metadata from 'this'. We know it's slice metadata.
// Extract the metadata from 'this'. We know it's slice metadata.
//
// SAFETY: '[()]' is a zero-sized type and references to it can be
// created from arbitrary pointers, since every pointer is valid for
Expand Down Expand Up @@ -160,19 +160,19 @@ impl fmt::Display for Header {
///
/// This 16-bit field provides information about the containing DNS message.
/// Its contents define the purpose of the message, e.g. whether it is a query
/// or a response. Due to its small size, it doesn't cover everything; the
/// or a response. Due to its small size, it doesn't cover everything; the
/// OPT record may provide additional information, if it is present.
///
/// # Specification
///
// TODO: Update regularly.
//
/// The header field has been updated by several RFCs and the interpretation
/// of its bits has changed in some places. The following is a collection of
/// of its bits has changed in some places. The following is a collection of
/// the relevant RFC notes; it is up-to-date as of *2025-04-03*.
///
/// The descriptions here are specific to the `QUERY` opcode, which is by far
/// the most common. Other opcodes can change the interpretation of the bits
/// the most common. Other opcodes can change the interpretation of the bits
/// here.
///
/// ```text
Expand Down Expand Up @@ -201,8 +201,8 @@ impl fmt::Display for Header {
///
/// - `TC`: whether the response is truncated (due to channel limitations).
///
/// Specified by [RFC 1035, section 4.1.1]. Behaviour clarified by [RFC
/// 2181, section 9]. Behaviour for DNSSEC servers specified by [RFC 4035,
/// Specified by [RFC 1035, section 4.1.1]. Behaviour clarified by [RFC
/// 2181, section 9]. Behaviour for DNSSEC servers specified by [RFC 4035,
/// section 3.1].
///
/// - `RD`: whether the DNS client wishes for a recursively resolved answer.
Expand All @@ -215,16 +215,16 @@ impl fmt::Display for Header {
///
/// - `AD`: whether the DNS server has authenticated the answer.
///
/// Defined by [RFC 2535, section 6.1]. Behaviour for authoritative name
/// servers specified by [RFC 4035, section 3.1.6]. Behaviour for recursive
/// Defined by [RFC 2535, section 6.1]. Behaviour for authoritative name
/// servers specified by [RFC 4035, section 3.1.6]. Behaviour for recursive
/// name servers specified by [RFC 4035, section 3.2.3] and updated by [RFC
/// 6840, section 5.8]. Behaviour for DNS clients specified by [RFC 6840,
/// 6840, section 5.8]. Behaviour for DNS clients specified by [RFC 6840,
/// section 5.7].
///
/// - `CD`: whether the DNS server should avoid authenticating the answer.
///
/// Defined by [RFC 2535, section 6.1]. Behaviour for authoritative name
/// servers specified by [RFC 4035, section 3.1.6]. Behaviour for recursive
/// Defined by [RFC 2535, section 6.1]. Behaviour for authoritative name
/// servers specified by [RFC 4035, section 3.1.6]. Behaviour for recursive
/// name servers specified by [RFC 4035, section 3.2.2] and updated by [RFC
/// 6840, section 5.9].
///
Expand Down Expand Up @@ -516,7 +516,7 @@ impl fmt::Display for SectionCounts {
/// A question or a record.
///
/// This is useful for building and parsing the contents of a [`Message`]
/// ergonomically and efficiently. An iterator of [`MessageItem`]s can be
/// ergonomically and efficiently. An iterator of [`MessageItem`]s can be
/// retrieved using [`Message::parse()`].
#[derive(Clone, Debug)]
pub enum MessageItem<N, RD, ED> {
Expand All @@ -536,7 +536,7 @@ pub enum MessageItem<N, RD, ED> {

/// An EDNS record.
///
/// This is a record in the additional section. It uses a distinct type
/// This is a record in the additional section. It uses a distinct type
/// as the class and TTL fields of the record are interpreted differently.
Edns(EdnsRecord<ED>),
}
Expand Down
42 changes: 21 additions & 21 deletions src/new/base/mod.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
//! Basic DNS.
//!
//! This module provides the essential types and functionality for working
//! with DNS. In particular, it allows building and parsing DNS messages to
//! with DNS. In particular, it allows building and parsing DNS messages to
//! and from the wire format.
//!
//! This provides a mid-level and low-level API. It guides users towards the
//! This provides a mid-level and low-level API. It guides users towards the
//! most efficient solutions for their needs, and (where necessary) provides
//! fallbacks that trade efficiency for flexibility and/or ergonomics.
//!
//! # A quick reference on types
//!
//! [`Message`] is the top-level type, representing a whole DNS message. It
//! [`Message`] is the top-level type, representing a whole DNS message. It
//! stores data in the wire format, making it trivial to parse into or build
//! from. It can provide direct access to the message [`Header`], and the
//! from. It can provide direct access to the message [`Header`], and the
//! questions and records within it (collectively called [`MessageItem`]s) can
//! be parsed/traversed using [`Message::parse()`].
//!
//! [`Question`] and [`Record`] are exactly what they look like, and are
//! simple `struct`s so they can be constructed and inspected easily. They
//! simple `struct`s so they can be constructed and inspected easily. They
//! are generic over a _domain name type_ (discussed below), which you will
//! need to pick explicitly. [`Record`] is also generic over the record data
//! type; you probably want [`new::rdata::RecordData`]. See the documentation
//! need to pick explicitly. [`Record`] is also generic over the record data
//! type; you probably want [`new::rdata::RecordData`]. See the documentation
//! on [`Record`] and [`new::rdata`] for more information.
//!
//! [`new::rdata`]: crate::new::rdata
//! [`new::rdata::RecordData`]: crate::new::rdata::RecordData
//!
//! The [`name`] module provides various types that represent domain
//! names, and describes the situations each type is most appropriate
//! for. As a quick summary: try to use [`RevNameBuf`] by default, or
//! for. As a quick summary: try to use [`RevNameBuf`] by default, or
//! <code>Box&lt;[RevName]&gt;</code> if lots of domain names need to be
//! stored. If DNSSEC canonical ordering is necessary, use [`NameBuf`] or
//! <code>Box&lt;[Name]&gt;</code> respectively. There are more efficient
//! stored. If DNSSEC canonical ordering is necessary, use [`NameBuf`] or
//! <code>Box&lt;[Name]&gt;</code> respectively. There are more efficient
//! alternatives in some cases; see [`name`].
//!
//! [Name]: name::Name
Expand All @@ -42,8 +42,8 @@
//! # Parsing DNS messages
//!
//! The [`parse`] module provides mid-level and low-level APIs for parsing
//! DNS messages from the wire format. To parse the questions and records in
//! a [`Message`], use [`Message::parse()`]. To parse a message (including
//! DNS messages from the wire format. To parse the questions and records in
//! a [`Message`], use [`Message::parse()`]. To parse a message (including
//! questions and records) from bytes, use [`MessageParser::new()`].
//!
//! [`MessageParser::new()`]: parse::MessageParser::new()
Expand Down Expand Up @@ -103,8 +103,8 @@
//! # Building DNS messages
//!
//! The [`build`] module provides mid-level and low-level APIs for building
//! DNS messages in the wire format. [`MessageBuilder`] is the primary entry
//! point; it writes into a user-provided byte buffer. To begin building a
//! DNS messages in the wire format. [`MessageBuilder`] is the primary entry
//! point; it writes into a user-provided byte buffer. To begin building a
//! DNS message, use [`MessageBuilder::new()`].
//!
//! [`MessageBuilder`]: build::MessageBuilder
Expand Down Expand Up @@ -152,23 +152,23 @@
//!
//! Because many elements of DNS messages have variable-length encodings in
//! the wire format, this module relies on Rust's language support for
//! _dynamically sized types_ (DSTs) to represent them. The top-level
//! _dynamically sized types_ (DSTs) to represent them. The top-level
//! [`Message`] type, [`CharStr`], [`Name`], etc. are all DSTs.
//!
//! [`Name`]: name::Name
//!
//! DSTs cannot be passed around by value because the compiler needs to know
//! (at compile-time) how much stack space to allocate for them. As such, a
//! (at compile-time) how much stack space to allocate for them. As such, a
//! DST has to be held indirectly, by reference or in a container like
//! [`Box`]. The former work well in "short-term" contexts (e.g. within a
//! [`Box`]. The former work well in "short-term" contexts (e.g. within a
//! function), while the latter are necessary in long-term contexts.
//!
//! [`Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html
//!
//! Container types that implement [`UnsizedCopyFrom`] automatically work with
//! any [`UnsizedCopy`] types. This trait allows DSTs to be copied into such
//! any [`UnsizedCopy`] types. This trait allows DSTs to be copied into such
//! container types, which is especially useful to store a DST for long-term
//! use. It is already implemented for [`Box`], [`Arc`], [`Vec`], etc., and
//! use. It is already implemented for [`Box`], [`Arc`], [`Vec`], etc., and
//! users can implement it on their own container types too.
//!
//! [`Arc`]: https://doc.rust-lang.org/std/sync/struct.Arc.html
Expand Down Expand Up @@ -214,8 +214,8 @@ pub mod wire;
/// A compatibility module with [`domain::base`].
///
/// This re-exports a large part of the `new::base` API surface using the same
/// import paths as the old `base` module. It is a stopgap measure to help
/// users port existing code over to `new::base`. Every export comes with a
/// import paths as the old `base` module. It is a stopgap measure to help
/// users port existing code over to `new::base`. Every export comes with a
/// deprecation message to help users switch to the right tools.
pub mod compat {
#![allow(deprecated)]
Expand Down
Loading
Loading