temporary fork of saphyr with serde support merged into main.
Find a file
arcayr c280135e4b
Some checks failed
CI / Lints and checks (push) Has been cancelled
CI / Test using Rust stable on macos-latest (push) Has been cancelled
CI / Test using Rust stable on ubuntu-latest (push) Has been cancelled
update readme to make it clear this is more or less a scratch repository.
2024-12-25 13:47:09 +11:00
.github/workflows Move CI from subprojects to root. 2024-10-17 19:25:19 +02:00
bench Remove Cargo.lock files. 2024-10-20 19:48:52 +02:00
fuzz Fuzz with both StrInput and BufferedInput. 2024-10-20 16:21:25 +02:00
parser parser: elide the lifetime as suggested by clippy 2024-12-25 13:43:48 +11:00
saphyr garden: consolidate configuration into a single the top-level file 2024-12-25 13:43:48 +11:00
serde Change names to saphyr_serde. 2024-10-26 00:13:20 +02:00
.gitignore Remove Cargo.lock files. 2024-10-20 19:48:52 +02:00
Cargo.toml Change names to saphyr_serde. 2024-10-26 00:13:20 +02:00
garden.yaml garden: add a remote for mkniewallner 2024-12-25 13:43:48 +11:00
justfile Add just fuzz convenience command. 2024-10-19 03:29:01 +02:00
README.md update readme to make it clear this is more or less a scratch repository. 2024-12-25 13:47:09 +11:00

NOTICE

this repository is a rebase of the master branch onto the serde branch of the saphyr rust crate.

nothing novel has been added to this repository. all updates and actual value can be found at its actual home.

this repository will remain available until the serde functionality is merged into master upstream.

the original readme follows this notice. the license claims below are as such for this repository as well.

Saphyr libraries

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

saphyr is the most user-friendly and high-level crate, providing quick-and-easy YAML importing, exporting and object manipulation.

use saphyr::{Yaml, YamlEmitter};

let docs = Yaml::load_from_str("[1, 2, 3]").unwrap();
let doc = &docs[0]; // select the first YAML document
assert_eq!(doc[0].as_i64().unwrap(), 1); // access elements by index

let mut out_str = String::new();
let mut emitter = YamlEmitter::new(&mut out_str);
emitter.dump(doc).unwrap(); // dump the YAML object to a String

saphyr-parser is the parser behind saphyr. It provides direct access to the parsing process by emitting YAML events. It does not include YAML to object mapping, but is a lightweight alternative to saphyr for those interested in building directly atop the parser, without having an intermediate conversion to a Rust object. More details on where to start are available on doc.rs.

/// Sink of events. Collects them into an array.
struct EventSink {
    events: Vec<Event>,
}

/// Implement `on_event`, pushing into `self.events`.
impl EventReceiver for EventSink {
    fn on_event(&mut self, ev: Event) {
        self.events.push(ev);
    }
}

/// Load events from a yaml string.
fn str_to_events(yaml: &str) -> Vec<Event> {
    let mut sink = EventSink { events: Vec::new() };
    let mut 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) the YAML test suite.

License

Sets of licences are available for each of the crates. Due to this project being based on a fork of chyh1990's yaml-rust, there are 2 licenses to be included if using saphyr or saphyr-parser. Refer to the projects' READMEs for details.

Contribution

Fork this repository and Create 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 submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

saphyr

saphyr-parser