summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml6
-rw-r--r--examples/async_http_client.rs9
-rw-r--r--examples/async_tcp_server.rs3
3 files changed, 9 insertions, 9 deletions
diff --git a/Cargo.toml b/Cargo.toml
index e6c1d01..92a8725 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -61,9 +61,9 @@ rustyline = "7.0"
criterion = "0.3"
trybuild = "1.0"
futures = "0.3.5"
-hyper = "0.13"
-reqwest = { version = "0.10", features = ["json"] }
-tokio = { version = "0.2", features = ["full"] }
+hyper = { version = "0.14", features = ["client", "server"] }
+reqwest = { version = "0.11", features = ["json"] }
+tokio = { version = "1.0", features = ["full"] }
futures-timer = "3.0"
serde_json = "1.0"
diff --git a/examples/async_http_client.rs b/examples/async_http_client.rs
index c536e90..f8c0793 100644
--- a/examples/async_http_client.rs
+++ b/examples/async_http_client.rs
@@ -2,8 +2,9 @@ use std::collections::HashMap;
use std::sync::Arc;
use bstr::BString;
-use hyper::{body::Body as HyperBody, Client as HyperClient};
-use tokio::{stream::StreamExt, sync::Mutex};
+use hyper::body::{Body as HyperBody, HttpBody as _};
+use hyper::Client as HyperClient;
+use tokio::sync::Mutex;
use mlua::{Error, Lua, Result, UserData, UserDataMethods};
@@ -20,8 +21,8 @@ impl UserData for BodyReader {
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
methods.add_async_method("read", |_, reader, ()| async move {
let mut reader = reader.0.lock().await;
- let bytes = reader.try_next().await.map_err(Error::external)?;
- if let Some(bytes) = bytes {
+ if let Some(bytes) = reader.data().await {
+ let bytes = bytes.map_err(Error::external)?;
return Ok(Some(BString::from(bytes.as_ref())));
}
Ok(None)
diff --git a/examples/async_tcp_server.rs b/examples/async_tcp_server.rs
index acd7b5e..5153cfe 100644
--- a/examples/async_tcp_server.rs
+++ b/examples/async_tcp_server.rs
@@ -1,4 +1,3 @@
-use std::net::Shutdown;
use std::sync::Arc;
use bstr::BString;
@@ -55,7 +54,7 @@ impl UserData for LuaTcpStream {
});
methods.add_async_method("close", |_, stream, ()| async move {
- stream.0.lock().await.shutdown(Shutdown::Both)?;
+ stream.0.lock().await.shutdown().await?;
Ok(())
});
}