Skip to content

Commit

Permalink
Merge branch 'main' into chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
saecki committed Aug 28, 2023
2 parents ace2621 + b69da26 commit d95b263
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/atom/chpl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl SimpleCollectChanges for Chpl<'_> {
0
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Chpl(self)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/atom/co64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl SimpleCollectChanges for Co64 {
0
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Co64(self)
}
}
4 changes: 2 additions & 2 deletions src/atom/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl Data {

/// Returns a reference to an image if `self` is of type [`Self::Jpeg`], [`Self::Png`] or
/// [`Self::Bmp`].
pub fn image(&self) -> Option<ImgRef> {
pub fn image(&self) -> Option<ImgRef<'_>> {
match self {
Self::Jpeg(v) => Some(Img::new(ImgFmt::Jpeg, v)),
Self::Png(v) => Some(Img::new(ImgFmt::Png, v)),
Expand All @@ -357,7 +357,7 @@ impl Data {

/// Returns a mutable reference to an image if `self` is of type [`Self::Jpeg`], [`Self::Png`]
/// or [`Self::Bmp`].
pub fn image_mut(&mut self) -> Option<ImgMut> {
pub fn image_mut(&mut self) -> Option<ImgMut<'_>> {
match self {
Self::Jpeg(v) => Some(Img::new(ImgFmt::Jpeg, v)),
Self::Png(v) => Some(Img::new(ImgFmt::Png, v)),
Expand Down
2 changes: 1 addition & 1 deletion src/atom/hdlr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl SimpleCollectChanges for Hdlr {
0
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Hdlr(self)
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/atom/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,16 @@ pub const SHOW_MOVEMENT: Fourcc = Fourcc(*b"shwm");
pub const APPLE_ITUNES_MEAN: &str = "com.apple.iTunes";

/// (`----:com.apple.iTunes:ISRC`)
pub const ISRC: FreeformIdent = FreeformIdent::new(APPLE_ITUNES_MEAN, "ISRC");
pub const ISRC: FreeformIdent<'_> = FreeformIdent::new(APPLE_ITUNES_MEAN, "ISRC");
/// (`----:com.apple.iTunes:LYRICIST`)
pub const LYRICIST: FreeformIdent = FreeformIdent::new(APPLE_ITUNES_MEAN, "LYRICIST");
pub const LYRICIST: FreeformIdent<'_> = FreeformIdent::new(APPLE_ITUNES_MEAN, "LYRICIST");

/// A trait providing information about an identifier.
pub trait Ident: PartialEq<DataIdent> {
/// Returns a 4 byte atom identifier.
fn fourcc(&self) -> Option<Fourcc>;
/// Returns a freeform identifier.
fn freeform(&self) -> Option<FreeformIdent>;
fn freeform(&self) -> Option<FreeformIdent<'_>>;
}

// TODO: figure out how to implement PartialEq for Ident or require an implementation as a trait bound.
Expand Down Expand Up @@ -225,7 +225,7 @@ impl Ident for Fourcc {
Some(*self)
}

fn freeform(&self) -> Option<FreeformIdent> {
fn freeform(&self) -> Option<FreeformIdent<'_>> {
None
}
}
Expand Down Expand Up @@ -281,13 +281,13 @@ impl Ident for FreeformIdent<'_> {
None
}

fn freeform(&self) -> Option<FreeformIdent> {
fn freeform(&self) -> Option<FreeformIdent<'_>> {
Some(self.clone())
}
}

impl fmt::Display for FreeformIdent<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "----:{}:{}", self.mean, self.name)
}
}
Expand Down Expand Up @@ -321,7 +321,7 @@ impl Ident for DataIdent {
}
}

fn freeform(&self) -> Option<FreeformIdent> {
fn freeform(&self) -> Option<FreeformIdent<'_>> {
match self {
Self::Fourcc(_) => None,
Self::Freeform { mean, name } => Some(FreeformIdent::new(mean.as_str(), name.as_str())),
Expand All @@ -330,7 +330,7 @@ impl Ident for DataIdent {
}

impl fmt::Display for DataIdent {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Fourcc(ident) => write!(f, "{ident}"),
Self::Freeform { mean, name } => write!(f, "----:{mean}:{name}"),
Expand All @@ -345,13 +345,13 @@ impl From<Fourcc> for DataIdent {
}

impl From<FreeformIdent<'_>> for DataIdent {
fn from(value: FreeformIdent) -> Self {
fn from(value: FreeformIdent<'_>) -> Self {
Self::freeform(value.mean, value.name)
}
}

impl From<&FreeformIdent<'_>> for DataIdent {
fn from(value: &FreeformIdent) -> Self {
fn from(value: &FreeformIdent<'_>) -> Self {
Self::freeform(value.mean, value.name)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/atom/ilst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl SimpleCollectChanges for Ilst<'_> {
0
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Ilst(self)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/atom/mdia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl SimpleCollectChanges for Mdia {
self.minf.collect_changes(bounds.end(), level, changes)
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Mdia(self)
}
}
2 changes: 1 addition & 1 deletion src/atom/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl SimpleCollectChanges for Meta<'_> {
+ self.hdlr.collect_changes(bounds.end(), level, changes)
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Meta(self)
}
}
2 changes: 1 addition & 1 deletion src/atom/minf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl SimpleCollectChanges for Minf {
self.stbl.collect_changes(bounds.end(), level, changes)
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Minf(self)
}
}
4 changes: 2 additions & 2 deletions src/atom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ trait SimpleCollectChanges: WriteAtom {
changes: &mut Vec<Change<'a>>,
) -> i64;

fn atom_ref(&self) -> AtomRef;
fn atom_ref(&self) -> AtomRef<'_>;
}

