refactor: Favor futures crate over futures-lite to reduce dependencies
This commit is contained in:
parent
b770b59e7b
commit
4153f9f060
18 changed files with 116 additions and 107 deletions
123
Cargo.lock
generated
123
Cargo.lock
generated
|
|
@ -161,15 +161,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "async-task"
|
||||
version = "4.1.0"
|
||||
version = "4.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d306121baf53310a3fd342d88dc0824f6bbeace68347593658525565abee8"
|
||||
checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.52"
|
||||
version = "0.1.53"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3"
|
||||
checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -276,9 +276,9 @@ checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
|
|||
|
||||
[[package]]
|
||||
name = "cairo-rs"
|
||||
version = "0.15.6"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8b14c80d8d1a02fa6d914b9d1afeeca9bc34257f8300d9696e1e331ae114223"
|
||||
checksum = "129e928d3eda625f53ce257589efbe5143416875fd01bddd08c8c6feb8b9962b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cairo-sys-rs",
|
||||
|
|
@ -356,9 +356,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.7"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6"
|
||||
checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"lazy_static",
|
||||
|
|
@ -366,9 +366,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "curl"
|
||||
version = "0.4.42"
|
||||
version = "0.4.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7de97b894edd5b5bcceef8b78d7da9b75b1d2f2f9a910569d0bde3dd31d84939"
|
||||
checksum = "37d855aeef205b43f65a5001e0997d81f8efca7badad4fad7d897aa7f0d0651f"
|
||||
dependencies = [
|
||||
"curl-sys",
|
||||
"libc",
|
||||
|
|
@ -381,9 +381,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "curl-sys"
|
||||
version = "0.4.52+curl-7.81.0"
|
||||
version = "0.4.53+curl-7.82.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14b8c2d1023ea5fded5b7b892e4b8e95f70038a421126a056761a84246a28971"
|
||||
checksum = "8092905a5a9502c312f223b2775f57ec5c5b715f9a15ee9d2a8591d1364a0352"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
|
@ -461,9 +461,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.6"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
|
||||
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
|
|
@ -487,9 +487,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "enumflags2"
|
||||
version = "0.7.3"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a25c90b056b3f84111cf183cbeddef0d3a0bbe9a674f057e1a1533c315f24def"
|
||||
checksum = "1b3ab37dc79652c9d85f1f7b6070d77d321d2467f5fe7b00d6b7a86c57b092ae"
|
||||
dependencies = [
|
||||
"enumflags2_derive",
|
||||
"serde",
|
||||
|
|
@ -497,9 +497,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "enumflags2_derive"
|
||||
version = "0.7.3"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "144ec79496cbab6f84fa125dc67be9264aef22eb8a28da8454d9c33f15108da4"
|
||||
checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -725,9 +725,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gdk-pixbuf"
|
||||
version = "0.15.6"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8750501d75f318c2ec0314701bc8403901303210def80bafd13f6b6059a3f45"
|
||||
checksum = "678516f1baef591d270ca10587c01a12542a731a7879cc62391a18191a470831"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"gdk-pixbuf-sys",
|
||||
|
|
@ -738,9 +738,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gdk-pixbuf-sys"
|
||||
version = "0.15.1"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "413424d9818621fa3cfc8a3a915cdb89a7c3c507d56761b4ec83a9a98e587171"
|
||||
checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7"
|
||||
dependencies = [
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
|
|
@ -800,9 +800,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gettext-sys"
|
||||
version = "0.21.2"
|
||||
version = "0.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afa9e06ab9e7514cc9ae668ea3b71ea1536259d767dff0289ac23ad134f99929"
|
||||
checksum = "c63ce2e00f56a206778276704bbe38564c8695249fdc8f354b4ef71c57c3839d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"temp-dir",
|
||||
|
|
@ -810,9 +810,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gio"
|
||||
version = "0.15.6"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96efd8a1c00d890f6b45671916e165b5e43ccec61957d443aff6d7e44f62d348"
|
||||
checksum = "76cd21a7a674ea811749661012512b0ba5237ba404ccbcab2850db5537549b64"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"futures-channel",
|
||||
|
|
@ -827,9 +827,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gio-sys"
|
||||
version = "0.15.6"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d0fa5052773f5a56b8ae47dab09d040f5d9ce1311f4f99006e16e9a08269296"
|
||||
checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
|
|
@ -840,9 +840,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.15.6"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa570813c504bdf7539a9400180c2dd4b789a819556fb86da7226d7d1b037b49"
|
||||
checksum = "a826fad715b57834920839d7a594c3b5e416358c7d790bdaba847a40d7c1d96d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"futures-channel",
|
||||
|
|
@ -860,9 +860,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.15.6"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41bfd8d227dead0829ac142454e97531b93f576d0805d779c42bfd799c65c572"
|
||||
checksum = "dac4d47c544af67747652ab1865ace0ffa1155709723ac4f32e97587dd4735b2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
|
|
@ -875,9 +875,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "glib-sys"
|
||||
version = "0.15.6"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4366377bd56697de8aaee24e673c575d2694d72e7756324ded2b0428829a7b8"
|
||||
checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"system-deps",
|
||||
|
|
@ -885,9 +885,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.15.5"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df6859463843c20cf3837e3a9069b6ab2051aeeadf4c899d33344f4aea83189a"
|
||||
checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"libc",
|
||||
|
|
@ -1069,9 +1069,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.119"
|
||||
version = "0.2.121"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
|
||||
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
|
||||
|
||||
[[package]]
|
||||
name = "libnghttp2-sys"
|
||||
|
|
@ -1085,9 +1085,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
version = "1.1.3"
|
||||
version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66"
|
||||
checksum = "6f35facd4a5673cb5a48822be2be1d4236c1c99cb4113cab7061ac720d5bf859"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
|
@ -1119,9 +1119,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
version = "0.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
|
@ -1250,9 +1250,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.9.0"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
|
||||
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-probe"
|
||||
|
|
@ -1285,9 +1285,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pango"
|
||||
version = "0.15.6"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78c7420fc01a390ec200da7395b64d705f5d82fe03e5d0708aee422c46538be7"
|
||||
checksum = "22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"glib",
|
||||
|
|
@ -1298,9 +1298,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pango-sys"
|
||||
version = "0.15.1"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7022c2fb88cd2d9d55e1a708a8c53a3ae8678234c4a54bf623400aeb7f31fac2"
|
||||
checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
|
|
@ -1407,7 +1407,7 @@ dependencies = [
|
|||
"blocking",
|
||||
"const_format",
|
||||
"dirs 4.0.0",
|
||||
"futures-lite",
|
||||
"futures",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
|
|
@ -1434,7 +1434,7 @@ dependencies = [
|
|||
"flume",
|
||||
"fork",
|
||||
"freedesktop-desktop-entry",
|
||||
"futures-lite",
|
||||
"futures",
|
||||
"gtk",
|
||||
"human-sort",
|
||||
"human_format",
|
||||
|
|
@ -1469,8 +1469,6 @@ dependencies = [
|
|||
"async-trait",
|
||||
"flume",
|
||||
"futures",
|
||||
"futures-core",
|
||||
"futures-lite",
|
||||
"futures_codec",
|
||||
"gen-z",
|
||||
"num_cpus",
|
||||
|
|
@ -1539,9 +1537,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.15"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
|
||||
checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
|
@ -1578,21 +1576,22 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.10"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
|
||||
checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.0"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
||||
checksum = "7776223e2696f1aa4c6b0170e83212f47296a00424305117d013dfe86fb0fe55"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"redox_syscall",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1869,9 +1868,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.86"
|
||||
version = "1.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
|
||||
checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -1985,9 +1984,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.22"
|
||||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23"
|
||||
checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"valuable",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ members = ["bin", "plugins", "service"]
|
|||
blocking = "1.2.0"
|
||||
const_format = "0.2.22"
|
||||
dirs = "4.0.0"
|
||||
futures-lite = "1.12.0"
|
||||
futures = "0.3.21"
|
||||
serde = { version = "1.0.136", features = ["derive"] }
|
||||
serde_json = "1.0.79"
|
||||
serde_with = "1.12.0"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ publish = false
|
|||
async-pidfd = "0.1.4"
|
||||
fork = "0.1.19"
|
||||
freedesktop-desktop-entry = "0.5.0"
|
||||
futures-lite = "1.12.0"
|
||||
gtk = "0.15.4"
|
||||
human_format = "1.0.3"
|
||||
human-sort = "0.2.2"
|
||||
|
|
@ -35,3 +34,4 @@ sysfs-class = "0.1.3"
|
|||
anyhow = "1.0.56"
|
||||
flume = "0.10.12"
|
||||
dirs = "4.0.0"
|
||||
futures = "0.3.21"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright © 2021 System76
|
||||
|
||||
use futures_lite::{AsyncBufReadExt, AsyncWriteExt, StreamExt};
|
||||
use futures::{AsyncBufReadExt, AsyncWriteExt, StreamExt};
|
||||
use pop_launcher::*;
|
||||
use regex::Regex;
|
||||
use smol::{
|
||||
|
|
@ -158,7 +158,7 @@ async fn qcalc(regex: &mut Regex, expression: &str, decimal_comma: bool) -> Opti
|
|||
}
|
||||
};
|
||||
|
||||
let mut reader = smol::io::BufReader::new(stdout).lines().skip(2);
|
||||
let mut reader = futures::io::BufReader::new(stdout).lines().skip(2);
|
||||
let mut output = String::new();
|
||||
|
||||
fn has_issue(line: &str) -> bool {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ mod graphics;
|
|||
|
||||
use crate::*;
|
||||
use freedesktop_desktop_entry::{default_paths, DesktopEntry, Iter as DesktopIter, PathSource};
|
||||
use futures_lite::{AsyncWrite, StreamExt};
|
||||
use futures::{AsyncWrite, StreamExt};
|
||||
use pop_launcher::*;
|
||||
use std::borrow::Cow;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright © 2021 System76
|
||||
|
||||
use futures_lite::prelude::*;
|
||||
use futures::prelude::*;
|
||||
use pop_launcher::*;
|
||||
use smol::Unblock;
|
||||
use std::{collections::BTreeMap, io, path::PathBuf};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright © 2021 System76
|
||||
|
||||
use futures_lite::*;
|
||||
use futures::*;
|
||||
use pop_launcher::*;
|
||||
use smol::process::{Child, ChildStdout, Command, Stdio};
|
||||
use std::cell::Cell;
|
||||
|
|
@ -107,7 +107,7 @@ pub async fn main() {
|
|||
Ok::<(), flume::SendError<Event>>(())
|
||||
};
|
||||
|
||||
let _ = future::zip(request_handler, search_handler).await;
|
||||
let _ = futures::future::join(request_handler, search_handler).await;
|
||||
}
|
||||
|
||||
/// Maintains state for search requests
|
||||
|
|
@ -148,7 +148,7 @@ impl SearchContext {
|
|||
tracing::debug!("searching for {}", search);
|
||||
|
||||
let (mut child, mut stdout) = match query(&search).await {
|
||||
Ok((child, stdout)) => (child, futures_lite::io::BufReader::new(stdout).lines()),
|
||||
Ok((child, stdout)) => (child, futures::io::BufReader::new(stdout).lines()),
|
||||
Err(why) => {
|
||||
tracing::error!("failed to spawn fdfind process: {}", why);
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ impl SearchContext {
|
|||
None
|
||||
};
|
||||
|
||||
match interrupt.or(stdout.next()).await {
|
||||
match crate::or(interrupt, stdout.next()).await {
|
||||
Some(result) => match result {
|
||||
Ok(line) => append = line,
|
||||
Err(why) => {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ pub mod scripts;
|
|||
pub mod terminal;
|
||||
pub mod web;
|
||||
|
||||
use futures_lite::{AsyncWrite, AsyncWriteExt};
|
||||
use futures::{AsyncWrite, AsyncWriteExt};
|
||||
use pop_launcher::PluginResponse;
|
||||
use std::{borrow::Cow, ffi::OsStr, path::Path};
|
||||
use std::{borrow::Cow, ffi::OsStr, future::Future, path::Path};
|
||||
|
||||
pub async fn send<W: AsyncWrite + Unpin>(tx: &mut W, response: PluginResponse) {
|
||||
if let Ok(mut bytes) = serde_json::to_string(&response) {
|
||||
|
|
@ -23,6 +23,17 @@ pub async fn send<W: AsyncWrite + Unpin>(tx: &mut W, response: PluginResponse) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Run both futures and take the output of the first one to finish.
|
||||
pub async fn or<T>(future1: impl Future<Output = T>, future2: impl Future<Output = T>) -> T {
|
||||
futures::pin_mut!(future1);
|
||||
futures::pin_mut!(future2);
|
||||
|
||||
futures::future::select(future1, future2)
|
||||
.await
|
||||
.factor_first()
|
||||
.0
|
||||
}
|
||||
|
||||
/// Fetch the mime for a given path
|
||||
pub fn mime_from_path(path: &Path) -> Cow<'static, str> {
|
||||
if path.is_dir() {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use crate::*;
|
||||
use freedesktop_desktop_entry as fde;
|
||||
use futures_lite::{AsyncWrite, AsyncWriteExt, StreamExt};
|
||||
use futures::{AsyncWrite, AsyncWriteExt, StreamExt};
|
||||
use pop_launcher::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{convert::TryFrom, fs, path::PathBuf, sync::Arc};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Copyright © 2021 System76
|
||||
|
||||
use async_pidfd::AsyncPidFd;
|
||||
use futures_lite::prelude::*;
|
||||
use futures::prelude::*;
|
||||
use pop_launcher::*;
|
||||
use smol::Unblock;
|
||||
use std::io;
|
||||
|
|
@ -145,7 +145,7 @@ fn pactl_sinks() -> flume::Receiver<String> {
|
|||
|
||||
if let Ok(mut child) = child {
|
||||
if let Some(stdout) = child.stdout.take() {
|
||||
let mut lines = futures_lite::io::BufReader::new(stdout).lines();
|
||||
let mut lines = futures::io::BufReader::new(stdout).lines();
|
||||
while let Some(Ok(line)) = lines.next().await {
|
||||
if let Some(stripped) = line.strip_prefix("Sink #") {
|
||||
let _ = tx.send_async(stripped.trim().to_owned()).await;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright © 2021 System76
|
||||
|
||||
use futures_lite::prelude::*;
|
||||
use futures::prelude::*;
|
||||
use gtk::prelude::*;
|
||||
use pop_launcher::*;
|
||||
use slab::Slab;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crate::*;
|
|||
use pop_launcher::*;
|
||||
|
||||
use flume::Sender;
|
||||
use futures_lite::{AsyncBufReadExt, StreamExt};
|
||||
use futures::{AsyncBufReadExt, StreamExt};
|
||||
use smol::process::{Command, Stdio};
|
||||
use std::collections::VecDeque;
|
||||
use std::{
|
||||
|
|
@ -98,7 +98,7 @@ impl App {
|
|||
}
|
||||
};
|
||||
|
||||
futures_lite::future::zip(script_sender, script_receiver).await;
|
||||
futures::future::join(script_sender, script_receiver).await;
|
||||
}
|
||||
|
||||
async fn search(&mut self, query: &str) {
|
||||
|
|
@ -158,7 +158,7 @@ async fn load_from(path: &Path, paths: &mut VecDeque<PathBuf>, tx: Sender<Script
|
|||
|
||||
smol::spawn(async move {
|
||||
let mut file = match smol::fs::File::open(&path).await {
|
||||
Ok(file) => smol::io::BufReader::new(file).lines(),
|
||||
Ok(file) => futures::io::BufReader::new(file).lines(),
|
||||
Err(why) => {
|
||||
tracing::error!("cannot open script at {}: {}", path.display(), why);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright © 2021 System76
|
||||
|
||||
use futures_lite::prelude::*;
|
||||
use futures::prelude::*;
|
||||
use pop_launcher::*;
|
||||
use smol::Unblock;
|
||||
use std::{io, path::PathBuf};
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ use std::io;
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
||||
use futures_lite::StreamExt;
|
||||
use futures::io::AsyncReadExt;
|
||||
use futures::StreamExt;
|
||||
use isahc::config::{Configurable, RedirectPolicy};
|
||||
use isahc::http::header::CONTENT_TYPE;
|
||||
use isahc::{AsyncReadResponseExt, HttpClient};
|
||||
use smol::io::AsyncReadExt;
|
||||
use smol::Unblock;
|
||||
use url::Url;
|
||||
|
||||
|
|
@ -159,9 +159,7 @@ impl App {
|
|||
// Ensure we recreate the pop-launcher cache dir if it was removed at runtime
|
||||
let cache_dir = favicon_path.parent().unwrap();
|
||||
if !cache_dir.exists() {
|
||||
smol::fs::create_dir_all(cache_dir)
|
||||
.await
|
||||
.expect("error creating cache directory");
|
||||
std::fs::create_dir_all(cache_dir).expect("error creating cache directory");
|
||||
}
|
||||
|
||||
let copy = smol::fs::write(&favicon_path, icon).await;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ async-oneshot = "0.5.0"
|
|||
async-trait = "0.1.52"
|
||||
futures = "0.3.21"
|
||||
futures_codec = "0.4.1"
|
||||
futures-lite = "1.12.0"
|
||||
gen-z = "0.1.0"
|
||||
num_cpus = "1.13.1"
|
||||
pop-launcher = { path = "../" }
|
||||
|
|
@ -26,6 +25,5 @@ strsim = "0.10.0"
|
|||
toml = "0.5.8"
|
||||
tracing = "0.1.31"
|
||||
tracing-subscriber = { version = "0.3.9", features = ["fmt"] }
|
||||
futures-core = "0.3.21"
|
||||
async-process = "1.3.0"
|
||||
flume = "0.10.12"
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ pub use client::*;
|
|||
|
||||
use crate::plugins::*;
|
||||
use flume::{Receiver, Sender};
|
||||
use futures::SinkExt;
|
||||
use futures_core::Stream;
|
||||
use futures_lite::{future, StreamExt};
|
||||
use futures::{future, SinkExt, Stream, StreamExt};
|
||||
use pop_launcher::*;
|
||||
use regex::Regex;
|
||||
use slab::Slab;
|
||||
|
|
@ -36,12 +34,14 @@ pub struct PluginHelp {
|
|||
|
||||
pub async fn main() {
|
||||
// Listens for a stream of requests from stdin.
|
||||
let input_stream = json_input_stream(async_stdin()).filter_map(|result| match result {
|
||||
Ok(request) => Some(request),
|
||||
Err(why) => {
|
||||
tracing::error!("malformed JSON input: {}", why);
|
||||
None
|
||||
}
|
||||
let input_stream = json_input_stream(async_stdin()).filter_map(|result| {
|
||||
future::ready(match result {
|
||||
Ok(request) => Some(request),
|
||||
Err(why) => {
|
||||
tracing::error!("malformed JSON input: {}", why);
|
||||
None
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
let (output_tx, output_rx) = flume::bounded(16);
|
||||
|
|
@ -59,7 +59,7 @@ pub async fn main() {
|
|||
}
|
||||
};
|
||||
|
||||
futures_lite::future::zip(service, responder).await;
|
||||
futures::future::join(service, responder).await;
|
||||
}
|
||||
|
||||
pub struct Service<O> {
|
||||
|
|
@ -91,7 +91,7 @@ impl<O: futures::Sink<Response> + Unpin> Service<O> {
|
|||
let (service_tx, service_rx) = flume::bounded(1);
|
||||
let stream = plugins::external::load::from_paths();
|
||||
|
||||
futures_lite::pin!(stream);
|
||||
futures::pin_mut!(stream);
|
||||
|
||||
while let Some((exec, config, regex)) = stream.next().await {
|
||||
tracing::info!("found plugin \"{}\"", exec.display());
|
||||
|
|
@ -121,7 +121,10 @@ impl<O: futures::Sink<Response> + Unpin> Service<O> {
|
|||
let f1 = request_handler(input, service_tx);
|
||||
let f2 = self.response_handler(service_rx);
|
||||
|
||||
future::or(f1, f2).await;
|
||||
futures::pin_mut!(f1);
|
||||
futures::pin_mut!(f2);
|
||||
|
||||
futures::future::select(f1, f2).await.factor_first().0;
|
||||
}
|
||||
|
||||
async fn response_handler(&mut self, service_rx: Receiver<Event>) {
|
||||
|
|
@ -574,7 +577,7 @@ impl<O: futures::Sink<Response> + Unpin> Service<O> {
|
|||
async fn request_handler(input: impl Stream<Item = Request>, tx: Sender<Event>) {
|
||||
let mut requested_to_exit = false;
|
||||
|
||||
futures_lite::pin!(input);
|
||||
futures::pin_mut!(input);
|
||||
|
||||
while let Some(request) = input.next().await {
|
||||
if let Request::Exit = request {
|
||||
|
|
|
|||
4
service/src/plugins/external/mod.rs
vendored
4
service/src/plugins/external/mod.rs
vendored
|
|
@ -15,7 +15,7 @@ use std::{
|
|||
use crate::{Event, Indice, Plugin, PluginResponse, Request};
|
||||
use async_oneshot::oneshot;
|
||||
use flume::Sender;
|
||||
use futures_lite::{AsyncWriteExt, FutureExt, StreamExt};
|
||||
use futures::{AsyncWriteExt, StreamExt};
|
||||
use smol::{
|
||||
process::{Child, Command, Stdio},
|
||||
Task,
|
||||
|
|
@ -105,7 +105,7 @@ impl ExternalPlugin {
|
|||
let _ = trip_rx.await;
|
||||
};
|
||||
|
||||
let _ = responder.or(trip).await;
|
||||
let _ = crate::or(responder, trip).await;
|
||||
|
||||
// Ensure that a task that was searching sends a finished signal if it dies.
|
||||
if searching.swap(false, Ordering::SeqCst) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use blocking::Unblock;
|
||||
use futures_lite::{AsyncBufReadExt, AsyncRead, Stream, StreamExt};
|
||||
use futures::{AsyncBufReadExt, AsyncRead, Stream, StreamExt};
|
||||
use serde::Deserialize;
|
||||
use std::io;
|
||||
|
||||
|
|
@ -22,9 +22,9 @@ where
|
|||
I: AsyncRead + Unpin + Send,
|
||||
S: for<'a> Deserialize<'a>,
|
||||
{
|
||||
futures_lite::io::BufReader::new(input)
|
||||
futures::io::BufReader::new(input)
|
||||
.lines()
|
||||
.take_while(Result::is_ok)
|
||||
.take_while(|x| futures::future::ready(x.is_ok()))
|
||||
.map(Result::unwrap)
|
||||
.map(|line| serde_json::from_str::<S>(&line))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue