MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / detect_precompiled

Function detect_precompiled

crates/wasmtime/src/engine/serialization.rs:151–167  ·  view source on GitHub ↗
(
    obj: ElfFile64<'data, Endianness, R>,
)

Source from the content-addressed store, hash-verified

149}
150
151fn detect_precompiled<'data, R: object::ReadRef<'data>>(
152 obj: ElfFile64<'data, Endianness, R>,
153) -> Option<Precompiled> {
154 match obj.flags() {
155 FileFlags::Elf {
156 os_abi: obj::ELFOSABI_WASMTIME,
157 abi_version: 0,
158 e_flags,
159 } if e_flags & obj::EF_WASMTIME_MODULE != 0 => Some(Precompiled::Module),
160 FileFlags::Elf {
161 os_abi: obj::ELFOSABI_WASMTIME,
162 abi_version: 0,
163 e_flags,
164 } if e_flags & obj::EF_WASMTIME_COMPONENT != 0 => Some(Precompiled::Component),
165 _ => None,
166 }
167}
168
169pub fn detect_precompiled_bytes(bytes: &[u8]) -> Option<Precompiled> {
170 detect_precompiled(ElfFile64::parse(bytes).ok()?)

Callers 2

detect_precompiled_bytesFunction · 0.70
detect_precompiled_fileFunction · 0.70

Calls 1

flagsMethod · 0.45

Tested by

no test coverage detected