Skip to main content

Mountain/IPC/WindServiceHandlers/Utilities/
JsonValueHelpers.rs

1#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2
3//! Serde-Value helpers shared across Wind handlers. `v_str` extracts a
4//! string from either a raw JSON string or a VS Code `UriComponents`
5//! object (`external` / `path` field). Any new cross-cutting coercer that
6//! accepts both shapes belongs here.
7
8use serde_json::Value;
9
10pub fn v_str(Value:&Value) -> Option<String> {
11	if let Some(s) = Value.as_str() {
12		return Some(s.to_string());
13	}
14	if let Some(Object) = Value.as_object() {
15		if let Some(s) = Object.get("external").and_then(|V| V.as_str()) {
16			return Some(s.to_string());
17		}
18		if let Some(s) = Object.get("path").and_then(|V| V.as_str()) {
19			return Some(s.to_string());
20		}
21	}
22	None
23}