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

Function chrome_button_png

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

Source from the content-addressed store, hash-verified

3242}
3243
3244async fn chrome_button_png(
3245 State(state): State<AppState>,
3246 Path((udid, button)): Path<(String, String)>,
3247 Query(query): Query<ChromeButtonPngQuery>,
3248) -> Result<(StatusCode, HeaderMap, Vec<u8>), AppError> {
3249 let button_name = button.strip_suffix(".png").unwrap_or(&button).to_owned();
3250 let png = if let Some(pressed) = query.pressed.as_deref().map(parse_asset_bool) {
3251 run_bridge_action(state, move |bridge| {
3252 bridge.chrome_button_png(&udid, &button_name, pressed)
3253 })
3254 .await?
3255 } else if let Some(base_name) = button_name.strip_suffix("-down").map(str::to_owned) {
3256 let exact_udid = udid.clone();
3257 let exact_name = button_name.clone();
3258 match run_bridge_action(state.clone(), move |bridge| {
3259 bridge.chrome_button_png(&exact_udid, &exact_name, false)
3260 })
3261 .await
3262 {
3263 Ok(png) => png,
3264 Err(_) => {
3265 run_bridge_action(state, move |bridge| {
3266 bridge.chrome_button_png(&udid, &base_name, true)
3267 })
3268 .await?
3269 }
3270 }
3271 } else {
3272 run_bridge_action(state, move |bridge| {
3273 bridge.chrome_button_png(&udid, &button_name, false)
3274 })
3275 .await?
3276 };
3277 let headers = chrome_asset_headers();
3278 Ok((StatusCode::OK, headers, png))
3279}
3280
3281async fn screen_mask_png(
3282 State(state): State<AppState>,

Callers

nothing calls this directly

Calls 4

run_bridge_actionFunction · 0.85
chrome_asset_headersFunction · 0.85
chrome_button_pngMethod · 0.80
cloneMethod · 0.65

Tested by

no test coverage detected