youtube_dl_parser/state/
parsed_output_state.rs

1use crate::state::output_state::OutputState;
2use crate::state::parsed_error_state::ParsedErrorState;
3use crate::state::parsed_state::ParsedState;
4
5/// The main state that a parsed output reader produces
6pub enum ParsedOutputState {
7    /// Occurs when an output was detected and parsed
8    Parsed(ParsedState),
9    /// Occurs when the output reader is finished
10    Finished,
11    /// Occurs when there's an error reading and the reader ends unexpectedly
12    Error(ParsedErrorState),
13}
14
15impl ParsedOutputState {
16    /// Parses a raw output state into a more specific one
17    pub fn parse(output_state: OutputState) -> ParsedOutputState {
18        match output_state {
19            OutputState::Outputting(output) => {
20                ParsedOutputState::Parsed(ParsedState::parse(output))
21            }
22            OutputState::Finished => ParsedOutputState::Finished,
23            OutputState::Error(error) => ParsedOutputState::Error(ParsedErrorState::parse(error)),
24        }
25    }
26}