Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Support emitting comments, blocks and alternate integer encodings in serialized output #234

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ keywords = ["yaml", "serde"]
ryu = "1.0"
indexmap = "1.5"
serde = "1.0.69"
yaml-rust = "0.4.5"
#yaml-rust = "0.4.5"
yaml-rust = {git = "https://github.com/cfrantz/yaml-rust", branch="blocks_and_comments"}
yamlformat_derive = {path = "yamlformat_derive"}
inventory = "0.2"
once_cell = "1.9"

[dev-dependencies]
anyhow = "1.0"
Expand Down
8 changes: 8 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub enum ErrorImpl {
Io(io::Error),
Utf8(str::Utf8Error),
FromUtf8(string::FromUtf8Error),
Format(String),

EndOfStream,
MoreThanOneDocument,
Expand Down Expand Up @@ -130,6 +131,10 @@ pub(crate) fn string_utf8(err: string::FromUtf8Error) -> Error {
Error(Box::new(ErrorImpl::FromUtf8(err)))
}

pub(crate) fn format(err: String) -> Error {
Error(Box::new(ErrorImpl::Format(err)))
}

pub(crate) fn recursion_limit_exceeded() -> Error {
Error(Box::new(ErrorImpl::RecursionLimitExceeded))
}
Expand Down Expand Up @@ -205,6 +210,7 @@ impl ErrorImpl {
ErrorImpl::Io(err) => error::Error::description(err),
ErrorImpl::Utf8(err) => error::Error::description(err),
ErrorImpl::FromUtf8(err) => error::Error::description(err),
ErrorImpl::Format(err) => err.as_str(),
ErrorImpl::EndOfStream => "EOF while parsing a value",
ErrorImpl::MoreThanOneDocument => {
"deserializing from YAML containing more than one document is not supported"
Expand Down Expand Up @@ -241,6 +247,7 @@ impl ErrorImpl {
ErrorImpl::Io(err) => Display::fmt(err, f),
ErrorImpl::Utf8(err) => Display::fmt(err, f),
ErrorImpl::FromUtf8(err) => Display::fmt(err, f),
ErrorImpl::Format(err) => Display::fmt(err, f),
ErrorImpl::EndOfStream => f.write_str("EOF while parsing a value"),
ErrorImpl::MoreThanOneDocument => f.write_str(
"deserializing from YAML containing more than one document is not supported",
Expand All @@ -258,6 +265,7 @@ impl ErrorImpl {
ErrorImpl::Io(io) => f.debug_tuple("Io").field(io).finish(),
ErrorImpl::Utf8(utf8) => f.debug_tuple("Utf8").field(utf8).finish(),
ErrorImpl::FromUtf8(from_utf8) => f.debug_tuple("FromUtf8").field(from_utf8).finish(),
ErrorImpl::Format(s) => f.debug_tuple("Format").field(s).finish(),
ErrorImpl::EndOfStream => f.debug_tuple("EndOfStream").finish(),
ErrorImpl::MoreThanOneDocument => f.debug_tuple("MoreThanOneDocument").finish(),
ErrorImpl::RecursionLimitExceeded => f.debug_tuple("RecursionLimitExceeded").finish(),
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ mod number;
mod path;
mod ser;
mod value;
pub mod yamlformat;
Loading