diff --git a/crux_time/src/lib.rs b/crux_time/src/lib.rs index 0a4c0c9ed..ec82f9cc4 100644 --- a/crux_time/src/lib.rs +++ b/crux_time/src/lib.rs @@ -40,7 +40,7 @@ fn get_timer_id() -> TimerId { #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum TimeResponse { - Now(Instant), + Now { instant: Instant }, InstantArrived { id: TimerId }, DurationElapsed { id: TimerId }, Cleared { id: TimerId }, @@ -231,10 +231,15 @@ mod test { #[test] fn test_serializing_the_response_types_as_json() { - let now = TimeResponse::Now(Instant::new(1, 2).expect("valid instant")); + let now = TimeResponse::Now { + instant: Instant::new(1, 2).expect("valid instant"), + }; let serialized = serde_json::to_string(&now).unwrap(); - assert_eq!(&serialized, r#"{"now":{"seconds":1,"nanos":2}}"#); + assert_eq!( + &serialized, + r#"{"now":{"instant":{"seconds":1,"nanos":2}}}"# + ); let deserialized: TimeResponse = serde_json::from_str(&serialized).unwrap(); assert_eq!(now, deserialized); diff --git a/crux_time/tests/time_test.rs b/crux_time/tests/time_test.rs index 6d1dd577a..ca84f07ae 100644 --- a/crux_time/tests/time_test.rs +++ b/crux_time/tests/time_test.rs @@ -65,8 +65,8 @@ mod shared { } }), Event::Set(time) => { - if let TimeResponse::Now(time) = time { - let time: DateTime = time.try_into().unwrap(); + if let TimeResponse::Now { instant } = time { + let time: DateTime = instant.try_into().unwrap(); model.time = time.to_rfc3339(); caps.render.render() } @@ -151,8 +151,8 @@ mod shell { let effs = match msg { Some(CoreMessage::Event(m)) => core.process_event(m), - Some(CoreMessage::Response(Outcome::Time(mut request, result))) => { - core.resolve(&mut request, TimeResponse::Now(result)) + Some(CoreMessage::Response(Outcome::Time(mut request, instant))) => { + core.resolve(&mut request, TimeResponse::Now { instant }) } _ => vec![], }; @@ -201,7 +201,9 @@ mod tests { .expect_time(); let now: DateTime = "2022-12-01T01:47:12.746202562+00:00".parse().unwrap(); - let response = TimeResponse::Now(now.try_into().unwrap()); + let response = TimeResponse::Now { + instant: now.try_into().unwrap(), + }; let _update = app.resolve_to_event_then_update(request, response, &mut model); assert_eq!(app.view(&model).time, "2022-12-01T01:47:12.746202562+00:00");