Sha256: a01d4a91bcd93048977ccafc6af160357297450395bf598351f5a3e6d322e0de

Contents?: true

Size: 1.01 KB

Versions: 54

Compression:

Stored size: 1.01 KB

Contents

use crate::{encoding_size, Encode, Section, SectionId};

/// An encoder for the start section of WebAssembly modules.
///
/// # Example
///
/// Note: this doesn't actually define the function at index 0, its type, or its
/// code body, so the resulting Wasm module will be invalid. See `TypeSection`,
/// `FunctionSection`, and `CodeSection` for details on how to generate those
/// things.
///
/// ```
/// use wasm_encoder::{Module, StartSection};
///
/// let start = StartSection { function_index: 0 };
///
/// let mut module = Module::new();
/// module.section(&start);
///
/// let wasm_bytes = module.finish();
/// ```
#[derive(Clone, Copy, Debug)]
pub struct StartSection {
    /// The index of the start function.
    pub function_index: u32,
}

impl Encode for StartSection {
    fn encode(&self, sink: &mut Vec<u8>) {
        encoding_size(self.function_index).encode(sink);
        self.function_index.encode(sink);
    }
}

impl Section for StartSection {
    fn id(&self) -> u8 {
        SectionId::Start.into()
    }
}

Version data entries

54 entries across 38 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/wasm-encoder-0.221.2/src/core/start.rs
wasmtime-28.0.0 ./ext/cargo-vendor/wasm-encoder-0.221.2/src/core/start.rs
wasmtime-27.0.0 ./ext/cargo-vendor/wasm-encoder-0.220.0/src/core/start.rs
wasmtime-27.0.0 ./ext/cargo-vendor/wasm-encoder-0.219.1/src/core/start.rs
wasmtime-26.0.0 ./ext/cargo-vendor/wasm-encoder-0.219.1/src/core/start.rs
wasmtime-26.0.0 ./ext/cargo-vendor/wasm-encoder-0.218.0/src/core/start.rs
wasmtime-25.0.2 ./ext/cargo-vendor/wasm-encoder-0.217.0/src/core/start.rs
wasmtime-25.0.2 ./ext/cargo-vendor/wasm-encoder-0.218.0/src/core/start.rs
wasmtime-25.0.1 ./ext/cargo-vendor/wasm-encoder-0.217.0/src/core/start.rs
wasmtime-25.0.0 ./ext/cargo-vendor/wasm-encoder-0.217.0/src/core/start.rs
wasmtime-24.0.0 ./ext/cargo-vendor/wasm-encoder-0.216.0/src/core/start.rs
wasmtime-24.0.0 ./ext/cargo-vendor/wasm-encoder-0.215.0/src/core/start.rs
wasmtime-23.0.2 ./ext/cargo-vendor/wasm-encoder-0.215.0/src/core/start.rs
wasmtime-23.0.2 ./ext/cargo-vendor/wasm-encoder-0.212.0/src/core/start.rs
wasmtime-22.0.0 ./ext/cargo-vendor/wasm-encoder-0.209.1/src/core/start.rs
wasmtime-21.0.1 ./ext/cargo-vendor/wasm-encoder-0.207.0/src/core/start.rs
wasmtime-21.0.1 ./ext/cargo-vendor/wasm-encoder-0.209.1/src/core/start.rs
wasmtime-20.0.2 ./ext/cargo-vendor/wasm-encoder-0.209.1/src/core/start.rs
wasmtime-20.0.2 ./ext/cargo-vendor/wasm-encoder-0.202.0/src/core/start.rs
wasmtime-20.0.0 ./ext/cargo-vendor/wasm-encoder-0.202.0/src/core/start.rs