Skip to content

Commit c7f6a7b

Browse files
committed
EBML: Rename TagType::Ebml -> TagType::Matroska
1 parent 1a2742e commit c7f6a7b

File tree

16 files changed

+69
-52
lines changed

16 files changed

+69
-52
lines changed

lofty/src/ebml/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pub use vint::*;
1919
#[lofty(internal_write_module_do_not_use_anywhere_else)]
2020
pub struct EbmlFile {
2121
/// An EBML tag
22-
#[lofty(tag_type = "Ebml")]
23-
pub(crate) ebml_tag: Option<EbmlTag>,
22+
#[lofty(tag_type = "Matroska")]
23+
pub(crate) ebml_tag: Option<MatroskaTag>,
2424
/// The file's audio properties
2525
pub(crate) properties: EbmlProperties,
2626
}

lofty/src/ebml/read/segment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::{segment_attachments, segment_info, segment_tags, segment_tracks};
22
use crate::config::ParseOptions;
33
use crate::ebml::element_reader::{ElementHeader, ElementIdent, ElementReader, ElementReaderYield};
44
use crate::ebml::properties::EbmlProperties;
5-
use crate::ebml::tag::EbmlTag;
5+
use crate::ebml::tag::MatroskaTag;
66
use crate::ebml::ElementId;
77
use crate::error::Result;
88

