rename project from `mpvipc` to `mpvipc-async`

This commit is contained in:
Oystein Kristoffer Tveit 2024-08-03 16:27:11 +02:00
parent cbd8b1aed2
commit 3574c55664
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
11 changed files with 29 additions and 29 deletions

View File

@ -1,15 +1,15 @@
[package]
name = "mpvipc"
version = "1.3.0"
name = "mpvipc-async"
version = "0.1.0"
authors = [
"Jonas Frei <freijon@pm.me>",
"h7x4 <h7x4@nani.wtf>"
]
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"

View File

@ -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> {

View File

@ -1,4 +1,4 @@
use mpvipc::{Mpv, MpvError, MpvExt};
use mpvipc_async::{Mpv, MpvError, MpvExt};
#[tokio::main]
async fn main() -> Result<(), MpvError> {

View File

@ -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) => {

View File

@ -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?;

View File

@ -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<T>(
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
}

View File

@ -1,4 +1,4 @@
use mpvipc::{MpvError, MpvExt};
use mpvipc_async::{MpvError, MpvExt};
use super::*;

View File

@ -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},

View File

@ -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};

View File

@ -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};

View File

@ -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};