Struct tinywasm_types::TinyWasmModule
source · pub struct TinyWasmModule {
pub version: Option<u16>,
pub start_func: Option<FuncAddr>,
pub funcs: Box<[TypedWasmFunction]>,
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§
§version: Option<u16>
The version of the WebAssembly module.
start_func: Option<FuncAddr>
The start function of the WebAssembly module.
funcs: Box<[TypedWasmFunction]>
The functions of the WebAssembly module.
func_types: Box<[FuncType]>
The types of the WebAssembly module.
exports: Box<[Export]>
The exports of the WebAssembly module.
globals: Box<[Global]>
The tables of the WebAssembly module.
table_types: Box<[TableType]>
The tables of the WebAssembly module.
memory_types: Box<[MemoryType]>
The memories of the WebAssembly module.
imports: Box<[Import]>
The imports of the WebAssembly module.
data: Box<[Data]>
Data segments of the WebAssembly module.
elements: Box<[Element]>
Element segments of the 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 unsafe fn from_twasm_unchecked(wasm: &[u8]) -> Self
pub unsafe fn from_twasm_unchecked(wasm: &[u8]) -> Self
Creates a TinyWasmModule from a slice of bytes.
§Safety
This function is only safe to call if the bytes have been created by a trusted source. Otherwise, it may cause undefined behavior.
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
§type Archived = ArchivedTinyWasmModule
type Archived = ArchivedTinyWasmModule
§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<u16>: Archive,
Archived<Option<u16>>: Deserialize<Option<u16>, __D>,
Option<FuncAddr>: Archive,
Archived<Option<FuncAddr>>: Deserialize<Option<FuncAddr>, __D>,
Box<[TypedWasmFunction]>: Archive,
Archived<Box<[TypedWasmFunction]>>: Deserialize<Box<[TypedWasmFunction]>, __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<u16>: Archive,
Archived<Option<u16>>: Deserialize<Option<u16>, __D>,
Option<FuncAddr>: Archive,
Archived<Option<FuncAddr>>: Deserialize<Option<FuncAddr>, __D>,
Box<[TypedWasmFunction]>: Archive,
Archived<Box<[TypedWasmFunction]>>: Deserialize<Box<[TypedWasmFunction]>, __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§fn eq(&self, other: &TinyWasmModule) -> bool
fn eq(&self, other: &TinyWasmModule) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<__S: Fallible + ?Sized> Serialize<__S> for TinyWasmModulewhere
Option<u16>: Serialize<__S>,
Option<FuncAddr>: Serialize<__S>,
Box<[TypedWasmFunction]>: 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<u16>: Serialize<__S>,
Option<FuncAddr>: Serialize<__S>,
Box<[TypedWasmFunction]>: 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 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
§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,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive
, it may be unsized. Read more