Serial-ATA / lofty-rs

Audio metadata library
Apache License 2.0
184 stars 34 forks source link

Add write options #228

Closed Serial-ATA closed 5 months ago

Serial-ATA commented 1 year ago

Summary

Just like ParseOptions, there may be some things that a caller wants to configure during a write. These options would be passed to AudioFile::save_to and TagExt::save_to.

Some options I can think of being useful are:

pub struct WriteOptions {
    // Default: 1024, seems like a safe size
    preferred_padding: usize,
    // Default: false, destructive
    remove_others: bool,
    // Default: true, potentially destructive?
    //          Read only items would take priority over newly created tag items.
    respect_read_only: bool,
    // Default: true, this is what 99% of software will expect
    uppercase_id3v2_chunk: bool,
    // ...?
}

pub trait TagExt {
    fn save_to(&self, file: &mut File, options: WriteOptions) -> std::result::Result<(), Self::Err>;
}

pub trait AudioFile {
    fn save_to(&self, file: &mut File, options: WriteOptions) -> Result<()>;
}