clr_assembler/formats/dll/
mod.rs1pub use self::{reader::DllReader, writer::DllWriter};
2use crate::program::ClrProgram;
3use gaia_types::{helpers::open_file, GaiaError};
4use std::{io::Cursor, path::Path};
5
6pub mod reader;
7pub mod writer;
8
9#[derive(Clone, Debug)]
18pub struct DllReadConfig {
19 pub assembly_ref_fallback_names: Vec<String>,
20}
21
22impl Default for DllReadConfig {
23 fn default() -> Self {
24 Self { assembly_ref_fallback_names: Vec::new() }
25 }
26}
27
28pub fn dll_from_file(file_path: &Path) -> Result<ClrProgram, GaiaError> {
30 let config = DllReadConfig::default();
31 let (file, url) = open_file(file_path)?;
32 let mut dll_reader = DllReader::new(file, &config);
33 dll_reader.to_clr_program()
34}
35
36pub fn dll_from_bytes(_bytes: &[u8]) -> Result<ClrProgram, GaiaError> {
38 let config = DllReadConfig::default();
39 let mut dll_reader = DllReader::new(Cursor::new(_bytes), &config);
40 dll_reader.to_clr_program()
41}
42
43pub fn is_dotnet_dll(_file_path: &Path) -> Result<bool, GaiaError> {
45 todo!()
47}
48
49pub fn read_dotnet_assembly(file_path: &Path, options: &DllReadConfig) -> Result<ClrProgram, GaiaError> {
51 let (file, url) = open_file(file_path)?;
52 let mut dll_reader = DllReader::new(file, options);
53 dll_reader.to_clr_program()
54}