dtolnay / serde-yaml

Strongly typed YAML library for Rust
Apache License 2.0
965 stars 164 forks source link

Expose `SerializerToYaml` #231

Closed andrewgazelka closed 2 years ago

andrewgazelka commented 2 years ago

It would be beneficial to expose yaml_rust::Yaml in some way (perhaps making SerializerToYaml public?). I want to add a commenting extension on top of serde-yaml—perhaps comment-yaml—which takes serde-yaml output and adds comments on top of it. However, the YAML representation provided by serde-yaml is insufficient as it does not include comments or a means of writing to a String.

Currently, I'd have to have a full reparse

Ideally, I'd be able to have:

where Comment is like Serialize but for comments.

dtolnay commented 2 years ago

It's intentional that yaml_rust is not exposed in the public API of this crate. I have not been happy with that library and I will be replacing it with a different yaml backend.

andrewgazelka commented 2 years ago

@dtolnay Do you have any backends in mind? If you are looking for a new backend similar in style to https://github.com/serde-rs/json/blob/master/src/de.rs, I might try implementing one. Ideally, I think the YAML lib should be able to Serialize comments without a full reparse, but I am not sure how you think this should (or even if it should) be done.