async fn fetch_and_cache_package_directory(
        &self,
        asset_id: AssetId,
        package_locator: &v2::PackageLocator,
    ) -> Result<io::DirectoryProxy, AssetCollectionError> {
        let package_url = package_locator.url.to_string();
        trace::duration!(
            "fonts",
            "asset:collection:fetch_and_cache_package_directory",
            "package_url" => &package_url[..]);

        // Get directory handle from FontResolver
        let font_resolver = connect_to_service::<FontResolverMarker>()
            .map_err(|e| AssetCollectionError::ServiceConnectionError(Error::from(e).into()))?;
        let mut update_policy = UpdatePolicy { fetch_if_absent: true, allow_old_versions: false };
        let (dir_proxy, dir_request) = create_proxy::<io::DirectoryMarker>()
            .map_err(|e| AssetCollectionError::ServiceConnectionError(Error::from(e).into()))?;

        let status = font_resolver
            .resolve(&package_url, &mut update_policy, dir_request)
            .await
            .map_err(|e| {
                AssetCollectionError::PackageResolverError(
                    package_locator.clone(),
                    Error::from(e).into(),
                )
            })?;
        zx::Status::ok(status).map_err(|e| {
            AssetCollectionError::PackageResolverError(
                package_locator.clone(),
                Error::from(e).into(),
            )
        })?;

        // Cache directory handle
        let mut directory_cache = self.id_to_dir_map.lock().await;
        directory_cache.insert(asset_id, Clone::clone(&dir_proxy));
        // TODO(8904): For "universe" fonts, send event to clients.

        Ok(dir_proxy)
    }
/// Resolves the requested package and adds its `Directory` to our cache.
Resolves the requested package and adds its `Directory` to our cache.
Resolves the requested package and adds its ` Directory ` to our cache .
async fn fetch_and_cache_package_directory(
        &self,
        asset_id: AssetId,
        package_locator: &v2::PackageLocator,
    ) -> Result<io::DirectoryProxy, AssetCollectionError> {
        let package_url = package_locator.url.to_string();
        trace::duration!(
            "fonts",
            "asset:collection:fetch_and_cache_package_directory",
            "package_url" => &package_url[..]);
        // Get directory handle from FontResolver
        let font_resolver = connect_to_service::<FontResolverMarker>()
            .map_err(|e| AssetCollectionError::ServiceConnectionError(Error::from(e).into()))?;
        let mut update_policy = UpdatePolicy { fetch_if_absent: true, allow_old_versions: false };
        let (dir_proxy, dir_request) = create_proxy::<io::DirectoryMarker>()
            .map_err(|e| AssetCollectionError::ServiceConnectionError(Error::from(e).into()))?;
        let status = font_resolver
            .resolve(&package_url, &mut update_policy, dir_request)
            .await
            .map_err(|e| {
                AssetCollectionError::PackageResolverError(
                    package_locator.clone(),
                    Error::from(e).into(),
                )
            })?;
        zx::Status::ok(status).map_err(|e| {
            AssetCollectionError::PackageResolverError(
                package_locator.clone(),
                Error::from(e).into(),
            )
        })?;
        // Cache directory handle
        let mut directory_cache = self.id_to_dir_map.lock().await;
        directory_cache.insert(asset_id, Clone::clone(&dir_proxy));
        // TODO(8904): For "universe" fonts, send event to clients.
        Ok(dir_proxy)
    }
async fn fetch_and_cache_package_directory ( & self , asset_id : AssetId , package_locator : & v2 :: PackageLocator , ) -> Result < io :: DirectoryProxy , AssetCollectionError > { let package_url = package_locator . url . to_string ( ) ; trace :: duration ! ( " " " " " " package_url [ ] ) ; // Get directory handle from FontResolver let font_resolver = connect_to_service :: < FontResolverMarker > ( ) . map_err ( | e | AssetCollectionError :: ServiceConnectionError ( Error :: from ( e ) . into ( ) ) ) ? ; let mut update_policy = UpdatePolicy { fetch_if_absent : true , allow_old_versions : false } ; let ( dir_proxy , dir_request ) = create_proxy :: < io :: DirectoryMarker > ( ) . map_err ( | e | AssetCollectionError :: ServiceConnectionError ( Error :: from ( e ) . into ( ) ) ) ? ; let status = font_resolver . resolve ( & package_url , & mut update_policy , dir_request ) . await . map_err ( | e | { AssetCollectionError :: PackageResolverError ( package_locator . clone ( ) , Error :: from ( e ) . into ( ) , ) } ) ? ; zx :: Status :: ok ( status ) . map_err ( | e | { AssetCollectionError :: PackageResolverError ( package_locator . clone ( ) , Error :: from ( e ) . into ( ) , ) } ) ? ; // Cache directory handle let mut directory_cache = self . id_to_dir_map . lock ( ) . await ; directory_cache . insert ( asset_id , Clone :: clone ( & dir_proxy ) ) ; // TODO(8904): For "universe" fonts, send event to clients. Ok ( dir_proxy ) }
Resolves the requested package and adds its `Directory` to our cache.
Resolves the requested package and adds its ` Directory ` to our cache .
&self
asset_id
AssetId
package_locator
&v2::PackageLocator
&self
asset_id
AssetId
package_locator
&v2::PackageLocator