Struct wasmprinter::Printer
source · [−]pub struct Printer { /* private fields */ }Expand description
Context used for printing a WebAssembly binary.
This is largely only required if you’d like to register custom printers for custom sections in a wasm binary.
Implementations
sourceimpl Printer
impl Printer
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Printer object that’s ready to start printing wasm
binaries to strings.
sourcepub fn add_custom_section_printer(
&mut self,
section: &str,
printer: impl FnMut(&mut Printer, usize, &[u8]) -> Result<()> + 'static
)
pub fn add_custom_section_printer(
&mut self,
section: &str,
printer: impl FnMut(&mut Printer, usize, &[u8]) -> Result<()> + 'static
)
Registers a custom printer function to get invoked whenever a custom
section of name section is seen.
This can be used to register printers into a textual format for custom sections, such as by emitting annotations and/or other textual references (maybe comments!)
By default all custom sections are ignored for the text format.
The printer function provided takes three arguments:
- A
&mut Printer, or where to print results to - A
usizeoffset which is the start of the offset for the custom section - A byte slice which is the actual contents of the custom section.
sourcepub fn result_mut(&mut self) -> &mut String
pub fn result_mut(&mut self) -> &mut String
Gets the output result of this Printer, or where all output is going.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Printer
impl !Send for Printer
impl !Sync for Printer
impl Unpin for Printer
impl !UnwindSafe for Printer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more