MCPcopy Create free account
hub / github.com/RetypeOS/parcode / main

Function main

examples/inspect_debug.rs:3–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1#![allow(missing_docs)]
2
3fn main() -> parcode::Result<()> {
4 use parcode::{Parcode, ParcodeObject};
5 use serde::{Deserialize, Serialize};
6 use std::collections::HashMap;
7
8 println!("=== PARCODE TORTURE TEST ===");
9
10 // ------------------------------------------------------------------
11 // SCENARIO 1: THE JAGGED VECTOR
12 // ------------------------------------------------------------------
13 println!("\n[Scenario 1] Jagged Vector (Tiny header, Massive body)");
14
15 #[derive(Serialize, Deserialize, ParcodeObject, PartialEq, Debug, Clone)]
16 struct JaggedContainer {
17 #[parcode(chunkable)]
18 data: Vec<String>,
19 }
20
21 let mut jagged_data = Vec::new();
22 for i in 0..100 {
23 jagged_data.push(format!("tiny_{}", i));
24 }
25 // Bomb: A 10MB String
26 let huge_string = "X".repeat(10 * 1024 * 1024);
27 jagged_data.push(huge_string.clone());
28 for i in 0..100 {
29 jagged_data.push(format!("tiny_tail_{}", i));
30 }
31
32 let jagged_obj = JaggedContainer { data: jagged_data };
33
34 Parcode::save("stress_jagged.par", &jagged_obj)?;
35
36 let report = Parcode::inspect("stress_jagged.par")?;
37 println!("{}", report);
38
39 // Verify Data
40 let loaded_jagged: JaggedContainer = Parcode::load("stress_jagged.par")?;
41 assert_eq!(loaded_jagged.data.len(), 201);
42 assert_eq!(
43 loaded_jagged.data.get(100).expect("Missing element").len(),
44 10 * 1024 * 1024
45 );
46 println!(">> Jagged Integrity Verified!");
47
48 // ------------------------------------------------------------------
49 // SCENARIO 2: THE MATRYOSHKA
50 // ------------------------------------------------------------------
51 println!("\n[Scenario 2] Deep Nesting (Root -> Vec -> Struct -> Map -> Vec)");
52
53 #[derive(Serialize, Deserialize, ParcodeObject, PartialEq, Debug, Clone)]
54 struct DeepRoot {
55 #[parcode(chunkable)]
56 level_1_vec: Vec<Wrapper>,
57 }
58
59 #[derive(Serialize, Deserialize, ParcodeObject, PartialEq, Debug, Clone)]
60 struct Wrapper {

Callers

nothing calls this directly

Calls 2

firstMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected