pub struct Generator { /* private fields */ }Expand description
Generates Rust bindings from the Ir of one or more builds.
Create one with Generator::new, optionally configure it, then call
generate.
§Examples
let generator = imping_codegen::Generator::new()
.module_name("TargetCore.dll", "target")
.accept_build("steam", "TargetCore.dll", 0x64b8f2a1, 0xa3c000);Implementations§
Source§impl Generator
impl Generator
Sourcepub fn module_name(
self,
ir_name: impl Into<String>,
rust_name: impl Into<String>,
) -> Self
pub fn module_name( self, ir_name: impl Into<String>, rust_name: impl Into<String>, ) -> Self
Names the Rust module generated for the IR module ir_name.
By default it’s the IR module’s file name without the extension, in
snake case: TargetCore.dll becomes target_core. If the same
ir_name is given more than once, the last call wins.
Sourcepub fn accept_build(
self,
label: impl Into<String>,
ir_name: impl Into<String>,
timestamp: u32,
image_size: u32,
) -> Self
pub fn accept_build( self, label: impl Into<String>, ir_name: impl Into<String>, timestamp: u32, image_size: u32, ) -> Self
Makes the generated init() of the IR module ir_name also accept, as
the build labelled label, the image with this timestamp and image
size.
Meant for the same code in a different image, such as an executable wrapped by a packer or DRM layer that keeps the timestamp but grows the image. The bindings promise the IR describes every build they accept, so only add images whose code and data match the analysed one.
Sourcepub fn generate(&self, builds: &[(&str, &Ir)]) -> Result<Bindings, Error>
pub fn generate(&self, builds: &[(&str, &Ir)]) -> Result<Bindings, Error>
Generates one set of bindings for every module in builds, the IR of
each build with its label.
Validates each IR first. A module’s items are matched across the
builds that have it; see Several builds.
Anything the generator can’t represent becomes a Warning instead
of an error. With no builds, the bindings are empty.
§Errors
Error::InvalidBuildLabelif a label isn’t lowercase letters, digits and single underscores, starting with a letter.Error::DuplicateBuildif two builds have the same label, or labels that make the sameBuildvariant.Error::InvalidIrif an IR failsIr::validate.Error::UnknownBuildif anaccept_buildnames a label none ofbuildshas.Error::UnknownModuleif amodule_namenames a module no IR has, or anaccept_buildone its build’s IR doesn’t have.Error::InvalidModuleNameif amodule_nameisn’t a valid Rust module name.Error::ModuleNameClashif two IR modules get the same Rust module name.Error::BuildsDifferif two builds disagree on a type, a function’s signature or a global’s type.