commands: add missing debug asserts
Some checks failed
Build and test / build (push) Failing after 16s
Build and test / test (push) Failing after 15s
Build and test / check (push) Failing after 59s
Build and test / docs (push) Successful in 1m17s

This commit is contained in:
Oystein Kristoffer Tveit 2024-12-13 19:31:40 +01:00
parent 86183e56ad
commit abacb54c8d
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
10 changed files with 29 additions and 5 deletions

View File

@ -10,12 +10,16 @@ impl Command for Pause {
const COMMAND: &'static str = "pause"; const COMMAND: &'static str = "pause";
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> { fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
match parts.next() { let result = match parts.next() {
Some("0") => Ok((Request::Pause(Some(false)), "")), Some("0") => Ok((Request::Pause(Some(false)), "")),
Some("1") => Ok((Request::Pause(Some(true)), "")), Some("1") => Ok((Request::Pause(Some(true)), "")),
Some(s) => Err(RequestParserError::SyntaxError(0, s.to_string())), Some(s) => Err(RequestParserError::SyntaxError(0, s.to_string())),
None => Ok((Request::Pause(None), "")), None => Ok((Request::Pause(None), "")),
} };
debug_assert!(parts.next().is_none());
result
} }
fn parse_response( fn parse_response(

View File

@ -27,6 +27,8 @@ impl Command for Seek {
None => return Err(RequestParserError::UnexpectedEOF), None => return Err(RequestParserError::UnexpectedEOF),
}; };
debug_assert!(parts.next().is_none());
Ok((Request::Seek(songpos, time), "")) Ok((Request::Seek(songpos, time), ""))
} }

View File

@ -40,6 +40,8 @@ impl Command for SeekCur {
), ),
}; };
debug_assert!(parts.next().is_none());
Ok((Request::SeekCur(mode, time), "")) Ok((Request::SeekCur(mode, time), ""))
} }

View File

@ -27,6 +27,8 @@ impl Command for SeekId {
None => return Err(RequestParserError::UnexpectedEOF), None => return Err(RequestParserError::UnexpectedEOF),
}; };
debug_assert!(parts.next().is_none());
Ok((Request::SeekId(songid, time), "")) Ok((Request::SeekId(songid, time), ""))
} }

View File

@ -21,6 +21,8 @@ impl Command for ListAll {
}) })
.transpose()?; .transpose()?;
debug_assert!(parts.next().is_none());
Ok((Request::ListAll(uri), "")) Ok((Request::ListAll(uri), ""))
} }

View File

@ -22,6 +22,8 @@ impl Command for ListAllInfo {
}) })
.transpose()?; .transpose()?;
debug_assert!(parts.next().is_none());
Ok((Request::ListAllInfo(uri), "")) Ok((Request::ListAllInfo(uri), ""))
} }

View File

@ -21,6 +21,8 @@ impl Command for ListFiles {
}) })
.transpose()?; .transpose()?;
debug_assert!(parts.next().is_none());
Ok((Request::ListFiles(uri), "")) Ok((Request::ListFiles(uri), ""))
} }

View File

@ -21,6 +21,8 @@ impl Command for LsInfo {
}) })
.transpose()?; .transpose()?;
debug_assert!(parts.next().is_none());
Ok((Request::LsInfo(uri), "")) Ok((Request::LsInfo(uri), ""))
} }

View File

@ -13,7 +13,7 @@ impl Command for Idle {
const COMMAND: &'static str = "idle"; const COMMAND: &'static str = "idle";
fn parse_request(mut parts: SplitWhitespace<'_>) -> RequestParserResult<'_> { fn parse_request(mut parts: SplitWhitespace<'_>) -> RequestParserResult<'_> {
parts let result = parts
.next() .next()
.map_or(Ok((Request::Idle(None), "")), |subsystems| { .map_or(Ok((Request::Idle(None), "")), |subsystems| {
let subsystems = subsystems let subsystems = subsystems
@ -21,7 +21,11 @@ impl Command for Idle {
.map(|subsystem| SubSystem::from_str(subsystem).unwrap()) .map(|subsystem| SubSystem::from_str(subsystem).unwrap())
.collect(); .collect();
Ok((Request::Idle(Some(subsystems)), "")) Ok((Request::Idle(Some(subsystems)), ""))
}) });
debug_assert!(parts.next().is_none());
result
} }
fn parse_response( fn parse_response(

View File

@ -162,7 +162,9 @@ impl Command for Status {
type Response = StatusResponse; type Response = StatusResponse;
const COMMAND: &'static str = "status"; const COMMAND: &'static str = "status";
fn parse_request(_parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> { fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
debug_assert!(parts.next().is_none());
Ok((Request::Status, "")) Ok((Request::Status, ""))
} }