forge
Explore
Log in

Don't you dare go Hollow

S1: Format::ALL replaces the list of formats in Reader::new

Browse files at this commit

cd5df0a9bc2e7be9e9de46ae23b91d68afe0e6c2Ahmet Kaan GümüşParent: 93365f3
crates/ec-probe/src/lib.rsmodified+17 -14
@@ -83,6 +83,20 @@ pub enum Format {
8383 }
8484
8585 impl Format {
86+ /// Every format this crate can open.
87+ pub const ALL: [Format; 10] = [
88+ Format::Wav,
89+ Format::Flac,
90+ Format::Mp3,
91+ Format::Adts,
92+ Format::Dts,
93+ Format::Ogg,
94+ Format::Mp4,
95+ Format::Matroska,
96+ Format::Avi,
97+ Format::Amr,
98+ ];
99+
86100 /// Short lowercase name for logs and capability tables.
87101 pub fn name(&self) -> &'static str {
88102 match self {
@@ -258,20 +272,9 @@ impl Reader {
258272 let format = sniff(&head)
259273 .or_else(|| {
260274 let hint = hint?.to_ascii_lowercase();
261- [
262- Format::Wav,
263- Format::Flac,
264- Format::Mp3,
265- Format::Adts,
266- Format::Dts,
267- Format::Ogg,
268- Format::Mp4,
269- Format::Matroska,
270- Format::Avi,
271- Format::Amr,
272- ]
273- .into_iter()
274- .find(|f| f.extensions().contains(&hint.as_str()))
275+ Format::ALL
276+ .into_iter()
277+ .find(|f| f.extensions().contains(&hint.as_str()))
275278 })
276279 .ok_or_else(|| {
277280 Error::unsupported(