pub struct Module {
pub header: Header,
pub sections: Vec<Section>,
}
Expand description
A WebAssembly module.
Fields§
§header: Header
§sections: Vec<Section>
Implementations§
Source§impl Module
impl Module
Sourcepub fn show(&self, verbose: bool) -> Result<(), WSError>
pub fn show(&self, verbose: bool) -> Result<(), WSError>
Print the structure of a module to the standard output, mainly for debugging purposes.
Set verbose
to true
in order to also print details about signature data.
Sourcepub fn split<P>(self, predicate: P) -> Result<Module, WSError>
pub fn split<P>(self, predicate: P) -> Result<Module, WSError>
Prepare a module for partial verification.
The predicate should return true
if a section is part of a set that can be verified,
and false
if the section can be ignored during verification.
It is highly recommended to always include the standard sections in the signed set.
Source§impl Module
impl Module
Sourcepub fn deserialize(reader: &mut impl Read) -> Result<Self, WSError>
pub fn deserialize(reader: &mut impl Read) -> Result<Self, WSError>
Deserialize a WebAssembly module from the given reader.
Sourcepub fn deserialize_from_file(file: impl AsRef<Path>) -> Result<Self, WSError>
pub fn deserialize_from_file(file: impl AsRef<Path>) -> Result<Self, WSError>
Deserialize a WebAssembly module from the given file.
Sourcepub fn serialize(&self, writer: &mut impl Write) -> Result<(), WSError>
pub fn serialize(&self, writer: &mut impl Write) -> Result<(), WSError>
Serialize a WebAssembly module to the given writer.
Sourcepub fn serialize_to_file(&self, file: impl AsRef<Path>) -> Result<(), WSError>
pub fn serialize_to_file(&self, file: impl AsRef<Path>) -> Result<(), WSError>
Serialize a WebAssembly module to the given file.
Sourcepub fn init_from_reader<T: Read>(
reader: &mut T,
) -> Result<ModuleStreamReader<'_, T>, WSError>
pub fn init_from_reader<T: Read>( reader: &mut T, ) -> Result<ModuleStreamReader<'_, T>, WSError>
Parse the module’s header. This function must be called before stream()
.
Sourcepub fn iterate<T: Read>(
module_stream: ModuleStreamReader<'_, T>,
) -> Result<SectionsIterator<'_, T>, WSError>
pub fn iterate<T: Read>( module_stream: ModuleStreamReader<'_, T>, ) -> Result<SectionsIterator<'_, T>, WSError>
Return an iterator over the sections of a WebAssembly module.
The module is read in a streaming fashion, and doesn’t have to be fully loaded into memory.