pub struct TinyWasmModule {
    pub start_func: Option<u32>,
    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<u32>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> Deserialize<TinyWasmModule, __D> for <TinyWasmModule as Archive>::Archivedwhere
    __D: Fallible + ?Sized,
    Option<u32>: Archive,
    <Option<u32> as Archive>::Archived: Deserialize<Option<u32>, __D>,
    Box<[WasmFunction]>: Archive,
    <Box<[WasmFunction]> as Archive>::Archived: Deserialize<Box<[WasmFunction]>, __D>,
    Box<[FuncType]>: Archive,
    <Box<[FuncType]> as Archive>::Archived: Deserialize<Box<[FuncType]>, __D>,
    Box<[Export]>: Archive,
    <Box<[Export]> as Archive>::Archived: Deserialize<Box<[Export]>, __D>,
    Box<[Global]>: Archive,
    <Box<[Global]> as Archive>::Archived: Deserialize<Box<[Global]>, __D>,
    Box<[TableType]>: Archive,
    <Box<[TableType]> as Archive>::Archived: Deserialize<Box<[TableType]>, __D>,
    Box<[MemoryType]>: Archive,
    <Box<[MemoryType]> as Archive>::Archived: Deserialize<Box<[MemoryType]>, __D>,
    Box<[Import]>: Archive,
    <Box<[Import]> as Archive>::Archived: Deserialize<Box<[Import]>, __D>,
    Box<[Data]>: Archive,
    <Box<[Data]> as Archive>::Archived: Deserialize<Box<[Data]>, __D>,
    Box<[Element]>: Archive,
    <Box<[Element]> as Archive>::Archived: Deserialize<Box<[Element]>, __D>,
 
impl<__D> Deserialize<TinyWasmModule, __D> for <TinyWasmModule as Archive>::Archivedwhere
    __D: Fallible + ?Sized,
    Option<u32>: Archive,
    <Option<u32> as Archive>::Archived: Deserialize<Option<u32>, __D>,
    Box<[WasmFunction]>: Archive,
    <Box<[WasmFunction]> as Archive>::Archived: Deserialize<Box<[WasmFunction]>, __D>,
    Box<[FuncType]>: Archive,
    <Box<[FuncType]> as Archive>::Archived: Deserialize<Box<[FuncType]>, __D>,
    Box<[Export]>: Archive,
    <Box<[Export]> as Archive>::Archived: Deserialize<Box<[Export]>, __D>,
    Box<[Global]>: Archive,
    <Box<[Global]> as Archive>::Archived: Deserialize<Box<[Global]>, __D>,
    Box<[TableType]>: Archive,
    <Box<[TableType]> as Archive>::Archived: Deserialize<Box<[TableType]>, __D>,
    Box<[MemoryType]>: Archive,
    <Box<[MemoryType]> as Archive>::Archived: Deserialize<Box<[MemoryType]>, __D>,
    Box<[Import]>: Archive,
    <Box<[Import]> as Archive>::Archived: Deserialize<Box<[Import]>, __D>,
    Box<[Data]>: Archive,
    <Box<[Data]> as Archive>::Archived: Deserialize<Box<[Data]>, __D>,
    Box<[Element]>: Archive,
    <Box<[Element]> as Archive>::Archived: Deserialize<Box<[Element]>, __D>,
Source§fn deserialize(
    &self,
    deserializer: &mut __D,
) -> Result<TinyWasmModule, <__D as Fallible>::Error>
 
fn deserialize( &self, deserializer: &mut __D, ) -> Result<TinyWasmModule, <__D as Fallible>::Error>
Source§impl From<&TinyWasmModule> for Module
 
impl From<&TinyWasmModule> for Module
Source§fn from(data: &TinyWasmModule) -> Self
 
fn from(data: &TinyWasmModule) -> Self
Source§impl From<TinyWasmModule> for Module
 
impl From<TinyWasmModule> for Module
Source§fn from(data: TinyWasmModule) -> Self
 
fn from(data: TinyWasmModule) -> Self
Source§impl PartialEq for TinyWasmModule
 
impl PartialEq for TinyWasmModule
Source§impl<__S> Serialize<__S> for TinyWasmModulewhere
    __S: Fallible + ?Sized,
    Option<u32>: 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> Serialize<__S> for TinyWasmModulewhere
    __S: Fallible + ?Sized,
    Option<u32>: 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>,
Source§impl TryFrom<ModuleReader> for TinyWasmModule
 
impl TryFrom<ModuleReader> for TinyWasmModule
Source§type Error = ParseError
 
type Error = ParseError
Source§fn try_from(reader: ModuleReader) -> Result<TinyWasmModule, ParseError>
 
fn try_from(reader: ModuleReader) -> Result<TinyWasmModule, ParseError>
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