MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / deserialize_lang_config

Method deserialize_lang_config

crates/test/src/lib.rs:1354–1376  ·  view source on GitHub ↗

Helper to convert `RuntimeTestConfig` to a `RuntimeTestConfig ` and then extract the `T`. This is called from within each language's implementation with a specific `T` necessary for that language.

(&self)

Source from the content-addressed store, hash-verified

1352 /// This is called from within each language's implementation with a
1353 /// specific `T` necessary for that language.
1354 fn deserialize_lang_config<T>(&self) -> Result<T>
1355 where
1356 T: Default + serde::de::DeserializeOwned,
1357 {
1358 // If this test has no language-specific configuration then return this
1359 // language's default configuration.
1360 if self.lang_config.is_none() {
1361 return Ok(T::default());
1362 }
1363
1364 // Otherwise re-parse the TOML at the top of the file but this time
1365 // with the specific `T` that we're interested in. This is expected
1366 // to then produce a value in the `lang` field since
1367 // `self.lang_config.is_some()` is true.
1368 let config = config::parse_test_config::<config::RuntimeTestConfig<T>>(
1369 &self.contents,
1370 self.language
1371 .obj()
1372 .comment_prefix_for_test_config()
1373 .unwrap(),
1374 )?;
1375 Ok(config.lang.unwrap())
1376 }
1377}

Callers

nothing calls this directly

Calls 2

objMethod · 0.80

Tested by

no test coverage detected