Skip to content

Commit

Permalink
Add Module::from_buffer_with_config (#285)
Browse files Browse the repository at this point in the history
Current `Module` construction API cannot create a module from a buffer
with a specific configuration:
  * `Module::with_config`
  * `Module::from_file`
  * `Module::from_file_with_config`
  * `Module::from_buffer`

This commit adds a new method `Module::from_buffer_with_config` to fill
the gap.
  • Loading branch information
kateinoigakukun authored Dec 3, 2024
1 parent 94522dc commit 9b4bb16
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ impl Module {
ModuleConfig::new().parse(wasm)
}

/// Construct a new module from the in-memory wasm buffer and configuration.
pub fn from_buffer_with_config(wasm: &[u8], config: &ModuleConfig) -> Result<Module> {
config.parse(wasm)
}

fn parse(wasm: &[u8], config: &ModuleConfig) -> Result<Module> {
let mut ret = Module {
config: config.clone(),
Expand Down

0 comments on commit 9b4bb16

Please sign in to comment.