pub struct TinyWasmModule {
pub start_func: Option<FuncAddr>,
pub funcs: Box<[WasmFunction]>,
pub func_types: Box<[FuncType]>,
pub exports: Box<[Export]>,
pub globals: Box<[Global]>,
pub table_types: Box<[TableType]>,
pub memory_types: Box<[MemoryType]>,
pub imports: Box<[Import]>,
pub data: Box<[Data]>,
pub elements: Box<[Element]>,
}
Expand description
A TinyWasm
WebAssembly Module
This is the internal representation of a WebAssembly module in TinyWasm
.
TinyWasmModules
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 TinyWasmModule
created by a third party to be valid.
Fields§
§start_func: Option<FuncAddr>
Optional address of the start function
Corresponds to the start
section of the original WebAssembly module.
funcs: Box<[WasmFunction]>
Optimized and validated WebAssembly functions
Contains data from to the code
, func
, and type
sections of the original WebAssembly module.
func_types: Box<[FuncType]>
A vector of type definitions, indexed by TypeAddr
Corresponds to the type
section of the original WebAssembly module.
exports: Box<[Export]>
Exported items of the WebAssembly module.
Corresponds to the export
section of the original WebAssembly module.
globals: Box<[Global]>
Global components of the WebAssembly module.
Corresponds to the global
section of the original WebAssembly module.
table_types: Box<[TableType]>
Table components of the WebAssembly module used to initialize tables.
Corresponds to the table
section of the original WebAssembly module.
memory_types: Box<[MemoryType]>
Memory components of the WebAssembly module used to initialize memories.
Corresponds to the memory
section of the original WebAssembly module.
imports: Box<[Import]>
Imports of the WebAssembly module.
Corresponds to the import
section of the original WebAssembly module.
data: Box<[Data]>
Data segments of the WebAssembly module.
Corresponds to the data
section of the original WebAssembly module.
elements: Box<[Element]>
Element segments of the WebAssembly module.
Corresponds to the elem
section of the original WebAssembly module.
Implementations§
Source§impl TinyWasmModule
impl TinyWasmModule
Sourcepub fn from_twasm(wasm: &[u8]) -> Result<TinyWasmModule, TwasmError>
pub fn from_twasm(wasm: &[u8]) -> Result<TinyWasmModule, TwasmError>
Creates a TinyWasmModule
from a slice of bytes.
Sourcepub fn serialize_twasm(&self) -> AlignedVec ⓘ
pub fn serialize_twasm(&self) -> AlignedVec ⓘ
Serializes the TinyWasmModule
into a vector of bytes.
AlignedVec
can be deferenced as a slice of bytes and
implements io::Write
when the std
feature is enabled.
Trait Implementations§
Source§impl Archive for TinyWasmModule
impl Archive for TinyWasmModule
Source§type Archived = ArchivedTinyWasmModule
type Archived = ArchivedTinyWasmModule
Source§type Resolver = TinyWasmModuleResolver
type Resolver = TinyWasmModuleResolver
Source§impl Clone for TinyWasmModule
impl Clone for TinyWasmModule
Source§fn clone(&self) -> TinyWasmModule
fn clone(&self) -> TinyWasmModule
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TinyWasmModule
impl Debug for TinyWasmModule
Source§impl Default for TinyWasmModule
impl Default for TinyWasmModule
Source§fn default() -> TinyWasmModule
fn default() -> TinyWasmModule
Source§impl<__D: Fallible + ?Sized> Deserialize<TinyWasmModule, __D> for Archived<TinyWasmModule>where
Option<FuncAddr>: Archive,
Archived<Option<FuncAddr>>: Deserialize<Option<FuncAddr>, __D>,
Box<[WasmFunction]>: Archive,
Archived<Box<[WasmFunction]>>: Deserialize<Box<[WasmFunction]>, __D>,
Box<[FuncType]>: Archive,
Archived<Box<[FuncType]>>: Deserialize<Box<[FuncType]>, __D>,
Box<[Export]>: Archive,
Archived<Box<[Export]>>: Deserialize<Box<[Export]>, __D>,
Box<[Global]>: Archive,
Archived<Box<[Global]>>: Deserialize<Box<[Global]>, __D>,
Box<[TableType]>: Archive,
Archived<Box<[TableType]>>: Deserialize<Box<[TableType]>, __D>,
Box<[MemoryType]>: Archive,
Archived<Box<[MemoryType]>>: Deserialize<Box<[MemoryType]>, __D>,
Box<[Import]>: Archive,
Archived<Box<[Import]>>: Deserialize<Box<[Import]>, __D>,
Box<[Data]>: Archive,
Archived<Box<[Data]>>: Deserialize<Box<[Data]>, __D>,
Box<[Element]>: Archive,
Archived<Box<[Element]>>: Deserialize<Box<[Element]>, __D>,
impl<__D: Fallible + ?Sized> Deserialize<TinyWasmModule, __D> for Archived<TinyWasmModule>where
Option<FuncAddr>: Archive,
Archived<Option<FuncAddr>>: Deserialize<Option<FuncAddr>, __D>,
Box<[WasmFunction]>: Archive,
Archived<Box<[WasmFunction]>>: Deserialize<Box<[WasmFunction]>, __D>,
Box<[FuncType]>: Archive,
Archived<Box<[FuncType]>>: Deserialize<Box<[FuncType]>, __D>,
Box<[Export]>: Archive,
Archived<Box<[Export]>>: Deserialize<Box<[Export]>, __D>,
Box<[Global]>: Archive,
Archived<Box<[Global]>>: Deserialize<Box<[Global]>, __D>,
Box<[TableType]>: Archive,
Archived<Box<[TableType]>>: Deserialize<Box<[TableType]>, __D>,
Box<[MemoryType]>: Archive,
Archived<Box<[MemoryType]>>: Deserialize<Box<[MemoryType]>, __D>,
Box<[Import]>: Archive,
Archived<Box<[Import]>>: Deserialize<Box<[Import]>, __D>,
Box<[Data]>: Archive,
Archived<Box<[Data]>>: Deserialize<Box<[Data]>, __D>,
Box<[Element]>: Archive,
Archived<Box<[Element]>>: Deserialize<Box<[Element]>, __D>,
Source§fn deserialize(
&self,
deserializer: &mut __D,
) -> Result<TinyWasmModule, __D::Error>
fn deserialize( &self, deserializer: &mut __D, ) -> Result<TinyWasmModule, __D::Error>
Source§impl PartialEq for TinyWasmModule
impl PartialEq for TinyWasmModule
Source§impl<__S: Fallible + ?Sized> Serialize<__S> for TinyWasmModulewhere
Option<FuncAddr>: Serialize<__S>,
Box<[WasmFunction]>: Serialize<__S>,
Box<[FuncType]>: Serialize<__S>,
Box<[Export]>: Serialize<__S>,
Box<[Global]>: Serialize<__S>,
Box<[TableType]>: Serialize<__S>,
Box<[MemoryType]>: Serialize<__S>,
Box<[Import]>: Serialize<__S>,
Box<[Data]>: Serialize<__S>,
Box<[Element]>: Serialize<__S>,
impl<__S: Fallible + ?Sized> Serialize<__S> for TinyWasmModulewhere
Option<FuncAddr>: Serialize<__S>,
Box<[WasmFunction]>: Serialize<__S>,
Box<[FuncType]>: Serialize<__S>,
Box<[Export]>: Serialize<__S>,
Box<[Global]>: Serialize<__S>,
Box<[TableType]>: Serialize<__S>,
Box<[MemoryType]>: Serialize<__S>,
Box<[Import]>: Serialize<__S>,
Box<[Data]>: Serialize<__S>,
Box<[Element]>: Serialize<__S>,
impl StructuralPartialEq for TinyWasmModule
Auto Trait Implementations§
impl Freeze for TinyWasmModule
impl RefUnwindSafe for TinyWasmModule
impl Send for TinyWasmModule
impl Sync for TinyWasmModule
impl Unpin for TinyWasmModule
impl UnwindSafe for TinyWasmModule
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive
, it may be unsized. Read more