[][src]Trait walrus::CustomSection

pub trait CustomSection: WalrusAny + Debug + Send + Sync {
    fn name(&self) -> &str;
fn data(&self, ids_to_indices: &IdsToIndices) -> Cow<[u8]>; fn add_gc_roots(&self, roots: &mut Roots) { ... }
fn apply_code_transform(&mut self, transform: &CodeTransform) { ... } }

A trait for implementing custom sections.

Custom sections are added to a walrus::Module via my_module.custom_sections.add(my_custom_section).

Required methods

fn name(&self) -> &str

Get this custom section's name.

For example ".debug_info" for one of the DWARF custom sections or "name" for the names custom section.

fn data(&self, ids_to_indices: &IdsToIndices) -> Cow<[u8]>

Get the data payload for this custom section.

This should not include the section header with id=0, the custom section's name, or the count of how many bytes are in the payload. walrus will handle these for you.

Loading content...

Provided methods

fn add_gc_roots(&self, roots: &mut Roots)

Add any core wasm roots to the provided roots argument.

This function will add any referenced core wasm items into the Roots array provided.

The default provided method does nothing.

fn apply_code_transform(&mut self, transform: &CodeTransform)

Apply the given code transformations to this custom section.

If the module was not configured with preserve_code_transform = true, then this method is never called.

This method is called after we have emitted the non-custom Wasm sections, just before a custom section's data is emitted into the Wasm binary. If this custom section references offsets in the Wasm code, this is a chance to update them so they are valid for the new, transformed Wasm code that is being emitted.

For example, DWARF debug info references Wasm instructions via offsets into the code section, and we can use these transforms to fix those offsets after having transformed various functions and instructions.

The default provided method does nothing.

Loading content...

Methods

impl dyn CustomSection[src]

pub fn into_any(self: Box<Self>) -> Box<dyn Any + Send + 'static>[src]

Convert this custom section to Box<Any> to do dynamic downcasting

pub fn as_any(&self) -> &(dyn Any + Send + Sync)[src]

Convert this custom section to &Any to do dynamic downcasting

pub fn as_any_mut(&mut self) -> &mut (dyn Any + Send + Sync)[src]

Convert this custom section to &mut Any to do dynamic downcasting

Implementors

impl CustomSection for RawCustomSection[src]

Loading content...