Skip to content

Commit 0bedf86

Browse files
authored
feat: add publisher (©pub) (#36)
1 parent 2878c96 commit 0bedf86

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

src/atom/ident.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ pub const CUSTOM_GENRE: Fourcc = Fourcc(*b"\xa9gen");
107107
pub const DISC_NUMBER: Fourcc = Fourcc(*b"disk");
108108
/// (`©too`)
109109
pub const ENCODER: Fourcc = Fourcc(*b"\xa9too");
110+
/// (`©pub`)
111+
pub const PUBLISHER: Fourcc = Fourcc(*b"\xa9pub");
110112
/// (`gnre`)
111113
pub const STANDARD_GENRE: Fourcc = Fourcc(*b"gnre");
112114
/// (`©nam`)

src/tag/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ impl fmt::Display for Tag {
6161
self.format_keywords(f)?;
6262
self.format_copyright(f)?;
6363
self.format_encoder(f)?;
64+
self.format_publisher(f)?;
6465
self.format_tv_show_name(f)?;
6566
self.format_tv_show_name_sort_order(f)?;
6667
self.format_tv_network_name(f)?;

src/tag/userdata/generate.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"encoder" = "©too"
77
"lyrics" = "©lyr"
88
"movement" = "©mvn"
9+
"publisher" = "©pub"
910
"title" = "©nam"
1011
"tv_episode_name" = "tven"
1112
"tv_network_name" = "tvnn"

src/tag/userdata/generated.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,38 @@ impl Userdata {
164164
}
165165
}
166166

167+
/// ### Publisher
168+
impl Userdata {
169+
/// Returns the publisher (`©pub`).
170+
pub fn publisher(&self) -> Option<&str> {
171+
self.strings_of(&ident::PUBLISHER).next()
172+
}
173+
174+
/// Removes and returns the publisher (`©pub`).
175+
pub fn take_publisher(&mut self) -> Option<String> {
176+
self.take_strings_of(&ident::PUBLISHER).next()
177+
}
178+
179+
/// Sets the publisher (`©pub`).
180+
pub fn set_publisher(&mut self, publisher: impl Into<String>) {
181+
self.set_data(ident::PUBLISHER, Data::Utf8(publisher.into()));
182+
}
183+
184+
/// Removes the publisher (`©pub`).
185+
pub fn remove_publisher(&mut self) {
186+
self.remove_data_of(&ident::PUBLISHER);
187+
}
188+
189+
/// Returns the publisher formatted in an easily readable way.
190+
#[allow(unused)]
191+
pub(crate) fn format_publisher(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
192+
match self.publisher() {
193+
Some(s) => writeln!(f, "publisher: {}", s),
194+
None => Ok(()),
195+
}
196+
}
197+
}
198+
167199
/// ### Title
168200
impl Userdata {
169201
/// Returns the title (`©nam`).

0 commit comments

Comments
 (0)