Skip to main content

Crate kv_parser

Crate kv_parser 

Source
Expand description

A simple parser for key-value strings and files.

This crate provides functions to parse key-value pairs from strings or text files into a hash map. Each line should contain a key and value separated by whitespace.

§Examples

use kv_parser::text_to_key_value_map;

let config = text_to_key_value_map("key1 value1\nkey2 value2")?;
assert_eq!(config.get("key1").map(AsRef::as_ref), Some("value1"));

Enums§

Error
Errors that can occur during key-value file parsing.

Functions§

file_to_key_value_map
Parses a key-value file into a hash map.
text_to_key_value_map
Parses a string containing key-value pairs into a hash map.