Skip to content

Commit d1ebad8

Browse files
author
Jakub Konka
committed
Should use OsOther to wrap custom stdio
1 parent a911442 commit d1ebad8

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

crates/c-api/src/wasi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ fn create_snapshot0_instance(store: &Store, config: wasi_config_t) -> Result<Was
238238

239239
fn wasi_preview_builder(config: wasi_config_t) -> Result<WasiPreview1CtxBuilder> {
240240
use std::convert::TryFrom;
241-
use wasi_common::OsFile;
241+
use wasi_common::OsOther;
242242
let mut builder = WasiPreview1CtxBuilder::new();
243243
if config.inherit_args {
244244
builder.inherit_args();
@@ -253,17 +253,17 @@ fn wasi_preview_builder(config: wasi_config_t) -> Result<WasiPreview1CtxBuilder>
253253
if config.inherit_stdin {
254254
builder.inherit_stdin();
255255
} else if let Some(file) = config.stdin {
256-
builder.stdin(OsFile::try_from(file)?);
256+
builder.stdin(OsOther::try_from(file)?);
257257
}
258258
if config.inherit_stdout {
259259
builder.inherit_stdout();
260260
} else if let Some(file) = config.stdout {
261-
builder.stdout(OsFile::try_from(file)?);
261+
builder.stdout(OsOther::try_from(file)?);
262262
}
263263
if config.inherit_stderr {
264264
builder.inherit_stderr();
265265
} else if let Some(file) = config.stderr {
266-
builder.stderr(OsFile::try_from(file)?);
266+
builder.stderr(OsOther::try_from(file)?);
267267
}
268268
for preopen in config.preopens {
269269
builder.preopened_dir(preopen.0, preopen.1);

crates/test-programs/tests/wasm_tests/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::{bail, Context};
22
use std::convert::TryFrom;
33
use std::fs::File;
44
use std::path::Path;
5-
use wasi_common::{OsFile, VirtualDirEntry};
5+
use wasi_common::{OsOther, VirtualDirEntry};
66
use wasmtime::{Instance, Module, Store};
77

88
#[derive(Clone, Copy, Debug)]
@@ -48,7 +48,7 @@ pub fn instantiate(
4848
// stdin is closed which causes tests to fail.
4949
let (reader, _writer) = os_pipe::pipe()?;
5050
let file = reader_to_file(reader);
51-
let handle = OsFile::try_from(file).context("failed to create OsFile from PipeReader")?;
51+
let handle = OsOther::try_from(file).context("failed to create OsOther from PipeReader")?;
5252
builder.stdin(handle);
5353
let snapshot1 = wasmtime_wasi::Wasi::new(&store, builder.build()?);
5454
let module = Module::new(&store, &data).context("failed to create wasm module")?;

crates/wasi-common/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub use ctx::{WasiCtx, WasiCtxBuilder, WasiCtxBuilderError};
3939
pub use handle::{Handle, HandleRights};
4040
pub use sys::osdir::OsDir;
4141
pub use sys::osfile::{OsFile, OsFileExt};
42+
pub use sys::osother::OsOther;
4243
pub use sys::preopen_dir;
4344
pub use sys::stdio::{Stdio, StdioExt};
4445
pub use virtfs::{FileContents, VirtualDirEntry};

crates/wasi-common/src/sys/osother.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::io::{self, Read, Write};
1111
use std::ops::Deref;
1212

1313
#[derive(Debug)]
14-
pub(crate) struct OsOther {
14+
pub struct OsOther {
1515
file_type: Filetype,
1616
rights: Cell<HandleRights>,
1717
handle: OsHandle,

0 commit comments

Comments
 (0)