diff options
| author | Henry <mail@henrygressmann.de> | 2026-07-24 14:45:52 +0200 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2026-07-24 14:45:52 +0200 |
| commit | c7c26e8900e86f8b2116648e988b1e34c85f4077 (patch) | |
| tree | ba0a88e0234eef0eb7a3438435256a463770c67a /crates/types/src | |
| parent | e96bab075ac8adc13bf96426628c47b66745c70a (diff) | |
docs: improve rust docs
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/types/src')
| -rw-r--r-- | crates/types/src/archive.rs | 5 | ||||
| -rw-r--r-- | crates/types/src/instructions.rs | 7 | ||||
| -rw-r--r-- | crates/types/src/lib.rs | 6 |
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>]>, |
