MCPcopy Create free account
hub / github.com/ElementsProject/lightning / from_slice

Function from_slice

plugins/rest-plugin/src/yaml.rs:22–37  ·  view source on GitHub ↗

Deserialize YAML into a `serde_json::Map`, bounding both the number of * nodes and the total size of materialized strings so that anchor/alias * expansion cannot exhaust memory. */

(bytes: &[u8])

Source from the content-addressed store, hash-verified

20 * nodes and the total size of materialized strings so that anchor/alias
21 * expansion cannot exhaust memory. */
22pub fn from_slice(bytes: &[u8]) -> Result<Map<String, Value>, serde_yaml_ng::Error> {
23 let nodes = Cell::new(0);
24 let byte_count = Cell::new(0);
25 let budget = Budget {
26 nodes: &nodes,
27 bytes: &byte_count,
28 };
29 let value = BoundedValue { budget }
30 .deserialize(serde_yaml_ng::Deserializer::from_slice(bytes))?;
31 match value {
32 Value::Object(map) => Ok(map),
33 _ => Err(serde_yaml_ng::Error::custom(
34 "expected a mapping at the top level",
35 )),
36 }
37}
38
39#[derive(Clone, Copy)]
40struct Budget<'a> {

Callers 15

try_fromMethod · 0.85
try_fromMethod · 0.85
deserializeMethod · 0.85
requestMethod · 0.85
registerMethod · 0.85
register_with_contextMethod · 0.85
handleMethod · 0.85

Calls 1

deserializeMethod · 0.45

Tested by 2