https://github.com/hoodie/yaml-pathfinder
🧠asciii's pathfinder logic
https://github.com/hoodie/yaml-pathfinder
Last synced: about 1 month ago
JSON representation
🧠asciii's pathfinder logic
- Host: GitHub
- URL: https://github.com/hoodie/yaml-pathfinder
- Owner: hoodie
- License: apache-2.0
- Created: 2019-12-25T12:17:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-29T18:49:12.000Z (over 5 years ago)
- Last Synced: 2025-02-10T08:44:11.356Z (3 months ago)
- Language: Rust
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-Apache
Awesome Lists containing this project
README
# Yaml PathFinder
A tiny convenience library that allows you to access values from structured data (e.g. Yaml) dynamically by path.
## Usage
You can either import the prelude, which contains our wrapper type `Yaml`;
```rust
use yaml_pathfinder::prelude::*;
let folders = Yaml::parse(r#"
home:
hendrik:
code:
rust:
- asciii
- notify-rust
- yaml_pathfinder
"#)?;let path_style = folders.get_str("/home/hendrik/code/rust/1")?;
println!("{:?}", path_style);
...
```You can also just import the `PathFinder` trait itself, it is implemented on `yaml_rust::Yaml` too.
```rust
use yaml_pathfinder::PathFinder;
use yaml_rust::YamlLoader;fn main() -> Result<(), Box> {
let folders = YamlLoader::load_from_str(r#"
home:
hendrik:
code:
rust:
- asciii
- notify-rust
- yaml_pathfinder
"#)?.remove(0);let path_style = folders.get_str("/home/hendrik/code/rust/1")?;
println!("{:?}", path_style);
...
}
```