chore: tidy up tokio dependency

This commit is contained in:
talwat 2025-12-06 22:33:32 +01:00
parent 702f29978f
commit 4f3fa02cb4
4 changed files with 22 additions and 11 deletions

4
Cargo.lock generated
View File

@ -2613,9 +2613,9 @@ dependencies = [
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.23.7" version = "0.23.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" checksum = "5d7cbc3b4b49633d57a0509303158ca50de80ae32c265093b24c414705807832"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"toml_datetime", "toml_datetime",

View File

@ -20,7 +20,13 @@ repository = "https://github.com/talwat/lowfi"
[features] [features]
mpris = ["dep:mpris-server"] mpris = ["dep:mpris-server"]
extra-audio-formats = ["rodio/default"] extra-audio-formats = ["rodio/default"]
scrape = ["dep:serde", "dep:serde_json", "dep:html-escape", "dep:scraper", "dep:indicatif"] scrape = [
"dep:serde",
"dep:serde_json",
"dep:html-escape",
"dep:scraper",
"dep:indicatif",
]
[dependencies] [dependencies]
# Basics # Basics
@ -30,9 +36,9 @@ fastrand = "2.3.0"
thiserror = "2.0.12" thiserror = "2.0.12"
# Async # Async
tokio = { version = "1.41.1", features = ["macros", "rt", "fs", "io-util"], default-features = false } tokio = { version = "1.41.1", features = ["macros", "rt", "fs", "io-util", "sync", "time"], default-features = false }
futures-util = { version = "0.3.31", default-features = false }
arc-swap = "1.7.1" arc-swap = "1.7.1"
futures-util = { version = "0.3.31", default-features = false, features = ["io"]}
# Data # Data
reqwest = { version = "0.12.9", features = ["stream", "http2", "default-tls"], default-features = false } reqwest = { version = "0.12.9", features = ["stream", "http2", "default-tls"], default-features = false }
@ -46,7 +52,7 @@ dirs = "6.0.0"
# Text processing # Text processing
unicode-segmentation = "1.12.0" unicode-segmentation = "1.12.0"
url = "2.5.4" url = { version = "2.5.4", default-features = false }
# Scraper # Scraper
serde = { version = "1.0.219", features = ["derive"], optional = true } serde = { version = "1.0.219", features = ["derive"], optional = true }

View File

@ -98,9 +98,12 @@ pub fn data_dir() -> crate::Result<PathBuf> {
/// Simply creates and runs the player, so that the [`Result`] of both operations /// Simply creates and runs the player, so that the [`Result`] of both operations
/// can be easily handled by the [`main`] function. /// can be easily handled by the [`main`] function.
async fn player(args: Args, environment: ui::Environment) -> crate::Result<()> { async fn player(
let stream = audio::stream()?; args: Args,
let mut player = Player::init(args, environment, stream.mixer()).await?; environment: ui::Environment,
mixer: &rodio::mixer::Mixer,
) -> crate::Result<()> {
let mut player = Player::init(args, environment, mixer).await?;
player.run().await?; player.run().await?;
Ok(()) Ok(())
@ -126,8 +129,9 @@ async fn main() -> eyre::Result<()> {
} }
} }
let stream = audio::stream()?;
let environment = ui::Environment::ready(args.alternate)?; let environment = ui::Environment::ready(args.alternate)?;
let result = player(args, environment).await; let result = player(args, environment, stream.mixer()).await;
environment.cleanup(result.is_ok())?; environment.cleanup(result.is_ok())?;
Ok(result?) Ok(result?)

View File

@ -6,7 +6,8 @@ use clap::ValueEnum;
use eyre::bail; use eyre::bail;
use reqwest::Client; use reqwest::Client;
use tokio::{ use tokio::{
fs::{self, File}, io::AsyncWriteExt, fs::{self, File},
io::AsyncWriteExt,
}; };
pub mod archive; pub mod archive;