Skip to content

Remove ItemKey::Unknown #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Serial-ATA opened this issue May 7, 2025 · 0 comments
Open

Remove ItemKey::Unknown #521

Serial-ATA opened this issue May 7, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@Serial-ATA
Copy link
Owner

ItemKey::Unknown has served its purpose, and has had better alternatives for a couple years now. It's been a source of confusion numerous times, and its existence also requires extra verification logic on conversions. I'd like to see it gone.

Comment taken from #520

ItemKey::Unknown was kind of a hacky way to retain tags that couldn't be mapped to concrete ItemKeys. There have been alternatives for awhile now though, with SplitTag, MergeTag, and GlobalOptions::preserve_format_specific_items() (see #302 for more info on that).

I envision people taking their Tags, converting them to a concrete format (e.g. VorbisComments), and then adding their custom fields to that. I'd rather not have a way to generically add custom fields, since the mappings for the concrete ItemKey variants are known to be valid, but with Unknown, there's extra verification that needs to be done on conversions that could be skipped if I just get rid of it entirely.

You'd go from:

tag.insert_text(ItemKey::Unknown(String::from("FOO")), String::from("BAR"));

to:

let mut vorbis_comments: VorbisComments = tag.into();
vorbis_comments.insert(String::from("FOO"), String::from("BAR"));

ItemKey supports the keys that the vast majority of users will need, anything else would be niche and require a little extra effort working with the concrete formats.

@Serial-ATA Serial-ATA added the enhancement New feature or request label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant