summaryrefslogtreecommitdiffstats
path: root/examples/pokedex
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-05 01:40:27 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-05 01:40:27 +0100
commit8f52604987038225ce90261f17fd8408f1a7ebe3 (patch)
tree095d453a7407cc727e6d91b95813331922233d8f /examples/pokedex
parent28fd9feb40a024ea29f73fa91c21fc3f2cf01d58 (diff)
downloadiced-8f52604987038225ce90261f17fd8408f1a7ebe3.tar.gz
iced-8f52604987038225ce90261f17fd8408f1a7ebe3.tar.bz2
iced-8f52604987038225ce90261f17fd8408f1a7ebe3.zip
Use `reqwest` and `tokio` in `pokedex` example
Diffstat (limited to 'examples/pokedex')
-rw-r--r--examples/pokedex/Cargo.toml6
-rw-r--r--examples/pokedex/src/main.rs14
2 files changed, 10 insertions, 10 deletions
diff --git a/examples/pokedex/Cargo.toml b/examples/pokedex/Cargo.toml
index 76a3a82f..b96eda91 100644
--- a/examples/pokedex/Cargo.toml
+++ b/examples/pokedex/Cargo.toml
@@ -6,9 +6,9 @@ edition = "2018"
publish = false
[dependencies]
-iced = { path = "../..", features = ["image"] }
-iced_futures = { path = "../../futures", features = ["async-std"] }
-surf = "1.0"
+iced = { path = "../..", features = ["image", "debug"] }
+iced_futures = { path = "../../futures", features = ["tokio"] }
+reqwest = { version = "0.10", features = ["json"] }
rand = "0.7"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs
index 283437b2..3c00d628 100644
--- a/examples/pokedex/src/main.rs
+++ b/examples/pokedex/src/main.rs
@@ -27,7 +27,7 @@ enum Message {
}
impl Application for Pokedex {
- type Executor = iced_futures::executor::AsyncStd;
+ type Executor = iced_futures::executor::Tokio;
type Message = Message;
fn new() -> (Pokedex, Command<Message>) {
@@ -175,8 +175,8 @@ impl Pokemon {
let sprite = format!("https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/{}.png", id);
let (entry, sprite): (Entry, _) = futures::future::try_join(
- surf::get(&url).recv_json(),
- surf::get(&sprite).recv_bytes(),
+ reqwest::get(&url).await?.json(),
+ reqwest::get(&sprite).await?.bytes(),
)
.await?;
@@ -195,7 +195,7 @@ impl Pokemon {
.chars()
.map(|c| if c.is_control() { ' ' } else { c })
.collect(),
- image: image::Handle::from_memory(sprite),
+ image: image::Handle::from_memory(sprite.as_ref().to_vec()),
})
}
}
@@ -206,9 +206,9 @@ enum Error {
LanguageError,
}
-impl From<surf::Exception> for Error {
- fn from(exception: surf::Exception) -> Error {
- dbg!(&exception);
+impl From<reqwest::Error> for Error {
+ fn from(error: reqwest::Error) -> Error {
+ dbg!(&error);
Error::APIError
}