| 1 | use proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#; |
| 2 | use quoterust-analyzer cargo quote 1.0.38 crate/::quoterust-analyzer cargo quote 1.0.38 quote!; |
| 3 | 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#, ParseStreamrust-analyzer cargo syn 2.0.96 parse/ParseStream#}; |
| 4 | 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#; |
| 5 | use synrust-analyzer cargo syn 2.0.96 crate/::spannedrust-analyzer cargo syn 2.0.96 spanned/::Spannedrust-analyzer cargo syn 2.0.96 spanned/Spanned#; |
| 6 | use synrust-analyzer cargo syn 2.0.96 crate/::{ |
| 7 | Errorrust-analyzer cargo syn 2.0.96 error/Error#, Exprrust-analyzer cargo syn 2.0.96 expr/Expr#, ExprLitrust-analyzer cargo syn 2.0.96 expr/ExprLit#, ItemStructrust-analyzer cargo syn 2.0.96 item/ItemStruct#, Litrust-analyzer cargo syn 2.0.96 lit/Lit#, LitStrrust-analyzer cargo syn 2.0.96 lit/LitStr#, Metarust-analyzer cargo syn 2.0.96 attr/Meta#, MetaListrust-analyzer cargo syn 2.0.96 attr/MetaList#, MetaNameValuerust-analyzer cargo syn 2.0.96 attr/MetaNameValue#, Pathrust-analyzer cargo syn 2.0.96 path/Path#, Resultrust-analyzer cargo syn 2.0.96 error/Result#, |
| 8 | Tokenrust-analyzer cargo syn 2.0.96 token/Token!, |
| 9 | }; |
| 10 | |
| 11 | enum SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat# { |
| 12 | Fullrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#Full#(Pathrust-analyzer cargo syn 2.0.96 path/Path#), |
| 13 | ReadOnlyrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#ReadOnly#(Pathrust-analyzer cargo syn 2.0.96 path/Path#), |
| 14 | } |
| 15 | |
| 16 | impl SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat# { |
| 17 | fn emit_doc_commentrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[SupportedFormat]emit_doc_comment().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 18 | match self { |
| 19 | SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#::Fullrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#Full#(path) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 20 | "* [`FileType::{ft}`](crate::file::FileType::{ft})\n", |
| 21 | ft = 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().() |
| 22 | ), |
| 23 | SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#::ReadOnlyrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#ReadOnly#(path) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 24 | "* [`FileType::{ft}`](crate::file::FileType::{ft}) **(READ ONLY)**\n", |
| 25 | ft = 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().() |
| 26 | ), |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | fn pathrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[SupportedFormat]path().(&self) -> &Pathrust-analyzer cargo syn 2.0.96 path/Path# { |
| 31 | match self { |
| 32 | SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#::Fullrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#Full#(path) | SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#::ReadOnlyrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#ReadOnly#(path) => path, |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | fn read_onlyrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[SupportedFormat]read_only().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Pathrust-analyzer cargo syn 2.0.96 path/Path#> { |
| 37 | match self { |
| 38 | SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#::ReadOnlyrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#ReadOnly#(path) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path), |
| 39 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | pub(craterust-analyzer cargo lofty_attr 0.11.1 crate/) struct LoftyTagrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag# { |
| 45 | attributerust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag#attribute.: LoftyTagAttributerust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute#, |
| 46 | inputrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag#input.: ItemStructrust-analyzer cargo syn 2.0.96 item/ItemStruct#, |
| 47 | } |
| 48 | |
| 49 | impl LoftyTagrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag# { |
| 50 | pub(craterust-analyzer cargo lofty_attr 0.11.1 crate/) fn newrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[LoftyTag]new().(attribute: LoftyTagAttributerust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute#, input: ItemStructrust-analyzer cargo syn 2.0.96 item/ItemStruct#) -> Selfrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[LoftyTag] { |
| 51 | LoftyTagrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag# { attributerust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag#attribute., inputrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag#input. } |
| 52 | } |
| 53 | |
| 54 | pub(craterust-analyzer cargo lofty_attr 0.11.1 crate/) fn emitrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[LoftyTag]emit().(&self) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# { |
| 55 | let ident = &self.inputrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag#input..identrust-analyzer cargo syn 2.0.96 item/ItemStruct#ident.; |
| 56 | let desc = &self.attributerust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag#attribute..descriptionrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute#description.; |
| 57 | |
| 58 | let supported_types_iter = self |
| 59 | .attributerust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag#attribute. |
| 60 | .supported_formatsrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute#supported_formats. |
| 61 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 62 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#::emit_doc_commentrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[SupportedFormat]emit_doc_comment().); |
| 63 | let flattened_file_types = self |
| 64 | .attributerust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag#attribute. |
| 65 | .supported_formatsrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute#supported_formats. |
| 66 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 67 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#::pathrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[SupportedFormat]path().); |
| 68 | let read_only_file_types = self |
| 69 | .attributerust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag#attribute. |
| 70 | .supported_formatsrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute#supported_formats. |
| 71 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 72 | .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#::read_onlyrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[SupportedFormat]read_only().); |
| 73 | |
| 74 | let input = &self.inputrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTag#input.; |
| 75 | TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::fromrust-analyzer cargo proc-macro2 1.0.93 impl#[`proc_macro::TokenStream`][`From<TokenStream>`]from().(quoterust-analyzer cargo quote 1.0.38 quote!! { |
| 76 | use ::lofty::_this_is_internal; |
| 77 | |
| 78 | #[doc = #desc] |
| 79 | #[doc = "\n"] |
| 80 | #[doc = "## Supported file types\n\n"] |
| 81 | #( #[doc = #supported_types_iter] )* |
| 82 | #[doc = "\n"] |
| 83 | #input |
| 84 | |
| 85 | impl #ident { |
| 86 | pub(crate) const SUPPORTED_FORMATS: &'static [::lofty::file::FileType] = &[ |
| 87 | #( ::lofty::file::FileType:: #flattened_file_types ),* |
| 88 | ]; |
| 89 | |
| 90 | pub(crate) const READ_ONLY_FORMATS: &'static [::lofty::file::FileType] = &[ |
| 91 | #( ::lofty::file::FileType:: #read_only_file_types ),* |
| 92 | ]; |
| 93 | } |
| 94 | }) |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | pub(craterust-analyzer cargo lofty_attr 0.11.1 crate/) struct LoftyTagAttributerust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute# { |
| 99 | descriptionrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute#description.: LitStrrust-analyzer cargo syn 2.0.96 lit/LitStr#, |
| 100 | supported_formatsrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute#supported_formats.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#>, |
| 101 | } |
| 102 | |
| 103 | impl Parserust-analyzer cargo syn 2.0.96 parse/Parse# for LoftyTagAttributerust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute# { |
| 104 | fn parserust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[LoftyTagAttribute][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.96 parse/ParseStream#<'_>) -> Resultrust-analyzer cargo syn 2.0.96 error/Result#<Selfrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[LoftyTagAttribute][Parse]> { |
| 105 | let mut description = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 106 | let mut supported_formats = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 107 | |
| 108 | let start_span = input.spanrust-analyzer cargo syn 2.0.96 parse/impl#[`ParseBuffer<'a>`]span().(); |
| 109 | |
| 110 | let args = Punctuatedrust-analyzer cargo syn 2.0.96 punctuated/Punctuated#::<Metarust-analyzer cargo syn 2.0.96 attr/Meta#, Tokenrust-analyzer cargo syn 2.0.96 token/Token!![,]>::parse_separated_nonemptyrust-analyzer cargo syn 2.0.96 punctuated/impl#[`Punctuated<T, P>`]parse_separated_nonempty().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 111 | for nested_meta in args { |
| 112 | match nested_meta { |
| 113 | Metarust-analyzer cargo syn 2.0.96 attr/Meta#::NameValuerust-analyzer cargo syn 2.0.96 attr/Meta#NameValue#(mnv) if mnv.pathrust-analyzer cargo syn 2.0.96 attr/MetaNameValue#path..is_identrust-analyzer cargo syn 2.0.96 path/impl#[Path]is_ident().("description") => { |
| 114 | if description.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 115 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo syn 2.0.96 error/Error#::newrust-analyzer cargo syn 2.0.96 error/impl#[Error]new().(mnv.spanrust-analyzer cargo syn 2.0.96 spanned/impl#[T][Spanned]span().(), "Duplicate `description` entry")); |
| 116 | } |
| 117 | |
| 118 | description = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parse_descriptionrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/parse_description().(mnv)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 119 | }, |
| 120 | Metarust-analyzer cargo syn 2.0.96 attr/Meta#::Listrust-analyzer cargo syn 2.0.96 attr/Meta#List#(list) if list.pathrust-analyzer cargo syn 2.0.96 attr/MetaList#path..is_identrust-analyzer cargo syn 2.0.96 path/impl#[Path]is_ident().("supported_formats") => { |
| 121 | parse_supported_formatsrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/parse_supported_formats().(list, &mut supported_formats)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 122 | }, |
| 123 | _ => { |
| 124 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo syn 2.0.96 error/Error#::newrust-analyzer cargo syn 2.0.96 error/impl#[Error]new().( |
| 125 | nested_meta.spanrust-analyzer cargo syn 2.0.96 spanned/impl#[T][Spanned]span().(), |
| 126 | "Unexpected input, check the format of the arguments", |
| 127 | )) |
| 128 | }, |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | if description.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 133 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo syn 2.0.96 error/Error#::newrust-analyzer cargo syn 2.0.96 error/impl#[Error]new().(start_span, "No description provided")); |
| 134 | } |
| 135 | |
| 136 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/impl#[LoftyTagAttribute][Parse] { |
| 137 | descriptionrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute#description.: description.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 138 | supported_formatsrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/LoftyTagAttribute#supported_formats., |
| 139 | }) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | fn parse_descriptionrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/parse_description().(name_value: MetaNameValuerust-analyzer cargo syn 2.0.96 attr/MetaNameValue#) -> Resultrust-analyzer cargo syn 2.0.96 error/Result#<LitStrrust-analyzer cargo syn 2.0.96 lit/LitStr#> { |
| 144 | match name_value.valuerust-analyzer cargo syn 2.0.96 attr/MetaNameValue#value. { |
| 145 | Exprrust-analyzer cargo syn 2.0.96 expr/Expr#::Litrust-analyzer cargo syn 2.0.96 expr/Expr#Lit#(ExprLitrust-analyzer cargo syn 2.0.96 expr/ExprLit# { |
| 146 | litrust-analyzer cargo syn 2.0.96 expr/ExprLit#lit.: Litrust-analyzer cargo syn 2.0.96 lit/Lit#::Strrust-analyzer cargo syn 2.0.96 lit/Lit#Str#(lit_str), |
| 147 | .. |
| 148 | }) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(lit_str), |
| 149 | _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo syn 2.0.96 error/Error#::newrust-analyzer cargo syn 2.0.96 error/impl#[Error]new().( |
| 150 | name_value.spanrust-analyzer cargo syn 2.0.96 spanned/impl#[T][Spanned]span().(), |
| 151 | "Invalid `description` entry, expected string value", |
| 152 | )), |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | fn parse_supported_formatsrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/parse_supported_formats().( |
| 157 | meta_list: MetaListrust-analyzer cargo syn 2.0.96 attr/MetaList#, |
| 158 | supported_formats: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#>, |
| 159 | ) -> Resultrust-analyzer cargo syn 2.0.96 error/Result#<()> { |
| 160 | let mut read_only_encountered = false; |
| 161 | meta_list.parse_nested_metarust-analyzer cargo syn 2.0.96 attr/impl#[MetaList]parse_nested_meta().(|meta| { |
| 162 | if meta.pathrust-analyzer cargo syn 2.0.96 meta/ParseNestedMeta#path..is_identrust-analyzer cargo syn 2.0.96 path/impl#[Path]is_ident().("read_only") { |
| 163 | if read_only_encountered { |
| 164 | return 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().("Duplicate `read_only` entry")); |
| 165 | } |
| 166 | |
| 167 | read_only_encountered = true; |
| 168 | |
| 169 | meta.parse_nested_metarust-analyzer cargo syn 2.0.96 meta/impl#[`ParseNestedMeta<'a>`]parse_nested_meta().(|nested_meta| { |
| 170 | supported_formats.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#::ReadOnlyrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#ReadOnly#(nested_meta.pathrust-analyzer cargo syn 2.0.96 meta/ParseNestedMeta#path.)); |
| 171 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 172 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 173 | } else { |
| 174 | supported_formats.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(SupportedFormatrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#::Fullrust-analyzer cargo lofty_attr 0.11.1 lofty_tag/SupportedFormat#Full#(meta.pathrust-analyzer cargo syn 2.0.96 meta/ParseNestedMeta#path.)); |
| 175 | } |
| 176 | |
| 177 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 178 | }) |
| 179 | } |