pub struct Encoder { /* private fields */ }
Expand description
The Encoder
may be used to encode tags with custom settings.
Implementations§
source§impl Encoder
impl Encoder
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new Encoder
with the following configuration:
Version
is ID3v2.4- Unsynchronization is disabled due to compatibility issues
- No compression
- File is not marked as altered
sourcepub fn padding(self, padding: usize) -> Self
pub fn padding(self, padding: usize) -> Self
Sets the padding that is written after the tag.
Should be only used when writing to a MP3 file
sourcepub fn unsynchronisation(self, unsynchronisation: bool) -> Self
pub fn unsynchronisation(self, unsynchronisation: bool) -> Self
Enables or disables the unsynchronisation scheme.
This avoids patterns that resemble MP3-frame headers from being encoded. If you are encoding to MP3 files and wish to be compatible with very old tools, you probably want this enabled.
sourcepub fn compression(self, compression: bool) -> Self
pub fn compression(self, compression: bool) -> Self
Enables or disables compression.
sourcepub fn file_altered(self, file_altered: bool) -> Self
pub fn file_altered(self, file_altered: bool) -> Self
Informs the encoder whether the file this tag belongs to has been changed.
This subsequently discards any tags that have their File Alter Preservation bits set and that have a relation to the file contents:
AENC, ETCO, EQUA, MLLT, POSS, SYLT, SYTC, RVAD, TENC, TLEN, TSIZ
sourcepub fn encode(&self, tag: &Tag, writer: impl Write) -> Result<()>
pub fn encode(&self, tag: &Tag, writer: impl Write) -> Result<()>
Encodes the specified Tag
using the settings set in the Encoder
.
Note that the plain tag is written, regardless of the original contents. To safely encode a
tag to an MP3 file, use Encoder::encode_to_path
.
sourcepub fn write_to_file(&self, tag: &Tag, file: impl StorageFile) -> Result<()>
pub fn write_to_file(&self, tag: &Tag, file: impl StorageFile) -> Result<()>
Encodes a Tag
and replaces any existing tag in the file.
sourcepub fn encode_to_file(&self, tag: &Tag, file: &mut File) -> Result<()>
👎Deprecated: Use write_to_file
pub fn encode_to_file(&self, tag: &Tag, file: &mut File) -> Result<()>
Encodes a Tag
and replaces any existing tag in the file.