marirs / nparse

Parser library for specific use-cases
MIT License
1 stars 1 forks source link
nom nom-parser parser rust rust-crate rust-lang rust-library

nparse 0.0.10

Build Status

Parser for various Rust Strings.

Parsers for:

Requirements

Usage

nparse = "0.0.10"

Example use

use std::{fs::File, io::Read};
use nparse::*;

fn main () {
    let path = "data/dmidecode.txt";
    let mut out = String::new();
    {
        let mut f = File::open(path).unwrap();
        f.read_to_string(&mut out).unwrap();
    }
    let result = out.indent_to_json();
    println!("{:?}", result);
}
use std::{fs::File, io::Read};
use nparse::*;

fn main () {
    let path = "data/lscpu.txt";
    let mut out = String::new();
    {
        let mut f = File::open(path).unwrap();
        f.read_to_string(&mut out).unwrap();
    }
    let result = out.kv_str_to_json();
    println!("{:?}", result);
}
use std::{fs::File, io::Read};
use nparse::*;

fn main () {
    let path = "data/os-release.txt";
    let mut out = String::new();
    {
        let mut f = File::open(path).unwrap();
        f.read_to_string(&mut out).unwrap();
    }
    let result = out.kev_str_to_json();
    println!("{:?}", result);
}
use std::{fs::File, io::Read};
use nparse::*;

fn main () {
    let path = "data/sysctl.txt";
    let mut out = String::new();
    {
        let mut f = File::open(path).unwrap();
        f.read_to_string(&mut out).unwrap();
    }
    let result = out.dotted_tree_to_json();
    println!("{:?}", result);
}

Tests, Build

Examples