use usize for request ids

This commit is contained in:
Oystein Kristoffer Tveit 2024-05-03 17:19:59 +02:00
parent e2eecafcd1
commit 7fdd7f2254
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
3 changed files with 10 additions and 10 deletions

View File

@ -41,7 +41,7 @@ pub enum MpvCommand {
to: usize, to: usize,
}, },
Observe { Observe {
id: isize, id: usize,
property: String, property: String,
}, },
PlaylistNext, PlaylistNext,
@ -59,7 +59,7 @@ pub enum MpvCommand {
option: SeekOptions, option: SeekOptions,
}, },
Stop, Stop,
Unobserve(isize), Unobserve(usize),
} }
/// Helper trait to keep track of the string literals that mpv expects. /// Helper trait to keep track of the string literals that mpv expects.

View File

@ -68,8 +68,8 @@ pub trait MpvExt {
async fn restart(&self) -> Result<(), MpvError>; async fn restart(&self) -> Result<(), MpvError>;
async fn prev(&self) -> Result<(), MpvError>; async fn prev(&self) -> Result<(), MpvError>;
async fn pause(&self) -> Result<(), MpvError>; async fn pause(&self) -> Result<(), MpvError>;
async fn unobserve_property(&self, id: isize) -> Result<(), MpvError>; async fn unobserve_property(&self, id: usize) -> Result<(), MpvError>;
async fn observe_property(&self, id: isize, property: &str) -> Result<(), MpvError>; async fn observe_property(&self, id: usize, property: &str) -> Result<(), MpvError>;
async fn next(&self) -> Result<(), MpvError>; async fn next(&self) -> Result<(), MpvError>;
async fn kill(&self) -> Result<(), MpvError>; async fn kill(&self) -> Result<(), MpvError>;
async fn get_playlist(&self) -> Result<Playlist, MpvError>; async fn get_playlist(&self) -> Result<Playlist, MpvError>;
@ -95,7 +95,7 @@ impl MpvExt for Mpv {
self.run_command(MpvCommand::PlaylistNext).await self.run_command(MpvCommand::PlaylistNext).await
} }
async fn observe_property(&self, id: isize, property: &str) -> Result<(), MpvError> { async fn observe_property(&self, id: usize, property: &str) -> Result<(), MpvError> {
self.run_command(MpvCommand::Observe { self.run_command(MpvCommand::Observe {
id, id,
property: property.to_string(), property: property.to_string(),
@ -103,7 +103,7 @@ impl MpvExt for Mpv {
.await .await
} }
async fn unobserve_property(&self, id: isize) -> Result<(), MpvError> { async fn unobserve_property(&self, id: usize) -> Result<(), MpvError> {
self.run_command(MpvCommand::Unobserve(id)).await self.run_command(MpvCommand::Unobserve(id)).await
} }

View File

@ -24,8 +24,8 @@ pub(crate) enum MpvIpcCommand {
Command(Vec<String>), Command(Vec<String>),
GetProperty(String), GetProperty(String),
SetProperty(String, Value), SetProperty(String, Value),
ObserveProperty(isize, String), ObserveProperty(usize, String),
UnobserveProperty(isize), UnobserveProperty(usize),
Exit, Exit,
} }
@ -114,7 +114,7 @@ impl MpvIpc {
pub(crate) async fn observe_property( pub(crate) async fn observe_property(
&mut self, &mut self,
id: isize, id: usize,
property: &str, property: &str,
) -> Result<Option<Value>, MpvError> { ) -> Result<Option<Value>, MpvError> {
self.send_command(&[json!("observe_property"), json!(id), json!(property)]) self.send_command(&[json!("observe_property"), json!(id), json!(property)])
@ -123,7 +123,7 @@ impl MpvIpc {
pub(crate) async fn unobserve_property( pub(crate) async fn unobserve_property(
&mut self, &mut self,
id: isize, id: usize,
) -> Result<Option<Value>, MpvError> { ) -> Result<Option<Value>, MpvError> {
self.send_command(&[json!("unobserve_property"), json!(id)]) self.send_command(&[json!("unobserve_property"), json!(id)])
.await .await