/// load_object will find the named object in the given namespace and return a VMO containing its
/// contents.
load_object will find the named object in the given namespace and return a VMO containing its
contents.
load_object will find the named object in the given namespace and return a VMO containing its contents .
pub async fn load_object(
    ns_map: &HashMap<PathBuf, DirectoryProxy>,
    object_path: PathBuf,
) -> Result<zx::Vmo, Error> {
    for (ns_prefix, current_dir) in ns_map.iter() {
        if object_path.starts_with(ns_prefix) {
            let sub_path = pathbuf_drop_prefix(&object_path, ns_prefix);
            let file_proxy = io_util::open_file(current_dir, &sub_path)?;
            let (status, fidlbuf) = await!(file_proxy.get_buffer(VMO_FLAG_READ | VMO_FLAG_EXEC))
                .map_err(|e| format_err!("reading object at {:?} failed: {}", object_path, e))?;
            let status = zx::Status::from_raw(status);
            if status != zx::Status::OK {
                return Err(format_err!("reading object at {:?} failed: {}", object_path, status));
            }
            return fidlbuf
                .map(|b| b.vmo)
                .ok_or(format_err!("bad status received on get_buffer: {}", status));
        }
    }
    Err(err_msg(format!("requested library not found: {:?}", object_path)))
}
pub async fn load_object ( ns_map : & HashMap < PathBuf , DirectoryProxy > , object_path : PathBuf , ) -> Result < zx :: Vmo , Error > { for ( ns_prefix , current_dir ) in ns_map . iter ( ) { if object_path . starts_with ( ns_prefix ) { let sub_path = pathbuf_drop_prefix ( & object_path , ns_prefix ) ; let file_proxy = io_util :: open_file ( current_dir , & sub_path ) ? ; let ( status , fidlbuf ) = await ! ( file_proxy get_buffer ( VMO_FLAG_READ VMO_FLAG_EXEC ) ) . map_err ( | e | format_err ! ( " " object_path e ) ) ? ; let status = zx :: Status :: from_raw ( status ) ; if status != zx :: Status :: OK { return Err ( format_err ! ( " " object_path status ) ) ; } return fidlbuf . map ( | b | b . vmo ) . ok_or ( format_err ! ( " " status ) ) ; } } Err ( err_msg ( format ! ( " " object_path ) ) ) }
load_object will find the named object in the given namespace and return a VMO containing its
contents.
load_object will find the named object in the given namespace and return a VMO containing its contents .
ns_map
&HashMap<PathBuf, DirectoryProxy>
object_path
PathBuf