diff options
-rw-r--r-- | examples/pokedex/Cargo.toml | 6 | ||||
-rw-r--r-- | examples/pokedex/src/main.rs | 14 | ||||
-rw-r--r-- | futures/Cargo.toml | 6 | ||||
-rw-r--r-- | futures/src/executor.rs | 8 |
4 files changed, 17 insertions, 17 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 } diff --git a/futures/Cargo.toml b/futures/Cargo.toml index 91860e1e..483e60cb 100644 --- a/futures/Cargo.toml +++ b/futures/Cargo.toml @@ -19,12 +19,12 @@ log = "0.4" [dependencies.futures] version = "0.3" -[dependencies.tokio] +[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio] version = "0.2" optional = true -features = ["rt-core"] +features = ["rt-core", "rt-threaded"] -[dependencies.async-std] +[target.'cfg(not(target_arch = "wasm32"))'.dependencies.async-std] version = "1.0" optional = true diff --git a/futures/src/executor.rs b/futures/src/executor.rs index c2b9cc72..2a5281af 100644 --- a/futures/src/executor.rs +++ b/futures/src/executor.rs @@ -4,10 +4,10 @@ mod null; #[cfg(feature = "thread-pool")] mod thread_pool; -#[cfg(feature = "tokio")] +#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))] mod tokio; -#[cfg(feature = "async-std")] +#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))] mod async_std; #[cfg(target_arch = "wasm32")] @@ -18,10 +18,10 @@ pub use null::Null; #[cfg(feature = "thread-pool")] pub use thread_pool::ThreadPool; -#[cfg(feature = "tokio")] +#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))] pub use self::tokio::Tokio; -#[cfg(feature = "async-std")] +#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))] pub use self::async_std::AsyncStd; #[cfg(target_arch = "wasm32")] |