1use std::path::Path;
2
3use crate::SUPPORTED_CONTAINERS;
4use serde::{Deserialize, Serialize};
5
6mod container_type_matcher;
7pub use container_type_matcher::*;
8
9mod trait_impls;
10
11#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Ord, Eq, Serialize, Deserialize)]
13pub enum ContainerFormat {
14 Flac,
15 Mp3,
16 Ogg,
17 Wav,
18}
19
20impl ContainerFormat {
21 #[must_use]
23 pub fn format_name(&self) -> &str {
24 match self {
25 ContainerFormat::Flac => "flac",
26 ContainerFormat::Mp3 => "mp3",
27 ContainerFormat::Ogg => "ogg",
28 ContainerFormat::Wav => "wav",
29 }
30 }
31
32 #[must_use]
34 pub fn is_supported(&self) -> bool {
35 SUPPORTED_CONTAINERS.contains(self)
36 }
37
38 pub fn from_file(path: impl AsRef<Path>) -> Option<Self> {
42 container_from_file(path)
43 }
44}