Skip to main content

Crate kvf

Crate kvf 

Source
Expand description

§kvf — Kv Format 1.0 Parser

kvf is a minimal, spec-compliant parser for Kv Format 1.0.

§Quick start

use kvf::{parse, Entry};

let input = b"APP_NAME=My Application\nDEBUG=true\n";
let entries = parse(input).unwrap();
for entry in &entries {
    if let Entry::Kv { key, value, .. } = entry {
        println!("{key} = {value}");
    }
}

§Parser configuration

use kvf::{parse_with_config, Entry, ParserConfig};

let config = ParserConfig {
    emit_comments: false,
    emit_blanks: false,
    emit_shebang: false,
};
let input = b"# comment\nKEY=value\n";
let entries = parse_with_config(input, &config).unwrap();
assert_eq!(entries.len(), 1);

§Streaming

use kvf::parse_iter;

let input = b"KEY=value\n";
for result in parse_iter(input) {
    println!("{:?}", result);
}

Structs§

ParserConfig
Configuration for the Kv Format parser.

Enums§

Entry
A parsed entry from a Kv Format text.
ParseError
Errors that can occur while parsing a Kv Format text.

Functions§

parse
Parse the entire input at once.
parse_iter
Return a streaming iterator over the input.
parse_iter_with_config
Return a streaming iterator over the input with a custom ParserConfig.
parse_with_config
Parse the entire input at once with a custom ParserConfig.