(payload: &[u8])
| 1019 | } |
| 1020 | |
| 1021 | fn parse_rpc_message(payload: &[u8]) -> Result<RpcMessage, AppError> { |
| 1022 | let value = Value::from_reader(Cursor::new(payload)) |
| 1023 | .map_err(|error| AppError::internal(format!("Unable to parse WebKit plist: {error}")))?; |
| 1024 | let dict = value |
| 1025 | .as_dictionary() |
| 1026 | .ok_or_else(|| AppError::internal("WebKit packet was not a dictionary."))?; |
| 1027 | let selector = dict |
| 1028 | .get("__selector") |
| 1029 | .and_then(Value::as_string) |
| 1030 | .ok_or_else(|| AppError::internal("WebKit packet did not include __selector."))? |
| 1031 | .to_owned(); |
| 1032 | let args = dict |
| 1033 | .get("__argument") |
| 1034 | .and_then(Value::as_dictionary) |
| 1035 | .cloned() |
| 1036 | .unwrap_or_default(); |
| 1037 | Ok(RpcMessage { selector, args }) |
| 1038 | } |
| 1039 | |
| 1040 | fn parse_application_list(args: &Dictionary) -> Vec<WebKitApplication> { |
| 1041 | let Some(apps) = args |
no test coverage detected