Skip to content

Commit 85cbea3

Browse files
committed
EBML: Impl some TagExt methods
1 parent df31dd9 commit 85cbea3

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

lofty/src/ebml/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub use vint::VInt;
1616
/// An EBML file
1717
#[derive(LoftyFile, Default)]
1818
#[lofty(read_fn = "read::read_from")]
19-
// TODO: #[lofty(internal_write_module_do_not_use_anywhere_else)]
19+
#[lofty(internal_write_module_do_not_use_anywhere_else)]
2020
pub struct EbmlFile {
2121
/// An EBML tag
2222
#[lofty(tag_type = "Ebml")]

lofty/src/ebml/tag/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mod attached_file;
22
mod simple_tag;
33
mod tag;
44
mod target;
5+
mod write;
56

67
pub use attached_file::*;
78
pub use simple_tag::*;
@@ -39,15 +40,19 @@ impl TagExt for EbmlTag {
3940
}
4041

4142
fn len(&self) -> usize {
42-
todo!()
43+
self.tags
44+
.iter()
45+
.map(|tag| tag.simple_tags.len())
46+
.sum::<usize>()
47+
+ self.attached_files.len()
4348
}
4449

4550
fn contains<'a>(&'a self, _key: Self::RefKey<'a>) -> bool {
4651
todo!()
4752
}
4853

4954
fn is_empty(&self) -> bool {
50-
todo!()
55+
self.tags.is_empty() && self.attached_files.is_empty()
5156
}
5257

5358
fn save_to<F>(
@@ -85,7 +90,8 @@ impl TagExt for EbmlTag {
8590
}
8691

8792
fn clear(&mut self) {
88-
todo!()
93+
self.tags.clear();
94+
self.attached_files.clear();
8995
}
9096
}
9197

lofty/src/ebml/tag/target.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,12 @@ pub struct Target {
9393
/// [`AttachedFile::uid`]: crate::ebml::AttachedFile::uid
9494
pub attachment_uids: Option<Vec<u64>>,
9595
}
96+
97+
impl From<TargetType> for Target {
98+
fn from(target_type: TargetType) -> Self {
99+
Self {
100+
target_type,
101+
..Default::default()
102+
}
103+
}
104+
}

lofty/src/ebml/tag/write/mod.rs

Whitespace-only changes.

lofty_attr/src/internal.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ pub(crate) fn init_write_lookup(
5151
.write_to(file, write_options)
5252
});
5353

54+
insert!(map, Ebml, { todo!() });
55+
5456
insert!(map, Id3v1, {
5557
Into::<lofty::id3::v1::tag::Id3v1TagRef<'_>>::into(tag).write_to(file, write_options)
5658
});

0 commit comments

Comments
 (0)