mod emit;
mod error;
mod parse;
mod scalar;
mod source;
pub use emit::{Out, write};
pub use error::{Error, ErrorKind, Location, Position};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Node {
pub position: Position,
pub value: Value,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Value {
Mapping(Vec<Entry>),
Sequence(Vec<Node>),
Scalar(Scalar),
Empty,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Entry {
pub key: String,
pub key_position: Position,
pub value: Node,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Scalar {
pub style: Style,
pub text: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Style {
Plain,
DoubleQuoted,
Literal,
}
pub fn read(bytes: &[u8]) -> Result<Option<Node>, Error> {
let text = source::decode(bytes)?;
parse::document(text)
}