1 use crate::rustc::middle::cstore::MetadataLoader;
2 use crate::rustc_data_structures::owning_ref::{self, OwningRef};
6 pub const METADATA_FILE: &'static [u8] = b"rust.metadata.bin" as &[u8];
8 pub struct CraneliftMetadataLoader;
10 impl MetadataLoader for CraneliftMetadataLoader {
13 _target: &crate::rustc_target::spec::Target,
15 ) -> Result<owning_ref::ErasedBoxRef<[u8]>, String> {
16 let mut archive = ar::Archive::new(File::open(path).map_err(|e| format!("{:?}", e))?);
17 // Iterate over all entries in the archive:
18 while let Some(entry_result) = archive.next_entry() {
19 let mut entry = entry_result.map_err(|e| format!("{:?}", e))?;
22 .identifier() == METADATA_FILE
24 let mut buf = Vec::new();
25 ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?;
26 let buf: OwningRef<Vec<u8>, [u8]> = OwningRef::new(buf).into();
27 return Ok(rustc_erase_owner!(buf.map_owner_box()));
31 Err("couldn't find metadata entry".to_string())
32 //self.get_dylib_metadata(target, path)
35 fn get_dylib_metadata(
37 _target: &crate::rustc_target::spec::Target,
39 ) -> Result<owning_ref::ErasedBoxRef<[u8]>, String> {
40 Err("dylib metadata loading is not yet supported".to_string())