# Full Documentation of Core Methods ### `VxdeParser::from_file` ```rust pub fn from_file(file_path: &str) -> io::Result ``` This function opens the given file and parses its contents. The file should follow the `.vxd` format, where each line can contain one or more key-value pairs, with keys and values separated by an equal sign (`=`) and pairs separated by semicolons (`;`). - Whitespace, tabs, and newlines are ignored. - Keys and values are parsed as strings. If a value is enclosed in double quotes (`"`), the quotes are removed from the value. - Keys and values are trimmed of leading and trailing whitespace. ### `VxdeParser::get_variables` ```rust pub fn get_variables(&self) -> &HashMap ``` This function returns the `HashMap` that holds the parsed key-value pairs from the `.vxd` file. You can use this method to access the parsed variables. ## Example `.vxd` File Formats The following are valid `.vxd` file formats: ### 1. Single Line, Clean Format ```plaintext USER_ISLOGGEDIN:Bool=true;USER_NAME:String="reanore";USER_PASS:i32="1234"; ``` ### 2. Spaced Out Format ```plaintext USER_ISLOGGEDIN : Bool = true; USER_NAME : Bool = "reanore"; USER_PASS : Bool = "1234"; ``` ### 3. Newlines Between Pairs ```plaintext USER_ISLOGGEDIN : Bool =true; USER_NAME : String ="reanore"; USER_PASS : String ="1234"; ``` ### 4. Mixed Spacing, Newlines, and Missing Values ```plaintext USER_ISLOGGEDIN : Bool = true; USER_NAME:String="reanore"; USER_PASS; ``` In the last example, the `USER_PASS` key has no value or type, and the parser will ignore it (i.e., no entry for `USER_PASS` will be in the `HashMap`). --- ## API Documentation ### `VxdeParser` The core struct of the library that handles parsing the `.vxd` file. #### `VxdeParser::from_file(file_path: &str) -> Result` Reads a `.vxd` file from the given path and parses its contents. ##### Arguments: - `file_path`: A string slice representing the path to the `.vxd` file. ##### Returns: - `Ok(VxdeParser)` if the file was parsed successfully. - `Err(io::Error)` if there was an error opening or reading the file. #### `VxdeParser::get_variables(&self) -> &HashMap` Returns a reference to the `HashMap` containing the parsed variables. ##### Returns: - A reference to a `HashMap`, where the keys are the variable names and the values are the corresponding values from the `.vxd` file. --- ## Usage Here's a basic example of how to use the `VxdeParser` to read and parse a `.vxd` file: ### Example Code ```rust use vxde::VxdeParser; fn main() { // Read and parse a .vxd file let file_path = "path_to_your_file.vxd"; match VxdeParser::from_file(file_path) { Ok(vxde) => { // Access the parsed variables let variables = vxde.get_variables(); // Print each key-value pair for (key, value) in variables { println!("{} = {}", key, value); } } Err(e) => { eprintln!("Failed to parse file: {}", e); } } } ``` ### Example `.vxd` File Content ```plaintext USER_ISLOGGEDIN:Bool=true;USER_NAME:String="reanore";USER_ID:I32=1234; ``` This will be parsed into a `HashMap` where the keys are `USER_ISLOGGEDIN`, `USER_NAME`, and `USER_PASS`, and the corresponding values will be `true`, `"reanore"`, and `1234`. ### Example Usage ```rust use vxde::VxdeParser; fn main() { let file_path = "config.vxd"; let vxde = VxdeParser::from_file(file_path).unwrap(); let variables = vxde.get_variables(); println!("Parsed variables:"); for (key, value) in variables { println!("{} = {}", key, value); } } ```