Skip to content

Commit

Permalink
Fix missing interface error in rune-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Jan 17, 2025
1 parent 66b4976 commit a833d25
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
10 changes: 6 additions & 4 deletions crates/rune-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use rune::ast::Spanned;
use rune::compile::LinkerError;
use rune::diagnostics::{Diagnostic, FatalDiagnosticKind};
use rune::modules::capture_io::CaptureIo;
use rune::runtime::{budget, Value, VmResult};
use rune::runtime::{budget, VmResult};
use rune::{Context, ContextError, Options};
use serde::{Deserialize, Serialize};
use wasm_bindgen::prelude::*;
Expand Down Expand Up @@ -106,7 +106,7 @@ impl WasmCompileResult {
/// Construct output from compile result.
fn output(
io: &CaptureIo,
output: Value,
result: String,
diagnostics_output: Option<String>,
diagnostics: Vec<WasmDiagnostic>,
instructions: Option<String>,
Expand All @@ -115,7 +115,7 @@ impl WasmCompileResult {
error: None,
diagnostics_output,
diagnostics,
result: Some(format!("{:?}", output)),
result: Some(result),
output: io.drain_utf8().ok().map(|s| s.into_std()),
instructions,
}
Expand Down Expand Up @@ -352,9 +352,11 @@ async fn inner_compile(
}
};

let result = vm.with(|| format!("{output:?}"));

Ok(WasmCompileResult::output(
io,
output,
result,
diagnostics_output(writer),
diagnostics,
instructions,
Expand Down
22 changes: 9 additions & 13 deletions crates/rune/src/runtime/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,20 +286,18 @@ impl Value {
}
}

/// Format the value using the [Protocol::DISPLAY_FMT] protocol.
///
/// Requires a work buffer `buf` which will be used in case the value
/// provided requires out-of-line formatting. This must be cleared between
/// calls and can be re-used.
/// Format the value using the [`DISPLAY_FMT`] protocol.
///
/// You must use [`Vm::with`] to specify which virtual machine this function
/// is called inside.
///
/// [`Vm::with`]: crate::Vm::with
///
/// # Panics
/// # Errors
///
/// This function errors if called outside of a virtual machine.
///
/// This function will panic if called outside of a virtual machine.
/// [`DISPLAY_FMT`]: Protocol::DISPLAY_FMT
pub fn display_fmt(&self, f: &mut Formatter) -> VmResult<()> {
self.display_fmt_with(f, &mut EnvProtocolCaller)
}
Expand Down Expand Up @@ -355,16 +353,14 @@ impl Value {

/// Perform a shallow clone of the value using the [`CLONE`] protocol.
///
/// This requires read access to the underlying value.
///
/// You must use [`Vm::with`] to specify which virtual machine this function
/// is called inside.
///
/// [`Vm::with`]: crate::Vm::with
///
/// # Panics
/// # Errors
///
/// This function will panic if called outside of a virtual machine.
/// This function errors if called outside of a virtual machine.
///
/// [`CLONE`]: Protocol::CLONE
pub fn clone_(&self) -> VmResult<Self> {
Expand Down Expand Up @@ -401,9 +397,9 @@ impl Value {
///
/// [`Vm::with`]: crate::Vm::with
///
/// # Panics
/// # Errors
///
/// This function will panic if called outside of a virtual machine.
/// This function errors if called outside of a virtual machine.
///
/// [`DEBUG_FMT`]: Protocol::DEBUG_FMT
pub fn debug_fmt(&self, f: &mut Formatter) -> VmResult<()> {
Expand Down

0 comments on commit a833d25

Please sign in to comment.