pe-assembler 0.1.1

PE/COFF assembler for Windows instruction sets - strongly typed, object-oriented, zero-dependency core
Documentation
#![deny(missing_debug_implementations, missing_copy_implementations)]
#![warn(missing_docs, rustdoc::missing_crate_level_docs)]
#![doc = include_str!("readme.md")]
#![doc(html_logo_url = "https://raw.githubusercontent.com/oovm/shape-rs/dev/projects/images/Trapezohedron.svg")]
#![doc(html_favicon_url = "https://raw.githubusercontent.com/oovm/shape-rs/dev/projects/images/Trapezohedron.svg")]

use crate::{formats::exe::writer::ExeWriter, helpers::PeWriter, types::PeProgram};
use gaia_types::{
    helpers::{create_file, Url},
    Result,
};
use std::path::Path;

pub mod formats;
pub mod helpers;
pub mod types;

/// Write a PE program to an EXE file at the specified path
///
/// This is a high-level API function that hides the direct usage details of ExeWriter.
///
/// # Parameters
///
/// * `pe` - The PE program to write
/// * `path` - Output file path
///
/// # Return Value
///
/// Returns the file URL on success, or a GaiaError on failure
///
/// # Example
///
/// ```rust,no_run
/// # use pe_assembler::exe_write_path;
/// # use std::path::Path;
///
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// // let pe_program = /* create PE program */;
/// // let output_path = Path::new("output.exe");
/// // let url = exe_write_path(&pe_program, output_path)?;
/// # Ok(())
/// # }
/// ```
pub fn exe_write_path(pe: &PeProgram, path: &Path) -> Result<Url> {
    let (file, url) = create_file(path)?;
    let mut exe = ExeWriter::new(file);
    exe.write_program(pe)?;
    Ok(url)
}