1#![warn(missing_docs)]
2#![doc = include_str!("../README.md")]
3
4mod bytes_buffer;
5mod dns;
6mod simple_dns_error;
7
8pub use simple_dns_error::SimpleDnsError;
9
10pub use dns::*;
11
12pub type Result<T> = std::result::Result<T, SimpleDnsError>;
14
15#[allow(missing_docs)]
16#[doc(hidden)]
17#[cfg(debug_assertions)]
18pub mod testing {
19 use super::rdata::RR;
20 use super::WireFormat;
21
22 #[allow(private_bounds)]
23 pub fn type_code<T: RR>() -> u16 {
24 T::TYPE_CODE
25 }
26
27 #[allow(private_bounds)]
28 pub fn parse<'a, T: WireFormat<'a>>(bytes: &'a [u8]) -> T {
29 let mut data = crate::bytes_buffer::BytesBuffer::new(bytes);
30 T::parse(&mut data).expect("Failed to parse")
31 }
32
33 #[allow(private_bounds)]
34 pub fn get_bytes<'a, T: WireFormat<'a>>(data: T) -> Vec<u8> {
35 let mut bytes = Vec::new();
36 data.write_to(&mut bytes).expect("Failed to write to vec");
37 bytes
38 }
39}