Deny missing documentation in wasmtime crate (#836)
* Deny missing documentation in `wasmtime` crate Everything is largely documented now, so let's be sure to keep it that way! * Add windows docs
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
//! and there to implement Rust idioms. This crate also defines the actual C API
|
//! and there to implement Rust idioms. This crate also defines the actual C API
|
||||||
//! itself for consumption from other languages.
|
//! itself for consumption from other languages.
|
||||||
|
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
mod callable;
|
mod callable;
|
||||||
mod externals;
|
mod externals;
|
||||||
mod instance;
|
mod instance;
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ impl Module {
|
|||||||
validate(binary, Some(config)).map_err(Error::new)
|
validate(binary, Some(config)).map_err(Error::new)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn from_exports(store: &Store, exports: Box<[ExportType]>) -> Self {
|
pub fn from_exports(store: &Store, exports: Box<[ExportType]>) -> Self {
|
||||||
let mut ret = Module::empty(store);
|
let mut ret = Module::empty(store);
|
||||||
Rc::get_mut(&mut ret.inner).unwrap().exports = exports;
|
Rc::get_mut(&mut ret.inner).unwrap().exports = exports;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::cell::{self, RefCell};
|
use std::cell::{self, RefCell};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use crate::instance::Instance;
|
|
||||||
use backtrace::Backtrace;
|
use backtrace::Backtrace;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -61,6 +60,8 @@ impl Trap {
|
|||||||
&self.inner.message
|
&self.inner.message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a list of function frames in WebAssembly code that led to this
|
||||||
|
/// trap happening.
|
||||||
pub fn trace(&self) -> &[FrameInfo] {
|
pub fn trace(&self) -> &[FrameInfo] {
|
||||||
&self.inner.wasm_trace
|
&self.inner.wasm_trace
|
||||||
}
|
}
|
||||||
@@ -102,6 +103,11 @@ impl fmt::Display for Trap {
|
|||||||
|
|
||||||
impl std::error::Error for Trap {}
|
impl std::error::Error for Trap {}
|
||||||
|
|
||||||
|
/// Description of a frame in a backtrace for a [`Trap`].
|
||||||
|
///
|
||||||
|
/// Whenever a WebAssembly trap occurs an instance of [`Trap`] is created. Each
|
||||||
|
/// [`Trap`] has a backtrace of the WebAssembly frames that led to the trap, and
|
||||||
|
/// each frame is described by this structure.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FrameInfo {
|
pub struct FrameInfo {
|
||||||
module_name: Option<String>,
|
module_name: Option<String>,
|
||||||
@@ -110,26 +116,41 @@ pub struct FrameInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FrameInfo {
|
impl FrameInfo {
|
||||||
pub fn instance(&self) -> *const Instance {
|
/// Returns the WebAssembly function index for this frame.
|
||||||
unimplemented!("FrameInfo::instance");
|
///
|
||||||
}
|
/// This function index is the index in the function index space of the
|
||||||
|
/// WebAssembly module that this frame comes from.
|
||||||
pub fn func_index(&self) -> u32 {
|
pub fn func_index(&self) -> u32 {
|
||||||
self.func_index
|
self.func_index
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn func_offset(&self) -> usize {
|
/// Returns the identifer of the module that this frame is for.
|
||||||
unimplemented!("FrameInfo::func_offset");
|
///
|
||||||
}
|
/// Module identifiers are present in the `name` section of a WebAssembly
|
||||||
|
/// binary, but this may not return the exact item in the `name` section.
|
||||||
pub fn module_offset(&self) -> usize {
|
/// Module names can be overwritten at construction time or perhaps inferred
|
||||||
unimplemented!("FrameInfo::module_offset");
|
/// from file names. The primary purpose of this function is to assist in
|
||||||
}
|
/// debugging and therefore may be tweaked over time.
|
||||||
|
///
|
||||||
|
/// This function returns `None` when no name can be found or inferred.
|
||||||
pub fn module_name(&self) -> Option<&str> {
|
pub fn module_name(&self) -> Option<&str> {
|
||||||
self.module_name.as_deref()
|
self.module_name.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a descriptive name of the function for this frame, if one is
|
||||||
|
/// available.
|
||||||
|
///
|
||||||
|
/// The name of this function may come from the `name` section of the
|
||||||
|
/// WebAssembly binary, or wasmtime may try to infer a better name for it if
|
||||||
|
/// not available, for example the name of the export if it's exported.
|
||||||
|
///
|
||||||
|
/// This return value is primarily used for debugging and human-readable
|
||||||
|
/// purposes for things like traps. Note that the exact return value may be
|
||||||
|
/// tweaked over time here and isn't guaranteed to be something in
|
||||||
|
/// particular about a wasm module due to its primary purpose of assisting
|
||||||
|
/// in debugging.
|
||||||
|
///
|
||||||
|
/// This function returns `None` when no name could be inferred.
|
||||||
pub fn func_name(&self) -> Option<&str> {
|
pub fn func_name(&self) -> Option<&str> {
|
||||||
self.func_name.as_deref()
|
self.func_name.as_deref()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,9 +116,13 @@ impl ValType {
|
|||||||
/// can either be imported or exported.
|
/// can either be imported or exported.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum ExternType {
|
pub enum ExternType {
|
||||||
|
/// This external type is the type of a WebAssembly function.
|
||||||
Func(FuncType),
|
Func(FuncType),
|
||||||
|
/// This external type is the type of a WebAssembly global.
|
||||||
Global(GlobalType),
|
Global(GlobalType),
|
||||||
|
/// This external type is the type of a WebAssembly table.
|
||||||
Table(TableType),
|
Table(TableType),
|
||||||
|
/// This external type is the type of a WebAssembly memory.
|
||||||
Memory(MemoryType),
|
Memory(MemoryType),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ use crate::Instance;
|
|||||||
|
|
||||||
/// Extensions for the [`Instance`] type only available on Windows.
|
/// Extensions for the [`Instance`] type only available on Windows.
|
||||||
pub trait InstanceExt {
|
pub trait InstanceExt {
|
||||||
// TODO: docs?
|
/// Configures a custom signal handler to execute.
|
||||||
|
///
|
||||||
|
/// TODO: needs more documentation.
|
||||||
unsafe fn set_signal_handler<H>(&self, handler: H)
|
unsafe fn set_signal_handler<H>(&self, handler: H)
|
||||||
where
|
where
|
||||||
H: 'static + Fn(winapi::um::winnt::EXCEPTION_POINTERS) -> bool;
|
H: 'static + Fn(winapi::um::winnt::EXCEPTION_POINTERS) -> bool;
|
||||||
|
|||||||
Reference in New Issue
Block a user