for future purposes, rewrite that our struct is encapsulated into an enum
All checks were successful
/ test (push) Successful in 10s
All checks were successful
/ test (push) Successful in 10s
This commit is contained in:
parent
a2a492dd74
commit
15a80c3d18
|
@ -6,7 +6,14 @@ pub const HEIGHT: usize = 32;
|
|||
// "Pixels" from left to right
|
||||
pub const WIDTH: usize = 32;
|
||||
#[derive(Serialize, Deserialize, Debug,PartialEq)]
|
||||
pub struct SemLine{
|
||||
pub enum SemLine{
|
||||
SlowPicture(SemLinePhoto),
|
||||
FastPicture(SemLinePhoto),
|
||||
Camera(SemLinePhoto)
|
||||
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Debug,PartialEq)]
|
||||
pub struct SemLinePhoto{
|
||||
line: u32,
|
||||
pixels:[u8;WIDTH]
|
||||
|
||||
|
@ -18,7 +25,7 @@ mod tests {
|
|||
use serde_json;
|
||||
#[test]
|
||||
fn test_serialize(){
|
||||
let test_struct: SemLine = SemLine{line:0,pixels:[0;WIDTH]};
|
||||
let test_struct: SemLine = SemLine::SlowPicture(SemLinePhoto{line:0,pixels:[0;WIDTH]});
|
||||
let serialized = serde_json::to_string(&test_struct).unwrap();
|
||||
let deserialized:SemLine = serde_json::from_str(&serialized).unwrap();
|
||||
assert_eq!(test_struct,deserialized);
|
||||
|
|
Loading…
Reference in a new issue