lib.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //! All the DNS transport types.
  2. #![warn(deprecated_in_future)]
  3. #![warn(future_incompatible)]
  4. #![warn(missing_copy_implementations)]
  5. #![warn(missing_docs)]
  6. #![warn(nonstandard_style)]
  7. #![warn(rust_2018_compatibility)]
  8. #![warn(rust_2018_idioms)]
  9. #![warn(single_use_lifetimes)]
  10. #![warn(trivial_casts, trivial_numeric_casts)]
  11. #![warn(unused)]
  12. #![warn(clippy::all, clippy::pedantic)]
  13. #![allow(clippy::module_name_repetitions)]
  14. #![allow(clippy::option_if_let_else)]
  15. #![allow(clippy::pub_enum_variant_names)]
  16. #![allow(clippy::wildcard_imports)]
  17. #![deny(clippy::cast_possible_truncation)]
  18. #![deny(clippy::cast_lossless)]
  19. #![deny(clippy::cast_possible_wrap)]
  20. #![deny(clippy::cast_sign_loss)]
  21. #![deny(unsafe_code)]
  22. mod auto;
  23. pub use self::auto::AutoTransport;
  24. mod udp;
  25. pub use self::udp::UdpTransport;
  26. mod tcp;
  27. pub use self::tcp::TcpTransport;
  28. mod tls;
  29. pub use self::tls::TlsTransport;
  30. mod https;
  31. pub use self::https::HttpsTransport;
  32. mod error;
  33. pub use self::error::Error;
  34. /// The trait implemented by all transport types.
  35. pub trait Transport {
  36. /// Convert the request to bytes, send it over the network, wait for a
  37. /// response, deserialise it from bytes, and return it, asynchronously.
  38. ///
  39. /// # Errors
  40. ///
  41. /// Returns an `Error` error if there’s an I/O error sending or
  42. /// receiving data, or the DNS packet in the response contained invalid
  43. /// bytes and failed to parse, or if there was a protocol-level error for
  44. /// the TLS and HTTPS transports.
  45. fn send(&self, request: &dns::Request) -> Result<dns::Response, Error>;
  46. }