impl<T: SimpleCollectChanges> CollectChanges for T {
Expand Down Expand Up @@ -662,7 +662,7 @@ pub(crate) fn write_tag(file: &File, cfg: &WriteConfig, userdata: &Userdata) ->
}

// collect changes
let mut changes = Vec::<Change>::new();
let mut changes = Vec::<Change<'_>>::new();
moov.collect_changes(0, 0, &mut changes);

changes.sort_by(|a, b| {
Expand Down
2 changes: 1 addition & 1 deletion src/atom/moov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl SimpleCollectChanges for Moov<'_> {
+ self.udta.collect_changes(bounds.end(), level, changes)
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Moov(self)
}
}
2 changes: 1 addition & 1 deletion src/atom/stbl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl SimpleCollectChanges for Stbl {
+ self.co64.collect_changes(bounds.end(), level, changes)
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Stbl(self)
}
}
2 changes: 1 addition & 1 deletion src/atom/stco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl SimpleCollectChanges for Stco {
0
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Stco(self)
}
}
2 changes: 1 addition & 1 deletion src/atom/trak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl SimpleCollectChanges for Trak {
self.mdia.collect_changes(bounds.end(), level, changes)
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Trak(self)
}
}
2 changes: 1 addition & 1 deletion src/atom/udta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl SimpleCollectChanges for Udta<'_> {
+ self.meta.collect_changes(bounds.end(), level, changes)
}

fn atom_ref(&self) -> AtomRef {
fn atom_ref(&self) -> AtomRef<'_> {
AtomRef::Udta(self)
}
}
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl From<string::FromUtf16Error> for Error {
}

impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.description.is_empty() {
write!(f, "{:?}", self.kind)
} else {
Expand All @@ -95,7 +95,7 @@ impl fmt::Debug for Error {
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.description.is_empty() {
write!(f, "{:?}", self.kind)
} else {
Expand Down
24 changes: 2 additions & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,8 @@
//! tag.set_data(isrc_ident, Data::Utf8("isrc".to_owned()));
//! tag.write_to_path("music.m4a").unwrap();
//! ```
#![deny(
bad_style,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
no_mangle_generic_items,
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
private_in_public,
unconditional_recursion,
unused,
unused_allocation,
unused_comparisons,
unused_parens,
while_true,
missing_docs,
trivial_casts,
trivial_numeric_casts,
unused_extern_crates,
unused_import_braces
)]
#![deny(rust_2018_idioms)]

pub use crate::atom::ident::*;
pub use crate::atom::{
ident, ChplTimescale, Data, ReadConfig, WriteChapters, WriteConfig, READ_CONFIG, WRITE_CONFIG,
Expand Down
4 changes: 2 additions & 2 deletions src/tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl DerefMut for Tag {
}

impl fmt::Display for Tag {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.format_album_artists(f)?;
self.format_artists(f)?;
self.format_composers(f)?;
Expand Down Expand Up @@ -86,7 +86,7 @@ impl fmt::Display for Tag {
}

impl Tag {
fn format_chapters(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn format_chapters(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if !self.userdata.chapters.is_empty() {
writeln!(f, "chapters:")?;
for (i, c) in self.userdata.chapters().enumerate() {
Expand Down
10 changes: 5 additions & 5 deletions src/tag/readonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Tag {
}

/// Returns the duration formatted in an easily readable way.
pub(crate) fn format_duration(&self, f: &mut fmt::Formatter) -> fmt::Result {
pub(crate) fn format_duration(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "duration: ")?;
util::format_duration(f, self.duration())?;
writeln!(f)
Expand All @@ -27,7 +27,7 @@ impl Tag {
self.info.channel_config
}

pub(crate) fn format_channel_config(&self, f: &mut fmt::Formatter) -> fmt::Result {
pub(crate) fn format_channel_config(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.channel_config() {
Some(c) => writeln!(f, "channel config: {c}"),
None => Ok(()),
Expand All @@ -39,7 +39,7 @@ impl Tag {
self.info.sample_rate
}

pub(crate) fn format_sample_rate(&self, f: &mut fmt::Formatter) -> fmt::Result {
pub(crate) fn format_sample_rate(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.sample_rate() {
Some(r) => writeln!(f, "sample rate: {r}"),
None => Ok(()),
Expand All @@ -51,7 +51,7 @@ impl Tag {
self.info.avg_bitrate
}

pub(crate) fn format_avg_bitrate(&self, f: &mut fmt::Formatter) -> fmt::Result {
pub(crate) fn format_avg_bitrate(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.avg_bitrate() {
Some(c) => writeln!(f, "average bitrate: {}kbps", c / 1024),
None => Ok(()),
Expand All @@ -63,7 +63,7 @@ impl Tag {
self.info.max_bitrate
}

pub(crate) fn format_max_bitrate(&self, f: &mut fmt::Formatter) -> fmt::Result {
pub(crate) fn format_max_bitrate(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.max_bitrate() {
Some(c) => writeln!(f, "maximum bitrate: {}kbps", c / 1024),
None => Ok(()),
Expand Down
2 changes: 1 addition & 1 deletion src/tag/userdata/genre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Userdata {
}

/// Returns all genres formatted in an easily readable way.
pub(crate) fn format_genres(&self, f: &mut fmt::Formatter) -> fmt::Result {
pub(crate) fn format_genres(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.genres().count() > 1 {
writeln!(f, "genres:")?;
for v in self.genres() {
Expand Down
Loading

0 comments on commit d95b263

Please sign in to comment.