1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#![forbid(unsafe_code)]
#![cfg_attr(ci_, deny(warnings))]
#![cfg_attr(all(test, feature = "bench"), feature(test))]
#![cfg_attr(not(feature = "std"), no_std)]
// #![warn(missing_docs)]

#[cfg(feature = "alloc")]
extern crate alloc;

macro_rules! error {
    ($name:ident $(($source:ident($x:expr) $(, $other:ident)*))? $(, $variant:ident)*) => {
        #[cfg(feature = "std")]
        impl ::std::error::Error for $name {
            fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
                match self {
                    $($name($source $(, $other)*) => Some($x),)?
                    $($name::$variant(s) => Some(s),)*

                    #[allow(unreachable_patterns)]
                    _ => None,
                }
            }
        }
    };
}

// FIXME rust-lang/rust#67295
// #[cfg(any(test, doctest))]
#[macro_export]
#[doc(hidden)]
macro_rules! declare_any_error {
    (@real ($($variant:ident $ty:ty,)+)) => {
        #[derive(Debug)]
        pub enum AnyError {
            $($variant($ty),)+
        }

        $(impl From<$ty> for AnyError {
            fn from(e: $ty) -> Self { Self::$variant(e) }
        })+
    };

    (@real ($($done:tt)*) ($($path:tt)+)($name:ident), $($rest:tt)*) => {
        $crate::declare_any_error!(@real ($($done)* $name $($path)+::$name,) $($rest)*);
    };

    (@real ($($done:tt)*) ($($path:tt)+)($name:ident) as $variant:ident, $($rest:tt)*) => {
        $crate::declare_any_error!(@real ($($done)* $variant $($path)+::$name,) $($rest)*);
    };

    ($name:ident) => {
        $crate::declare_any_error!(
            @real ()
            (::core::convert)(Infallible),
            ($crate::view)(BoundsError),
            ($crate::view)(MessageError),
            ($crate::view)(QuestionError),
            ($crate::view)(RecordError),
            ($crate::view)(NameError),
            ($crate::view)(LabelError),
            ($crate::view)(ExtensionError),
            ($crate::view::rdata)(RdataError),
            ($crate::view::rdata)(SoaError),
            ($crate::emit)(SinkError),
            ($crate::emit)(GrowError),
            ($crate::emit::extension)(ExtensionError) as EmitExtensionError,
            ($crate::emit::message)(MessageError) as EmitMessageError,
            ($crate::emit::name)(NameError) as EmitNameError,
            ($crate::emit::question)(QuestionError) as EmitQuestionError,
            ($crate::emit::record)(RecordError) as EmitRecordError,
            ($crate::core)(TypeFromStrError),
            ($crate::core)(ClassFromStrError),
            ($crate::core)(TtlFromStrError),
            (::core::fmt)(Error),
        );
    };
}

pub mod r#const;
pub mod core;
pub mod emit;
pub mod view;
pub mod zone;

mod seen;