Open mkj opened 2 years ago
I'm up for changing ParsedAttribute ::Property
. Some options I see:
ParsedAttribute::Property(Ident, TokenTree);
ParsedAttribute::LiteralProperty(Ident, Literal);
and ParsedAttribute::IdentProperty(Ident, Ident)
(names bikesheddable)I do feel like there is a better way that virtue
could do derive attribute parsing, but I can't quite put my finger on it. If you have suggestions for a major overhaul please let me know
I wonder if it would make more sense for it to be something like
parse_tagged_attributes(prefix: &str, atts: &[Attributes]) -> HashMap<Ident, Vec<ParsedAttributeValue>>
rather than having to group and iterate over attributes? That would hide the relative ordering of attributes, I'm not sure if that matters?
Or it could even drop the returned Vec
if repeated tags aren't expected?
For Property
I think just a IdentProperty
is probably fine - I've realised a TokenTree
wouldn't be enough anyway if there were something like
#[sshwire(variant = SSH_NAME_ED25519.to_uppercase()]
unless it wrapped the value part in a Group
The other missing combination is ParsedAttribute::LiteralTag(Literal)
. I found myself wanting to parse #[endpoint("/some/where", paginated=offset)]
.
Thanks for virtue, it works nicely for my purposes parsing SSH binary protocol. I'm using enum variant attributes that can have
Ident
s in them such as#[sshwire(variant = SSH_NAME_ED25519)]
, where theSSH_NAME_ED25519
is aconst &'static str
. That meansParsedAttribute
won't work since it only allows aLiteral
value.Would it make sense to allow any
TokenTree
forProperty
, rather than just aLiteral
? (I guessPunct
wouldn't make sense).