Skip to content

Commit

Permalink
EBML: Impl some TagExt methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA committed Sep 16, 2024
1 parent df31dd9 commit 85cbea3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lofty/src/ebml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub use vint::VInt;
/// An EBML file
#[derive(LoftyFile, Default)]
#[lofty(read_fn = "read::read_from")]
// TODO: #[lofty(internal_write_module_do_not_use_anywhere_else)]
#[lofty(internal_write_module_do_not_use_anywhere_else)]
pub struct EbmlFile {
/// An EBML tag
#[lofty(tag_type = "Ebml")]
Expand Down
12 changes: 9 additions & 3 deletions lofty/src/ebml/tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod attached_file;
mod simple_tag;
mod tag;
mod target;
mod write;

pub use attached_file::*;
pub use simple_tag::*;
Expand Down Expand Up @@ -39,15 +40,19 @@ impl TagExt for EbmlTag {
}

fn len(&self) -> usize {
todo!()
self.tags
.iter()
.map(|tag| tag.simple_tags.len())
.sum::<usize>()
+ self.attached_files.len()
}

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

fn is_empty(&self) -> bool {
todo!()
self.tags.is_empty() && self.attached_files.is_empty()
}

fn save_to<F>(
Expand Down Expand Up @@ -85,7 +90,8 @@ impl TagExt for EbmlTag {
}

fn clear(&mut self) {
todo!()
self.tags.clear();
self.attached_files.clear();
}
}

Expand Down
9 changes: 9 additions & 0 deletions lofty/src/ebml/tag/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,12 @@ pub struct Target {
/// [`AttachedFile::uid`]: crate::ebml::AttachedFile::uid
pub attachment_uids: Option<Vec<u64>>,
}

impl From<TargetType> for Target {
fn from(target_type: TargetType) -> Self {
Self {
target_type,
..Default::default()
}
}
}
Empty file added lofty/src/ebml/tag/write/mod.rs
Empty file.
2 changes: 2 additions & 0 deletions lofty_attr/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub(crate) fn init_write_lookup(
.write_to(file, write_options)
});

insert!(map, Ebml, { todo!() });

insert!(map, Id3v1, {
Into::<lofty::id3::v1::tag::Id3v1TagRef<'_>>::into(tag).write_to(file, write_options)
});
Expand Down

0 comments on commit 85cbea3

Please sign in to comment.