async fn handle_dns_server_watcher_done(
        &mut self,
        source: DnsServersUpdateSource,
        dns_watchers: &mut DnsServerWatchers<'_>,
    ) -> Result<(), anyhow::Error> {
        match source {
            DnsServersUpdateSource::Default => {
                return Err(anyhow::anyhow!(
                    "should not have a DNS server watcher for the default source"
                ));
            }
            DnsServersUpdateSource::Netstack => {}
            DnsServersUpdateSource::Dhcpv6 { interface_id } => {
                let state = self
                    .interface_states
                    .get_mut(&interface_id)
                    .ok_or(anyhow::anyhow!("no interface state found for id={}", interface_id))?;

                match state {
                    InterfaceState::Host(HostInterfaceState { dhcpv6_client_addr }) => {
                        let _: fnet::Ipv6SocketAddress =
                            dhcpv6_client_addr.take().ok_or(anyhow::anyhow!(
                                "DHCPv6 was not being performed on host interface with id={}",
                                interface_id
                            ))?;
                    }
                    InterfaceState::WlanAp(WlanApInterfaceState {}) => {
                        return Err(anyhow::anyhow!(
                            "should not have a DNS watcher for a WLAN AP interface with id={}",
                            interface_id
                        ));
                    }
                }
            }
        }

        let () = self
            .update_dns_servers(source, vec![])
            .await
            .with_context(|| {
                format!("error clearing DNS servers for {:?} after completing DNS watcher", source)
            })
            .or_else(|e| match e {
                errors::Error::NonFatal(e) => {
                    error!("non-fatal error: {:?}", e);
                    Ok(())
                }
                errors::Error::Fatal(e) => Err(e),
            })?;

        // The watcher stream may have already been removed if it was exhausted so we don't
        // care what the return value is. At the end of this function, it is guaranteed that
        // `dns_watchers` will not have a stream for `source` anyways.
        let _: Option<Pin<Box<stream::BoxStream<'_, _>>>> = dns_watchers.remove(&source);

        Ok(())
    }
/// Handles the completion of the DNS server watcher associated with `source`.
///
/// Clears the servers for `source` and removes the watcher from `dns_watchers`.
Handles the completion of the DNS server watcher associated with `source`.
Clears the servers for `source` and removes the watcher from `dns_watchers`.
Handles the completion of the DNS server watcher associated with ` source ` . Clears the servers for ` source ` and removes the watcher from ` dns_watchers ` .
async fn handle_dns_server_watcher_done(
        &mut self,
        source: DnsServersUpdateSource,
        dns_watchers: &mut DnsServerWatchers<'_>,
    ) -> Result<(), anyhow::Error> {
        match source {
            DnsServersUpdateSource::Default => {
                return Err(anyhow::anyhow!(
                    "should not have a DNS server watcher for the default source"
                ));
            }
            DnsServersUpdateSource::Netstack => {}
            DnsServersUpdateSource::Dhcpv6 { interface_id } => {
                let state = self
                    .interface_states
                    .get_mut(&interface_id)
                    .ok_or(anyhow::anyhow!("no interface state found for id={}", interface_id))?;
                match state {
                    InterfaceState::Host(HostInterfaceState { dhcpv6_client_addr }) => {
                        let _: fnet::Ipv6SocketAddress =
                            dhcpv6_client_addr.take().ok_or(anyhow::anyhow!(
                                "DHCPv6 was not being performed on host interface with id={}",
                                interface_id
                            ))?;
                    }
                    InterfaceState::WlanAp(WlanApInterfaceState {}) => {
                        return Err(anyhow::anyhow!(
                            "should not have a DNS watcher for a WLAN AP interface with id={}",
                            interface_id
                        ));
                    }
                }
            }
        }
        let () = self
            .update_dns_servers(source, vec![])
            .await
            .with_context(|| {
                format!("error clearing DNS servers for {:?} after completing DNS watcher", source)
            })
            .or_else(|e| match e {
                errors::Error::NonFatal(e) => {
                    error!("non-fatal error: {:?}", e);
                    Ok(())
                }
                errors::Error::Fatal(e) => Err(e),
            })?;
        // The watcher stream may have already been removed if it was exhausted so we don't
        // care what the return value is. At the end of this function, it is guaranteed that
        // `dns_watchers` will not have a stream for `source` anyways.
        let _: Option<Pin<Box<stream::BoxStream<'_, _>>>> = dns_watchers.remove(&source);
        Ok(())
    }
async fn handle_dns_server_watcher_done ( & mut self , source : DnsServersUpdateSource , dns_watchers : & mut DnsServerWatchers < ' _ > , ) -> Result < ( ) , anyhow :: Error > { match source { DnsServersUpdateSource :: Default => { return Err ( anyhow :: anyhow ! ( " " ) ) ; } DnsServersUpdateSource :: Netstack => { } DnsServersUpdateSource :: Dhcpv6 { interface_id } => { let state = self . interface_states . get_mut ( & interface_id ) . ok_or ( anyhow :: anyhow ! ( " " interface_id ) ) ? ; match state { InterfaceState :: Host ( HostInterfaceState { dhcpv6_client_addr } ) => { let _ : fnet :: Ipv6SocketAddress = dhcpv6_client_addr . take ( ) . ok_or ( anyhow :: anyhow ! ( " " interface_id ) ) ? ; } InterfaceState :: WlanAp ( WlanApInterfaceState { } ) => { return Err ( anyhow :: anyhow ! ( " " interface_id ) ) ; } } } } let ( ) = self . update_dns_servers ( source , vec ! [ ] ) . await . with_context ( | | { format ! ( " " source ) } ) . or_else ( | e | match e { errors :: Error :: NonFatal ( e ) => { error ! ( " " e ) ; Ok ( ( ) ) } errors :: Error :: Fatal ( e ) => Err ( e ) , } ) ? ; // The watcher stream may have already been removed if it was exhausted so we don't // care what the return value is. At the end of this function, it is guaranteed that // `dns_watchers` will not have a stream for `source` anyways. let _ : Option < Pin < Box < stream :: BoxStream < ' _ , _ > > > > = dns_watchers . remove ( & source ) ; Ok ( ( ) ) }
Handles the completion of the DNS server watcher associated with `source`.
Handles the completion of the DNS server watcher associated with ` source ` .
&mut self
source
DnsServersUpdateSource
dns_watchers
&mut DnsServerWatchers<'_>
&mut self
source
DnsServersUpdateSource
dns_watchers
&mut DnsServerWatchers<'_>