1#![warn(missing_docs)]
2#![doc = include_str!("../README.md")]
3#![cfg_attr(not(feature = "std"), no_std)]
4
5#[cfg(feature = "alloc")]
6extern crate alloc;
7
8#[cfg(feature = "std")]
9extern crate std;
10
11mod bytes_buffer;
12mod cursor;
13mod dns;
14mod seek;
15mod simple_dns_error;
16mod write;
17
18pub use simple_dns_error::SimpleDnsError;
19
20pub use dns::*;
21
22mod lib {
23 mod core {
24 #[cfg(not(feature = "std"))]
25 pub use core::*;
26 #[cfg(feature = "std")]
27 pub use std::*;
28 }
29
30 pub use self::core::net::Ipv4Addr;
31 pub use self::core::net::Ipv6Addr;
32
33 #[cfg(all(feature = "alloc", not(feature = "std")))]
34 pub use alloc::borrow::Cow;
35 #[cfg(feature = "std")]
36 pub use std::borrow::Cow;
37
38 #[cfg(all(feature = "alloc", not(feature = "std")))]
39 pub use alloc::string::{FromUtf8Error, String, ToString};
40 #[cfg(feature = "std")]
41 pub use std::string::{FromUtf8Error, String, ToString};
42
43 #[cfg(all(feature = "alloc", not(feature = "std")))]
44 pub use alloc::vec::Vec;
45 #[cfg(feature = "std")]
46 pub use std::vec::Vec;
47
48 #[cfg(all(feature = "alloc", not(feature = "std")))]
49 pub use alloc::vec;
50 #[cfg(feature = "std")]
51 pub use std::vec;
52
53 #[allow(unused)]
54 #[cfg(all(feature = "alloc", not(feature = "std")))]
55 pub use alloc::boxed::Box;
56 #[allow(unused)]
57 #[cfg(feature = "std")]
58 pub use std::boxed::Box;
59
60 #[cfg(all(feature = "alloc", not(feature = "std")))]
61 pub use alloc::format;
62 #[cfg(feature = "std")]
63 pub use std::format;
64
65 #[cfg(all(feature = "alloc", not(feature = "std")))]
66 pub use alloc::collections::BTreeMap;
67 #[cfg(feature = "std")]
68 pub use std::collections::BTreeMap;
69
70 #[cfg(all(feature = "alloc", not(feature = "std")))]
71 pub use alloc::collections::btree_map::Entry as BTreeEntry;
72
73 #[cfg(feature = "std")]
74 pub use std::collections::btree_map::Entry as BTreeEntry;
75
76 #[cfg(all(feature = "alloc", not(feature = "std")))]
77 pub use alloc::collections::BTreeSet;
78 #[cfg(feature = "std")]
79 pub use std::collections::BTreeSet;
80
81 pub use crate::seek::Seek;
82 pub use crate::seek::SeekFrom;
83 pub use crate::write::Write;
84
85 #[cfg(not(feature = "std"))]
86 pub use crate::cursor::Cursor;
87 #[cfg(feature = "std")]
88 pub use std::io::Cursor;
89
90 #[cfg(feature = "std")]
91 pub use std::collections::HashMap;
92
93 pub use self::core::array::TryFromSliceError;
94 pub use self::core::error::Error;
95 pub use self::core::result::Result;
96
97 pub use self::core::hash::Hash;
98 pub use self::core::hash::Hasher;
99 pub use self::core::slice::Iter;
100
101 pub use self::core::convert::TryFrom;
102 pub use self::core::ops::Deref;
103 pub use self::core::ops::DerefMut;
104 #[allow(unused)]
105 pub use self::core::str::FromStr;
106
107 pub mod fmt {
108 pub use super::core::fmt::*;
109 }
110
111 pub mod str {
112 pub use super::core::str::*;
113 }
114
115 pub mod mem {
116 pub use super::core::mem::*;
117 }
118}
119
120pub type Result<T> = lib::Result<T, SimpleDnsError>;
122
123#[allow(missing_docs)]
124#[doc(hidden)]
125#[cfg(debug_assertions)]
126pub mod testing {
127 use super::rdata::RR;
128 use crate::{lib::Vec, WireFormat};
129
130 #[allow(private_bounds)]
131 pub fn type_code<T: RR>() -> u16 {
132 T::TYPE_CODE
133 }
134
135 #[allow(private_bounds)]
136 pub fn parse<'a, T: WireFormat<'a>>(bytes: &'a [u8]) -> T {
137 let mut data = crate::bytes_buffer::BytesBuffer::new(bytes);
138 T::parse(&mut data).expect("Failed to parse")
139 }
140
141 #[allow(private_bounds)]
142 pub fn get_bytes<'a, T: WireFormat<'a>>(data: T) -> Vec<u8> {
143 let mut bytes = Vec::new();
144 data.write_to(&mut bytes).expect("Failed to write to vec");
145 bytes
146 }
147}