mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
Migrate lune-std-serde to async-io instead of tokio
This commit is contained in:
parent
aeaebf4290
commit
2a701e919c
3 changed files with 12 additions and 21 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -183,9 +183,9 @@ dependencies = [
|
||||||
"brotli",
|
"brotli",
|
||||||
"flate2",
|
"flate2",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
"futures-io",
|
||||||
"memchr",
|
"memchr",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"tokio",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1711,8 +1711,10 @@ version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-compression",
|
"async-compression",
|
||||||
"blake3",
|
"blake3",
|
||||||
|
"blocking",
|
||||||
"bstr",
|
"bstr",
|
||||||
"digest",
|
"digest",
|
||||||
|
"futures-lite",
|
||||||
"hmac",
|
"hmac",
|
||||||
"lune-utils",
|
"lune-utils",
|
||||||
"lz4",
|
"lz4",
|
||||||
|
@ -1724,7 +1726,6 @@ dependencies = [
|
||||||
"sha1 0.10.6",
|
"sha1 0.10.6",
|
||||||
"sha2",
|
"sha2",
|
||||||
"sha3",
|
"sha3",
|
||||||
"tokio",
|
|
||||||
"toml",
|
"toml",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,16 @@ workspace = true
|
||||||
mlua = { version = "0.10.3", features = ["luau", "serialize"] }
|
mlua = { version = "0.10.3", features = ["luau", "serialize"] }
|
||||||
|
|
||||||
async-compression = { version = "0.4", features = [
|
async-compression = { version = "0.4", features = [
|
||||||
"tokio",
|
"futures-io",
|
||||||
"brotli",
|
"brotli",
|
||||||
"deflate",
|
"deflate",
|
||||||
"gzip",
|
"gzip",
|
||||||
"zlib",
|
"zlib",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
|
blocking = "1.6"
|
||||||
bstr = "1.9"
|
bstr = "1.9"
|
||||||
|
futures-lite = "2.6"
|
||||||
lz4 = "1.26"
|
lz4 = "1.26"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||||
|
@ -39,9 +42,4 @@ sha3 = "0.10.8"
|
||||||
# Check before updating it.
|
# Check before updating it.
|
||||||
blake3 = { version = "=1.5.0", features = ["traits-preview"] }
|
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" }
|
lune-utils = { version = "0.1.3", path = "../lune-utils" }
|
||||||
|
|
|
@ -2,14 +2,12 @@ use std::io::{copy as copy_std, Cursor, Read as _, Write as _};
|
||||||
|
|
||||||
use mlua::prelude::*;
|
use mlua::prelude::*;
|
||||||
|
|
||||||
|
use blocking::unblock;
|
||||||
|
use futures_lite::io::{copy, BufReader};
|
||||||
use lz4::{Decoder, EncoderBuilder};
|
use lz4::{Decoder, EncoderBuilder};
|
||||||
use tokio::{
|
|
||||||
io::{copy, BufReader},
|
|
||||||
task::spawn_blocking,
|
|
||||||
};
|
|
||||||
|
|
||||||
use async_compression::{
|
use async_compression::{
|
||||||
tokio::bufread::{
|
futures::bufread::{
|
||||||
BrotliDecoder, BrotliEncoder, GzipDecoder, GzipEncoder, ZlibDecoder, ZlibEncoder,
|
BrotliDecoder, BrotliEncoder, GzipDecoder, GzipEncoder, ZlibDecoder, ZlibEncoder,
|
||||||
},
|
},
|
||||||
Level::Best as CompressionQuality,
|
Level::Best as CompressionQuality,
|
||||||
|
@ -124,10 +122,7 @@ pub async fn compress(
|
||||||
) -> LuaResult<Vec<u8>> {
|
) -> LuaResult<Vec<u8>> {
|
||||||
if let CompressDecompressFormat::LZ4 = format {
|
if let CompressDecompressFormat::LZ4 = format {
|
||||||
let source = source.as_ref().to_vec();
|
let source = source.as_ref().to_vec();
|
||||||
return spawn_blocking(move || compress_lz4(source))
|
return unblock(move || compress_lz4(source)).await.into_lua_err();
|
||||||
.await
|
|
||||||
.into_lua_err()?
|
|
||||||
.into_lua_err();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
|
@ -169,10 +164,7 @@ pub async fn decompress(
|
||||||
) -> LuaResult<Vec<u8>> {
|
) -> LuaResult<Vec<u8>> {
|
||||||
if let CompressDecompressFormat::LZ4 = format {
|
if let CompressDecompressFormat::LZ4 = format {
|
||||||
let source = source.as_ref().to_vec();
|
let source = source.as_ref().to_vec();
|
||||||
return spawn_blocking(move || decompress_lz4(source))
|
return unblock(move || decompress_lz4(source)).await.into_lua_err();
|
||||||
.await
|
|
||||||
.into_lua_err()?
|
|
||||||
.into_lua_err();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
|
|
Loading…
Add table
Reference in a new issue