tree-wide: replace serde_json::from_value(a_value.clone())
`&Value` itself implements `Deserializer` and can therefore be passed directly to `T::deserialize` without requiring an intermediate `clone()`. (This also enables optionally borrowing strings if the result has a short enough lifetime) Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
845baef61b
commit
38774184a9
@ -1,4 +1,5 @@
|
||||
use anyhow::Error;
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
@ -77,7 +78,7 @@ async fn list_media(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(),
|
||||
};
|
||||
|
||||
fn render_status(_value: &Value, record: &Value) -> Result<String, Error> {
|
||||
let record: MediaListEntry = serde_json::from_value(record.clone())?;
|
||||
let record = MediaListEntry::deserialize(record)?;
|
||||
Ok(match record.status {
|
||||
MediaStatus::Damaged | MediaStatus::Retired => serde_json::to_value(&record.status)?
|
||||
.as_str()
|
||||
|
Reference in New Issue
Block a user