treewide: fix type for property change event ids
This commit is contained in:
parent
81479d2f64
commit
eb7277e4fd
src
tests/integration_tests
@ -36,30 +36,18 @@ pub enum MpvCommand {
|
|||||||
option: PlaylistAddOptions,
|
option: PlaylistAddOptions,
|
||||||
},
|
},
|
||||||
PlaylistClear,
|
PlaylistClear,
|
||||||
PlaylistMove {
|
PlaylistMove { from: usize, to: usize },
|
||||||
from: usize,
|
Observe { id: u64, property: String },
|
||||||
to: usize,
|
|
||||||
},
|
|
||||||
Observe {
|
|
||||||
id: usize,
|
|
||||||
property: String,
|
|
||||||
},
|
|
||||||
PlaylistNext,
|
PlaylistNext,
|
||||||
PlaylistPrev,
|
PlaylistPrev,
|
||||||
PlaylistRemove(usize),
|
PlaylistRemove(usize),
|
||||||
PlaylistShuffle,
|
PlaylistShuffle,
|
||||||
Quit,
|
Quit,
|
||||||
ScriptMessage(Vec<String>),
|
ScriptMessage(Vec<String>),
|
||||||
ScriptMessageTo {
|
ScriptMessageTo { target: String, args: Vec<String> },
|
||||||
target: String,
|
Seek { seconds: f64, option: SeekOptions },
|
||||||
args: Vec<String>,
|
|
||||||
},
|
|
||||||
Seek {
|
|
||||||
seconds: f64,
|
|
||||||
option: SeekOptions,
|
|
||||||
},
|
|
||||||
Stop,
|
Stop,
|
||||||
Unobserve(usize),
|
Unobserve(u64),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper trait to keep track of the string literals that mpv expects.
|
/// Helper trait to keep track of the string literals that mpv expects.
|
||||||
|
@ -109,7 +109,7 @@ pub enum Event {
|
|||||||
VideoReconfig,
|
VideoReconfig,
|
||||||
AudioReconfig,
|
AudioReconfig,
|
||||||
PropertyChange {
|
PropertyChange {
|
||||||
id: usize,
|
id: u64,
|
||||||
name: String,
|
name: String,
|
||||||
data: Option<MpvDataType>,
|
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> {
|
fn parse_property_change(event: &Map<String, Value>) -> Result<Event, MpvError> {
|
||||||
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 property_name = get_key_as!(as_str, "name", event);
|
||||||
let data = event.get("data").map(json_to_value).transpose()?;
|
let data = event.get("data").map(json_to_value).transpose()?;
|
||||||
|
|
||||||
|
@ -88,11 +88,11 @@ pub trait MpvExt {
|
|||||||
|
|
||||||
/// Notify mpv to send events whenever a property changes.
|
/// Notify mpv to send events whenever a property changes.
|
||||||
/// See [`Mpv::get_event_stream`] and [`Property`](crate::Property) for more information.
|
/// 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.
|
/// Stop observing a property.
|
||||||
/// See [`Mpv::get_event_stream`] and [`Property`](crate::Property) for more information.
|
/// 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.
|
/// Skip to the next entry in the playlist.
|
||||||
async fn next(&self) -> Result<(), MpvError>;
|
async fn next(&self) -> Result<(), MpvError>;
|
||||||
@ -259,7 +259,7 @@ impl MpvExt for Mpv {
|
|||||||
self.run_command(MpvCommand::PlaylistPrev).await
|
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 {
|
self.run_command(MpvCommand::Observe {
|
||||||
id,
|
id,
|
||||||
property: property.to_string(),
|
property: property.to_string(),
|
||||||
@ -267,7 +267,7 @@ impl MpvExt for Mpv {
|
|||||||
.await
|
.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
|
self.run_command(MpvCommand::Unobserve(id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
src/ipc.rs
11
src/ipc.rs
@ -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(usize, String),
|
ObserveProperty(u64, String),
|
||||||
UnobserveProperty(usize),
|
UnobserveProperty(u64),
|
||||||
Exit,
|
Exit,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,17 +114,14 @@ impl MpvIpc {
|
|||||||
|
|
||||||
pub(crate) async fn observe_property(
|
pub(crate) async fn observe_property(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: usize,
|
id: u64,
|
||||||
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)])
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn unobserve_property(
|
pub(crate) async fn unobserve_property(&mut self, id: u64) -> Result<Option<Value>, MpvError> {
|
||||||
&mut self,
|
|
||||||
id: usize,
|
|
||||||
) -> Result<Option<Value>, MpvError> {
|
|
||||||
self.send_command(&[json!("unobserve_property"), json!(id)])
|
self.send_command(&[json!("unobserve_property"), json!(id)])
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use test_log::test;
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const MPV_CHANNEL_ID: usize = 1337;
|
const MPV_CHANNEL_ID: u64 = 1337;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
enum PropertyCheckingThreadError {
|
enum PropertyCheckingThreadError {
|
||||||
|
Loading…
Reference in New Issue
Block a user