pe_assembler/formats/lib/
mod.rs1#![doc = include_str!("readme.md")]
2
3pub mod reader;
5pub mod writer;
7
8use crate::{
9 helpers::CoffReader,
10 types::{CoffFileType, CoffInfo, StaticLibrary},
11};
12use gaia_types::{helpers::open_file, GaiaError};
13pub use reader::LibReader;
14use std::{
15 io::{BufReader, Cursor},
16 path::Path,
17};
18pub use writer::WriteConfig;
19
20#[derive(Copy, Clone, Debug)]
22pub struct LibReadConfig {}
23
24pub fn lib_from_bytes(data: &[u8]) -> Result<StaticLibrary, GaiaError> {
26 let reader = LibReader::new(Cursor::new(data));
27 reader.finish().result
28}
29
30pub fn lib_from_file<P>(path: P) -> Result<StaticLibrary, GaiaError>
32where
33 P: AsRef<Path>,
34{
35 let (file, url) = open_file(path.as_ref())?;
36 let reader = LibReader::new(file).with_url(url);
37 reader.finish().result
38}
39
40pub fn lib_file_type<P: AsRef<Path>>(path: P) -> Result<CoffFileType, GaiaError> {
42 let (file, url) = open_file(path.as_ref())?;
43 let mut reader = LibReader::new(BufReader::new(file)).with_url(url);
44 reader.get_coff_header()?;
45 todo!()
46}
47
48pub fn lib_file_info<P: AsRef<Path>>(path: P) -> Result<CoffInfo, GaiaError> {
50 let (file, url) = open_file(path.as_ref())?;
51 let mut reader = LibReader::new(BufReader::new(file)).with_url(url);
52 reader.get_coff_header()?;
53 todo!()
54}