Skip to content

Error handling serde_json::from_str() return in nvme.rs functions #42

@robsonsmartins

Description

@robsonsmartins

There is a bug in handling the return of serde_json::from_str() in the nvme.rs functions (get_error_log, get_firmware_log and get_smart_log):

let deserialized: String = serde_json::from_str(&stdout)?;

The serde_json::from_str() function returns a Value and not a String.

Perhaps the best thing is that the get_error_log, get_firmware_log and get_smart_log functions were rewritten to return BlockResult<Value> instead of BlockResult<String>, so the user could call, for example:

let log = get_firmware_log(&device_path).expect("error getting log");
println!("temp: {:.2} ºC", log.get("temperature").and_then(Value::as_f64).unwrap_or_default() - 273.15);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions