diff --git a/Cargo.lock b/Cargo.lock index 62ad18e15..6434d10bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -286,7 +286,6 @@ name = "all-is-cubes-server" version = "0.8.0" dependencies = [ "anyhow", - "async_fn_traits", "axum", "clap", "include_dir", diff --git a/all-is-cubes-desktop/src/lib.rs b/all-is-cubes-desktop/src/lib.rs index b67903c00..27ed10de9 100644 --- a/all-is-cubes-desktop/src/lib.rs +++ b/all-is-cubes-desktop/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(async_closure)] #![feature(never_type)] //! Components for creating a desktop application that renders interactive [`all_is_cubes`] diff --git a/all-is-cubes-desktop/src/session.rs b/all-is-cubes-desktop/src/session.rs index 1a403ed37..f59527dd8 100644 --- a/all-is-cubes-desktop/src/session.rs +++ b/all-is-cubes-desktop/src/session.rs @@ -14,7 +14,7 @@ use all_is_cubes::universe::Universe; use all_is_cubes::universe::UniverseStepInfo; use all_is_cubes::util::ErrorChain; use all_is_cubes_render::camera::Viewport; -use all_is_cubes_ui::apps::ExitMainTask; +use all_is_cubes_ui::apps::{ExitMainTask, MainTaskContext}; use crate::Session; @@ -153,25 +153,26 @@ impl DesktopSession { // TODO: Also make a way to do this that isn't replacing the main task, // or that defines a way for the existing main task to coordinate. - self.session.set_main_task(move |mut ctx| async move { - // TODO: Offer confirmation before replacing the current universe. - // TODO: Then open a progress-bar UI page while we load. - - match loader_task.await.unwrap() { - Ok(universe) => { - ctx.set_universe(universe); - } - Err(e) => { - ctx.show_modal_message(arcstr::format!( - "Failed to load file '{path}':\n{e}", - path = path.display(), - e = ErrorChain(&e), - )); + self.session + .set_main_task(async move |mut ctx: MainTaskContext| { + // TODO: Offer confirmation before replacing the current universe. + // TODO: Then open a progress-bar UI page while we load. + + match loader_task.await.unwrap() { + Ok(universe) => { + ctx.set_universe(universe); + } + Err(e) => { + ctx.show_modal_message(arcstr::format!( + "Failed to load file '{path}':\n{e}", + path = path.display(), + e = ErrorChain(&e), + )); + } } - } - ExitMainTask - }) + ExitMainTask + }) } /// Set the “fixed” window title — the portion of the title not determined by the universe, diff --git a/all-is-cubes-desktop/src/startup.rs b/all-is-cubes-desktop/src/startup.rs index f933b69be..38162b151 100644 --- a/all-is-cubes-desktop/src/startup.rs +++ b/all-is-cubes-desktop/src/startup.rs @@ -87,7 +87,7 @@ pub fn inner_main( match *options {} } - dsession.session.set_main_task(|mut ctx| async move { + dsession.session.set_main_task(async move |mut ctx| { let universe_result: Result = match universe_task_future.await { // nested Results because one is template failure and the other is tokio JoinHandle failure Ok(Ok(u)) => Ok(u), diff --git a/all-is-cubes-server/Cargo.toml b/all-is-cubes-server/Cargo.toml index 2352e4470..89f944598 100644 --- a/all-is-cubes-server/Cargo.toml +++ b/all-is-cubes-server/Cargo.toml @@ -45,7 +45,6 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } tower-http = { version = "0.5.0", features = ["fs"] } [dev-dependencies] -async_fn_traits = { workspace = true } # Note that with default features disabled, reqwest has no TLS/SSL support. # This is usable because we are only using it to talk to the local server. reqwest = { version = "0.12.2", default-features = false } diff --git a/all-is-cubes-server/tests/http.rs b/all-is-cubes-server/tests/http.rs index 6828a23e9..7434878c8 100644 --- a/all-is-cubes-server/tests/http.rs +++ b/all-is-cubes-server/tests/http.rs @@ -1,13 +1,14 @@ +#![feature(async_closure)] + //! Test starting and contacting the web server, externally. use std::process::Stdio; -use async_fn_traits::AsyncFnOnce1; use reqwest::header::HeaderValue; use reqwest::Url; use tokio::io::AsyncBufReadExt; -async fn with_server>(client_source: &'static str, f: F) { +async fn with_server(client_source: &'static str, f: F) { let mut server = tokio::process::Command::new(env!("CARGO_BIN_EXE_aic-server")) .arg("--client-source") .arg(client_source) diff --git a/all-is-cubes-ui/src/apps/session.rs b/all-is-cubes-ui/src/apps/session.rs index c93e737e5..fa4a42ef5 100644 --- a/all-is-cubes-ui/src/apps/session.rs +++ b/all-is-cubes-ui/src/apps/session.rs @@ -1377,7 +1377,7 @@ mod tests { let mut cameras = session.create_cameras(ListenableSource::constant(Viewport::ARBITRARY)); session.set_main_task({ let noticed_step = noticed_step.clone(); - move |mut ctx| async move { + async move |mut ctx: MainTaskContext| { eprintln!("main task: waiting for new universe"); let new_universe = recv.await.unwrap(); ctx.set_universe(new_universe); diff --git a/all-is-cubes-ui/src/lib.rs b/all-is-cubes-ui/src/lib.rs index fa6b1730f..1f7008c86 100644 --- a/all-is-cubes-ui/src/lib.rs +++ b/all-is-cubes-ui/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(async_closure)] #![feature(never_type)] #![feature(noop_waker)] diff --git a/test-renderers/tests/wgpu-render.rs b/test-renderers/tests/wgpu-render.rs index 09a3286c4..b22f6f584 100644 --- a/test-renderers/tests/wgpu-render.rs +++ b/test-renderers/tests/wgpu-render.rs @@ -1,5 +1,7 @@ //! Runs [`test_renderers::harness_main`] against [`all_is_cubes_gpu::in_wgpu`]. +#![feature(async_closure)] + use clap::Parser as _; use tokio::sync::OnceCell; @@ -29,6 +31,9 @@ async fn main() -> test_renderers::HarnessResult { RendererId::Wgpu, test_renderers::SuiteId::Renderers, test_renderers::test_cases::all_tests, + // TODO: Change this to + // async move |label| { ... }, + // when is fixed. move |label| async move { get_factory(label).await.unwrap() }, parallelism, )