1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Format-preserving YAML edits: change what you name, keep every other byte.
//!
//! `yamled` replaces, removes, and inserts the values you name in a YAML file.
//! Comments, blank lines, quoting, block and flow style, and indentation stay
//! as they were. It indexes the source through [`granit-parser`] spans and
//! writes values through [`serde-saphyr`].
//!
//! # Quick start
//!
//! ```
//! use indoc::indoc;
//! use yamled::{Document, Path};
//!
//! let mut ledger = Document::parse(indoc! {"
//! active: A-1 # the row in progress
//! queue:
//! - id: A-1
//! title: Write the index
//! "})?;
//!
//! ledger.replace(&Path::root().key("active"), "A-2")?;
//! ledger.replace(
//! &Path::root().key("queue").index(0).key("title"),
//! "Write the index: v2",
//! )?;
//!
//! assert_eq!(
//! ledger.as_str(),
//! indoc! {"
//! active: A-2 # the row in progress
//! queue:
//! - id: A-1
//! title: 'Write the index: v2'
//! "}
//! );
//! # Ok::<(), yamled::Error>(())
//! ```
//!
//! # Failed edits
//!
//! Every edit parses its result. When the result would not parse, the edit
//! returns an [`Error`] and the document keeps its old text.
//!
//! # Cargo features
//!
//! | Feature | Adds | Depends on |
//! |:--|:--|:--|
//! | (none) | The location index, [`remove`], [`take`], [`put`], [`reorder`], [`reindent`] | `granit-parser` |
//! | `serde` (default) | `replace`, `insert`, `push`, `insert_item`, their `_text` forms, `TextStyle`, `Quotes` | `serde`, `serde-saphyr` |
//!
//! A caller that needs only the line and column of a path, such as a schema
//! error reporter, depends on `yamled` with `default-features = false`.
//!
//! [`granit-parser`]: https://docs.rs/granit-parser
//! [`serde-saphyr`]: https://docs.rs/serde-saphyr
//! [`remove`]: Document::remove
//! [`take`]: Document::take
//! [`put`]: Document::put
//! [`reorder`]: Document::reorder
//! [`reindent`]: Document::reindent
pub use cratePosition;
pub use crate;
pub use crateError;
pub use crate;
pub use crate;
pub use crate;
/// The writer's style decision, for the benchmarks in `benches/`. Not part
/// of the API: it may change in any release.