From e6c1fc58b3a9b6256dd2b7fe0b6fa9576e5fbaf3 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sat, 3 Aug 2024 16:27:11 +0200 Subject: [PATCH] rename project from `mpvipc` to `mpvipc-async` --- .gitea/workflows/build-and-test.yml | 4 ++-- Cargo.toml | 10 +++++----- README.md | 8 ++++---- examples/fetch_state.rs | 2 +- examples/media_player.rs | 4 ++-- src/core_api.rs | 8 ++++---- tests/integration_tests/event_property_parser.rs | 16 ++++++++-------- tests/integration_tests/misc.rs | 2 +- tests/integration_tests/util.rs | 2 +- tests/mock_socket_tests/events.rs | 2 +- tests/mock_socket_tests/get_property.rs | 2 +- tests/mock_socket_tests/set_property.rs | 2 +- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.gitea/workflows/build-and-test.yml b/.gitea/workflows/build-and-test.yml index 475c25f..c833052 100644 --- a/.gitea/workflows/build-and-test.yml +++ b/.gitea/workflows/build-and-test.yml @@ -99,7 +99,7 @@ jobs: uses: https://git.pvv.ntnu.no/oysteikt/rsync-action@main with: source: target/coverage/html/ - target: mpvipc/${{ gitea.ref_name }}/coverage/ + target: mpvipc-async/${{ gitea.ref_name }}/coverage/ username: oysteikt ssh-key: ${{ secrets.OYSTEIKT_GITEA_WEBDOCS_SSH_KEY }} host: microbel.pvv.ntnu.no @@ -126,7 +126,7 @@ jobs: uses: https://git.pvv.ntnu.no/oysteikt/rsync-action@main with: source: target/doc/ - target: mpvipc/${{ gitea.ref_name }}/docs/ + target: mpvipc-async/${{ gitea.ref_name }}/docs/ username: oysteikt ssh-key: ${{ secrets.OYSTEIKT_GITEA_WEBDOCS_SSH_KEY }} host: microbel.pvv.ntnu.no diff --git a/Cargo.toml b/Cargo.toml index 99e9fae..e6f0b42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "mpvipc" -version = "1.3.0" +name = "mpvipc-async" +version = "0.1.0" authors = [ "Jonas Frei ", "h7x4 " ] description = "A small library which provides bindings to control existing mpv instances through sockets." license = "GPL-3.0" -homepage = "https://git.pvv.ntnu.no/oysteikt/mpvipc" -repository = "https://git.pvv.ntnu.no/oysteikt/mpvipc" -documentation = "https://pvv.ntnu.no/~oysteikt/gitea/mpvipc/master/docs/mpvipc/" +homepage = "https://git.pvv.ntnu.no/oysteikt/mpvipc-async" +repository = "https://git.pvv.ntnu.no/oysteikt/mpvipc-async" +documentation = "https://pvv.ntnu.no/~oysteikt/gitea/mpvipc-async/master/docs/mpvipc-async/" edition = "2021" rust-version = "1.75" diff --git a/README.md b/README.md index b85d402..b65cbe1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -[![Coverage](https://pvv.ntnu.no/~oysteikt/gitea/mpvipc/master/coverage/badges/for_the_badge.svg)](https://pvv.ntnu.no/~oysteikt/gitea/mpvipc/master/coverage/src/) -[![Docs](https://img.shields.io/badge/docs-blue?style=for-the-badge&logo=rust)](https://pvv.ntnu.no/~oysteikt/gitea/mpvipc/master/docs/mpvipc/) +[![Coverage](https://pvv.ntnu.no/~oysteikt/gitea/mpvipc-async/master/coverage/badges/for_the_badge.svg)](https://pvv.ntnu.no/~oysteikt/gitea/mpvipc-async/master/coverage/src/) +[![Docs](https://img.shields.io/badge/docs-blue?style=for-the-badge&logo=rust)](https://pvv.ntnu.no/~oysteikt/gitea/mpvipc-async/master/docs/mpvipc-async/) -# mpvipc +# mpvipc-async > **NOTE:** This is a fork of [gitlab.com/mpv-ipc/mpvipc](https://gitlab.com/mpv-ipc/mpvipc), which introduces a lot of changes to be able to use the library asynchronously with [tokio](https://github.com/tokio-rs/tokio). @@ -26,7 +26,7 @@ $ mpv --input-ipc-server=/tmp/mpv.sock --idle Here is a small code example which connects to the socket `/tmp/mpv.sock` and toggles playback. ```rust -use mpvipc::*; +use mpvipc_async::*; #[tokio::main] async fn main() -> Result<(), MpvError> { diff --git a/examples/fetch_state.rs b/examples/fetch_state.rs index 64ea98b..f073e01 100644 --- a/examples/fetch_state.rs +++ b/examples/fetch_state.rs @@ -1,4 +1,4 @@ -use mpvipc::{Mpv, MpvError, MpvExt}; +use mpvipc_async::{Mpv, MpvError, MpvExt}; #[tokio::main] async fn main() -> Result<(), MpvError> { diff --git a/examples/media_player.rs b/examples/media_player.rs index 891015c..afe8e63 100644 --- a/examples/media_player.rs +++ b/examples/media_player.rs @@ -1,5 +1,5 @@ use futures::StreamExt; -use mpvipc::{parse_property, Event, Mpv, MpvDataType, MpvError, MpvExt, Property}; +use mpvipc_async::{parse_property, Event, Mpv, MpvDataType, MpvError, MpvExt, Property}; fn seconds_to_hms(total: f64) -> String { let total = total as u64; @@ -25,7 +25,7 @@ async fn main() -> Result<(), MpvError> { let mut events = mpv.get_event_stream().await; while let Some(Ok(event)) = events.next().await { match event { - mpvipc::Event::PropertyChange { name, data, .. } => { + mpvipc_async::Event::PropertyChange { name, data, .. } => { match parse_property(&name, data)? { Property::Path(Some(value)) => println!("\nPlaying: {}", value), Property::Pause(value) => { diff --git a/src/core_api.rs b/src/core_api.rs index d5e1517..72e7a76 100644 --- a/src/core_api.rs +++ b/src/core_api.rs @@ -321,7 +321,7 @@ impl Mpv { /// /// # Example /// ``` - /// use mpvipc::{Mpv, MpvError}; + /// use mpvipc_async::{Mpv, MpvError}; /// /// #[tokio::main] /// async fn main() -> Result<(), MpvError> { @@ -453,7 +453,7 @@ impl Mpv { /// /// # Example /// ``` - /// use mpvipc::{Mpv, MpvError}; + /// use mpvipc_async::{Mpv, MpvError}; /// /// #[tokio::main] /// async fn main() -> Result<(), MpvError> { @@ -482,7 +482,7 @@ impl Mpv { /// # Example /// /// ``` - /// use mpvipc::{Mpv, MpvError}; + /// use mpvipc_async::{Mpv, MpvError}; /// /// #[tokio::main] /// async fn main() -> Result<(), MpvError> { @@ -521,7 +521,7 @@ impl Mpv { /// /// # Example /// ``` - /// use mpvipc::{Mpv, MpvError}; + /// use mpvipc_async::{Mpv, MpvError}; /// async fn main() -> Result<(), MpvError> { /// let mpv = Mpv::connect("/tmp/mpvsocket").await?; /// mpv.set_property("pause", true).await?; diff --git a/tests/integration_tests/event_property_parser.rs b/tests/integration_tests/event_property_parser.rs index 3bb986e..13c013d 100644 --- a/tests/integration_tests/event_property_parser.rs +++ b/tests/integration_tests/event_property_parser.rs @@ -1,5 +1,5 @@ use futures::{stream::StreamExt, Stream}; -use mpvipc::{parse_property, Event, Mpv, MpvError, MpvExt}; +use mpvipc_async::{parse_property, Event, Mpv, MpvError, MpvExt, Property}; use thiserror::Error; use tokio::time::sleep; use tokio::time::{timeout, Duration}; @@ -13,14 +13,14 @@ const MPV_CHANNEL_ID: usize = 1337; #[derive(Error, Debug)] enum PropertyCheckingThreadError { #[error("Unexpected property: {0:?}")] - UnexpectedPropertyError(mpvipc::Property), + UnexpectedPropertyError(Property), #[error(transparent)] MpvError(#[from] MpvError), } /// This function will create an ongoing tokio task that collects [`Event::PropertyChange`] events, -/// and parses them into [`mpvipc::Property`]s. It will then run the property through the provided +/// and parses them into [`Property`]s. It will then run the property through the provided /// closure, and return an error if the closure returns false. /// /// The returned cancellation token can be used to stop the task. @@ -32,7 +32,7 @@ fn create_interruptable_event_property_checking_thread( tokio_util::sync::CancellationToken, ) where - T: Fn(mpvipc::Property) -> bool + Send + 'static, + T: Fn(Property) -> bool + Send + 'static, { let cancellation_token = tokio_util::sync::CancellationToken::new(); let cancellation_token_clone = cancellation_token.clone(); @@ -122,7 +122,7 @@ async fn test_highlevel_event_pause() -> Result<(), MpvError> { let events = mpv.get_event_stream().await; let (handle, cancellation_token) = create_interruptable_event_property_checking_thread(events, |property| match property { - mpvipc::Property::Pause(_) => { + Property::Pause(_) => { log::debug!("{:?}", property); true } @@ -150,7 +150,7 @@ async fn test_highlevel_event_volume() -> Result<(), MpvError> { let events = mpv.get_event_stream().await; let (handle, cancellation_token) = create_interruptable_event_property_checking_thread(events, |property| match property { - mpvipc::Property::Volume(_) => { + Property::Volume(_) => { log::trace!("{:?}", property); true } @@ -180,7 +180,7 @@ async fn test_highlevel_event_mute() -> Result<(), MpvError> { let events = mpv.get_event_stream().await; let (handle, cancellation_token) = create_interruptable_event_property_checking_thread(events, |property| match property { - mpvipc::Property::Mute(_) => { + Property::Mute(_) => { log::trace!("{:?}", property); true } @@ -209,7 +209,7 @@ async fn test_highlevel_event_duration() -> Result<(), MpvError> { let events = mpv.get_event_stream().await; let (handle, cancellation_token) = create_interruptable_event_property_checking_thread(events, |property| match property { - mpvipc::Property::Duration(_) => { + Property::Duration(_) => { log::trace!("{:?}", property); true } diff --git a/tests/integration_tests/misc.rs b/tests/integration_tests/misc.rs index 709f755..7c11044 100644 --- a/tests/integration_tests/misc.rs +++ b/tests/integration_tests/misc.rs @@ -1,4 +1,4 @@ -use mpvipc::{MpvError, MpvExt}; +use mpvipc_async::{MpvError, MpvExt}; use super::*; diff --git a/tests/integration_tests/util.rs b/tests/integration_tests/util.rs index 1de4bad..a0f6079 100644 --- a/tests/integration_tests/util.rs +++ b/tests/integration_tests/util.rs @@ -1,6 +1,6 @@ use std::{path::Path, time::Duration}; -use mpvipc::{Mpv, MpvError}; +use mpvipc_async::{Mpv, MpvError}; use tokio::{ process::{Child, Command}, time::{sleep, timeout}, diff --git a/tests/mock_socket_tests/events.rs b/tests/mock_socket_tests/events.rs index 018e642..0b8722b 100644 --- a/tests/mock_socket_tests/events.rs +++ b/tests/mock_socket_tests/events.rs @@ -1,5 +1,5 @@ use futures::{stream::StreamExt, SinkExt}; -use mpvipc::{Event, Mpv, MpvDataType, MpvExt}; +use mpvipc_async::{Event, Mpv, MpvDataType, MpvExt}; use serde_json::json; use test_log::test; use tokio::{net::UnixStream, task::JoinHandle}; diff --git a/tests/mock_socket_tests/get_property.rs b/tests/mock_socket_tests/get_property.rs index ab58695..595d633 100644 --- a/tests/mock_socket_tests/get_property.rs +++ b/tests/mock_socket_tests/get_property.rs @@ -1,7 +1,7 @@ use std::{panic, time::Duration}; use futures::{stream::FuturesUnordered, SinkExt, StreamExt}; -use mpvipc::{Mpv, MpvError, MpvExt, Playlist, PlaylistEntry}; +use mpvipc_async::{Mpv, MpvError, MpvExt, Playlist, PlaylistEntry}; use serde_json::{json, Value}; use test_log::test; use tokio::{net::UnixStream, task::JoinHandle}; diff --git a/tests/mock_socket_tests/set_property.rs b/tests/mock_socket_tests/set_property.rs index 55bf1d6..75ba0b2 100644 --- a/tests/mock_socket_tests/set_property.rs +++ b/tests/mock_socket_tests/set_property.rs @@ -1,7 +1,7 @@ use std::{panic, time::Duration}; use futures::{stream::FuturesUnordered, SinkExt, StreamExt}; -use mpvipc::{Mpv, MpvError}; +use mpvipc_async::{Mpv, MpvError}; use serde_json::{json, Value}; use test_log::test; use tokio::{net::UnixStream, task::JoinHandle};