Migrate lune-std-serde to async-io instead of tokio

This commit is contained in:
Filip Tibell 2025-04-23 23:28:33 +02:00
parent aeaebf4290
commit 2a701e919c
No known key found for this signature in database
3 changed files with 12 additions and 21 deletions

5
Cargo.lock generated
View file

@ -183,9 +183,9 @@ dependencies = [
"brotli",
"flate2",
"futures-core",
"futures-io",
"memchr",
"pin-project-lite",
"tokio",
]
[[package]]
@ -1711,8 +1711,10 @@ version = "0.1.2"
dependencies = [
"async-compression",
"blake3",
"blocking",
"bstr",
"digest",
"futures-lite",
"hmac",
"lune-utils",
"lz4",
@ -1724,7 +1726,6 @@ dependencies = [
"sha1 0.10.6",
"sha2",
"sha3",
"tokio",
"toml",
]

View file

@ -16,13 +16,16 @@ workspace = true
mlua = { version = "0.10.3", features = ["luau", "serialize"] }
async-compression = { version = "0.4", features = [
"tokio",
"futures-io",
"brotli",
"deflate",
"gzip",
"zlib",
] }
blocking = "1.6"
bstr = "1.9"
futures-lite = "2.6"
lz4 = "1.26"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
@ -39,9 +42,4 @@ sha3 = "0.10.8"
# Check before updating it.
blake3 = { version = "=1.5.0", features = ["traits-preview"] }
tokio = { version = "1", default-features = false, features = [
"rt",
"io-util",
] }
lune-utils = { version = "0.1.3", path = "../lune-utils" }

View file

@ -2,14 +2,12 @@ use std::io::{copy as copy_std, Cursor, Read as _, Write as _};
use mlua::prelude::*;
use blocking::unblock;
use futures_lite::io::{copy, BufReader};
use lz4::{Decoder, EncoderBuilder};
use tokio::{
io::{copy, BufReader},
task::spawn_blocking,
};
use async_compression::{
tokio::bufread::{
futures::bufread::{
BrotliDecoder, BrotliEncoder, GzipDecoder, GzipEncoder, ZlibDecoder, ZlibEncoder,
},
Level::Best as CompressionQuality,
@ -124,10 +122,7 @@ pub async fn compress(
) -> LuaResult<Vec<u8>> {
if let CompressDecompressFormat::LZ4 = format {
let source = source.as_ref().to_vec();
return spawn_blocking(move || compress_lz4(source))
.await
.into_lua_err()?
.into_lua_err();
return unblock(move || compress_lz4(source)).await.into_lua_err();
}
let mut bytes = Vec::new();
@ -169,10 +164,7 @@ pub async fn decompress(
) -> LuaResult<Vec<u8>> {
if let CompressDecompressFormat::LZ4 = format {
let source = source.as_ref().to_vec();
return spawn_blocking(move || decompress_lz4(source))
.await
.into_lua_err()?
.into_lua_err();
return unblock(move || decompress_lz4(source)).await.into_lua_err();
}
let mut bytes = Vec::new();