/// Attempt to connect to a service, returning `None` if the service does not
/// exist in the service directory.
Attempt to connect to a service, returning `None` if the service does not
exist in the service directory.
Attempt to connect to a service returning ` None ` if the service does not exist in the service directory .
async fn optional_svc_connect<S: fidl::endpoints::DiscoverableProtocolMarker>(
    svc_dir: &fio::DirectoryProxy,
) -> Result<Option<S::Proxy>, anyhow::Error> {
    let req = new_protocol_connector_in_dir::<S>(&svc_dir);
    if !req.exists().await.context("error checking for service existence")? {
        Ok(None)
    } else {
        req.connect().context("error connecting to service").map(Some)
    }
}
async fn optional_svc_connect < S : fidl :: endpoints :: DiscoverableProtocolMarker > ( svc_dir : & fio :: DirectoryProxy , ) -> Result < Option < S :: Proxy > , anyhow :: Error > { let req = new_protocol_connector_in_dir :: < S > ( & svc_dir ) ; if ! req . exists ( ) . await . context ( " " ) ? { Ok ( None ) } else { req . connect ( ) . context ( " " ) . map ( Some ) } }
Attempt to connect to a service, returning `None` if the service does not
exist in the service directory.
Attempt to connect to a service returning ` None ` if the service does not exist in the service directory .
svc_dir
&fio::DirectoryProxy