Skip to content

Commit 20b383b

Browse files
committed
Extract function to create Outcome from responses
1 parent da9864a commit 20b383b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

ui/src/server_axum.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,16 @@ impl IsSuccess for coordinator::ExecuteResponse {
338338
}
339339
}
340340

341+
impl Outcome {
342+
fn from_success(other: impl IsSuccess) -> Self {
343+
if other.is_success() {
344+
Outcome::Success
345+
} else {
346+
Outcome::ErrorUserCode
347+
}
348+
}
349+
}
350+
341351
async fn with_coordinator<WebReq, WebResp, Req, Resp, F>(req: WebReq, f: F) -> Result<WebResp>
342352
where
343353
WebReq: TryInto<Req>,
@@ -364,13 +374,7 @@ where
364374
let elapsed = start.elapsed();
365375

366376
let outcome = match &resp {
367-
Ok(Ok(v)) => {
368-
if v.is_success() {
369-
Outcome::Success
370-
} else {
371-
Outcome::ErrorUserCode
372-
}
373-
}
377+
Ok(Ok(v)) => Outcome::from_success(v),
374378
Ok(Err(_)) => Outcome::ErrorServer,
375379
Err(_) => Outcome::ErrorTimeoutSoft,
376380
};

0 commit comments

Comments
 (0)