grapheme_stdlib/
capability.rs1use crate::envelope;
4use serde_json::{json, Value as JsonValue};
5
6pub struct CapabilityResponse;
7
8impl CapabilityResponse {
9 pub fn scaffold(op: &str, note: &str) -> JsonValue {
10 envelope::success(json!({
11 "ok": false,
12 "op": op,
13 "status": "scaffold",
14 "note": note,
15 "release": "0.6.0",
16 }))
17 }
18
19 pub fn invalid_args(message: impl AsRef<str>) -> JsonValue {
20 envelope::failure(message.as_ref())
21 }
22
23 pub fn ok(payload: JsonValue) -> JsonValue {
24 let body = match payload {
25 JsonValue::Object(mut map) => {
26 map.entry("ok".to_string()).or_insert(json!(true));
27 JsonValue::Object(map)
28 }
29 other => json!({ "ok": true, "value": other }),
30 };
31 envelope::success(body)
32 }
33}