Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/id3/v2/frame/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ impl<'a> FrameID<'a> {
Ok(())
}

pub(super) fn into_owned(self) -> FrameID<'static> {
/// Obtains a borrowed instance
pub fn as_borrowed(&'a self) -> Self {
match self {
Self::Valid(inner) => Self::Valid(Cow::Borrowed(inner)),
Self::Outdated(inner) => Self::Outdated(Cow::Borrowed(inner)),
}
}

/// Obtains an owned instance
pub fn into_owned(self) -> FrameID<'static> {
match self {
Self::Valid(inner) => FrameID::Valid(Cow::Owned(inner.into_owned())),
Self::Outdated(inner) => FrameID::Outdated(Cow::Owned(inner.into_owned())),
Expand Down
10 changes: 6 additions & 4 deletions src/mp4/atom_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ pub enum AtomIdent<'a> {
}

impl<'a> AtomIdent<'a> {
pub(crate) fn as_borrowed(&'a self) -> Self {
/// Obtains a borrowed instance
pub fn as_borrowed(&'a self) -> Self {
match self {
Self::Fourcc(fourcc) => AtomIdent::Fourcc(*fourcc),
Self::Freeform { mean, name } => AtomIdent::Freeform {
Self::Fourcc(fourcc) => Self::Fourcc(*fourcc),
Self::Freeform { mean, name } => Self::Freeform {
mean: Cow::Borrowed(&mean),
name: Cow::Borrowed(&name),
},
}
}

pub(crate) fn into_owned(self) -> AtomIdent<'static> {
/// Obtains an owned instance
pub fn into_owned(self) -> AtomIdent<'static> {
match self {
Self::Fourcc(fourcc) => AtomIdent::Fourcc(fourcc),
Self::Freeform { mean, name } => AtomIdent::Freeform {
Expand Down
4 changes: 2 additions & 2 deletions src/mp4/ilst/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ impl<'a> Atom<'a> {
}

/// Returns the atom's [`AtomIdent`]
pub fn ident(&self) -> AtomIdent<'_> {
self.ident.as_borrowed()
pub fn ident(&self) -> &AtomIdent<'_> {
&self.ident
}

/// Returns the atom's [`AtomData`]
Expand Down