| 40 | |
| 41 | impl 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 | |
| 68 | fn find_rename(attributes: &[syn::Attribute]) -> Result<Option<syn::LitStr>> { |