From d05c0d6367bce2d9fa438bdde001af30f770a1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Misty=20De=20M=C3=A9o?= Date: Mon, 30 Oct 2023 14:30:14 -0700 Subject: [PATCH 1/2] chore: update toml_edit --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7aa351e..266992e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ tar = { version = "0.4.38", optional = true } zip = { version = "0.6.4", optional = true } flate2 = { version = "1.0.25", optional = true } xz2 = { version = "0.1.7", optional = true } -toml_edit = { version = "0.19.9", optional = true } +toml_edit = { version = "0.20.7", optional = true } walkdir = "2.3.3" [dev-dependencies] From 913b6fcef7ea4f1ef254e8797254abc22112b351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Misty=20De=20M=C3=A9o?= Date: Mon, 30 Oct 2023 14:30:49 -0700 Subject: [PATCH 2/2] chore: reexport toml_edit::Document --- src/lib.rs | 6 ++++++ src/source.rs | 27 +++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 77c53a5..94953c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,8 +27,14 @@ use error::Result; pub use local::LocalAsset; #[cfg(feature = "remote")] pub use remote::RemoteAsset; +#[cfg(feature = "json-serde")] +pub use serde_json; pub use source::SourceFile; pub use spanned::Spanned; +#[cfg(feature = "toml-serde")] +pub use toml; +#[cfg(feature = "toml-edit")] +pub use toml_edit; /// An asset can either be a local asset, which is designated by a path on the /// local file system, or a remote asset, which is designated by an http or diff --git a/src/source.rs b/src/source.rs index 0ab2c10..307eb7e 100644 --- a/src/source.rs +++ b/src/source.rs @@ -6,6 +6,12 @@ use miette::{MietteSpanContents, SourceCode, SourceSpan}; use crate::{error::*, LocalAsset}; +#[cfg(feature = "toml-edit")] +use crate::toml_edit::Document; + +#[cfg(feature = "json-serde")] +use crate::serde_json; + /// The inner contents of a [`SourceFile`][]. #[derive(Eq, PartialEq)] struct SourceFileInner { @@ -112,18 +118,15 @@ impl SourceFile { /// Try to deserialize the contents of the SourceFile as a toml_edit Document #[cfg(feature = "toml-edit")] - pub fn deserialize_toml_edit(&self) -> Result { - let toml = self - .contents() - .parse::() - .map_err(|details| { - let span = details.span().map(SourceSpan::from); - AxoassetError::TomlEdit { - source: self.clone(), - span, - details, - } - })?; + pub fn deserialize_toml_edit(&self) -> Result { + let toml = self.contents().parse::().map_err(|details| { + let span = details.span().map(SourceSpan::from); + AxoassetError::TomlEdit { + source: self.clone(), + span, + details, + } + })?; Ok(toml) }