Class: Wasmtime::WasiCtxBuilder
- Inherits:
-
Object
- Object
- Wasmtime::WasiCtxBuilder
- Defined in:
- ext/src/ruby_api/wasi_ctx_builder.rs
Overview
WASI context builder to be sent as Store.new’s wasi_ctx
keyword argument.
Instance methods mutate the current object and return self
.
Class Method Summary collapse
-
.new ⇒ WasiCtxBuilder
Create a new WasiCtxBuilder.
Instance Method Summary collapse
-
#inherit_stderr ⇒ WasiCtxBuilder
Inherit stderr from the current Ruby process.
-
#inherit_stdin ⇒ WasiCtxBuilder
Inherit stdin from the current Ruby process.
-
#inherit_stdout ⇒ WasiCtxBuilder
Inherit stdout from the current Ruby process.
-
#set_argv(args) ⇒ WasiCtxBuilder
Set the arguments (argv) to the specified
Array
. -
#set_env(env) ⇒ WasiCtxBuilder
Set env to the specified
Hash
. -
#set_stderr_buffer(buffer, capacity) ⇒ WasiCtxBuilder
Set stderr to write to a string buffer.
-
#set_stderr_file(path) ⇒ WasiCtxBuilder
Set stderr to write to a file.
-
#set_stdin_file(path) ⇒ WasiCtxBuilder
Set stdin to read from the specified file.
-
#set_stdin_string(content) ⇒ WasiCtxBuilder
Set stdin to the specified String.
-
#set_stdout_buffer(buffer, capacity) ⇒ WasiCtxBuilder
Set stdout to write to a string buffer.
-
#set_stdout_file(path) ⇒ WasiCtxBuilder
Set stdout to write to a file.
Class Method Details
.new ⇒ WasiCtxBuilder
Create a new Wasmtime::WasiCtxBuilder. By default, it has nothing: no stdin/out/err, no env, no argv, no file access.
99 100 101 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 99
pub fn new() -> Self {
Self::default()
}
|
Instance Method Details
#inherit_stderr ⇒ WasiCtxBuilder
Inherit stderr from the current Ruby process.
172 173 174 175 176 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 172
pub fn inherit_stderr(rb_self: RbSelf) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.stderr = Some(WriteStream::Inherit);
rb_self
}
|
#inherit_stdin ⇒ WasiCtxBuilder
Inherit stdin from the current Ruby process.
106 107 108 109 110 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 106
pub fn inherit_stdin(rb_self: RbSelf) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.stdin = Some(ReadStream::Inherit);
rb_self
}
|
#inherit_stdout ⇒ WasiCtxBuilder
Inherit stdout from the current Ruby process.
137 138 139 140 141 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 137
pub fn inherit_stdout(rb_self: RbSelf) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.stdout = Some(WriteStream::Inherit);
rb_self
}
|
#set_argv(args) ⇒ WasiCtxBuilder
Set the arguments (argv) to the specified Array
.
219 220 221 222 223 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 219
pub fn set_argv(rb_self: RbSelf, argv: RArray) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.args = Some(argv.into());
rb_self
}
|
#set_env(env) ⇒ WasiCtxBuilder
Set env to the specified Hash
.
208 209 210 211 212 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 208
pub fn set_env(rb_self: RbSelf, env: RHash) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.env = Some(env.into());
rb_self
}
|
#set_stderr_buffer(buffer, capacity) ⇒ WasiCtxBuilder
Set stderr to write to a string buffer. If the string buffer is frozen, Wasm execution will raise a Wasmtime::Error error. No encoding checks are done on the resulting string, it is the caller’s responsibility to ensure the string contains a valid encoding
198 199 200 201 202 203 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 198
pub fn set_stderr_buffer(rb_self: RbSelf, buffer: RString, capacity: usize) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.stderr = Some(WriteStream::Buffer(buffer.into(), capacity));
rb_self
}
/// @yard
|
#set_stderr_file(path) ⇒ WasiCtxBuilder
Set stderr to write to a file. Will truncate the file if it exists, otherwise try to create it.
184 185 186 187 188 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 184
pub fn set_stderr_file(rb_self: RbSelf, path: RString) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.stderr = Some(WriteStream::Path(path.into()));
rb_self
}
|
#set_stdin_file(path) ⇒ WasiCtxBuilder
Set stdin to read from the specified file.
117 118 119 120 121 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 117
pub fn set_stdin_file(rb_self: RbSelf, path: RString) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.stdin = Some(ReadStream::Path(path.into()));
rb_self
}
|
#set_stdin_string(content) ⇒ WasiCtxBuilder
Set stdin to the specified String.
128 129 130 131 132 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 128
pub fn set_stdin_string(rb_self: RbSelf, content: RString) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.stdin = Some(ReadStream::String(content.into()));
rb_self
}
|
#set_stdout_buffer(buffer, capacity) ⇒ WasiCtxBuilder
Set stdout to write to a string buffer. If the string buffer is frozen, Wasm execution will raise a Wasmtime::Error error. No encoding checks are done on the resulting string, it is the caller’s responsibility to ensure the string contains a valid encoding
163 164 165 166 167 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 163
pub fn set_stdout_buffer(rb_self: RbSelf, buffer: RString, capacity: usize) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.stdout = Some(WriteStream::Buffer(buffer.into(), capacity));
rb_self
}
|
#set_stdout_file(path) ⇒ WasiCtxBuilder
Set stdout to write to a file. Will truncate the file if it exists, otherwise try to create it.
149 150 151 152 153 |
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 149
pub fn set_stdout_file(rb_self: RbSelf, path: RString) -> RbSelf {
let mut inner = rb_self.inner.borrow_mut();
inner.stdout = Some(WriteStream::Path(path.into()));
rb_self
}
|