harbor run -t openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-1970harbor download openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-1970You are tasked with implementing a Rust module located in the /app/ directory, which includes two main functionalities:
TreeNode Structure:
TreeNode enum that can represent either a Leaf or a Branch. Each Leaf should contain a key of type String and a value of type Value. Each Branch should contain an optional key and a list of child TreeNodes (i.e., a vector of TreeNode).TreeNode struct:
find(&self, chain: &[String]) -> Result<&Value, EGError>: This method should locate a value in the tree based on a chain of keys. If the chain is empty, return an error. If the requested key does not exist in the current branch, return an error indicating the key does not exist. If it reaches a leaf, return the value stored there.insert(&mut self, chain: &[String], value: Value) -> Result<(), EGError>: This method should insert a value into the tree at the location specified by the chain of keys. If a chain already exists at the specified location or conflicts arise (e.g., trying to insert into a leaf or inserting into a branch that already has children), return an error.LineParser Struct:
LineParser struct which should take a byte slice (&[u8]) as input and implement parsing functionality.parse() method, which should:
=) followed by a value (which may be a Value::Int, Value::Float, Value::String, or Value::List).ParseResult that contains the chain of identifiers as a vector of strings and the parsed value.EGError enum for any cases where parsing or tree manipulation fails. Any string error messages should be meaningful and specific to the situation.