MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / screenshot_png

Function screenshot_png

packages/server/src/api/routes.rs:2465–2495  ·  view source on GitHub ↗
(
    State(state): State<AppState>,
    Path(udid): Path<String>,
    Query(query): Query<ScreenshotPngQuery>,
)

Source from the content-addressed store, hash-verified

2463}
2464
2465async fn screenshot_png(
2466 State(state): State<AppState>,
2467 Path(udid): Path<String>,
2468 Query(query): Query<ScreenshotPngQuery>,
2469) -> Result<(StatusCode, HeaderMap, Vec<u8>), AppError> {
2470 let include_bezel = query
2471 .bezel
2472 .as_deref()
2473 .map(parse_asset_bool)
2474 .unwrap_or(false);
2475 let png = if android::is_android_id(&udid) {
2476 if include_bezel {
2477 return Err(AppError::bad_request(
2478 "Android emulators do not support bezeled screenshots.",
2479 ));
2480 }
2481 run_android_action(state, move |android| android.screenshot_png(&udid)).await?
2482 } else {
2483 run_bridge_action(state, move |bridge| {
2484 bridge.screenshot_png(&udid, include_bezel)
2485 })
2486 .await?
2487 };
2488 let mut headers = HeaderMap::new();
2489 headers.insert(header::CONTENT_TYPE, "image/png".parse().unwrap());
2490 headers.insert(
2491 header::CACHE_CONTROL,
2492 "no-cache, no-store, must-revalidate".parse().unwrap(),
2493 );
2494 Ok((StatusCode::OK, headers, png))
2495}
2496
2497async fn screen_recording(
2498 State(state): State<AppState>,

Callers

nothing calls this directly

Calls 6

is_android_idFunction · 0.85
run_android_actionFunction · 0.85
run_bridge_actionFunction · 0.85
insertMethod · 0.80
screenshot_pngMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected