pub(crate) async fn pbms_from_tree(build_path: &Path) -> Result<Entries> {
    if let Ok(entries) = from_config().await {
        return Ok(entries);
    }

    // The product_bundle.json path will be a relative path under `build_path`.
    // The "images.json" file provides an index of named items to paths. Open
    // "images.json" and search for the path of the "product_bundle" entry.
    let manifest_path = build_path.join("images.json");
    let images: Images = File::open(manifest_path.clone())
        .map_err(|e| {
            ffx_error!(
                "Cannot open file {:?}\nerror: {:?}. Doing `fx build` may help.",
                manifest_path,
                e
            )
        })
        .map(BufReader::new)
        .map(serde_json::from_reader)?
        .map_err(|e| anyhow!("json parsing error {}", e))?;
    let product_bundle =
        images.0.iter().find(|i| i.name == "product_bundle").map(|i| i.path.clone());
    let product_bundle_path = if let Some(pb) = product_bundle {
        build_path.join(pb)
    } else {
        ffx_bail!(
            "Could not find the Product Bundle in the SDK. Build a product (`fx build`) and retry."
        );
    };
    let mut entries = Entries::new();
    let file = File::open(&product_bundle_path).context("open product bundle")?;
    entries.add_json(&mut BufReader::new(file)).context("add metadata")?;
    Ok(entries)
}
/// Load FMS Entries from the local in-tree build (rather than from the SDK).
///
/// Tip: `let build_path = sdk.get_path_prefix();`.
Load FMS Entries from the local in-tree build (rather than from the SDK).
Load FMS Entries from the local in - tree build ( rather than from the SDK ) .
pub(crate) async fn pbms_from_tree(build_path: &Path) -> Result<Entries> {
    if let Ok(entries) = from_config().await {
        return Ok(entries);
    }
    // The product_bundle.json path will be a relative path under `build_path`.
    // The "images.json" file provides an index of named items to paths. Open
    // "images.json" and search for the path of the "product_bundle" entry.
    let manifest_path = build_path.join("images.json");
    let images: Images = File::open(manifest_path.clone())
        .map_err(|e| {
            ffx_error!(
                "Cannot open file {:?}\nerror: {:?}. Doing `fx build` may help.",
                manifest_path,
                e
            )
        })
        .map(BufReader::new)
        .map(serde_json::from_reader)?
        .map_err(|e| anyhow!("json parsing error {}", e))?;
    let product_bundle =
        images.0.iter().find(|i| i.name == "product_bundle").map(|i| i.path.clone());
    let product_bundle_path = if let Some(pb) = product_bundle {
        build_path.join(pb)
    } else {
        ffx_bail!(
            "Could not find the Product Bundle in the SDK. Build a product (`fx build`) and retry."
        );
    };
    let mut entries = Entries::new();
    let file = File::open(&product_bundle_path).context("open product bundle")?;
    entries.add_json(&mut BufReader::new(file)).context("add metadata")?;
    Ok(entries)
}
pub ( crate ) async fn pbms_from_tree ( build_path : & Path ) -> Result < Entries > { if let Ok ( entries ) = from_config ( ) . await { return Ok ( entries ) ; } // The product_bundle.json path will be a relative path under `build_path`. // The "images.json" file provides an index of named items to paths. Open // "images.json" and search for the path of the "product_bundle" entry. let manifest_path = build_path . join ( " " ) ; let images : Images = File :: open ( manifest_path . clone ( ) ) . map_err ( | e | { ffx_error ! ( " \n " manifest_path e ) } ) . map ( BufReader :: new ) . map ( serde_json :: from_reader ) ? . map_err ( | e | anyhow ! ( " " e ) ) ? ; let product_bundle = images . 0 . iter ( ) . find ( | i | i . name == " " ) . map ( | i | i . path . clone ( ) ) ; let product_bundle_path = if let Some ( pb ) = product_bundle { build_path . join ( pb ) } else { ffx_bail ! ( " " ) ; } ; let mut entries = Entries :: new ( ) ; let file = File :: open ( & product_bundle_path ) . context ( " " ) ? ; entries . add_json ( & mut BufReader :: new ( file ) ) . context ( " " ) ? ; Ok ( entries ) }
Load FMS Entries from the local in-tree build (rather than from the SDK).
Load FMS Entries from the local in - tree build ( rather than from the SDK ) .
build_path
&Path
build_path
&Path