From 351684caec220d9b790d72415aed468ebbf94b1f Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Fri, 3 Sep 2021 16:08:39 -0400 Subject: [PATCH] Add TaggedFile::tag and TaggedFile::tag_mut for fetching specific TagTypes --- src/types/file.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/types/file.rs b/src/types/file.rs index cd80a4b6..ecdd3612 100644 --- a/src/types/file.rs +++ b/src/types/file.rs @@ -101,6 +101,16 @@ impl TaggedFile { self.tags.first_mut() } + /// Get a reference to a specific [`TagType`] + pub fn tag(&self, tag_type: &TagType) -> Option<&Tag> { + self.tags.iter().find(|i| i.tag_type() == tag_type) + } + + /// Get a mutable reference to a specific [`TagType`] + pub fn tag_mut(&mut self, tag_type: &TagType) -> Option<&mut Tag> { + self.tags.iter_mut().find(|i| i.tag_type() == tag_type) + } + /// Returns the file's [`FileType`] pub fn file_type(&self) -> &FileType { &self.ty