diff --git a/src/event_parser.rs b/src/event_parser.rs index 84f2b89..24ad225 100644 --- a/src/event_parser.rs +++ b/src/event_parser.rs @@ -109,7 +109,7 @@ pub enum Event { VideoReconfig, AudioReconfig, PropertyChange { - id: u64, + id: Option, name: String, data: Option, }, @@ -296,7 +296,7 @@ fn parse_client_message(event: &Map) -> Result { } fn parse_property_change(event: &Map) -> Result { - let id = get_key_as!(as_u64, "id", event); + let id = get_optional_key_as!(as_u64, "id", event); let property_name = get_key_as!(as_str, "name", event); let data = event.get("data").map(json_to_value).transpose()?; diff --git a/tests/integration_tests/event_property_parser.rs b/tests/integration_tests/event_property_parser.rs index 9eb296c..84b2dbe 100644 --- a/tests/integration_tests/event_property_parser.rs +++ b/tests/integration_tests/event_property_parser.rs @@ -43,7 +43,7 @@ where match event { Some(Ok(event)) => { match event { - Event::PropertyChange { id: MPV_CHANNEL_ID, name, data } => { + Event::PropertyChange { id: Some(MPV_CHANNEL_ID), name, data } => { let property = parse_property(&name, data).unwrap(); if !on_property(property.clone()) { return Err(PropertyCheckingThreadError::UnexpectedPropertyError(property)) diff --git a/tests/mock_socket_tests/events.rs b/tests/mock_socket_tests/events.rs index 0b8722b..bc0481d 100644 --- a/tests/mock_socket_tests/events.rs +++ b/tests/mock_socket_tests/events.rs @@ -52,7 +52,7 @@ async fn test_observe_event_successful() { assert_eq!( event, Event::PropertyChange { - id: 1, + id: Some(1), name: "volume".to_string(), data: Some(MpvDataType::Double(64.0)) }