summaryrefslogtreecommitdiff
path: root/crates/types
diff options
context:
space:
mode:
Diffstat (limited to 'crates/types')
-rw-r--r--crates/types/src/archive.rs5
-rw-r--r--crates/types/src/instructions.rs7
-rw-r--r--crates/types/src/lib.rs6
3 files changed, 11 insertions, 7 deletions
diff --git a/crates/types/src/archive.rs b/crates/types/src/archive.rs
index 48dc53f..99238ab 100644
--- a/crates/types/src/archive.rs
+++ b/crates/types/src/archive.rs
@@ -45,7 +45,10 @@ impl Display for TwasmError {
impl core::error::Error for TwasmError {}
impl Module {
- /// Creates a [`Module`] from a slice of bytes.
+ /// Creates a [`Module`] from internal `twasm` archive bytes.
+ ///
+ /// Archives are version-specific and are not validated as untrusted input.
+ /// Only load archives from a trusted source.
pub fn try_from_twasm(wasm: &[u8]) -> Result<Self, TwasmError> {
let len = validate_magic(wasm)?;
postcard::from_bytes(&wasm[len..]).map_err(TwasmError::InvalidArchive)
diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs
index a22279e..cec9d5b 100644
--- a/crates/types/src/instructions.rs
+++ b/crates/types/src/instructions.rs
@@ -116,10 +116,11 @@ pub enum BinOp128 {
I64x2Mul,
}
-/// A WebAssembly Instruction
+/// A TinyWasm bytecode instruction.
///
-/// These are our own internal bytecode instructions so they may not match the spec exactly.
-/// Wasm Bytecode can map to multiple of these instructions.
+/// These instructions are an internal, version-specific representation and do not
+/// map one-to-one to WebAssembly instructions. Their variants and serialized form
+/// may change between TinyWasm releases.
///
/// See <https://webassembly.github.io/spec/core/binary/instructions.html>
#[rustfmt::skip]
diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs
index fcac23c..0b4b54c 100644
--- a/crates/types/src/lib.rs
+++ b/crates/types/src/lib.rs
@@ -45,8 +45,8 @@ pub mod archive {
/// A `TinyWasm` WebAssembly Module
///
/// This is the internal representation of a WebAssembly module in `TinyWasm`.
-/// [`Module`] are validated before being created, so they are guaranteed to be valid (as long as they were created by `TinyWasm`).
-/// This means you should not trust a [`Module`] created by a third party to be valid.
+/// Modules produced by the parser are validated by default, but validation can be
+/// disabled for trusted input. Do not trust modules or archives from third parties.
#[derive(Clone, Default, PartialEq)]
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))]
@@ -76,7 +76,7 @@ pub struct ModuleInner {
/// Corresponds to the `start` section of the original WebAssembly module.
pub start_func: Option<FuncAddr>,
- /// Optimized and validated WebAssembly functions
+ /// Optimized WebAssembly functions
///
/// Contains data from to the `code`, `func`, and `type` sections of the original WebAssembly module.
pub funcs: Box<[Arc<WasmFunction>]>,