MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / deserialize

Method deserialize

src/program/serde.rs:50–73  ·  view source on GitHub ↗
(de: &mut Deserializer)

Source from the content-addressed store, hash-verified

48
49impl Deserialize for Program {
50 fn deserialize(de: &mut Deserializer) -> Result<Self> {
51 let mut program = Program::default();
52 de.consume_token_until("<ID> ")?;
53 let id: usize = de.parse_number()?;
54 program.id = id;
55 de.consume_token_until("//<Prompt> ")?;
56 let combination = de.eat_token_until("\n")?;
57 let combination: Vec<String> = serde_json::from_str(combination)?;
58 let combination: Vec<&'static FuncGadget> = combination
59 .iter()
60 .map(|func| get_func_gadget(func).unwrap())
61 .collect();
62 program.combination = combination;
63
64 de.consume_token_until("/*<Combination>:")?;
65 de.consume_token_until("*/")?;
66 de.consume_token_until("<Quality> ")?;
67 let quality = de.consume_token_until("\n")?;
68 let quality: Quality = serde_json::from_str(quality).unwrap_or_default();
69 let statements = de.input.to_string();
70 program.statements = statements;
71 program.set_quality(quality);
72 Ok(program)
73 }
74}
75
76pub struct Deserializer<'de> {

Callers

nothing calls this directly

Calls 5

get_func_gadgetFunction · 0.85
consume_token_untilMethod · 0.80
parse_numberMethod · 0.80
eat_token_untilMethod · 0.80
set_qualityMethod · 0.80

Tested by

no test coverage detected