Skip to content

Commit

Permalink
feat: add ReadConfig::NONE and WriteConfig::NONE
Browse files Browse the repository at this point in the history
  • Loading branch information
saecki committed Feb 25, 2025
1 parent 8fc4896 commit dcb4cd0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [unreleased]

- Add ReadConfig::NONE and WriteConfig::NONE

## mp4ameta v0.12.0

- Implement FromStr for Fourcc
Expand Down
37 changes: 37 additions & 0 deletions src/atom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,26 @@ impl ReadConfig {
read_audio_info: true,
chpl_timescale: ChplTimescale::DEFAULT,
};

/// A configuration that would read no data at all.
///
/// ```
/// use mp4ameta::ReadConfig;
///
/// let cfg = ReadConfig {
/// read_meta_items: true,
/// read_image_data: true,
/// ..ReadConfig::NONE
/// };
/// ```
pub const NONE: ReadConfig = ReadConfig {
read_meta_items: false,
read_image_data: false,
read_chapter_list: false,
read_chapter_track: false,
read_audio_info: false,
chpl_timescale: ChplTimescale::DEFAULT,
};
}

impl Default for ReadConfig {
Expand Down Expand Up @@ -584,6 +604,23 @@ impl WriteConfig {
write_chapter_track: true,
chpl_timescale: ChplTimescale::DEFAULT,
};

/// A configuration that would write no data at all.
///
/// ```
/// use mp4ameta::WriteConfig;
///
/// let cfg = WriteConfig {
/// write_meta_items: true,
/// ..WriteConfig::NONE
/// };
/// ```
pub const NONE: WriteConfig = WriteConfig {
write_meta_items: false,
write_chapter_list: false,
write_chapter_track: false,
chpl_timescale: ChplTimescale::DEFAULT,
};
}

impl Default for WriteConfig {
Expand Down
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@
//! let read_cfg = ReadConfig {
//! read_meta_items: true,
//! read_image_data: false,
//! read_chapter_list: false,
//! read_chapter_track: false,
//! read_audio_info: false,
//! chpl_timescale: ChplTimescale::DEFAULT,
//! ..ReadConfig::NONE
//! };
//! let mut tag = Tag::read_with_path("music.m4a", &read_cfg).unwrap();
//!
Expand All @@ -91,9 +88,7 @@
//! // Only overwrite the metadata item list, leave chapters intact
//! let write_cfg = WriteConfig {
//! write_meta_items: true,
//! write_chapter_list: false,
//! write_chapter_track: false,
//! chpl_timescale: ChplTimescale::DEFAULT,
//! ..WriteConfig::NONE
//! };
//! tag.write_with_path("music.m4a", &write_cfg).unwrap();
//! ```
Expand Down

0 comments on commit dcb4cd0

Please sign in to comment.