yaml-reader 1.0.1

yaml-reader是一个yaml读取工具,可以直接通过`x.y.z.w`方式读取yaml中的内容,不用逐层解析
Documentation
  • Coverage
  • 54.55%
    6 out of 11 items documented1 out of 9 items with examples
  • Size
  • Source code size: 14.42 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.8 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 24s Average build duration of successful builds.
  • all releases: 25s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Documentation
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • TheoryDance

yaml-reader

介绍

yaml-reader是一个yaml读取工具,可以直接通过x.y.z.w方式读取yaml中的内容,不用逐层解析

使用示例

use yaml_reader::YamlWrapper;

#[test]
fn test_config_util() {
    let wrapper = YamlWrapper::new("docs/config.yaml").unwrap(); // yaml配置
    // let warpper = YamlWrapper::from_string("......").unwrap();

    // 注意: 这里面的children是一个数组,不管是数组还是对象,都是通过点来操作
    let x = wrapper.get("address.children.name");
    // address.children.name = [String("r"), String("s")]
    println!("address.children.name = {:?}", x);
    println!("=============================================================");

    // 作为配置使用,正常是知晓需要
    let x = wrapper.get_one("address.x.y").as_str().unwrap();
    // address.x.y = hello, json!
    println!("address.x.y = {}", x);
}

安装教程

cargo add yaml-reader