From 32cb3d46646b6e2480bda7828f8a6002b11a0a95 Mon Sep 17 00:00:00 2001 From: Martin Hoffmann Date: Mon, 6 Feb 2023 17:38:38 +0100 Subject: [PATCH] Documentation fixes. --- src/base/cmp.rs | 5 ++- src/base/message_builder.rs | 7 ++-- src/base/mod.rs | 5 ++- src/base/name/dname.rs | 2 -- src/base/record.rs | 6 ++-- src/base/scan.rs | 2 +- src/rdata/macros.rs | 70 ------------------------------------- 7 files changed, 15 insertions(+), 82 deletions(-) diff --git a/src/base/cmp.rs b/src/base/cmp.rs index b4b3e40a..025f8772 100644 --- a/src/base/cmp.rs +++ b/src/base/cmp.rs @@ -11,9 +11,8 @@ //! as they are for comparisons. In order to make it clear when this mode //! of comparision is used, this module defines a new trait [`CanonicalOrd`] //! that allows types to define how they should be compared in the context of -//! DNSSEC. The trait is accompanied by -//! [`Compose::compose_canonical`][super::octets::Compose::compose_canonical] -//! which produces the canonical form of this data. +//! DNSSEC. The trait is accompanied by `compose_canonical` methods on all +//! types that have or may have a canonical form. use core::cmp::Ordering; diff --git a/src/base/message_builder.rs b/src/base/message_builder.rs index f02db5ae..5781f0cc 100644 --- a/src/base/message_builder.rs +++ b/src/base/message_builder.rs @@ -501,9 +501,10 @@ impl QuestionBuilder { /// Appends a question to the question section. /// /// This method accepts anything that implements the [`ComposeQuestion`] - /// trait. Apart from an actual [`Question`] or a reference to it, this - /// can also be a tuple of a domain name, record type, and class or, if - /// the class is the usual IN, a pair of just the name and type. + /// trait. Apart from an actual [`Question`][super::question::Question] + /// or a reference to it, this can also be a tuple of a domain name, + /// record type, and class or, if the class is the usual IN, a pair of + /// just the name and type. /// /// In other words, the options are: /// diff --git a/src/base/mod.rs b/src/base/mod.rs index 6d05d77f..e8ea10e8 100644 --- a/src/base/mod.rs +++ b/src/base/mod.rs @@ -68,7 +68,10 @@ //! # Zone File Processing //! //! Handling for the text format for DNS data from zone files is available -//! via the [zonefile] module. See there for more information. +//! via the crate’s +#![cfg_attr(feature = "zonefile", doc = "[zonefile][crate::zonefile]")] +#![cfg_attr(not(feature = "zonefile"), doc = "zonefile")] +//! module. See there for more information. //! //! //! # Support for `no_std` diff --git a/src/base/name/dname.rs b/src/base/name/dname.rs index e6eac8c4..af4c39f7 100644 --- a/src/base/name/dname.rs +++ b/src/base/name/dname.rs @@ -268,8 +268,6 @@ impl Dname { /// # Properties /// -/// More of the usual methods on octets sequences, such as `len`, are -/// available via the implementation of `Deref`. impl + ?Sized> Dname { /// Returns whether the name is the root label only. pub fn is_root(&self) -> bool { diff --git a/src/base/record.rs b/src/base/record.rs index afc41474..fb3886dc 100644 --- a/src/base/record.rs +++ b/src/base/record.rs @@ -70,8 +70,10 @@ use octseq::parse::Parser; /// the generics through type inference. Secondly, you can parse a record /// from an existing message. [`Message`] and its friends provide a way to /// do that; see there for all the details. Finally, you can scan a record -/// from zone file format. See the [`domain::zonefile`] module for -/// that. +/// from zone file format. See the crate’s +#[cfg_attr(feature = "zonefile", doc = "[zonefile][crate::zonefile]")] +#[cfg_attr(not(feature = "zonefile"), doc = "zonefile")] +/// module for that. /// /// [`new`]: #method.new /// [`Message`]: ../message/struct.Message.html diff --git a/src/base/scan.rs b/src/base/scan.rs index 110f08f9..42048bfb 100644 --- a/src/base/scan.rs +++ b/src/base/scan.rs @@ -15,7 +15,7 @@ //! This module provides a simple scanner that uses a sequence of strings as //! its source and can be used to, for instance, read record data from //! command line arguments. A “proper” scanner is included in the -#![cfg_attr(feature = "zonefile", doc = "[zonefile]")] +#![cfg_attr(feature = "zonefile", doc = "[zonefile][crate::zonefile]")] #![cfg_attr(not(feature = "zonefile"), doc = "zonefile")] //! module. #![allow(clippy::manual_range_contains)] // Hard disagree. diff --git a/src/rdata/macros.rs b/src/rdata/macros.rs index fb616cbb..1ed3779c 100644 --- a/src/rdata/macros.rs +++ b/src/rdata/macros.rs @@ -472,61 +472,6 @@ macro_rules! rdata_types { } } - /* - //--- Serialize and Deserialize - - #[cfg(feature = "serde")] - impl serde::Serialize for ZoneRecordData - where - O: AsRef<[u8]> + crate::base::octets::SerializeOctets, - N: serde::Serialize, - { - fn serialize( - &self, serializer: S - ) -> Result { - use crate::base::iana::Rtype; - - match *self { - $( $( $( - ZoneRecordData::$mtype(ref inner) => { - serializer.serialize_newtype_variant( - "ZoneRecordData", - Rtype::$mtype.to_int().into(), - stringify!($mtype), - inner - ) - } - )* )* )* - ZoneRecordData::Unknown(ref inner) => { - serializer.serialize_newtype_variant( - "ZoneRecordData", - u32::MAX, - "Unknown", - inner - ) - } - } - } - } - - #[cfg(feature = "serde")] - impl<'de, O, N> serde::Deserialize<'de> for ZoneRecordData - where - O: crate::base::octets::FromBuilder - + crate::base::octets::DeserializeOctets<'de>, - ::Builder: - crate::base::octets::OctetsBuilder - + crate::base::octets::EmptyBuilder, - N: serde::Deserialize<'de>, - { - fn deserialize>( - _deserializer: D - ) -> Result { - unimplemented!() - } - } - */ - //------------- AllRecordData ---------------------------------------- /// Record data for all record types. @@ -562,21 +507,6 @@ macro_rules! rdata_types { } )* )* )* - /* - $( $( $( - AllRecordData::$mtype(_) => { - <$mtype $( < $( $mn ),* > )* - as $crate::base::rdata::RtypeRecordData>::RTYPE - } - )* )* )* - $( $( $( - AllRecordData::$ptype(_) => { - <$ptype $( < $( $pn ),* > )* - as $crate::base::rdata::RtypeRecordData>::RTYPE - } - )* )* )* - */ - AllRecordData::Opt(_) => $crate::base::iana::Rtype::Opt, AllRecordData::Unknown(ref inner) => inner.rtype(), }