Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 //! Macros for [Lofty](https://crates.io/crates/lofty)
2
3 #![allow(
4 unknown_lints,
5 clippy::too_many_lines,
6 clippy::cast_precision_loss,
7 clippy::cast_sign_loss,
8 clippy::cast_possible_wrap,
9 clippy::cast_possible_truncation,
10 clippy::module_name_repetitions,
11 clippy::must_use_candidate,
12 clippy::doc_markdown,
13 let_underscore_drop,
14 clippy::match_wildcard_for_single_variants,
15 clippy::semicolon_if_nothing_returned,
16 clippy::new_without_default,
17 clippy::from_over_into,
18 clippy::upper_case_acronyms,
19 clippy::single_match_else,
20 clippy::similar_names,
21 clippy::tabs_in_doc_comments,
22 clippy::len_without_is_empty,
23 clippy::needless_late_init,
24 clippy::type_complexity,
25 clippy::type_repetition_in_bounds,
26 unused_qualifications,
27 clippy::return_self_not_must_use,
28 clippy::bool_to_int_with_if,
29 clippy::uninlined_format_args, /* This should be changed for any normal "{}", but I'm not a fan of it for any debug or width specific formatting */
30 clippy::manual_let_else,
31 clippy::struct_excessive_bools,
32 clippy::match_bool,
33 clippy::needless_pass_by_value
34 )]
35
36 mod attribute;
37 mod internal;
38 mod lofty_file;
39 mod lofty_tag;
40 mod util;
41
42 use crate::lofty_file::LoftyFile;
43 use crate::lofty_tag::{LoftyTag, LoftyTagAttribute};
44
45 use proc_macro::TokenStream;
46 use syn::{parse_macro_input, ItemStruct};
47
48 /// Creates a file usable by Lofty
49 ///
50 /// See [here](https://github.com/Serial-ATA/lofty-rs/tree/main/examples/custom_resolver) for an example of how to use it.
51 #[proc_macro_derive(LoftyFile, attributes(lofty))]
52 pub fn lofty_file(input: TokenStream) -> TokenStream {
53 let lofty_file = parse_macro_input!(input as LoftyFile);
54 match lofty_file.emit() {
55 Ok(ret) => ret,
56 Err(e) => e.to_compile_error().into(),
57 }
58 }
59
60 #[proc_macro_attribute]
61 #[doc(hidden)]
62 pub fn tag(args_input: TokenStream, input: TokenStream) -> TokenStream {
63 let attribute = parse_macro_input!(args_input as LoftyTagAttribute);
64 let input = parse_macro_input!(input as ItemStruct);
65
66 let lofty_tag = LoftyTag::new(attribute, input);
67 lofty_tag.emit()
68 }