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

Method serialize

src/program/serde.rs:21–46  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

19
20impl Serialize for Program {
21 fn serialize(&self) -> String {
22 let combination: Vec<String> = self
23 .combination
24 .iter()
25 .map(|x| x.get_func_name().to_string())
26 .collect();
27 let mut out = format!("//<ID> {}\n", self.id);
28 out.push_str(&format!(
29 "//<Prompt> {}\n",
30 serde_json::to_string(&combination).unwrap()
31 ));
32 out.push_str("/*<Combination>: [");
33 out.push_str(&combination_to_str(&self.combination));
34 out.push_str("\n*/\n");
35 out.push_str(&format!(
36 "//<score> {}, nr_unique_branch: {}\n",
37 self.get_quality().compute_quality_score(),
38 self.get_quality().get_nr_unique_branches(),
39 ));
40 out.push_str(&format!(
41 "//<Quality> {}\n",
42 serde_json::to_string(&self.quality).unwrap()
43 ));
44 out.push_str(&self.statements);
45 out
46 }
47}
48
49impl Deserialize for Program {

Callers 4

save_programMethod · 0.45
save_succ_programMethod · 0.45
save_err_programMethod · 0.45

Calls 2

combination_to_strFunction · 0.85
get_func_nameMethod · 0.80

Tested by

no test coverage detected