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

Method parse

crates/component-macro/src/component.rs:42–65  ·  view source on GitHub ↗
(input: ParseStream)

Source from the content-addressed store, hash-verified

40
41impl Parse for ComponentAttr {
42 fn parse(input: ParseStream) -> Result<Self> {
43 let lookahead = input.lookahead1();
44 if lookahead.peek(kw::record) {
45 input.parse::<kw::record>()?;
46 Ok(ComponentAttr::Style(Style::Record))
47 } else if lookahead.peek(kw::variant) {
48 input.parse::<kw::variant>()?;
49 Ok(ComponentAttr::Style(Style::Variant))
50 } else if lookahead.peek(Token![enum]) {
51 input.parse::<Token![enum]>()?;
52 Ok(ComponentAttr::Style(Style::Enum))
53 } else if lookahead.peek(kw::wasmtime_crate) {
54 input.parse::<kw::wasmtime_crate>()?;
55 input.parse::<Token![=]>()?;
56 Ok(ComponentAttr::WasmtimeCrate(input.parse()?))
57 } else if input.peek(kw::flags) {
58 Err(input.error(
59 "`flags` not allowed here; \
60 use `wasmtime::component::flags!` macro to define `flags` types",
61 ))
62 } else {
63 Err(lookahead.error())
64 }
65 }
66}
67
68fn find_rename(attributes: &[syn::Attribute]) -> Result<Option<syn::LitStr>> {

Callers

nothing calls this directly

Calls 10

OkFunction · 0.85
StyleEnum · 0.85
find_renameFunction · 0.85
collectMethod · 0.80
peekMethod · 0.45
errorMethod · 0.45
mapMethod · 0.45
valueMethod · 0.45
to_stringMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected