pub fn new(format: Format, res: Response) -> io::Result<ResponseOut> {
        let payload_cnt = res.payload.len();

        Ok(match format {
            Format::Json => ResponseOut::StdoutLine(
                serde_json::to_string(&res)
                    .map_err(|x| io::Error::new(io::ErrorKind::InvalidData, x))?,
            ),

            // NOTE: For shell, we assume a singular entry in the response's payload
            Format::Shell if payload_cnt != 1 => {
                return Err(io::Error::new(
                    io::ErrorKind::InvalidData,
                    format!(
                        "Got {} entries in payload data, but shell expects exactly 1",
                        payload_cnt
                    ),
                ))
            }
            Format::Shell => format_shell(res.payload.into_iter().next().unwrap()),
        })
    }
/// Create a new output message for the given response based on the specified format
Create a new output message for the given response based on the specified format
Create a new output message for the given response based on the specified format
pub fn new(format: Format, res: Response) -> io::Result<ResponseOut> {
        let payload_cnt = res.payload.len();
        Ok(match format {
            Format::Json => ResponseOut::StdoutLine(
                serde_json::to_string(&res)
                    .map_err(|x| io::Error::new(io::ErrorKind::InvalidData, x))?,
            ),
            // NOTE: For shell, we assume a singular entry in the response's payload
            Format::Shell if payload_cnt != 1 => {
                return Err(io::Error::new(
                    io::ErrorKind::InvalidData,
                    format!(
                        "Got {} entries in payload data, but shell expects exactly 1",
                        payload_cnt
                    ),
                ))
            }
            Format::Shell => format_shell(res.payload.into_iter().next().unwrap()),
        })
    }
pub fn new ( format : Format , res : Response ) -> io :: Result < ResponseOut > { let payload_cnt = res . payload . len ( ) ; Ok ( match format { Format :: Json => ResponseOut :: StdoutLine ( serde_json :: to_string ( & res ) . map_err ( | x | io :: Error :: new ( io :: ErrorKind :: InvalidData , x ) ) ? , ) , // NOTE: For shell, we assume a singular entry in the response's payload Format :: Shell if payload_cnt != 1 => { return Err ( io :: Error :: new ( io :: ErrorKind :: InvalidData , format ! ( " " payload_cnt ) , ) ) } Format :: Shell => format_shell ( res . payload . into_iter ( ) . next ( ) . unwrap ( ) ) , } ) }
Create a new output message for the given response based on the specified format
Create a new output message for the given response based on the specified format
format
Format
res
Response