pub async fn create_resolver(dns: Option<ResolverConfig>, rt: Handle) -> io::Result<TokioAsyncResolver> {
    {
        // To make this independent, if targeting macOS, BSD, Linux, or Windows, we can use the system's configuration:
        #[cfg(any(unix, windows))]
        {
            if let Some(conf) = dns {
                use trust_dns_resolver::config::ResolverOpts;
                trace!(
                    "Initializing DNS resolver with config {:?} opts {:?}",
                    conf,
                    ResolverOpts::default()
                );
                TokioAsyncResolver::new(conf, ResolverOpts::default(), rt)
            } else {
                use trust_dns_resolver::system_conf::read_system_conf;
                // use the system resolver configuration
                let (config, opts) = match read_system_conf() {
                    Ok(o) => o,
                    Err(err) => {
                        error!("Failed to initialize DNS resolver with system-config, error: {}", err);
                        return Err(From::from(err));
                    }
                };

                trace!(
                    "Initializing DNS resolver with system-config {:?} opts {:?}",
                    config,
                    opts
                );

                TokioAsyncResolver::new(config, opts, rt)
            }
        }

        // For other operating systems, we can use one of the preconfigured definitions
        #[cfg(not(any(unix, windows)))]
        {
            // Directly reference the config types
            use trust_dns_resolver::config::{ResolverConfig, ResolverOpts};

            if let Some(conf) = dns {
                trace!(
                    "Initializing DNS resolver with config {:?} opts {:?}",
                    conf,
                    ResolverOpts::default()
                );
                TokioAsyncResolver::new(conf, ResolverOpts::default(), rt)
            } else {
                // Get a new resolver with the google nameservers as the upstream recursive resolvers
                trace!(
                    "Initializing DNS resolver with google-config {:?} opts {:?}",
                    ResolverConfig::google(),
                    ResolverOpts::default()
                );
                TokioAsyncResolver::new(ResolverConfig::google(), ResolverOpts::default(), rt)
            }
        }
    }
    .await
    .map_err(|err| {
        error!("Failed to create trust-dns DNS Resolver, {}", err);
        Error::new(ErrorKind::Other, "failed to create trust-dns DNS resolver")
    })
}
/// Create a `trust-dns` asynchronous DNS resolver
Create a `trust-dns` asynchronous DNS resolver
Create a ` trust - dns ` asynchronous DNS resolver
pub async fn create_resolver(dns: Option<ResolverConfig>, rt: Handle) -> io::Result<TokioAsyncResolver> {
    {
        // To make this independent, if targeting macOS, BSD, Linux, or Windows, we can use the system's configuration:
        #[cfg(any(unix, windows))]
        {
            if let Some(conf) = dns {
                use trust_dns_resolver::config::ResolverOpts;
                trace!(
                    "Initializing DNS resolver with config {:?} opts {:?}",
                    conf,
                    ResolverOpts::default()
                );
                TokioAsyncResolver::new(conf, ResolverOpts::default(), rt)
            } else {
                use trust_dns_resolver::system_conf::read_system_conf;
                // use the system resolver configuration
                let (config, opts) = match read_system_conf() {
                    Ok(o) => o,
                    Err(err) => {
                        error!("Failed to initialize DNS resolver with system-config, error: {}", err);
                        return Err(From::from(err));
                    }
                };
                trace!(
                    "Initializing DNS resolver with system-config {:?} opts {:?}",
                    config,
                    opts
                );
                TokioAsyncResolver::new(config, opts, rt)
            }
        }
        // For other operating systems, we can use one of the preconfigured definitions
        #[cfg(not(any(unix, windows)))]
        {
            // Directly reference the config types
            use trust_dns_resolver::config::{ResolverConfig, ResolverOpts};
            if let Some(conf) = dns {
                trace!(
                    "Initializing DNS resolver with config {:?} opts {:?}",
                    conf,
                    ResolverOpts::default()
                );
                TokioAsyncResolver::new(conf, ResolverOpts::default(), rt)
            } else {
                // Get a new resolver with the google nameservers as the upstream recursive resolvers
                trace!(
                    "Initializing DNS resolver with google-config {:?} opts {:?}",
                    ResolverConfig::google(),
                    ResolverOpts::default()
                );
                TokioAsyncResolver::new(ResolverConfig::google(), ResolverOpts::default(), rt)
            }
        }
    }
    .await
    .map_err(|err| {
        error!("Failed to create trust-dns DNS Resolver, {}", err);
        Error::new(ErrorKind::Other, "failed to create trust-dns DNS resolver")
    })
}
pub async fn create_resolver ( dns : Option < ResolverConfig > , rt : Handle ) -> io :: Result < TokioAsyncResolver > { { // To make this independent, if targeting macOS, BSD, Linux, or Windows, we can use the system's configuration: # [ cfg ( any ( unix windows ) ) ] { if let Some ( conf ) = dns { use trust_dns_resolver :: config :: ResolverOpts ; trace ! ( " " conf ResolverOpts default ( ) ) ; TokioAsyncResolver :: new ( conf , ResolverOpts :: default ( ) , rt ) } else { use trust_dns_resolver :: system_conf :: read_system_conf ; // use the system resolver configuration let ( config , opts ) = match read_system_conf ( ) { Ok ( o ) => o , Err ( err ) => { error ! ( " " err ) ; return Err ( From :: from ( err ) ) ; } } ; trace ! ( " " config opts ) ; TokioAsyncResolver :: new ( config , opts , rt ) } } // For other operating systems, we can use one of the preconfigured definitions # [ cfg ( not ( any ( unix windows ) ) ) ] { // Directly reference the config types use trust_dns_resolver :: config :: { ResolverConfig , ResolverOpts } ; if let Some ( conf ) = dns { trace ! ( " " conf ResolverOpts default ( ) ) ; TokioAsyncResolver :: new ( conf , ResolverOpts :: default ( ) , rt ) } else { // Get a new resolver with the google nameservers as the upstream recursive resolvers trace ! ( " " ResolverConfig google ( ) ResolverOpts default ( ) ) ; TokioAsyncResolver :: new ( ResolverConfig :: google ( ) , ResolverOpts :: default ( ) , rt ) } } } . await . map_err ( | err | { error ! ( " " err ) ; Error :: new ( ErrorKind :: Other , " " ) } ) }
Create a `trust-dns` asynchronous DNS resolver
Create a ` trust - dns ` asynchronous DNS resolver
dns
Option<ResolverConfig>
rt
Handle
dns
Option<ResolverConfig>
rt
Handle