Class: Wasmtime::WasiCtxBuilder

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Class Method Details

.newWasiCtxBuilder

Create a new Wasmtime::WasiCtxBuilder. By default, it has nothing: no stdin/out/err, no env, no argv, no file access.

Returns:



96
97
98
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 96

pub fn new() -> Self {
    Self::default()
}

Instance Method Details

#inherit_stderrWasiCtxBuilder

Inherit stderr from the current Ruby process.

Returns:



155
156
157
158
159
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 155

pub fn inherit_stderr(rb_self: RbSelf) -> RbSelf {
    let mut inner = rb_self.get().inner.borrow_mut();
    inner.stderr = Some(WriteStream::Inherit);
    rb_self
}

#inherit_stdinWasiCtxBuilder

Inherit stdin from the current Ruby process.

Returns:



103
104
105
106
107
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 103

pub fn inherit_stdin(rb_self: RbSelf) -> RbSelf {
    let mut inner = rb_self.get().inner.borrow_mut();
    inner.stdin = Some(ReadStream::Inherit);
    rb_self
}

#inherit_stdoutWasiCtxBuilder

Inherit stdout from the current Ruby process.

Returns:



134
135
136
137
138
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 134

pub fn inherit_stdout(rb_self: RbSelf) -> RbSelf {
    let mut inner = rb_self.get().inner.borrow_mut();
    inner.stdout = Some(WriteStream::Inherit);
    rb_self
}

#set_argv(args) ⇒ WasiCtxBuilder

Set the arguments (argv) to the specified Array.

Parameters:

  • args (Array<String>)

Returns:



189
190
191
192
193
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 189

pub fn set_argv(rb_self: RbSelf, argv: RArray) -> RbSelf {
    let mut inner = rb_self.get().inner.borrow_mut();
    inner.args = Some(argv);
    rb_self
}

#set_env(env) ⇒ WasiCtxBuilder

Set env to the specified Hash.

Parameters:

  • env (Hash<String, String>)

Returns:



178
179
180
181
182
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 178

pub fn set_env(rb_self: RbSelf, env: RHash) -> RbSelf {
    let mut inner = rb_self.get().inner.borrow_mut();
    inner.env = Some(env);
    rb_self
}

#set_stderr_file(path) ⇒ WasiCtxBuilder

Set stderr to write to a file. Will truncate the file if it exists, otherwise try to create it.

Parameters:

  • path (String)

    The path of the file to write to.

Returns:



167
168
169
170
171
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 167

pub fn set_stderr_file(rb_self: RbSelf, path: RString) -> RbSelf {
    let mut inner = rb_self.get().inner.borrow_mut();
    inner.stderr = Some(WriteStream::Path(path));
    rb_self
}

#set_stdin_file(path) ⇒ WasiCtxBuilder

Set stdin to read from the specified file.

Parameters:

  • path (String)

    The path of the file to read from.

Returns:



114
115
116
117
118
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 114

pub fn set_stdin_file(rb_self: RbSelf, path: RString) -> RbSelf {
    let mut inner = rb_self.get().inner.borrow_mut();
    inner.stdin = Some(ReadStream::Path(path));
    rb_self
}

#set_stdin_string(content) ⇒ WasiCtxBuilder

Set stdin to the specified String.

Parameters:

  • content (String)

Returns:



125
126
127
128
129
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 125

pub fn set_stdin_string(rb_self: RbSelf, content: RString) -> RbSelf {
    let mut inner = rb_self.get().inner.borrow_mut();
    inner.stdin = Some(ReadStream::String(content));
    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.

Parameters:

  • path (String)

    The path of the file to write to.

Returns:



146
147
148
149
150
# File 'ext/src/ruby_api/wasi_ctx_builder.rs', line 146

pub fn set_stdout_file(rb_self: RbSelf, path: RString) -> RbSelf {
    let mut inner = rb_self.get().inner.borrow_mut();
    inner.stdout = Some(WriteStream::Path(path));
    rb_self
}