pub struct RoundtripReencoder;
Available on crate feature
wasmparser
only.Expand description
Reencodes wasmparser
into wasm-encoder
so that the encoded wasm is
identical to the input and can be parsed and encoded again.
Trait Implementations§
Source§impl Debug for RoundtripReencoder
impl Debug for RoundtripReencoder
Source§impl Reencode for RoundtripReencoder
impl Reencode for RoundtripReencoder
type Error = Infallible
fn data_index(&mut self, data: u32) -> u32
fn element_index(&mut self, element: u32) -> u32
fn function_index(&mut self, func: u32) -> u32
fn global_index(&mut self, global: u32) -> u32
fn memory_index(&mut self, memory: u32) -> u32
fn table_index(&mut self, table: u32) -> u32
fn tag_index(&mut self, tag: u32) -> u32
fn type_index(&mut self, ty: u32) -> u32
fn type_index_unpacked( &mut self, ty: UnpackedIndex, ) -> Result<u32, Error<Self::Error>>
fn external_index(&mut self, kind: ExternalKind, index: u32) -> u32
fn abstract_heap_type(&mut self, value: AbstractHeapType) -> AbstractHeapType
fn array_type( &mut self, array_ty: ArrayType, ) -> Result<ArrayType, Error<Self::Error>>
fn block_type( &mut self, arg: BlockType, ) -> Result<BlockType, Error<Self::Error>>
fn const_expr( &mut self, const_expr: ConstExpr<'_>, ) -> Result<ConstExpr, Error<Self::Error>>
fn catch(&mut self, arg: Catch) -> Catch
fn composite_type( &mut self, composite_ty: CompositeType, ) -> Result<CompositeType, Error<Self::Error>>
fn entity_type( &mut self, type_ref: TypeRef, ) -> Result<EntityType, Error<Self::Error>>
fn export_kind(&mut self, external_kind: ExternalKind) -> ExportKind
fn field_type( &mut self, field_ty: FieldType, ) -> Result<FieldType, Error<Self::Error>>
fn func_type( &mut self, func_ty: FuncType, ) -> Result<FuncType, Error<Self::Error>>
fn cont_type( &mut self, cont_ty: ContType, ) -> Result<ContType, Error<Self::Error>>
fn global_type( &mut self, global_ty: GlobalType, ) -> Result<GlobalType, Error<Self::Error>>
fn handle(&mut self, on: Handle) -> Handle
fn heap_type( &mut self, heap_type: HeapType, ) -> Result<HeapType, Error<Self::Error>>
fn instruction<'a>( &mut self, arg: Operator<'a>, ) -> Result<Instruction<'a>, Error<Self::Error>>
fn memory_type(&mut self, memory_ty: MemoryType) -> MemoryType
fn mem_arg(&mut self, arg: MemArg) -> MemArg
fn ordering(&mut self, arg: Ordering) -> Ordering
fn ref_type(&mut self, ref_type: RefType) -> Result<RefType, Error<Self::Error>>
fn storage_type( &mut self, storage_ty: StorageType, ) -> Result<StorageType, Error<Self::Error>>
fn struct_type( &mut self, struct_ty: StructType, ) -> Result<StructType, Error<Self::Error>>
fn sub_type(&mut self, sub_ty: SubType) -> Result<SubType, Error<Self::Error>>
fn table_type( &mut self, table_ty: TableType, ) -> Result<TableType, Error<Self::Error>>
fn tag_kind(&mut self, kind: TagKind) -> TagKind
fn tag_type(&mut self, tag_ty: TagType) -> TagType
fn val_type(&mut self, val_ty: ValType) -> Result<ValType, Error<Self::Error>>
Source§fn parse_custom_section(
&mut self,
module: &mut Module,
section: CustomSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_custom_section( &mut self, module: &mut Module, section: CustomSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and
adds the custom section to the module
.Source§fn custom_section<'a>(
&mut self,
section: CustomSectionReader<'a>,
) -> CustomSection<'a>
fn custom_section<'a>( &mut self, section: CustomSectionReader<'a>, ) -> CustomSection<'a>
Converts the input
section
given from the wasmparser
crate into an
encoded custom section.Source§fn parse_code_section(
&mut self,
code: &mut CodeSection,
section: CodeSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_code_section( &mut self, code: &mut CodeSection, section: CodeSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the code to the code
section.Source§fn parse_function_body(
&mut self,
code: &mut CodeSection,
func: FunctionBody<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_function_body( &mut self, code: &mut CodeSection, func: FunctionBody<'_>, ) -> Result<(), Error<Self::Error>>
Parses a single
wasmparser::FunctionBody
and adds it to the code
section.Source§fn new_function_with_parsed_locals(
&mut self,
func: &FunctionBody<'_>,
) -> Result<Function, Error<Self::Error>>
fn new_function_with_parsed_locals( &mut self, func: &FunctionBody<'_>, ) -> Result<Function, Error<Self::Error>>
Create a new
crate::Function
by parsing the locals declarations from the
provided wasmparser::FunctionBody
.Source§fn parse_instruction<'a>(
&mut self,
reader: &mut OperatorsReader<'a>,
) -> Result<Instruction<'a>, Error<Self::Error>>
fn parse_instruction<'a>( &mut self, reader: &mut OperatorsReader<'a>, ) -> Result<Instruction<'a>, Error<Self::Error>>
Parses a single instruction from
reader
and adds it to function
.Source§fn parse_data_section(
&mut self,
data: &mut DataSection,
section: DataSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_data_section( &mut self, data: &mut DataSection, section: DataSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the data to the data
section.Source§fn parse_data(
&mut self,
data: &mut DataSection,
datum: Data<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_data( &mut self, data: &mut DataSection, datum: Data<'_>, ) -> Result<(), Error<Self::Error>>
Parses a single
wasmparser::Data
and adds it to the data
section.Source§fn parse_element_section(
&mut self,
elements: &mut ElementSection,
section: ElementSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_element_section( &mut self, elements: &mut ElementSection, section: ElementSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the elements to the element
section.Source§fn parse_element(
&mut self,
elements: &mut ElementSection,
element: Element<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_element( &mut self, elements: &mut ElementSection, element: Element<'_>, ) -> Result<(), Error<Self::Error>>
Parses the single
wasmparser::Element
provided and adds it to the
element
section.fn element_items<'a>( &mut self, items: ElementItems<'a>, ) -> Result<Elements<'a>, Error<Self::Error>>
Source§fn parse_export_section(
&mut self,
exports: &mut ExportSection,
section: ExportSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_export_section( &mut self, exports: &mut ExportSection, section: ExportSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the exports to the exports
section.Source§fn parse_export(&mut self, exports: &mut ExportSection, export: Export<'_>)
fn parse_export(&mut self, exports: &mut ExportSection, export: Export<'_>)
Parses the single
wasmparser::Export
provided and adds it to the
exports
section.Source§fn parse_function_section(
&mut self,
functions: &mut FunctionSection,
section: FunctionSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_function_section( &mut self, functions: &mut FunctionSection, section: FunctionSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the functions to the functions
section.Source§fn parse_global_section(
&mut self,
globals: &mut GlobalSection,
section: GlobalSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_global_section( &mut self, globals: &mut GlobalSection, section: GlobalSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the globals to the globals
section.Source§fn parse_global(
&mut self,
globals: &mut GlobalSection,
global: Global<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_global( &mut self, globals: &mut GlobalSection, global: Global<'_>, ) -> Result<(), Error<Self::Error>>
Parses the single
wasmparser::Global
provided and adds it to the
globals
section.Source§fn parse_import_section(
&mut self,
imports: &mut ImportSection,
section: ImportSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_import_section( &mut self, imports: &mut ImportSection, section: ImportSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the imports to the import
section.Source§fn parse_import(
&mut self,
imports: &mut ImportSection,
import: Import<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_import( &mut self, imports: &mut ImportSection, import: Import<'_>, ) -> Result<(), Error<Self::Error>>
Parses the single
wasmparser::Import
provided and adds it to the
import
section.Source§fn parse_memory_section(
&mut self,
memories: &mut MemorySection,
section: MemorySectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_memory_section( &mut self, memories: &mut MemorySection, section: MemorySectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the memories to the memories
section.Source§fn parse_table_section(
&mut self,
tables: &mut TableSection,
section: TableSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_table_section( &mut self, tables: &mut TableSection, section: TableSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the tables to the tables
section.Source§fn parse_table(
&mut self,
tables: &mut TableSection,
table: Table<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_table( &mut self, tables: &mut TableSection, table: Table<'_>, ) -> Result<(), Error<Self::Error>>
Parses a single
wasmparser::Table
and adds it to the tables
section.Source§fn parse_tag_section(
&mut self,
tags: &mut TagSection,
section: TagSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_tag_section( &mut self, tags: &mut TagSection, section: TagSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the tags to the tags
section.Source§fn parse_type_section(
&mut self,
types: &mut TypeSection,
section: TypeSectionReader<'_>,
) -> Result<(), Error<Self::Error>>
fn parse_type_section( &mut self, types: &mut TypeSection, section: TypeSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
Parses the input
section
given from the wasmparser
crate and adds
all the types to the types
section.Source§fn parse_recursive_type_group(
&mut self,
encoder: CoreTypeEncoder<'_>,
rec_group: RecGroup,
) -> Result<(), Error<Self::Error>>
fn parse_recursive_type_group( &mut self, encoder: CoreTypeEncoder<'_>, rec_group: RecGroup, ) -> Result<(), Error<Self::Error>>
Parses a single
wasmparser::RecGroup
and adds it to the types
section.fn parse_unknown_section( &mut self, module: &mut Module, id: u8, contents: &[u8], ) -> Result<(), Error<Self::Error>>
Source§fn intersperse_section_hook(
&mut self,
module: &mut Module,
after: Option<SectionId>,
before: Option<SectionId>,
) -> Result<(), Error<Self::Error>>
fn intersperse_section_hook( &mut self, module: &mut Module, after: Option<SectionId>, before: Option<SectionId>, ) -> Result<(), Error<Self::Error>>
A hook method that is called inside
Reencode::parse_core_module
before and after every non-custom core wasm section. Read morefn parse_core_module( &mut self, module: &mut Module, parser: Parser, data: &[u8], ) -> Result<(), Error<Self::Error>>
fn custom_name_section( &mut self, section: NameSectionReader<'_>, ) -> Result<NameSection, Error<Self::Error>>
fn parse_custom_name_subsection( &mut self, names: &mut NameSection, section: Name<'_>, ) -> Result<(), Error<Self::Error>>
fn data_count(&mut self, count: u32) -> u32
fn start_section(&mut self, start: u32) -> u32
Source§impl ReencodeComponent for RoundtripReencoder
Available on crate feature component-model
only.
impl ReencodeComponent for RoundtripReencoder
Available on crate feature
component-model
only.fn component_type_index(&mut self, ty: u32) -> u32
fn component_instance_index(&mut self, ty: u32) -> u32
fn component_func_index(&mut self, ty: u32) -> u32
fn component_index(&mut self, ty: u32) -> u32
fn module_index(&mut self, ty: u32) -> u32
fn instance_index(&mut self, ty: u32) -> u32
fn component_value_index(&mut self, ty: u32) -> u32
fn outer_type_index(&mut self, count: u32, ty: u32) -> u32
fn outer_component_type_index(&mut self, count: u32, ty: u32) -> u32
fn outer_component_index(&mut self, count: u32, component: u32) -> u32
fn outer_module_index(&mut self, count: u32, module: u32) -> u32
fn push_depth(&mut self)
fn pop_depth(&mut self)
fn component_external_index( &mut self, kind: ComponentExternalKind, index: u32, ) -> u32
fn parse_component( &mut self, component: &mut Component, parser: Parser, data: &[u8], ) -> Result<(), Error<Self::Error>>
fn parse_component_payload( &mut self, component: &mut Component, payload: Payload<'_>, whole_component: &[u8], ) -> Result<(), Error<Self::Error>>
fn parse_component_submodule( &mut self, component: &mut Component, parser: Parser, module: &[u8], ) -> Result<(), Error<Self::Error>>
fn parse_component_subcomponent( &mut self, component: &mut Component, parser: Parser, subcomponent: &[u8], whole_component: &[u8], ) -> Result<(), Error<Self::Error>>
fn parse_unknown_component_section( &mut self, component: &mut Component, id: u8, contents: &[u8], ) -> Result<(), Error<Self::Error>>
fn parse_component_custom_section( &mut self, component: &mut Component, section: CustomSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_type_section( &mut self, types: &mut ComponentTypeSection, section: ComponentTypeSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_type( &mut self, dst: ComponentTypeEncoder<'_>, ty: ComponentType<'_>, ) -> Result<(), Error<Self::Error>>
fn component_instance_type( &mut self, ty: Box<[InstanceTypeDeclaration<'_>]>, ) -> Result<InstanceType, Error<Self::Error>>
fn parse_component_instance_type_declaration( &mut self, ty: &mut InstanceType, decl: InstanceTypeDeclaration<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_core_type( &mut self, ty: ComponentCoreTypeEncoder<'_>, core: CoreType<'_>, ) -> Result<(), Error<Self::Error>>
fn component_type( &mut self, ty: Box<[ComponentTypeDeclaration<'_>]>, ) -> Result<ComponentType, Error<Self::Error>>
fn parse_component_type_declaration( &mut self, component: &mut ComponentType, decl: ComponentTypeDeclaration<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_func_type( &mut self, func: ComponentFuncTypeEncoder<'_>, ty: ComponentFuncType<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_defined_type( &mut self, defined: ComponentDefinedTypeEncoder<'_>, ty: ComponentDefinedType<'_>, ) -> Result<(), Error<Self::Error>>
fn component_module_type( &mut self, ty: Box<[ModuleTypeDeclaration<'_>]>, ) -> Result<ModuleType, Error<Self::Error>>
fn parse_component_module_type_declaration( &mut self, module: &mut ModuleType, decl: ModuleTypeDeclaration<'_>, ) -> Result<(), Error<Self::Error>>
fn component_alias<'a>( &mut self, alias: ComponentAlias<'a>, ) -> Result<Alias<'a>, Error<Self::Error>>
fn parse_component_import_section( &mut self, imports: &mut ComponentImportSection, section: ComponentImportSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_canonical_section( &mut self, canonical: &mut CanonicalFunctionSection, section: ComponentCanonicalSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_canonical( &mut self, section: &mut CanonicalFunctionSection, func: CanonicalFunction, ) -> Result<(), Error<Self::Error>>
fn parse_component_alias_section( &mut self, aliases: &mut ComponentAliasSection, section: ComponentAliasSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_instance_section( &mut self, instances: &mut ComponentInstanceSection, section: ComponentInstanceSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_instance( &mut self, instances: &mut ComponentInstanceSection, instance: ComponentInstance<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_instance_section( &mut self, instances: &mut InstanceSection, section: InstanceSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_instance( &mut self, instances: &mut InstanceSection, instance: Instance<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_core_type_section( &mut self, types: &mut CoreTypeSection, section: CoreTypeSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_export_section( &mut self, exports: &mut ComponentExportSection, section: ComponentExportSectionReader<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_export( &mut self, exports: &mut ComponentExportSection, export: ComponentExport<'_>, ) -> Result<(), Error<Self::Error>>
fn parse_component_start_section( &mut self, component: &mut Component, func: ComponentStartFunction, ) -> Result<(), Error<Self::Error>>
fn component_type_ref(&mut self, ty: ComponentTypeRef) -> ComponentTypeRef
fn component_primitive_val_type( &mut self, ty: PrimitiveValType, ) -> PrimitiveValType
fn component_export_kind( &mut self, ty: ComponentExternalKind, ) -> ComponentExportKind
fn component_outer_alias_kind( &mut self, kind: ComponentOuterAliasKind, ) -> ComponentOuterAliasKind
fn component_val_type(&mut self, ty: ComponentValType) -> ComponentValType
fn type_bounds(&mut self, ty: TypeBounds) -> TypeBounds
fn canonical_option(&mut self, ty: CanonicalOption) -> CanonicalOption
fn custom_component_name_section( &mut self, section: ComponentNameSectionReader<'_>, ) -> Result<ComponentNameSection, Error<Self::Error>>
fn parse_custom_component_name_subsection( &mut self, names: &mut ComponentNameSection, section: ComponentName<'_>, ) -> Result<(), Error<Self::Error>>
Auto Trait Implementations§
impl Freeze for RoundtripReencoder
impl RefUnwindSafe for RoundtripReencoder
impl Send for RoundtripReencoder
impl Sync for RoundtripReencoder
impl Unpin for RoundtripReencoder
impl UnwindSafe for RoundtripReencoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more