Browse and listen to thousands of radio stations across the globe right from your terminal ๐ŸŒŽ ๐Ÿ“ป ๐ŸŽตโœจ
radio rust tokio web-radio command-line-tool tui

app: CurrentDisplayMode: impl FromStr

Changed files
+28 -1
src
+28 -1
src/app.rs
··· 100 100 None, 101 101 } 102 102 103 + impl std::str::FromStr for CurrentDisplayMode { 104 + type Err = InvalidDisplayModeError; 105 + 106 + fn from_str(s: &str) -> Result<Self, Self::Err> { 107 + match s { 108 + "Oscilloscope" => Ok(Self::Oscilloscope), 109 + "Vectorscope" => Ok(Self::Vectorscope), 110 + "Spectroscope" => Ok(Self::Spectroscope), 111 + "None" => Ok(Self::None), 112 + _ => Err(InvalidDisplayModeError), 113 + } 114 + } 115 + } 116 + 117 + /// Invalid display mode error. 118 + #[derive(Debug)] 119 + pub struct InvalidDisplayModeError; 120 + 121 + impl std::fmt::Display for InvalidDisplayModeError { 122 + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 123 + write!(f, "invalid display mode") 124 + } 125 + } 126 + 127 + impl std::error::Error for InvalidDisplayModeError {} 128 + 103 129 pub struct App { 104 130 #[allow(unused)] 105 131 channels: u8, ··· 116 142 ui: &crate::cfg::UiOptions, 117 143 source: &crate::cfg::SourceOptions, 118 144 frame_rx: Receiver<minimp3::Frame>, 145 + mode: CurrentDisplayMode, 119 146 ) -> Self { 120 147 let graph = GraphConfig { 121 148 axis_color: Color::DarkGray, ··· 145 172 oscilloscope, 146 173 vectorscope, 147 174 spectroscope, 148 - mode: CurrentDisplayMode::Spectroscope, 175 + mode, 149 176 channels: source.channels as u8, 150 177 frame_rx, 151 178 }