sfparse 0.1.1

RFC 9651 Structured Field Values parser
Documentation
  • Coverage
  • 63.16%
    12 out of 19 items documented1 out of 1 items with examples
  • Size
  • Source code size: 122.32 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.9 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tatsuhiro-t

sfparse-rs

sfparse-rs is RFC 9651 Structured Field Values parser written in Rust. It is the port of sfparse written in C.

It is designed not to do any extra allocation, like allocating maps, lists, and Strings, and do the minimal stuff to parse the input data.

use sfparse::{Parser, Value};

let mut urgency :i32 = 3;
let mut incremental = false;
let mut p = Parser::new("u=2, i".as_bytes());

loop {
    match p.parse_dict().unwrap() {
        None => break,
        Some(("u", Value::Integer(v))) if (0i64..=7i64).contains(&v) => urgency = v as i32,
        Some(("i", Value::Bool(v))) => incremental = v,
        _ => (),
    }
}

println!("urgency={urgency} incremental={incremental}");

License

The MIT License

Copyright (c) 2024 sfparse-rs contributors