From 0c4e8e7eb05f28907a2011868531bc0cceaa5483 Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Wed, 22 Mar 2023 09:11:15 -0400 Subject: [PATCH] picture: add `into_data()` --- src/picture.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/picture.rs b/src/picture.rs index f5cc6f45d..e2c655a99 100644 --- a/src/picture.rs +++ b/src/picture.rs @@ -535,11 +535,16 @@ impl Picture { self.description = description.map(Cow::from); } - /// Returns the picture data + /// Returns the [`Picture`] data as borrowed bytes. pub fn data(&self) -> &[u8] { &self.data } + /// Consumes a [`Picture`], returning the data as [`Vec`] without clones or allocation. + pub fn into_data(self) -> Vec { + self.data.into_owned() + } + /// Convert a [`Picture`] to a ID3v2 A/PIC byte Vec /// /// NOTE: This does not include the frame header