swift_mt_message_macros/utils/
attributes.rs1use syn::{Attribute, Meta};
2
3pub fn extract_message_type_attribute(attrs: &[Attribute]) -> Option<String> {
4 for attr in attrs {
5 if attr.path().is_ident("swift_message") {
6 if let Meta::List(meta_list) = &attr.meta {
7 let tokens = meta_list.tokens.to_string();
8 if let Some(eq_pos) = tokens.find('=') {
10 let value_part = tokens[eq_pos + 1..].trim();
11 if let Some(nested) = value_part.strip_prefix('"') {
12 if let Some(value) = nested.strip_suffix('"') {
13 return Some(value.to_string());
14 }
15 }
16 }
17 }
18 }
19 }
20 None
21}