소스 검색

Make constants exposed in DNS socket API public

`MAX_ADDRESS_COUNT` is useful when naming the output type of
`dns::Socket::get_query_result`.

`MAX_SERVER_COUNT` is necessary to ensure `dns::Socket::new` and
`dns::Socket::update_servers` do not panic if passing a user-provided
list of DNS servers.
Ed Barnard 2 년 전
부모
커밋
7a0d4827f1
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      src/socket/dns.rs

+ 3 - 2
src/socket/dns.rs

@@ -12,10 +12,11 @@ use crate::wire::{self, IpAddress, IpProtocol, IpRepr, UdpRepr};
 #[cfg(feature = "async")]
 use super::WakerRegistration;
 
+pub const MAX_ADDRESS_COUNT: usize = 4;
+pub const MAX_SERVER_COUNT: usize = 4;
+
 const DNS_PORT: u16 = 53;
 const MAX_NAME_LEN: usize = 255;
-const MAX_ADDRESS_COUNT: usize = 4;
-const MAX_SERVER_COUNT: usize = 4;
 const RETRANSMIT_DELAY: Duration = Duration::from_millis(1_000);
 const MAX_RETRANSMIT_DELAY: Duration = Duration::from_millis(10_000);
 const RETRANSMIT_TIMEOUT: Duration = Duration::from_millis(10_000); // Should generally be 2-10 secs