| 1 | use synrust-analyzer cargo syn 2.0.96 crate/::parserust-analyzer cargo syn 2.0.96 parse/::Parserust-analyzer cargo syn 2.0.96 parse/Parse#; |
| 2 | use synrust-analyzer cargo syn 2.0.96 crate/::punctuatedrust-analyzer cargo syn 2.0.96 punctuated/::Punctuatedrust-analyzer cargo syn 2.0.96 punctuated/Punctuated#; |
| 3 | use synrust-analyzer cargo syn 2.0.96 crate/::{tokenrust-analyzer cargo syn 2.0.96 token/, Attributerust-analyzer cargo syn 2.0.96 attr/Attribute#, Exprrust-analyzer cargo syn 2.0.96 expr/Expr#, Identrust-analyzer cargo proc-macro2 1.0.93 Ident#, LitStrrust-analyzer cargo syn 2.0.96 lit/LitStr#, Tokenrust-analyzer cargo syn 2.0.96 token/Token!}; |
| 4 | |
| 5 | pub(craterust-analyzer cargo lofty_attr 0.11.1 crate/) enum AttributeValuerust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue# { |
| 6 | /// `#[lofty(attribute_name)]` |
| 7 | Pathrust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue#Path#(Identrust-analyzer cargo proc-macro2 1.0.93 Ident#), |
| 8 | /// `#[lofty(attribute_name = "value")]` |
| 9 | NameValuerust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue#NameValue#(Identrust-analyzer cargo proc-macro2 1.0.93 Ident#, LitStrrust-analyzer cargo syn 2.0.96 lit/LitStr#), |
| 10 | #[allow(dead_code)] |
| 11 | /// `#[lofty(attribute_name(value1, value2, value3))]` |
| 12 | SingleListrust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue#SingleList#(Identrust-analyzer cargo proc-macro2 1.0.93 Ident#, Punctuatedrust-analyzer cargo syn 2.0.96 punctuated/Punctuated#<Exprrust-analyzer cargo syn 2.0.96 expr/Expr#, Tokenrust-analyzer cargo syn 2.0.96 token/Token!![,]>), |
| 13 | } |
| 14 | |
| 15 | impl AttributeValuerust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue# { |
| 16 | pub(craterust-analyzer cargo lofty_attr 0.11.1 crate/) fn from_attributerust-analyzer cargo lofty_attr 0.11.1 attribute/impl#[AttributeValue]from_attribute().( |
| 17 | expected_path: &str, |
| 18 | attribute: &Attributerust-analyzer cargo syn 2.0.96 attr/Attribute#, |
| 19 | ) -> synrust-analyzer cargo syn 2.0.96 crate/::Resultrust-analyzer cargo syn 2.0.96 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo lofty_attr 0.11.1 attribute/impl#[AttributeValue]>> { |
| 20 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().attribute.pathrust-analyzer cargo syn 2.0.96 attr/impl#[Attribute]path().().is_identrust-analyzer cargo syn 2.0.96 path/impl#[Path]is_ident().(expected_path) { |
| 21 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 22 | } |
| 23 | |
| 24 | let mut value = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 25 | attribute.parse_nested_metarust-analyzer cargo syn 2.0.96 attr/impl#[Attribute]parse_nested_meta().(|meta| { |
| 26 | // `#[lofty(attribute_name)]` |
| 27 | if meta.inputrust-analyzer cargo syn 2.0.96 meta/ParseNestedMeta#input..is_emptyrust-analyzer cargo syn 2.0.96 parse/impl#[`ParseBuffer<'a>`]is_empty().() { |
| 28 | value = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AttributeValuerust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue#::Pathrust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue#Path#(meta.pathrust-analyzer cargo syn 2.0.96 meta/ParseNestedMeta#path..get_identrust-analyzer cargo syn 2.0.96 path/impl#[Path]get_ident().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().clonerust-analyzer cargo proc-macro2 1.0.93 impl#[Ident][Clone]clone().())); |
| 29 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 30 | } |
| 31 | |
| 32 | // `#[lofty(attribute_name = "value")]` |
| 33 | if meta.inputrust-analyzer cargo syn 2.0.96 meta/ParseNestedMeta#input..peekrust-analyzer cargo syn 2.0.96 parse/impl#[`ParseBuffer<'a>`]peek().(tokenrust-analyzer cargo syn 2.0.96 token/::Eqrust-analyzer cargo syn 2.0.96 token/Eq().) { |
| 34 | let val = meta.valuerust-analyzer cargo syn 2.0.96 meta/impl#[`ParseNestedMeta<'a>`]value().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 35 | let str_value: LitStrrust-analyzer cargo syn 2.0.96 lit/LitStr# = val.parserust-analyzer cargo syn 2.0.96 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 36 | |
| 37 | value = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AttributeValuerust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue#::NameValuerust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue#NameValue#( |
| 38 | meta.pathrust-analyzer cargo syn 2.0.96 meta/ParseNestedMeta#path..get_identrust-analyzer cargo syn 2.0.96 path/impl#[Path]get_ident().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().clonerust-analyzer cargo proc-macro2 1.0.93 impl#[Ident][Clone]clone().(), |
| 39 | str_value, |
| 40 | )); |
| 41 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 42 | } |
| 43 | |
| 44 | // `#[lofty(attribute_name(value1, value2, value3))]` |
| 45 | if meta.inputrust-analyzer cargo syn 2.0.96 meta/ParseNestedMeta#input..peekrust-analyzer cargo syn 2.0.96 parse/impl#[`ParseBuffer<'a>`]peek().(tokenrust-analyzer cargo syn 2.0.96 token/::Parenrust-analyzer cargo syn 2.0.96 token/Paren().) { |
| 46 | return meta.parse_nested_metarust-analyzer cargo syn 2.0.96 meta/impl#[`ParseNestedMeta<'a>`]parse_nested_meta().(|meta| { |
| 47 | let list = meta.inputrust-analyzer cargo syn 2.0.96 meta/ParseNestedMeta#input..parse_terminatedrust-analyzer cargo syn 2.0.96 parse/impl#[`ParseBuffer<'a>`]parse_terminated().(synrust-analyzer cargo syn 2.0.96 crate/::Exprrust-analyzer cargo syn 2.0.96 expr/Expr#::parserust-analyzer cargo syn 2.0.96 expr/parsing/impl#[Expr][Parse]parse()., Tokenrust-analyzer cargo syn 2.0.96 token/Token!![,])?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 48 | value = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AttributeValuerust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue#::SingleListrust-analyzer cargo lofty_attr 0.11.1 attribute/AttributeValue#SingleList#( |
| 49 | meta.pathrust-analyzer cargo syn 2.0.96 meta/ParseNestedMeta#path..get_identrust-analyzer cargo syn 2.0.96 path/impl#[Path]get_ident().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().clonerust-analyzer cargo proc-macro2 1.0.93 impl#[Ident][Clone]clone().(), |
| 50 | list, |
| 51 | )); |
| 52 | |
| 53 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 54 | }); |
| 55 | } |
| 56 | |
| 57 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(meta.errorrust-analyzer cargo syn 2.0.96 meta/impl#[`ParseNestedMeta<'a>`]error().("Unrecognized attribute format")) |
| 58 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 59 | |
| 60 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) |
| 61 | } |
| 62 | } |