selene_core/container/trait_impls.rs
1use std::str::FromStr;
2
3use crate::container::ContainerFormat;
4
5impl FromStr for ContainerFormat {
6 type Err = String;
7
8 fn from_str(s: &str) -> Result<Self, Self::Err> {
9 match s {
10 "flac" => Ok(Self::Flac),
11 "mp3" => Ok(Self::Mp3),
12 "ogg" | "opus" => Ok(Self::Ogg),
13 "wav" => Ok(Self::Wav),
14 _ => Err(format!("Invalid or unknown/unrecognized container: {s}"))?,
15 }
16 }
17}