Skip to content
Draft
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
117 changes: 79 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ edition = "2018"
all-features = true

[features]
default = ["serde_yaml", "serde_json", "colored", "graphemes_support", "toml"]
default = ["serde_yaml_ng", "serde_json", "colored", "graphemes_support", "toml"]
graphemes_support = ["unicode-segmentation"]

[dependencies]
colored = { version = "2", optional = true }
serde_json = { version = "1", optional = true }
serde = { version = "1", features = ["derive"] }
serde_yaml = { version = "0.8", optional = true }
serde_yaml_ng = { version = "0.10", optional = true }
unicode-segmentation = { version = "1", optional = true }
toml = { version = "0.5", optional = true }

Expand All @@ -37,11 +37,11 @@ pretty_assertions = "0.7"

[[example]]
name = "serde_yaml"
required-features = ["serde_yaml"]
required-features = ["serde_yaml_ng"]

[[example]]
name = "serde_yaml_long"
required-features = ["serde_yaml"]
required-features = ["serde_yaml_ng"]

[[example]]
name = "serde_json"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() -> Result<(), anyhow::Error> {
- 'second'
- third:";

let config = serde_yaml::from_str::<Config>(config_str)
let config = serde_yaml_ng::from_str::<Config>(config_str)
.map_err(|err| SerdeError::new(config_str.to_string(), err))?;

dbg!(config);
Expand Down
2 changes: 1 addition & 1 deletion examples/serde_yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() -> Result<(), anyhow::Error> {
- 'second'
- third:";

let config = serde_yaml::from_str::<Config>(config_str)
let config = serde_yaml_ng::from_str::<Config>(config_str)
.map_err(|err| SerdeError::new(config_str.to_string(), err))?;

dbg!(config);
Expand Down
2 changes: 1 addition & 1 deletion examples/serde_yaml_long.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() -> Result<(), anyhow::Error> {
consectetur in eu felis. Vivamus lacus odio, tincidunt ac elit vel, varius \
ultricies est. In blandit tincidunt interdum.";

let config = serde_yaml::from_str::<Config>(config_str)
let config = serde_yaml_ng::from_str::<Config>(config_str)
.map_err(|err| SerdeError::new(config_str.to_string(), err))?;

dbg!(config);
Expand Down
18 changes: 9 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
//! values: Vec<String>,
//! }
//! # fn main() {
//! # #[cfg(feature = "serde_yaml")]
//! # #[cfg(feature = "serde_yaml_ng")]
//! # if let Err(err) = parse_config() {
//! # eprintln!("{}", err)
//! # }
//! # }
//!
//! # #[cfg(feature = "serde_yaml")]
//! # #[cfg(feature = "serde_yaml_ng")]
//! fn parse_config() -> Result<Config, anyhow::Error> {
//! let config_str = "values:
//! - 'first'
Expand Down Expand Up @@ -224,9 +224,9 @@ pub enum ErrorTypes {
/// Contains [`serde_json::Error`].
Json(serde_json::Error),

#[cfg(feature = "serde_yaml")]
/// Contains [`serde_yaml::Error`].
Yaml(serde_yaml::Error),
#[cfg(feature = "serde_yaml_ng")]
/// Contains [`serde_yaml_ng::Error`].
Yaml(serde_yaml_ng::Error),

#[cfg(feature = "toml")]
/// Contains [`toml::de::Error`].
Expand Down Expand Up @@ -259,9 +259,9 @@ impl From<serde_json::Error> for ErrorTypes {
}
}

#[cfg(feature = "serde_yaml")]
impl From<serde_yaml::Error> for ErrorTypes {
fn from(err: serde_yaml::Error) -> Self {
#[cfg(feature = "serde_yaml_ng")]
impl From<serde_yaml_ng::Error> for ErrorTypes {
fn from(err: serde_yaml_ng::Error) -> Self {
Self::Yaml(err)
}
}
Expand Down Expand Up @@ -293,7 +293,7 @@ impl SerdeError {
#[cfg(feature = "serde_json")]
ErrorTypes::Json(e) => (e.to_string(), Some(e.line()), Some(e.column())),

#[cfg(feature = "serde_yaml")]
#[cfg(feature = "serde_yaml_ng")]
ErrorTypes::Yaml(e) => match e.location() {
// Don't set line/column if we don't have a location
None => (e.to_string(), None, None),
Expand Down
4 changes: 2 additions & 2 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mod toml {
}

// TODO: Make tests that only use serde_yaml feature
#[cfg(all(feature = "serde_yaml", feature = "colored"))]
#[cfg(all(feature = "serde_yaml_ng", feature = "colored"))]
mod yaml {
use anyhow::bail;
use colored::Colorize;
Expand All @@ -116,7 +116,7 @@ mod yaml {
};

fn run_yaml(config_str: &str) -> Result<String, anyhow::Error> {
match serde_yaml::from_str::<Config>(config_str) {
match serde_yaml_ng::from_str::<Config>(config_str) {
Ok(_) => bail!("expecting error got a ok"),
Err(err) => Ok(format!("{}", SerdeError::new(config_str.to_string(), err))),
}
Expand Down