From 442f121b2e7f63d5706acd6f2121d72245a6692e Mon Sep 17 00:00:00 2001 From: Jonas Frei Date: Sun, 10 Jul 2022 20:59:52 +0200 Subject: [PATCH] Using _isize_ instead of _usize_ for observation as per mpv documentation --- Cargo.toml | 2 +- src/ipc.rs | 4 ++-- src/lib.rs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5b57241..f1d13bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mpvipc" -version = "1.2.0" +version = "1.2.1" authors = ["Jonas Frei "] description = "A small library which provides bindings to control existing mpv instances through sockets." license = "GPL-3.0" diff --git a/src/ipc.rs b/src/ipc.rs index efecb7c..5f78333 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -257,7 +257,7 @@ pub fn run_mpv_command(instance: &Mpv, command: &str, args: &[&str]) -> Result<( } } -pub fn observe_mpv_property(instance: &Mpv, id: &usize, property: &str) -> Result<(), Error> { +pub fn observe_mpv_property(instance: &Mpv, id: &isize, property: &str) -> Result<(), Error> { let ipc_string = format!( "{{ \"command\": [\"observe_property\", {}, \"{}\"] }}\n", id, property @@ -278,7 +278,7 @@ pub fn observe_mpv_property(instance: &Mpv, id: &usize, property: &str) -> Resul } } -pub fn unobserve_mpv_property(instance: &Mpv, id: &usize) -> Result<(), Error> { +pub fn unobserve_mpv_property(instance: &Mpv, id: &isize) -> Result<(), Error> { let ipc_string = format!("{{ \"command\": [\"unobserve_property\", {}] }}\n", id); match serde_json::from_str::(&send_command_sync(instance, &ipc_string)) { Ok(feedback) => { diff --git a/src/lib.rs b/src/lib.rs index c2eaa14..5bb122e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,7 +53,7 @@ pub enum MpvCommand { to: usize, }, Observe { - id: usize, + id: isize, property: String }, PlaylistNext, @@ -66,7 +66,7 @@ pub enum MpvCommand { option: SeekOptions, }, Stop, - Unobserve(usize), + Unobserve(isize), } #[derive(Debug)] @@ -410,14 +410,14 @@ impl Mpv { self.run_command(MpvCommand::PlaylistNext) } - pub fn observe_property(&self, id: usize, property: &str) -> Result<(), Error> { + pub fn observe_property(&self, id: isize, property: &str) -> Result<(), Error> { self.run_command(MpvCommand::Observe { id: id, property: property.to_string(), }) } - pub fn unobserve_property(&self, id: usize) -> Result<(), Error> { + pub fn unobserve_property(&self, id: isize) -> Result<(), Error> { self.run_command(MpvCommand::Unobserve(id)) }