Skip to content

Commit 9052384

Browse files
committed
EBML: Stub implement EbmlFile and EbmlTag
1 parent 1505ddf commit 9052384

File tree

7 files changed

+150
-3
lines changed

7 files changed

+150
-3
lines changed

lofty/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ mod util;
119119

120120
pub mod aac;
121121
pub mod ape;
122+
pub mod ebml;
122123
pub mod flac;
123124
pub mod id3;
124125
pub mod iff;

lofty/src/probe.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::ogg::vorbis::VorbisFile;
1919
use crate::resolve::custom_resolvers;
2020
use crate::wavpack::WavPackFile;
2121

22+
use crate::ebml::EbmlFile;
2223
use std::fs::File;
2324
use std::io::{BufReader, Cursor, Read, Seek, SeekFrom};
2425
use std::path::Path;
@@ -468,6 +469,7 @@ impl<R: Read + Seek> Probe<R> {
468469
FileType::Aac => AacFile::read_from(reader, options)?.into(),
469470
FileType::Aiff => AiffFile::read_from(reader, options)?.into(),
470471
FileType::Ape => ApeFile::read_from(reader, options)?.into(),
472+
FileType::Ebml => EbmlFile::read_from(reader, options)?.into(),
471473
FileType::Flac => FlacFile::read_from(reader, options)?.into(),
472474
FileType::Mpeg => MpegFile::read_from(reader, options)?.into(),
473475
FileType::Opus => OpusFile::read_from(reader, options)?.into(),

lofty_attr/src/internal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use quote::quote;
99
pub(crate) fn opt_internal_file_type(
1010
struct_name: String,
1111
) -> Option<(proc_macro2::TokenStream, bool)> {
12-
const LOFTY_FILE_TYPES: [&str; 12] = [
13-
"Aac", "Aiff", "Ape", "Flac", "Mpeg", "Mp4", "Mpc", "Opus", "Vorbis", "Speex", "Wav",
14-
"WavPack",
12+
const LOFTY_FILE_TYPES: [&str; 13] = [
13+
"Aac", "Aiff", "Ape", "Ebml", "Flac", "Mpeg", "Mp4", "Mpc", "Opus", "Vorbis", "Speex",
14+
"Wav", "WavPack",
1515
];
1616

1717
const ID3V2_STRIPPABLE: [&str; 2] = ["Flac", "Ape"];

src/ebml/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! EBML specific items
2+
mod properties;
3+
mod read;
4+
mod tag;
5+
6+
use lofty_attr::LoftyFile;
7+
8+
// Exports
9+
10+
pub use properties::EbmlProperties;
11+
pub use tag::EbmlTag;
12+
13+
/// An EBML file
14+
#[derive(LoftyFile, Default)]
15+
#[lofty(read_fn = "read::read_from")]
16+
pub struct EbmlFile {
17+
/// An ID3v2 tag
18+
#[lofty(tag_type = "Id3v2")]
19+
pub(crate) ebml_tag: Option<EbmlTag>,
20+
/// The file's audio properties
21+
pub(crate) properties: EbmlProperties,
22+
}

src/ebml/properties.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use crate::properties::FileProperties;
2+
3+
/// EBML audio properties
4+
#[derive(Debug, Clone, PartialEq, Default)]
5+
pub struct EbmlProperties {}
6+
7+
impl From<EbmlProperties> for FileProperties {
8+
fn from(input: EbmlProperties) -> Self {
9+
todo!()
10+
}
11+
}

src/ebml/read.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use super::EbmlFile;
2+
use crate::error::Result;
3+
use crate::probe::ParseOptions;
4+
5+
use std::io::{Read, Seek};
6+
7+
pub(super) fn read_from<R>(reader: &mut R, parse_options: ParseOptions) -> Result<EbmlFile>
8+
where
9+
R: Read + Seek,
10+
{
11+
todo!()
12+
}

src/ebml/tag/mod.rs

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
use crate::error::LoftyError;
2+
use crate::tag::Tag;
3+
use crate::traits::{Accessor, MergeTag, SplitTag, TagExt};
4+
5+
use std::fs::File;
6+
use std::io::Write;
7+
use std::ops::Deref;
8+
use std::path::Path;
9+
10+
use lofty_attr::tag;
11+
12+
/// TODO
13+
#[derive(Default, Debug, PartialEq, Eq, Clone)]
14+
#[tag(description = "An `EBML` tag", supported_formats(Ebml))]
15+
pub struct EbmlTag {}
16+
17+
impl Accessor for EbmlTag {}
18+
19+
impl TagExt for EbmlTag {
20+
type Err = LoftyError;
21+
type RefKey<'a> = &'a str;
22+
23+
fn len(&self) -> usize {
24+
todo!()
25+
}
26+
27+
fn contains<'a>(&'a self, key: Self::RefKey<'a>) -> bool {
28+
todo!()
29+
}
30+
31+
fn is_empty(&self) -> bool {
32+
todo!()
33+
}
34+
35+
fn save_to(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
36+
todo!()
37+
}
38+
39+
fn dump_to<W: Write>(&self, writer: &mut W) -> std::result::Result<(), Self::Err> {
40+
todo!()
41+
}
42+
43+
fn remove_from_path<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), Self::Err> {
44+
todo!()
45+
}
46+
47+
fn remove_from(&self, file: &mut File) -> std::result::Result<(), Self::Err> {
48+
todo!()
49+
}
50+
51+
fn clear(&mut self) {
52+
todo!()
53+
}
54+
}
55+
56+
#[derive(Debug, Clone, Default)]
57+
pub struct SplitTagRemainder(EbmlTag);
58+
59+
impl From<SplitTagRemainder> for EbmlTag {
60+
fn from(from: SplitTagRemainder) -> Self {
61+
from.0
62+
}
63+
}
64+
65+
impl Deref for SplitTagRemainder {
66+
type Target = EbmlTag;
67+
68+
fn deref(&self) -> &Self::Target {
69+
&self.0
70+
}
71+
}
72+
73+
impl SplitTag for EbmlTag {
74+
type Remainder = SplitTagRemainder;
75+
76+
fn split_tag(mut self) -> (Self::Remainder, Tag) {
77+
todo!()
78+
}
79+
}
80+
81+
impl MergeTag for SplitTagRemainder {
82+
type Merged = EbmlTag;
83+
84+
fn merge_tag(self, tag: Tag) -> Self::Merged {
85+
todo!()
86+
}
87+
}
88+
89+
impl From<EbmlTag> for Tag {
90+
fn from(input: EbmlTag) -> Self {
91+
input.split_tag().1
92+
}
93+
}
94+
95+
impl From<Tag> for EbmlTag {
96+
fn from(input: Tag) -> Self {
97+
SplitTagRemainder::default().merge_tag(input)
98+
}
99+
}

0 commit comments

Comments
 (0)