use crate::error::Error;
use alloc::vec::Vec;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct IStatR {
pub inputs: Vec<u8>,
}
impl IStatR {
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(self.inputs.clone())
}
pub fn decode(data: &[u8]) -> Result<Self, Error> {
Ok(Self {
inputs: data.to_vec(),
})
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn roundtrip() {
let body = IStatR {
inputs: alloc::vec![0, 1, 0, 1],
};
let bytes = body.encode().unwrap();
assert_eq!(bytes, [0, 1, 0, 1]);
assert_eq!(IStatR::decode(&bytes).unwrap(), body);
}
#[test]
fn empty_inputs_is_valid() {
assert_eq!(IStatR::decode(&[]).unwrap(), IStatR { inputs: Vec::new() });
}
}