forked from dtolnay/serde-yaml
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New API to get anchors and aliases from a document
When deserializing a YAML document, the location and names of anchors and aliases is not preserved. That information is useful, though, as users of the library may want to deduplicate references to the same mapping. This commit introduces an API that exposes such mappings by parsing the metadata in `struct Document`. The new API has been added to `struct Deserializer` and provides the following signature: `pub fn anchors(&self) -> Option<Vec<DocumentAnchor>>` As an example, given the following YAML document: ``` a: enum: &io INPUT: 0 OUTPUT: 1 b: enum: *io c: enum: *io ``` this API returns: ``` Some([DocumentAnchor { anchor_name: "io", anchor_path: "/a/enum", aliases: ["/b/enum", "/c/enum"], }])
- Loading branch information
Showing
4 changed files
with
159 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters