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

Function inspector_session

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

Source from the content-addressed store, hash-verified

4031}
4032
4033async fn inspector_session(
4034 udid: &str,
4035 frontmost_pid: Option<i64>,
4036) -> Result<InspectorSession, String> {
4037 let mut probed_inspectors = Vec::new();
4038 let mut probe_errors = Vec::new();
4039
4040 if let Some(session) = find_inspector_session_on_ports(
4041 udid,
4042 frontmost_pid,
4043 inspector_agent_ports().collect(),
4044 &mut probed_inspectors,
4045 &mut probe_errors,
4046 )
4047 .await?
4048 {
4049 return Ok(session);
4050 }
4051
4052 let discovered_ports = match discover_simulator_listener_ports(udid).await {
4053 Ok(ports) => ports
4054 .into_iter()
4055 .filter(|port| !inspector_agent_ports().contains(port))
4056 .collect::<Vec<_>>(),
4057 Err(error) => {
4058 probe_errors.push(format!("listener discovery: {error}"));
4059 Vec::new()
4060 }
4061 };
4062
4063 if let Some(session) = find_inspector_session_on_ports(
4064 udid,
4065 frontmost_pid,
4066 discovered_ports,
4067 &mut probed_inspectors,
4068 &mut probe_errors,
4069 )
4070 .await?
4071 {
4072 return Ok(session);
4073 }
4074
4075 if !probed_inspectors.is_empty() {
4076 return Err(format!(
4077 "No in-app inspector matched simulator {udid}. Found inspectors on {}.",
4078 probed_inspectors.join(", ")
4079 ));
4080 }
4081
4082 let first_port = INSPECTOR_AGENT_DEFAULT_PORT;
4083 let last_port = inspector_agent_last_port();
4084 let detail = probe_errors
4085 .first()
4086 .map(|error| format!(" First probe error: {error}"))
4087 .unwrap_or_default();
4088 Err(format!(
4089 "No in-app inspector found for simulator {udid} on ports {first_port}-{last_port} or simulator-local listener ports.{detail}"
4090 ))

Callers 2

Calls 5

inspector_agent_portsFunction · 0.85
is_emptyMethod · 0.80

Tested by

no test coverage detected