| 4934 | } |
| 4935 | |
| 4936 | fn attach_tree_metadata( |
| 4937 | mut snapshot: Value, |
| 4938 | available_sources: &[String], |
| 4939 | fallback_reason: Option<String>, |
| 4940 | ) -> Value { |
| 4941 | if let Value::Object(ref mut object) = snapshot { |
| 4942 | object.insert( |
| 4943 | "availableSources".to_owned(), |
| 4944 | Value::Array( |
| 4945 | available_sources |
| 4946 | .iter() |
| 4947 | .map(|source| Value::String(source.clone())) |
| 4948 | .collect(), |
| 4949 | ), |
| 4950 | ); |
| 4951 | if let Some(reason) = fallback_reason { |
| 4952 | object.insert("fallbackReason".to_owned(), Value::String(reason)); |
| 4953 | if object.get("source").and_then(Value::as_str) == Some(SOURCE_NATIVE_AX) { |
| 4954 | object.insert( |
| 4955 | "fallbackSource".to_owned(), |
| 4956 | Value::String(SOURCE_NATIVE_AX.to_owned()), |
| 4957 | ); |
| 4958 | } |
| 4959 | } |
| 4960 | } |
| 4961 | snapshot |
| 4962 | } |
| 4963 | |
| 4964 | fn inspector_metadata( |
| 4965 | info: &Value, |