Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A set of crates dedicated to parsing YAML.

NotificationsYou must be signed in to change notification settings

saphyr-rs/saphyr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository is home tosaphyr-parser,saphyr and soon-to-besaphyr-serde. These crates provide fully YAML 1.2 compliant parsing andmanipulation, with a focus on correctness, performance and API friendliness (in that order).

saphyr is the most user-friendly andhigh-level crate, providing quick-and-easy YAML importing, exporting and objectmanipulation.

use saphyr::{LoadableYamlNode,Yaml,YamlEmitter};let docs =Yaml::load_from_str("[1, 2, 3]").unwrap();let doc =&docs[0];// select the first YAML documentassert_eq!(doc[0].as_integer().unwrap(),1);// access elements by indexletmut out_str =String::new();letmut emitter =YamlEmitter::new(&mut out_str);emitter.dump(doc).unwrap();// dump the YAML object to a String

saphyr-parser is theparser behindsaphyr. It provides direct access to the parsing process byemittingYAMLevents.It does not include YAML to object mapping, but is a lightweight alternative tosaphyr for those interested in building directly atop the parser, withouthaving an intermediate conversion to a Rust object. More details on where tostart are availableondoc.rs.

/// Sink of events. Collects them into an array.structEventSink{events:Vec<Event>,}/// Implement `on_event`, pushing into `self.events`.implEventReceiverforEventSink{fnon_event(&mutself,ev:Event){self.events.push(ev);}}/// Load events from a yaml string.fnstr_to_events(yaml:&str) ->Vec<Event>{letmut sink =EventSink{events:Vec::new()};letmut parser =Parser::new_from_str(yaml);// Load events using our sink as the receiver.    parser.load(&mut sink,true).unwrap();    sink.events}

Specification Compliance

This implementation is fully compatible with the YAML 1.2 specification.saphyr-parser) tests against (and passes) theYAML testsuite.

License

Sets of licences are available for each of the crates. Due to this projectbeing based on a fork ofchyh1990'syaml-rust, there are 2 licenses to beincluded if usingsaphyr orsaphyr-parser. Refer to the projects' READMEsfor details.

Contribution

Fork this repository andCreate a Pull Request on Github.You may need to click on "compare across forks" and select your fork's branch.

Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in the work by you, as defined in the Apache-2.0 license, shallbe dual licensed as above, without any additional terms or conditions.

Links

saphyr

saphyr-parser

Other links


[8]ページ先頭

©2009-2025 Movatter.jp