MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / handle_pr_stop_req

Function handle_pr_stop_req

chirpstack/src/api/backend/mod.rs:375–413  ·  view source on GitHub ↗
(
    sender_client: Arc<backend::Client>,
    bp: backend::BasePayload,
    b: &[u8],
)

Source from the content-addressed store, hash-verified

373}
374
375async fn handle_pr_stop_req(
376 sender_client: Arc<backend::Client>,
377 bp: backend::BasePayload,
378 b: &[u8],
379) -> Response {
380 if sender_client.is_async() {
381 let b = b.to_vec();
382 task::spawn(async move {
383 let ans = match _handle_pr_stop_req(&b).await {
384 Ok(v) => v,
385 Err(e) => {
386 let msg = e.to_string();
387 backend::PRStopAnsPayload {
388 base: bp.to_base_payload_result(err_to_result_code(e), &msg),
389 }
390 }
391 };
392
393 log_request_response(&bp, &b, &ans).await;
394
395 if let Err(e) = sender_client.pr_stop_ans(backend::Role::SNS, &ans).await {
396 error!(error = %e.full(), "Send async PRStopAns error");
397 }
398 });
399 (StatusCode::OK, "").into_response()
400 } else {
401 match _handle_pr_stop_req(b).await {
402 Ok(ans) => {
403 log_request_response(&bp, b, &ans).await;
404 Json(&ans).into_response()
405 }
406 Err(e) => {
407 let ans = err_to_response(e, &bp);
408 log_request_response(&bp, b, &ans).await;
409 Json(&ans).into_response()
410 }
411 }
412 }
413}
414
415async fn _handle_pr_stop_req(b: &[u8]) -> Result<backend::PRStopAnsPayload> {
416 let pl: backend::PRStopReqPayload = serde_json::from_slice(b)?;

Callers 1

_handle_requestFunction · 0.85

Calls 9

_handle_pr_stop_reqFunction · 0.85
err_to_result_codeFunction · 0.85
log_request_responseFunction · 0.85
err_to_responseFunction · 0.85
is_asyncMethod · 0.80
to_stringMethod · 0.80
pr_stop_ansMethod · 0.80
to_vecMethod · 0.45

Tested by

no test coverage detected