Compare commits

...

4 Commits

Author SHA1 Message Date
a6c6bf4388
Move project from Projects to Grzegorz
All checks were successful
Build and test / check (push) Successful in 59s
Build and test / docs (push) Successful in 1m16s
Build and test / test (push) Successful in 2m27s
Build and test / build (push) Successful in 57s
2025-01-06 16:31:12 +01:00
5a74dd0b02
highlevel_api: fix pause toggling
Some checks failed
Build and test / docs (push) Has been cancelled
Build and test / check (push) Successful in 1m9s
Build and test / build (push) Successful in 1m10s
Build and test / test (push) Successful in 2m33s
2024-12-15 17:37:48 +01:00
ee5aa30335
core: mark MpvDataType as serde(untagged)
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
2024-12-15 16:21:25 +01:00
e3297bef15
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
2024-12-15 15:31:01 +01:00
8 changed files with 11 additions and 10 deletions

View File

@ -7,8 +7,8 @@ authors = [
] ]
description = "A small library which provides bindings to control existing mpv instances through sockets." description = "A small library which provides bindings to control existing mpv instances through sockets."
license = "GPL-3.0" license = "GPL-3.0"
repository = "https://git.pvv.ntnu.no/Projects/mpvipc-async" repository = "https://git.pvv.ntnu.no/Grzegorz/mpvipc-async"
documentation = "https://pages.pvv.ntnu.no/Projects/mpvipc-async/main/docs/mpvipc_async/" documentation = "https://pages.pvv.ntnu.no/Grzegorz/mpvipc-async/main/docs/mpvipc_async/"
edition = "2021" edition = "2021"
rust-version = "1.75" rust-version = "1.75"

View File

@ -1,5 +1,5 @@
[![Coverage](https://pages.pvv.ntnu.no/Projects/mpvipc-async/main/coverage/badges/for_the_badge.svg)](https://pages.pvv.ntnu.no/Projects/mpvipc-async/main/coverage/src/) [![Coverage](https://pages.pvv.ntnu.no/Grzegorz/mpvipc-async/main/coverage/badges/for_the_badge.svg)](https://pages.pvv.ntnu.no/Grzegorz/mpvipc-async/main/coverage/src/)
[![Docs](https://img.shields.io/badge/docs-blue?style=for-the-badge&logo=rust)](https://pages.pvv.ntnu.no/Projects/mpvipc-async/main/docs/mpvipc_async/) [![Docs](https://img.shields.io/badge/docs-blue?style=for-the-badge&logo=rust)](https://pages.pvv.ntnu.no/Grzegorz/mpvipc-async/main/docs/mpvipc_async/)
# mpvipc-async # mpvipc-async

View File

@ -95,6 +95,7 @@ pub(crate) trait IntoRawCommandPart {
/// Generic data type representing all possible data types that mpv can return. /// Generic data type representing all possible data types that mpv can return.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MpvDataType { pub enum MpvDataType {
Array(Vec<MpvDataType>), Array(Vec<MpvDataType>),
Bool(bool), Bool(bool),

View File

@ -109,7 +109,7 @@ pub enum Event {
VideoReconfig, VideoReconfig,
AudioReconfig, AudioReconfig,
PropertyChange { PropertyChange {
id: u64, id: Option<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); let id = get_optional_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()?;

View File

@ -323,9 +323,9 @@ impl MpvExt for Mpv {
Switch::Off => "yes", Switch::Off => "yes",
Switch::Toggle => { Switch::Toggle => {
if self.is_playing().await? { if self.is_playing().await? {
"no"
} else {
"yes" "yes"
} else {
"no"
} }
} }
}; };

Binary file not shown.

View File

@ -43,7 +43,7 @@ where
match event { match event {
Some(Ok(event)) => { Some(Ok(event)) => {
match 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(); let property = parse_property(&name, data).unwrap();
if !on_property(property.clone()) { if !on_property(property.clone()) {
return Err(PropertyCheckingThreadError::UnexpectedPropertyError(property)) return Err(PropertyCheckingThreadError::UnexpectedPropertyError(property))

View File

@ -52,7 +52,7 @@ async fn test_observe_event_successful() {
assert_eq!( assert_eq!(
event, event,
Event::PropertyChange { Event::PropertyChange {
id: 1, id: Some(1),
name: "volume".to_string(), name: "volume".to_string(),
data: Some(MpvDataType::Double(64.0)) data: Some(MpvDataType::Double(64.0))
} }