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

Method instance

crates/wasmtime/src/runtime/component/matching.rs:154–174  ·  view source on GitHub ↗
(
        &mut self,
        expected: &TypeComponentInstance,
        actual: Option<&NameMap<Atom, Definition>>,
    )

Source from the content-addressed store, hash-verified

152 }
153
154 fn instance(
155 &mut self,
156 expected: &TypeComponentInstance,
157 actual: Option<&NameMap<Atom, Definition>>,
158 ) -> Result<()> {
159 // Like modules, every export in the expected type must be present in
160 // the actual type. It's ok, though, to have extra exports in the actual
161 // type.
162 for (name, expected) in expected.exports.iter() {
163 // Interface types may be exported from a component in order to give them a name, but
164 // they don't have a definition in the sense that this search is interested in, so
165 // ignore them.
166 if let TypeDef::Interface(_) = expected.ty {
167 continue;
168 }
169 let actual = actual.and_then(|actual| actual.get(name, self.strings));
170 self.definition(&expected.ty, actual)
171 .with_context(|| format!("instance export `{name}` has the wrong type"))?;
172 }
173 Ok(())
174 }
175
176 fn func(&self, expected: TypeFuncIndex, actual: &HostFunc) -> Result<()> {
177 let instance_type = InstanceType {

Callers 1

definitionMethod · 0.45

Calls 5

OkFunction · 0.85
with_contextMethod · 0.80
iterMethod · 0.45
getMethod · 0.45
definitionMethod · 0.45

Tested by

no test coverage detected