Configure the version information used in serialized and deserialized [`crate::Module`]s. This effects the behavior of [`crate::Module::serialize()`], as well as [`crate::Module::deserialize()`] and related functions. The default strategy is to use the wasmtime crate's Cargo package version.
(&mut self, strategy: ModuleVersionStrategy)
| 2092 | /// |
| 2093 | /// The default strategy is to use the wasmtime crate's Cargo package version. |
| 2094 | pub fn module_version(&mut self, strategy: ModuleVersionStrategy) -> Result<&mut Self> { |
| 2095 | match strategy { |
| 2096 | // This case requires special precondition for assertion in SerializedModule::to_bytes |
| 2097 | ModuleVersionStrategy::Custom(ref v) => { |
| 2098 | if v.as_bytes().len() > 255 { |
| 2099 | bail!("custom module version cannot be more than 255 bytes: {v}"); |
| 2100 | } |
| 2101 | } |
| 2102 | _ => {} |
| 2103 | } |
| 2104 | self.module_version = strategy; |
| 2105 | Ok(self) |
| 2106 | } |
| 2107 | |
| 2108 | /// Configure whether wasmtime should compile a module using multiple |
| 2109 | /// threads. |