Make WasiCtxBuilder by-ref.
This commit makes `WasiCtxBuilder` take `&mut Self` and return `&mut Self` for its methods. This is needed to allow for the same (unmoved) `WasiCtxBuilder` to be used when building a WASI context. Also fixes up the C API to remove the unnecessary `Box::from_raw` and `forget` calls which were previously needed for the moving version of `WasiCtxBuilder`.
This commit is contained in:
@@ -303,22 +303,25 @@ impl ModuleRegistry {
|
||||
argv: &[String],
|
||||
vars: &[(String, String)],
|
||||
) -> Result<ModuleRegistry> {
|
||||
let mut cx1 = wasi_common::WasiCtxBuilder::new()
|
||||
.inherit_stdio()
|
||||
.args(argv)
|
||||
.envs(vars);
|
||||
let mut cx1 = wasi_common::WasiCtxBuilder::new();
|
||||
|
||||
cx1.inherit_stdio().args(argv).envs(vars);
|
||||
|
||||
for (name, file) in preopen_dirs {
|
||||
cx1 = cx1.preopened_dir(file.try_clone()?, name);
|
||||
cx1.preopened_dir(file.try_clone()?, name);
|
||||
}
|
||||
|
||||
let cx1 = cx1.build()?;
|
||||
|
||||
let mut cx2 = wasi_common::old::snapshot_0::WasiCtxBuilder::new()
|
||||
.inherit_stdio()
|
||||
.args(argv)
|
||||
.envs(vars);
|
||||
|
||||
for (name, file) in preopen_dirs {
|
||||
cx2 = cx2.preopened_dir(file.try_clone()?, name);
|
||||
}
|
||||
|
||||
let cx2 = cx2.build()?;
|
||||
|
||||
Ok(ModuleRegistry {
|
||||
|
||||
Reference in New Issue
Block a user