@@ -12,7 +12,7 @@ pub(super) fn read_from<R>(
1212
element_reader: &mut ElementReader<R>,
1313
parse_options: ParseOptions,
1414
properties: &mut EbmlProperties,
15-
) -> Result<Option<EbmlTag>>
15+
) -> Result<Option<MatroskaTag>>
1616
where
1717
R: Read + Seek,
1818
{

lofty/src/ebml/read/segment_attachments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::config::ParseOptions;
22
use crate::ebml::element_reader::{
33
ElementChildIterator, ElementIdent, ElementReader, ElementReaderYield,
44
};
5-
use crate::ebml::{AttachedFile, EbmlTag};
5+
use crate::ebml::{AttachedFile, MatroskaTag};
66
use crate::error::Result;
77
use crate::macros::decode_err;
88
use crate::picture::MimeType;
@@ -13,7 +13,7 @@ use std::io::{Read, Seek};
1313
pub(super) fn read_from<R>(
1414
children_reader: &mut ElementChildIterator<'_, R>,
1515
_parse_options: ParseOptions,
16-
tag: &mut EbmlTag,
16+
tag: &mut MatroskaTag,
1717
) -> Result<()>
1818
where
1919
R: Read + Seek,

lofty/src/ebml/read/segment_chapters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::config::ParseOptions;
22
use crate::ebml::element_reader::ElementChildIterator;
3-
use crate::ebml::EbmlTag;
3+
use crate::ebml::MatroskaTag;
44
use crate::error::Result;
55

66
use std::io::{Read, Seek};
@@ -9,7 +9,7 @@ use std::io::{Read, Seek};
99
pub(super) fn read_from<R>(
1010
_children_reader: &mut ElementChildIterator<'_, R>,
1111
_parse_options: ParseOptions,
12-
_tag: &mut EbmlTag,
12+
_tag: &mut MatroskaTag,
1313
) -> Result<()>
1414
where
1515
R: Read + Seek,

lofty/src/ebml/read/segment_tags.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::config::ParseOptions;
22
use crate::ebml::element_reader::{ElementChildIterator, ElementIdent, ElementReaderYield};
3-
use crate::ebml::{EbmlTag, Language, SimpleTag, Tag, TagValue, Target, TargetType};
3+
use crate::ebml::{Language, MatroskaTag, SimpleTag, Tag, TagValue, Target, TargetType};
44
use crate::error::Result;
55
use crate::macros::decode_err;
66

@@ -9,7 +9,7 @@ use std::io::{Read, Seek};
99
pub(super) fn read_from<R>(
1010
children_reader: &mut ElementChildIterator<'_, R>,
1111
_parse_options: ParseOptions,
12-
tag: &mut EbmlTag,
12+
tag: &mut MatroskaTag,
1313
) -> Result<()>
1414
where
1515
R: Read + Seek,

lofty/src/ebml/tag/generic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! NOTE: We can **ONLY** convert `SimpleTags` that come from a target with **NO** uids
44
5-
use super::{EbmlTag, Language, SimpleTag, TargetType, TOMBSTONE_SIMPLE_TAG};
5+
use super::{Language, MatroskaTag, SimpleTag, TargetType, TOMBSTONE_SIMPLE_TAG};
66
use crate::tag::items::Lang;
77
use crate::tag::{ItemKey, Tag, TagItem, TagType};
88

@@ -135,8 +135,8 @@ matroska_mapping_tables!(
135135
const TAG_RETAINED: bool = true;
136136
const TAG_CONSUMED: bool = false;
137137

138-
pub(super) fn split_tag(mut ebml_tag: EbmlTag) -> (EbmlTag, Tag) {
139-
let mut tag = Tag::new(TagType::Ebml);
138+
pub(super) fn split_tag(mut ebml_tag: MatroskaTag) -> (MatroskaTag, Tag) {
139+
let mut tag = Tag::new(TagType::Matroska);
140140

141141
// TODO: Pictures, can they be handled in a generic way?
142142
// What about the uid and referral?

lofty/src/ebml/tag/mod.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ macro_rules! impl_accessor {
3131
paste::paste! {
3232
$(
3333
fn $method(&self) -> Option<Cow<'_, str>> {
34-
self.get_str(EbmlTagKey(TargetType::$target, Cow::Borrowed($name)))
34+
self.get_str(MatroskaTagKey(TargetType::$target, Cow::Borrowed($name)))
3535
}
3636

3737
fn [<set_ $method>](&mut self, value: String) {
@@ -57,18 +57,18 @@ macro_rules! impl_accessor {
5757
/// * [`Target`]
5858
/// * [`AttachedFile`]
5959
#[derive(Default, Debug, PartialEq, Eq, Clone)]
60-
#[tag(description = "An `EBML` \"tag\"", supported_formats(Ebml))]
61-
pub struct EbmlTag {
60+
#[tag(description = "A Matroska/WebM \"tag\"", supported_formats(Ebml))]
61+
pub struct MatroskaTag {
6262
pub(crate) tags: Vec<Tag<'static>>,
6363
pub(crate) attached_files: Vec<AttachedFile<'static>>,
6464
}
6565

6666
// TODO
6767
#[allow(missing_docs)]
68-
pub struct EbmlTagKey<'a>(TargetType, Cow<'a, str>);
68+
pub struct MatroskaTagKey<'a>(TargetType, Cow<'a, str>);
6969

70-
impl EbmlTag {
71-
fn get(&self, key: EbmlTagKey<'_>) -> Option<&SimpleTag<'_>> {
70+
impl MatroskaTag {
71+
fn get(&self, key: MatroskaTagKey<'_>) -> Option<&SimpleTag<'_>> {
7272
fn tag_matches_target(tag: &Tag<'_>, target_type: TargetType) -> bool {
7373
let Some(target) = &tag.target else {
7474
// An empty target is implicitly `Album`
@@ -78,7 +78,7 @@ impl EbmlTag {
7878
target.is_candidate_for_type(target_type)
7979
}
8080

81-
let EbmlTagKey(target, key) = key;
81+
let MatroskaTagKey(target, key) = key;
8282

8383
let applicable_tags = self
8484
.tags
@@ -98,7 +98,7 @@ impl EbmlTag {
9898
None
9999
}
100100

101-
fn get_str(&self, key: EbmlTagKey<'_>) -> Option<Cow<'_, str>> {
101+
fn get_str(&self, key: MatroskaTagKey<'_>) -> Option<Cow<'_, str>> {
102102
let simple_tag = self.get(key)?;
103103
simple_tag.get_str().map(Cow::from)
104104
}
@@ -131,11 +131,11 @@ impl EbmlTag {
131131
/// # Examples
132132
///
133133
/// ```rust,no_run
134-
/// use lofty::ebml::EbmlTag;
134+
/// use lofty::ebml::MatroskaTag;
135135
/// use lofty::picture::Picture;
136136
///
137137
/// # fn main() -> lofty::error::Result<()> {
138-
/// let mut tag = EbmlTag::default();
138+
/// let mut tag = MatroskaTag::default();
139139
///
140140
/// let mut picture = std::fs::read("something.png")?;
141141
/// let mut picture2 = std::fs::read("something_else.png")?;
@@ -153,14 +153,14 @@ impl EbmlTag {
153153

154154
/// Inserts a new [`Picture`]
155155
///
156-
/// Note: See [`EbmlTag::insert_attached_file`]
156+
/// Note: See [`MatroskaTag::insert_attached_file`]
157157
///
158158
/// ```rust,no_run
159-
/// use lofty::ebml::EbmlTag;
159+
/// use lofty::ebml::MatroskaTag;
160160
/// use lofty::picture::Picture;
161161
///
162162
/// # fn main() -> lofty::error::Result<()> {
163-
/// let mut tag = EbmlTag::default();
163+
/// let mut tag = MatroskaTag::default();
164164
///
165165
/// let mut picture_file = std::fs::read("something.png")?;
166166
/// tag.insert_picture(Picture::from_reader(&mut &picture_file[..])?);
@@ -219,7 +219,7 @@ impl EbmlTag {
219219
}
220220
}
221221

222-
impl Accessor for EbmlTag {
222+
impl Accessor for MatroskaTag {
223223
impl_accessor!(
224224
artist => (Track, "ARTIST"),
225225
title => (Track, "TITLE"),
@@ -267,21 +267,21 @@ impl Accessor for EbmlTag {
267267
}
268268
}
269269

270-
impl TagExt for EbmlTag {
270+
impl TagExt for MatroskaTag {
271271
type Err = LoftyError;
272-
type RefKey<'a> = EbmlTagKey<'a>;
272+
type RefKey<'a> = MatroskaTagKey<'a>;
273273

274274
#[inline]
275275
fn tag_type(&self) -> TagType {
276-
TagType::Ebml
276+
TagType::Matroska
277277
}
278278

279279
fn len(&self) -> usize {
280280
self.tags.iter().map(Tag::len).sum::<usize>() + self.attached_files.len()
281281
}
282282

283283
fn contains<'a>(&'a self, key: Self::RefKey<'a>) -> bool {
284-
let EbmlTagKey(target_type, key) = key;
284+
let MatroskaTagKey(target_type, key) = key;
285285
self.tags.iter().any(|tag| {
286286
if let Some(target) = &tag.target {
287287
return target.target_type == target_type
@@ -338,23 +338,23 @@ impl TagExt for EbmlTag {
338338

339339
#[doc(hidden)]
340340
#[derive(Debug, Clone, Default)]
341-
pub struct SplitTagRemainder(EbmlTag);
341+
pub struct SplitTagRemainder(MatroskaTag);
342342

343-
impl From<SplitTagRemainder> for EbmlTag {
343+
impl From<SplitTagRemainder> for MatroskaTag {
344344
fn from(from: SplitTagRemainder) -> Self {
345345
from.0
346346
}
347347
}
348348

349349
impl Deref for SplitTagRemainder {
350-
type Target = EbmlTag;
350+
type Target = MatroskaTag;
351351

352352
fn deref(&self) -> &Self::Target {
353353
&self.0
354354
}
355355
}
356356

357-
impl SplitTag for EbmlTag {
357+
impl SplitTag for MatroskaTag {
358358
type Remainder = SplitTagRemainder;
359359

360360
fn split_tag(mut self) -> (Self::Remainder, crate::tag::Tag) {
@@ -364,20 +364,20 @@ impl SplitTag for EbmlTag {
364364
}
365365

366366
impl MergeTag for SplitTagRemainder {
367-
type Merged = EbmlTag;
367+
type Merged = MatroskaTag;
368368

369369
fn merge_tag(self, _tag: crate::tag::Tag) -> Self::Merged {
370370
todo!()
371371
}
372372
}
373373

374-
impl From<EbmlTag> for crate::tag::Tag {
375-
fn from(input: EbmlTag) -> Self {
374+
impl From<MatroskaTag> for crate::tag::Tag {
375+
fn from(input: MatroskaTag) -> Self {
376376
input.split_tag().1
377377
}
378378
}
379379

380-
impl From<crate::tag::Tag> for EbmlTag {
380+
impl From<crate::tag::Tag> for MatroskaTag {
381381
fn from(input: crate::tag::Tag) -> Self {
382382
SplitTagRemainder::default().merge_tag(input)
383383
}

lofty/src/file/file_type.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl FileType {
3535
/// | `Ape` , `Mpc`, `WavPack` | `Ape` |
3636
/// | `Flac`, `Opus`, `Vorbis`, `Speex` | `VorbisComments` |
3737
/// | `Mp4` | `Mp4Ilst` |
38+
/// | `Ebml` | `Matroska` |
3839
///
3940
/// # Panics
4041
///
@@ -53,7 +54,7 @@ impl FileType {
5354
match self {
5455
FileType::Aac | FileType::Aiff | FileType::Mpeg | FileType::Wav => TagType::Id3v2,
5556
FileType::Ape | FileType::Mpc | FileType::WavPack => TagType::Ape,
56-
FileType::Ebml => TagType::Ebml,
57+
FileType::Ebml => TagType::Matroska,
5758
FileType::Flac | FileType::Opus | FileType::Vorbis | FileType::Speex => {
5859
TagType::VorbisComments
5960
},
@@ -92,7 +93,7 @@ impl FileType {
9293

9394
match tag_type {
9495
TagType::Ape => crate::ape::ApeTag::SUPPORTED_FORMATS.contains(self),
95-
TagType::Ebml => crate::ebml::EbmlTag::SUPPORTED_FORMATS.contains(self),
96+
TagType::Matroska => crate::ebml::MatroskaTag::SUPPORTED_FORMATS.contains(self),
9697
TagType::Id3v1 => crate::id3::v1::Id3v1Tag::SUPPORTED_FORMATS.contains(self),
9798
TagType::Id3v2 => crate::id3::v2::Id3v2Tag::SUPPORTED_FORMATS.contains(self),
9899
TagType::Mp4Ilst => crate::mp4::Ilst::SUPPORTED_FORMATS.contains(self),

lofty/src/tag/companion_tag.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
use crate::ebml::MatroskaTag;
12
use crate::id3::v2::Id3v2Tag;
23
use crate::mp4::Ilst;
34

45
#[derive(Debug, Clone)]
56
pub(crate) enum CompanionTag {
67
Id3v2(Id3v2Tag),
78
Ilst(Ilst),
9+
Matroska(MatroskaTag),
810
}
911

1012
impl CompanionTag {
@@ -21,4 +23,11 @@ impl CompanionTag {
2123
_ => None,
2224
}
2325
}
26+
27+
pub(crate) fn matroska(self) -> Option<MatroskaTag> {
28+
match self {
29+
CompanionTag::Matroska(tag) => Some(tag),
30+
_ => None,
31+
}
32+
}
2433
}

lofty/src/tag/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ impl TagItem {
902902
return VALID_ITEMKEYS.contains(&self.item_key);
903903
}
904904

905-
if tag_type == TagType::Ebml {
905+
if tag_type == TagType::Matroska {
906906
use crate::ebml::tag::SUPPORTED_ITEMKEYS;
907907

908908
return SUPPORTED_ITEMKEYS.contains(&self.item_key);

0 commit comments

Comments
 (0)