Skip to content

Commit 04f7783

Browse files
committed
Use AsyncFnOnce
1 parent eb199de commit 04f7783

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

ui/src/server_axum.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use axum_extra::{
2424
headers::{authorization::Bearer, Authorization, CacheControl, ETag, IfNoneMatch},
2525
TypedHeader,
2626
};
27-
use futures::{future::BoxFuture, FutureExt, TryFutureExt};
27+
use futures::{FutureExt, TryFutureExt};
2828
use orchestrator::coordinator::{self, CoordinatorFactory, DockerBackend, TRACKED_CONTAINERS};
2929
use snafu::prelude::*;
3030
use std::{
@@ -231,8 +231,8 @@ async fn evaluate(
231231
Json(req): Json<api::EvaluateRequest>,
232232
) -> Result<Json<api::EvaluateResponse>> {
233233
attempt_record_request(db, req, |req| async {
234-
with_coordinator(&factory.0, req, |c, req| {
235-
c.execute(req).context(EvaluateSnafu).boxed()
234+
with_coordinator(&factory.0, req, async |c, req| {
235+
c.execute(req).context(EvaluateSnafu).await
236236
})
237237
.await
238238
.map(Json)
@@ -246,8 +246,8 @@ async fn compile(
246246
Json(req): Json<api::CompileRequest>,
247247
) -> Result<Json<api::CompileResponse>> {
248248
attempt_record_request(db, req, |req| async {
249-
with_coordinator(&factory.0, req, |c, req| {
250-
c.compile(req).context(CompileSnafu).boxed()
249+
with_coordinator(&factory.0, req, async |c, req| {
250+
c.compile(req).context(CompileSnafu).await
251251
})
252252
.await
253253
.map(Json)
@@ -261,8 +261,8 @@ async fn execute(
261261
Json(req): Json<api::ExecuteRequest>,
262262
) -> Result<Json<api::ExecuteResponse>> {
263263
attempt_record_request(db, req, |req| async {
264-
with_coordinator(&factory.0, req, |c, req| {
265-
c.execute(req).context(ExecuteSnafu).boxed()
264+
with_coordinator(&factory.0, req, async |c, req| {
265+
c.execute(req).context(ExecuteSnafu).await
266266
})
267267
.await
268268
.map(Json)
@@ -276,8 +276,8 @@ async fn format(
276276
Json(req): Json<api::FormatRequest>,
277277
) -> Result<Json<api::FormatResponse>> {
278278
attempt_record_request(db, req, |req| async {
279-
with_coordinator(&factory.0, req, |c, req| {
280-
c.format(req).context(FormatSnafu).boxed()
279+
with_coordinator(&factory.0, req, async |c, req| {
280+
c.format(req).context(FormatSnafu).await
281281
})
282282
.await
283283
.map(Json)
@@ -291,8 +291,8 @@ async fn clippy(
291291
Json(req): Json<api::ClippyRequest>,
292292
) -> Result<Json<api::ClippyResponse>> {
293293
attempt_record_request(db, req, |req| async {
294-
with_coordinator(&factory.0, req, |c, req| {
295-
c.clippy(req).context(ClippySnafu).boxed()
294+
with_coordinator(&factory.0, req, async |c, req| {
295+
c.clippy(req).context(ClippySnafu).await
296296
})
297297
.await
298298
.map(Json)
@@ -306,8 +306,8 @@ async fn miri(
306306
Json(req): Json<api::MiriRequest>,
307307
) -> Result<Json<api::MiriResponse>> {
308308
attempt_record_request(db, req, |req| async {
309-
with_coordinator(&factory.0, req, |c, req| {
310-
c.miri(req).context(MiriSnafu).boxed()
309+
with_coordinator(&factory.0, req, async |c, req| {
310+
c.miri(req).context(MiriSnafu).await
311311
})
312312
.await
313313
.map(Json)
@@ -321,8 +321,8 @@ async fn macro_expansion(
321321
Json(req): Json<api::MacroExpansionRequest>,
322322
) -> Result<Json<api::MacroExpansionResponse>> {
323323
attempt_record_request(db, req, |req| async {
324-
with_coordinator(&factory.0, req, |c, req| {
325-
c.macro_expansion(req).context(MacroExpansionSnafu).boxed()
324+
with_coordinator(&factory.0, req, async |c, req| {
325+
c.macro_expansion(req).context(MacroExpansionSnafu).await
326326
})
327327
.await
328328
.map(Json)
@@ -430,10 +430,10 @@ impl Outcome {
430430
}
431431
}
432432

433-
async fn with_coordinator<WebReq, WebResp, Req, Resp, F>(
433+
async fn with_coordinator<WebReq, WebResp, Req, Resp>(
434434
factory: &CoordinatorFactory,
435435
req: WebReq,
436-
f: F,
436+
f: impl AsyncFnOnce(&coordinator::Coordinator<DockerBackend>, Req) -> Result<Resp>,
437437
) -> Result<WebResp>
438438
where
439439
WebReq: TryInto<Req>,
@@ -442,8 +442,6 @@ where
442442
Req: HasLabelsCore,
443443
Resp: Into<WebResp>,
444444
Resp: IsSuccess,
445-
for<'f> F:
446-
FnOnce(&'f coordinator::Coordinator<DockerBackend>, Req) -> BoxFuture<'f, Result<Resp>>,
447445
{
448446
let coordinator = factory.build();
449447

0 commit comments

Comments
 (0)