summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2024-03-21 22:29:34 +0000
committerAlex Orlenko <zxteam@protonmail.com>2024-03-21 22:29:34 +0000
commit80fff4f2e7f8250c28bc6f5de79dace1ec914b31 (patch)
tree9ee07bc4f84a5d0a9ba7730e1a2555ff4d036db1
parent973414631342b316bc8fb5e65ce858c1b497ae60 (diff)
downloadmlua-80fff4f2e7f8250c28bc6f5de79dace1ec914b31.zip
Update `reqwest` to 0.12
-rw-r--r--Cargo.toml2
-rw-r--r--examples/async_http_reqwest.rs20
2 files changed, 8 insertions, 14 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8bee1eb..a83f0ae 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -64,7 +64,7 @@ libloading = { version = "0.8", optional = true }
trybuild = "1.0"
futures = "0.3.5"
hyper = { version = "0.14", features = ["client", "server"] }
-reqwest = { version = "0.11", features = ["json"] }
+reqwest = { version = "0.12", features = ["json"] }
tokio = { version = "1.0", features = ["macros", "rt", "time"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
diff --git a/examples/async_http_reqwest.rs b/examples/async_http_reqwest.rs
index 4d67564..2021e84 100644
--- a/examples/async_http_reqwest.rs
+++ b/examples/async_http_reqwest.rs
@@ -1,11 +1,9 @@
-use mlua::{chunk, ExternalResult, Lua, LuaSerdeExt, Result};
+use mlua::{chunk, ExternalResult, Lua, LuaSerdeExt, Result, Value};
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
let lua = Lua::new();
- let null = lua.null();
-
let fetch_json = lua.create_async_function(|lua, uri: String| async move {
let resp = reqwest::get(&uri)
.await
@@ -15,19 +13,15 @@ async fn main() -> Result<()> {
lua.to_value(&json)
})?;
+ let dbg = lua.create_function(|_, value: Value| {
+ println!("{value:#?}");
+ Ok(())
+ })?;
+
let f = lua
.load(chunk! {
- function print_r(t, indent)
- local indent = indent or ""
- for k, v in pairs(t) do
- io.write(indent, tostring(k))
- if type(v) == "table" then io.write(":\n") print_r(v, indent.." ")
- else io.write(": ", v == $null and "null" or tostring(v), "\n") end
- end
- end
-
local res = $fetch_json(...)
- print_r(res)
+ $dbg(res)
})
.into_function()?;