From 3cf5c2c5156a5b452e0c846f20e42f9f9d6af2df Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sat, 14 Dec 2024 12:55:14 +0100 Subject: [PATCH] treewide: fix type for property change event ids --- src/core_api.rs | 4 ++-- src/event_parser.rs | 4 ++-- src/highlevel_api_extension.rs | 8 ++++---- src/ipc.rs | 8 ++++---- tests/integration_tests/event_property_parser.rs | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/core_api.rs b/src/core_api.rs index a529a85..804d894 100644 --- a/src/core_api.rs +++ b/src/core_api.rs @@ -41,7 +41,7 @@ pub enum MpvCommand { to: usize, }, Observe { - id: usize, + id: u64, property: String, }, PlaylistNext, @@ -59,7 +59,7 @@ pub enum MpvCommand { option: SeekOptions, }, Stop, - Unobserve(usize), + Unobserve(u64), } /// Helper trait to keep track of the string literals that mpv expects. diff --git a/src/event_parser.rs b/src/event_parser.rs index 62feacc..84f2b89 100644 --- a/src/event_parser.rs +++ b/src/event_parser.rs @@ -109,7 +109,7 @@ pub enum Event { VideoReconfig, AudioReconfig, PropertyChange { - id: usize, + id: u64, 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) as usize; + let id = get_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/src/highlevel_api_extension.rs b/src/highlevel_api_extension.rs index badef0c..29d564b 100644 --- a/src/highlevel_api_extension.rs +++ b/src/highlevel_api_extension.rs @@ -88,11 +88,11 @@ pub trait MpvExt { /// Notify mpv to send events whenever a property changes. /// See [`Mpv::get_event_stream`] and [`Property`](crate::Property) for more information. - async fn observe_property(&self, id: usize, property: &str) -> Result<(), MpvError>; + async fn observe_property(&self, id: u64, property: &str) -> Result<(), MpvError>; /// Stop observing a property. /// See [`Mpv::get_event_stream`] and [`Property`](crate::Property) for more information. - async fn unobserve_property(&self, id: usize) -> Result<(), MpvError>; + async fn unobserve_property(&self, id: u64) -> Result<(), MpvError>; /// Skip to the next entry in the playlist. async fn next(&self) -> Result<(), MpvError>; @@ -259,7 +259,7 @@ impl MpvExt for Mpv { self.run_command(MpvCommand::PlaylistPrev).await } - async fn observe_property(&self, id: usize, property: &str) -> Result<(), MpvError> { + async fn observe_property(&self, id: u64, property: &str) -> Result<(), MpvError> { self.run_command(MpvCommand::Observe { id, property: property.to_string(), @@ -267,7 +267,7 @@ impl MpvExt for Mpv { .await } - async fn unobserve_property(&self, id: usize) -> Result<(), MpvError> { + async fn unobserve_property(&self, id: u64) -> Result<(), MpvError> { self.run_command(MpvCommand::Unobserve(id)).await } diff --git a/src/ipc.rs b/src/ipc.rs index 83087f9..6ab6ef9 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -24,8 +24,8 @@ pub(crate) enum MpvIpcCommand { Command(Vec), GetProperty(String), SetProperty(String, Value), - ObserveProperty(usize, String), - UnobserveProperty(usize), + ObserveProperty(u64, String), + UnobserveProperty(u64), Exit, } @@ -114,7 +114,7 @@ impl MpvIpc { pub(crate) async fn observe_property( &mut self, - id: usize, + id: u64, property: &str, ) -> Result, MpvError> { self.send_command(&[json!("observe_property"), json!(id), json!(property)]) @@ -123,7 +123,7 @@ impl MpvIpc { pub(crate) async fn unobserve_property( &mut self, - id: usize, + id: u64, ) -> Result, MpvError> { self.send_command(&[json!("unobserve_property"), json!(id)]) .await diff --git a/tests/integration_tests/event_property_parser.rs b/tests/integration_tests/event_property_parser.rs index 13c013d..9eb296c 100644 --- a/tests/integration_tests/event_property_parser.rs +++ b/tests/integration_tests/event_property_parser.rs @@ -8,7 +8,7 @@ use test_log::test; use super::*; -const MPV_CHANNEL_ID: usize = 1337; +const MPV_CHANNEL_ID: u64 = 1337; #[derive(Error, Debug)] enum PropertyCheckingThreadError {