mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2025-03-04 06:47:12 +00:00
EBML: Impl some TagExt methods
This commit is contained in:
parent
6f1404ae61
commit
0eb55e6b68
5 changed files with 21 additions and 4 deletions
|
@ -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")]
|
||||
|
|
|
@ -2,6 +2,7 @@ mod attached_file;
|
|||
mod simple_tag;
|
||||
mod tag;
|
||||
mod target;
|
||||
mod write;
|
||||
|
||||
pub use attached_file::*;
|
||||
pub use simple_tag::*;
|
||||
|
@ -39,7 +40,11 @@ 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 {
|
||||
|
@ -47,7 +52,7 @@ impl TagExt for EbmlTag {
|
|||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
todo!()
|
||||
self.tags.is_empty() && self.attached_files.is_empty()
|
||||
}
|
||||
|
||||
fn save_to<F>(
|
||||
|
@ -85,7 +90,8 @@ impl TagExt for EbmlTag {
|
|||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
todo!()
|
||||
self.tags.clear();
|
||||
self.attached_files.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
0
lofty/src/ebml/tag/write/mod.rs
Normal file
0
lofty/src/ebml/tag/write/mod.rs
Normal file
|
@ -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)
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue