#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(in crate::schema::generate) enum Kind {
Document,
Sequence,
Mapping,
Scalar,
Alias,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub(in crate::schema::generate) struct Style {
pub(in crate::schema::generate) tagged: bool,
pub(in crate::schema::generate) double: bool,
pub(in crate::schema::generate) single: bool,
pub(in crate::schema::generate) literal: bool,
pub(in crate::schema::generate) folded: bool,
pub(in crate::schema::generate) flow: bool,
}
impl Style {
pub(in crate::schema::generate) fn indicates_string(self) -> bool {
self.double || self.single || self.literal || self.folded
}
}
#[derive(Debug, Clone)]
pub(in crate::schema::generate) struct Node {
pub(in crate::schema::generate) kind: Kind,
pub(in crate::schema::generate) style: Style,
pub(in crate::schema::generate) tag: String,
pub(in crate::schema::generate) value: String,
pub(in crate::schema::generate) anchor: String,
pub(in crate::schema::generate) alias: Option<usize>,
pub(in crate::schema::generate) content: Vec<usize>,
pub(in crate::schema::generate) head_comment: String,
pub(in crate::schema::generate) line_comment: String,
pub(in crate::schema::generate) foot_comment: String,
pub(in crate::schema::generate) line: usize,
pub(in crate::schema::generate) column: usize,
}
impl Node {
pub(in crate::schema::generate) fn new(kind: Kind) -> Self {
Self {
kind,
style: Style::default(),
tag: String::new(),
value: String::new(),
anchor: String::new(),
alias: None,
content: Vec::new(),
head_comment: String::new(),
line_comment: String::new(),
foot_comment: String::new(),
line: 0,
column: 0,
}
}
}
#[derive(Debug, Clone, Default)]
pub(in crate::schema::generate) struct Doc {
pub(in crate::schema::generate) nodes: Vec<Node>,
pub(in crate::schema::generate) root: Option<usize>,
}
impl Doc {
pub(in crate::schema::generate) fn add(&mut self, node: Node) -> usize {
self.nodes.push(node);
self.nodes.len() - 1
}
}