event_parser: make id optional
Some checks are pending
Build and test / build (push) Waiting to run
Build and test / check (push) Waiting to run
Build and test / test (push) Waiting to run
Build and test / docs (push) Waiting to run

This commit is contained in:
Oystein Kristoffer Tveit 2024-12-15 15:31:01 +01:00
parent 00cae63272
commit e3297bef15
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
3 changed files with 4 additions and 4 deletions

View File

@ -109,7 +109,7 @@ pub enum Event {
VideoReconfig,
AudioReconfig,
PropertyChange {
id: u64,
id: Option<u64>,
name: String,
data: Option<MpvDataType>,
},
@ -296,7 +296,7 @@ fn parse_client_message(event: &Map<String, Value>) -> Result<Event, MpvError> {
}
fn parse_property_change(event: &Map<String, Value>) -> Result<Event, MpvError> {
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()?;

View File

@ -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))

View File

@ -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))
}