mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-16 23:35:03 +00:00
clippy: use strip_prefix instead of manual stripping
it's less error-prone (off-by-one!) Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
28f3b0df9e
commit
724e2f47f9
@ -127,13 +127,13 @@ pub async fn send_command<P>(
|
||||
if rx.read_line(&mut data).await? == 0 {
|
||||
bail!("no response");
|
||||
}
|
||||
if data.starts_with("OK: ") {
|
||||
match data[4..].parse::<Value>() {
|
||||
if let Some(res) = data.strip_prefix("OK: ") {
|
||||
match res.parse::<Value>() {
|
||||
Ok(v) => Ok(v),
|
||||
Err(err) => bail!("unable to parse json response - {}", err),
|
||||
}
|
||||
} else if data.starts_with("ERROR: ") {
|
||||
bail!("{}", &data[7..]);
|
||||
} else if let Some(err) = data.strip_prefix("ERROR: ") {
|
||||
bail!("{}", err);
|
||||
} else {
|
||||
bail!("unable to parse response: {}", data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user