read_tree and tree to string work

This commit is contained in:
2025-04-08 19:26:27 +02:00
parent 4c00c14258
commit d7e13bf84f
2 changed files with 72 additions and 28 deletions

View File

@@ -7,7 +7,7 @@ mod byte_writer;
mod node;
use byte_writer::{binary_to_string, string_to_binary};
use node::Node;
use node::{Node, read_tree, tree_to_string};
fn main() -> std::io::Result<()> {
let args: Vec<String> = env::args().collect();
@@ -19,12 +19,19 @@ fn main() -> std::io::Result<()> {
}
let file = File::open("test.txt")?;
let mut file2 = File::open("fo.txt")?;
//let mut file2 = File::open("fo.txt")?;
let map = get_map_file(file).expect("Failed to load!");
let vec = nodes_at_vec(map);
let root = node::create_tree(vec);
eprintln!("root.n = {:#?}", root.n);
let mut root = node::create_tree(vec);
//eprintln!("root.n = {:#?}", root.l.unwrap().n);
let txt = tree_to_string(&mut root);
//eprintln!("txt = {:?}", txt);
let mut root2 = read_tree(&txt.0, &txt.1);
eprintln!(
"root2.l.unwrap().l.unwrap().val = {:?}",
root2.l.unwrap().l.unwrap().val
);
/*
let binary = "101100001";
@@ -38,7 +45,7 @@ fn main() -> std::io::Result<()> {
println!("101100001");
file2.write_all(&len_bytes)?;
file2.write_all(&v)?;*/
/*
let mut buffer = [0u8; 1];
file2.read_exact(&mut buffer)?;
eprintln!("buffer = {:?}", buffer);
@@ -51,6 +58,7 @@ fn main() -> std::io::Result<()> {
//let current = read[4..].to_vec();
let string = binary_to_string(read, len);
eprintln!("string = {:?}", string);
*/
//eprintln!("v = {:#?}", v);
//eprintln!("buffer = {:#?}", buffer);