mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-17 08:24:09 +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 {
|
if rx.read_line(&mut data).await? == 0 {
|
||||||
bail!("no response");
|
bail!("no response");
|
||||||
}
|
}
|
||||||
if data.starts_with("OK: ") {
|
if let Some(res) = data.strip_prefix("OK: ") {
|
||||||
match data[4..].parse::<Value>() {
|
match res.parse::<Value>() {
|
||||||
Ok(v) => Ok(v),
|
Ok(v) => Ok(v),
|
||||||
Err(err) => bail!("unable to parse json response - {}", err),
|
Err(err) => bail!("unable to parse json response - {}", err),
|
||||||
}
|
}
|
||||||
} else if data.starts_with("ERROR: ") {
|
} else if let Some(err) = data.strip_prefix("ERROR: ") {
|
||||||
bail!("{}", &data[7..]);
|
bail!("{}", err);
|
||||||
} else {
|
} else {
|
||||||
bail!("unable to parse response: {}", data);
|
bail!("unable to parse response: {}", data);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user