/// Converts a JSON object into a Manticore command.
///
/// This function deserializes a message in JSON format from `input_file` and
/// then serializes a header + message in wire format to.`output_file`.
///
/// Uses `cmd_type` and `is_request` to determine the message type since the
/// JSON format does not include the message header.
Converts a JSON object into a Manticore command.
This function deserializes a message in JSON format from `input_file` and
then serializes a header + message in wire format to.`output_file`.

Uses `cmd_type` and `is_request` to determine the message type since the
JSON format does not include the message header.
Converts a JSON object into a Manticore command . This function deserializes a message in JSON format from ` input_file ` and then serializes a header + message in wire format to . ` output_file ` . Uses ` cmd_type ` and ` is_request ` to determine the message type since the JSON format does not include the message header .
fn from_json(
    cmd_type: CommandType,
    is_request: bool,
    input: impl Read,
    mut output: impl Write,
) {
    let mut stdwrite = StdWrite(&mut output);
    Header {
        is_request: is_request,
        command: cmd_type,
    }
    .to_wire(&mut stdwrite)
    .expect("failed to write header");
    match (is_request, cmd_type) {
        (true, CommandType::FirmwareVersion) => {
            from_json_to_wire::<firmware_version::FirmwareVersionRequest, _, _>(
                input, stdwrite,
            )
        }
        (false, CommandType::FirmwareVersion) => {
            from_json_to_wire::<firmware_version::FirmwareVersionResponse, _, _>(
                input, stdwrite,
            )
        }
        _ => panic!("Unsupported message type"),
    }
}
fn from_json ( cmd_type : CommandType , is_request : bool , input : impl Read , mut output : impl Write , ) { let mut stdwrite = StdWrite ( & mut output ) ; Header { is_request : is_request , command : cmd_type , } . to_wire ( & mut stdwrite ) . expect ( " " ) ; match ( is_request , cmd_type ) { ( true , CommandType :: FirmwareVersion ) => { from_json_to_wire :: < firmware_version :: FirmwareVersionRequest , _ , _ > ( input , stdwrite , ) } ( false , CommandType :: FirmwareVersion ) => { from_json_to_wire :: < firmware_version :: FirmwareVersionResponse , _ , _ > ( input , stdwrite , ) } _ => panic ! ( " " ) , } }
Converts a JSON object into a Manticore command.
Converts a JSON object into a Manticore command .
cmd_type
CommandType
is_request
bool
input
impl Read
output
impl Write