mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-13 22:22:31 +00:00
Tags: Add a <Tag>::new()
alias for <Tag>::default()
This commit is contained in:
parent
4741a0c770
commit
83b26b30f4
8 changed files with 108 additions and 0 deletions
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- **Properties**: Expose channel mask (only supported for WAV and MPEG for now) ([PR](https://github.com/Serial-ATA/lofty-rs/pull/155))
|
||||
- **ItemKey**: `InitialKey` mapping for Vorbis Comments ([PR](https://github.com/Serial-ATA/lofty-rs/pull/156))
|
||||
- **VorbisComments**: `VorbisComments::push` to allow for a non-replacing insertion
|
||||
- **Tags**: `<Tag>::new()` as an alias for `<Tag>::default()`
|
||||
|
||||
### Changed
|
||||
- **APE**/**ID3v1**/**ID3v2**/**Tag**:
|
||||
|
|
|
@ -75,6 +75,21 @@ pub struct ApeTag {
|
|||
}
|
||||
|
||||
impl ApeTag {
|
||||
/// Create a new empty `ApeTag`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use lofty::ape::ApeTag;
|
||||
/// use lofty::TagExt;
|
||||
///
|
||||
/// let ape_tag = ApeTag::new();
|
||||
/// assert!(ape_tag.is_empty());
|
||||
/// ```
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Get an [`ApeItem`] by key
|
||||
///
|
||||
/// NOTE: While `APE` items are supposed to be case-sensitive,
|
||||
|
|
|
@ -89,6 +89,23 @@ pub struct ID3v1Tag {
|
|||
pub genre: Option<u8>,
|
||||
}
|
||||
|
||||
impl ID3v1Tag {
|
||||
/// Create a new empty `ID3v1Tag`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use lofty::id3::v1::ID3v1Tag;
|
||||
/// use lofty::TagExt;
|
||||
///
|
||||
/// let id3v1_tag = ID3v1Tag::new();
|
||||
/// assert!(id3v1_tag.is_empty());
|
||||
/// ```
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl Accessor for ID3v1Tag {
|
||||
impl_accessor!(title, artist, album,);
|
||||
|
||||
|
|
|
@ -132,6 +132,21 @@ impl Default for ID3v2Tag {
|
|||
}
|
||||
|
||||
impl ID3v2Tag {
|
||||
/// Create a new empty `ID3v2Tag`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use lofty::id3::v2::ID3v2Tag;
|
||||
/// use lofty::TagExt;
|
||||
///
|
||||
/// let id3v2_tag = ID3v2Tag::new();
|
||||
/// assert!(id3v2_tag.is_empty());
|
||||
/// ```
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns the [`ID3v2TagFlags`]
|
||||
pub fn flags(&self) -> &ID3v2TagFlags {
|
||||
&self.flags
|
||||
|
|
|
@ -120,6 +120,21 @@ impl Accessor for AIFFTextChunks {
|
|||
}
|
||||
|
||||
impl AIFFTextChunks {
|
||||
/// Create a new empty `AIFFTextChunks`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use lofty::iff::aiff::AIFFTextChunks;
|
||||
/// use lofty::TagExt;
|
||||
///
|
||||
/// let aiff_tag = AIFFTextChunks::new();
|
||||
/// assert!(aiff_tag.is_empty());
|
||||
/// ```
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns the copyright message
|
||||
pub fn copyright(&self) -> Option<&str> {
|
||||
self.copyright.as_deref()
|
||||
|
|
|
@ -49,6 +49,21 @@ pub struct RIFFInfoList {
|
|||
}
|
||||
|
||||
impl RIFFInfoList {
|
||||
/// Create a new empty `RIFFInfoList`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use lofty::iff::wav::RIFFInfoList;
|
||||
/// use lofty::TagExt;
|
||||
///
|
||||
/// let riff_info_tag = RIFFInfoList::new();
|
||||
/// assert!(riff_info_tag.is_empty());
|
||||
/// ```
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Get an item by key
|
||||
pub fn get(&self, key: &str) -> Option<&str> {
|
||||
self.items
|
||||
|
|
|
@ -84,6 +84,21 @@ pub struct Ilst {
|
|||
}
|
||||
|
||||
impl Ilst {
|
||||
/// Create a new empty `Ilst`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use lofty::mp4::Ilst;
|
||||
/// use lofty::TagExt;
|
||||
///
|
||||
/// let ilst_tag = Ilst::new();
|
||||
/// assert!(ilst_tag.is_empty());
|
||||
/// ```
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Get an item by its [`AtomIdent`]
|
||||
pub fn atom(&self, ident: &AtomIdent<'_>) -> Option<&Atom<'static>> {
|
||||
self.atoms.iter().find(|a| &a.ident == ident)
|
||||
|
|
|
@ -52,6 +52,21 @@ pub struct VorbisComments {
|
|||
}
|
||||
|
||||
impl VorbisComments {
|
||||
/// Create a new empty `VorbisComments`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use lofty::ogg::VorbisComments;
|
||||
/// use lofty::TagExt;
|
||||
///
|
||||
/// let vorbis_comments_tag = VorbisComments::new();
|
||||
/// assert!(vorbis_comments_tag.is_empty());
|
||||
/// ```
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns the vendor string
|
||||
pub fn vendor(&self) -> &str {
|
||||
&self.vendor
|
||||
|
|
Loading…
Reference in a new issue