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

Function registry_inspector_session

packages/server/src/api/routes.rs:3965–4012  ·  view source on GitHub ↗
(
    state: &AppState,
    udid: &str,
    frontmost_pid: Option<i64>,
)

Source from the content-addressed store, hash-verified

3963}
3964
3965async fn registry_inspector_session(
3966 state: &AppState,
3967 udid: &str,
3968 frontmost_pid: Option<i64>,
3969) -> Result<InspectorSession, String> {
3970 let mut probed_inspectors = Vec::new();
3971 let mut candidates = Vec::new();
3972 for inspector in state.inspectors.published_inspectors().await {
3973 if frontmost_pid.is_some_and(|pid| pid != inspector.process_identifier) {
3974 probed_inspectors.push(format!(
3975 "background registry process {}",
3976 inspector.process_identifier
3977 ));
3978 continue;
3979 }
3980 if !inspector_process_belongs_to_udid(udid, inspector.process_identifier).await? {
3981 probed_inspectors.push(format!("registry process {}", inspector.process_identifier));
3982 continue;
3983 }
3984 let session = inspector_session_from_published(inspector);
3985 if query_inspector_session(state, &session, "Runtime.ping", Value::Null)
3986 .await
3987 .is_err()
3988 {
3989 probed_inspectors.push(format!(
3990 "unreachable registry process {}",
3991 session.process_identifier
3992 ));
3993 continue;
3994 }
3995 candidates.push(session);
3996 }
3997
3998 if let Some(session) = best_inspector_session(candidates) {
3999 return Ok(session);
4000 }
4001
4002 if probed_inspectors.is_empty() {
4003 Err(format!(
4004 "No published app inspector found for simulator {udid}."
4005 ))
4006 } else {
4007 Err(format!(
4008 "No published app inspector matched simulator {udid}. Found inspectors for {}.",
4009 probed_inspectors.join(", ")
4010 ))
4011 }
4012}
4013
4014fn inspector_session_from_published(inspector: PublishedInspector) -> InspectorSession {
4015 let mut available_sources = inspector_available_sources(&inspector.info);

Callers 1

Calls 6

query_inspector_sessionFunction · 0.85
best_inspector_sessionFunction · 0.85
published_inspectorsMethod · 0.80
is_emptyMethod · 0.80

Tested by

no test coverage detected