blob: cc61ae3d99261cf1016e0099b739b9638a675986 [file] [log] [blame] [edit]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use anyhow::Context as _;
use cm_rust::{ComponentDecl, FidlIntoNative};
use fidl::encoding::unpersist;
use fidl_fuchsia_component_decl as fdecl;
use std::{fs, path::Path};
pub fn load_manifest(cm: impl AsRef<Path>) -> anyhow::Result<ComponentDecl> {
let cm_raw = fs::read(cm).context("reading component manifest")?;
let component: fdecl::Component = unpersist(&cm_raw).context("decoding component manifest")?;
Ok(component.fidl_into_native())
}