From 47a5752f91a3a9e2ab7abbbf62e8346a4ad1e159 Mon Sep 17 00:00:00 2001 From: Amos Wenger Date: Fri, 29 Nov 2024 20:10:44 +0100 Subject: [PATCH] Yus --- .zed/settings.json | 2 +- Cargo.lock | 11 +- Cargo.toml | 1 - merde/Cargo.toml | 12 +- merde_core/Cargo.toml | 6 + merde_core/README.md | 8 +- merde_core/src/lib.rs | 3 + .../src/lib.rs => merde_core/src/rfc3339.rs | 27 ++-- merde_time/CHANGELOG.md | 144 ------------------ merde_time/Cargo.toml | 28 ---- merde_time/README.md | 14 -- 11 files changed, 31 insertions(+), 225 deletions(-) rename merde_time/src/lib.rs => merde_core/src/rfc3339.rs (79%) delete mode 100644 merde_time/CHANGELOG.md delete mode 100644 merde_time/Cargo.toml delete mode 100644 merde_time/README.md diff --git a/.zed/settings.json b/.zed/settings.json index d341759..3310fff 100644 --- a/.zed/settings.json +++ b/.zed/settings.json @@ -10,7 +10,7 @@ "command": "clippy" }, "cargo": { - "features": ["merde/full", "merde_core/full", "merde_time/full", "merde_json/full"] + "features": ["merde/full", "merde_core/full", "merde_json/full"] } } } diff --git a/Cargo.lock b/Cargo.lock index 2e6c29d..d005faf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,7 +323,6 @@ dependencies = [ "merde_core", "merde_json", "merde_msgpack", - "merde_time", "merde_yaml", ] @@ -339,6 +338,7 @@ dependencies = [ "rubicon", "rusqlite", "serde", + "time", "trybuild", ] @@ -372,15 +372,6 @@ dependencies = [ "rmp", ] -[[package]] -name = "merde_time" -version = "8.0.3" -dependencies = [ - "merde_core", - "merde_json", - "time", -] - [[package]] name = "merde_yaml" version = "8.0.2" diff --git a/Cargo.toml b/Cargo.toml index 6233d80..db043a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ resolver = "2" members = [ "merde", "merde_json", - "merde_time", "merde_core", "merde_yaml", "merde_msgpack", diff --git a/merde/Cargo.toml b/merde/Cargo.toml index 6261787..afb0015 100644 --- a/merde/Cargo.toml +++ b/merde/Cargo.toml @@ -60,17 +60,13 @@ merde_core = { version = "8.1.1", path = "../merde_core", optional = true } merde_json = { version = "8.0.2", path = "../merde_json", optional = true } merde_yaml = { version = "8.0.2", path = "../merde_yaml", optional = true } merde_msgpack = { version = "8.0.2", path = "../merde_msgpack", optional = true } -merde_time = { version = "8.0.3", path = "../merde_time", optional = true, features = [ - "merde", - "serialize", - "deserialize", -] } ahash = { version = "0.8.11", optional = true } [features] -default = ["core", "deserialize"] +default = ["core"] full = [ "core", + "serialize", "deserialize", "json", "yaml", @@ -79,16 +75,18 @@ full = [ "rusqlite", ] core = ["dep:merde_core"] +serialize = ["core"] deserialize = ["core"] + # merde_core re-exports serde = ["merde_core/serde"] rusqlite = ["merde_core/rusqlite"] +time = ["merde_core/time"] # non-core crates json = ["dep:merde_json"] yaml = ["dep:merde_yaml"] msgpack = ["dep:merde_msgpack"] -time = ["dep:merde_time"] # others ahash = ["dep:ahash"] diff --git a/merde_core/Cargo.toml b/merde_core/Cargo.toml index f470329..6a7a740 100644 --- a/merde_core/Cargo.toml +++ b/merde_core/Cargo.toml @@ -19,6 +19,7 @@ rubicon = "3.4.9" rusqlite = { version = "0.32.1", optional = true } serde = { version = "1", optional = true } pin-project-lite = "0.2.15" +time = { version = "0.3.36", optional = true, features = ["parsing", "formatting"] } [features] default = [] @@ -26,8 +27,13 @@ full = [ # (1 per line) "serde", "rusqlite", + "time", ] +# Add `serde` implementations for merde_core types serde = ["dep:serde", "compact_str/serde"] +# Add `merde` implementations for types of the `time` crate +time = ["dep:time"] +# Add `merde` implementations for types of the `rusqlite` crate rusqlite = ["dep:rusqlite"] [dev-dependencies] diff --git a/merde_core/README.md b/merde_core/README.md index bd5a798..fb5bcea 100644 --- a/merde_core/README.md +++ b/merde_core/README.md @@ -16,10 +16,8 @@ and `CowStr<'s>` (a copy-on-write string type that also leverages [compact_str](https://crates.io/crates/compact_str)'s small string optimization), and traits like `Deserialize` and `IntoStatic`. -Crates that provide support for formats (like [merde_json](https://crates.io/crates/merde_json)), -and crates that provide wrappers around other crates' types, to allow serializing/deserializing -them (like [merde_time](https://crates.io/crates/merde_time)), depend only on the "core" crate. +Crates that provide support for formats (like [merde_json](https://crates.io/crates/merde_json)), depend only on the "core" crate. The umbrella crate [merde](https://crates.io/crates/merde) re-exports core's types, along -with a `derive!` macro which lets you implement `ValueDeserialize`, `IntoStatic`, and format-specific -traits like `JsonSerialize` on structs, with or without lifetime parameters. +with a `derive!` macro which lets you implement `Serialize`, `Deserialize`, `IntoStatic`, +on structs, enums, etc. diff --git a/merde_core/src/lib.rs b/merde_core/src/lib.rs index 4b72fde..86b0885 100644 --- a/merde_core/src/lib.rs +++ b/merde_core/src/lib.rs @@ -45,6 +45,9 @@ pub use deserialize::DeserializeOwned; pub use deserialize::Deserializer; pub use deserialize::FieldSlot; +mod rfc3339; +pub use rfc3339::Rfc3339; + rubicon::compatibility_check! { ("merde_core_pkg_version", env!("CARGO_PKG_VERSION")), } diff --git a/merde_time/src/lib.rs b/merde_core/src/rfc3339.rs similarity index 79% rename from merde_time/src/lib.rs rename to merde_core/src/rfc3339.rs index d915ca2..0efa019 100644 --- a/merde_time/src/lib.rs +++ b/merde_core/src/rfc3339.rs @@ -1,5 +1,5 @@ //! Provides [Rfc3339], a wrapper around [time::OffsetDateTime] that implements -//! [merde_core::Serialize] and [merde_core::Deserialize] when the right +//! [Serialize] and [Deserialize] when the right //! cargo features are enabled. use std::{ @@ -7,8 +7,6 @@ use std::{ ops::{Deref, DerefMut}, }; -pub use time::OffsetDateTime; - /// A wrapper around date-time types that implements `Serialize` and `Deserialize` /// when the right cargo features are enabled. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -53,11 +51,12 @@ where } } -#[cfg(feature = "merde")] -mod merde_impls { +#[cfg(feature = "time")] +mod time_impls { use super::*; - impl merde_core::IntoStatic for Rfc3339 { + use time::OffsetDateTime; + impl crate::IntoStatic for Rfc3339 { type Output = Rfc3339; fn into_static(self) -> Self::Output { @@ -65,35 +64,33 @@ mod merde_impls { } } - #[cfg(feature = "deserialize")] - impl<'s> merde_core::Deserialize<'s> for Rfc3339 { + impl<'s> crate::Deserialize<'s> for Rfc3339 { async fn deserialize(de: &mut D) -> Result> where - D: merde_core::Deserializer<'s> + ?Sized, + D: crate::Deserializer<'s> + ?Sized, { - let s = merde_core::CowStr::deserialize(de).await?; + let s = crate::CowStr::deserialize(de).await?; Ok(Rfc3339( time::OffsetDateTime::parse( s.as_ref(), &time::format_description::well_known::Rfc3339, ) - .map_err(|_| merde_core::MerdeError::InvalidDateTimeValue)?, + .map_err(|_| crate::MerdeError::InvalidDateTimeValue)?, )) } } - #[cfg(feature = "serialize")] - impl merde_core::Serialize for Rfc3339 { + impl crate::Serialize for Rfc3339 { async fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where - S: merde_core::Serializer + ?Sized, + S: crate::Serializer + ?Sized, { let s = self .0 .format(&time::format_description::well_known::Rfc3339) .unwrap(); serializer - .write(merde_core::Event::Str(merde_core::CowStr::Borrowed(&s))) + .write(crate::Event::Str(crate::CowStr::Borrowed(&s))) .await } } diff --git a/merde_time/CHANGELOG.md b/merde_time/CHANGELOG.md deleted file mode 100644 index 6e629da..0000000 --- a/merde_time/CHANGELOG.md +++ /dev/null @@ -1,144 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -## [8.0.3](https://github.com/bearcove/merde/compare/merde_time-v8.0.2...merde_time-v8.0.3) - 2024-11-24 - -### Other - -- updated the following local packages: merde_core - -## [8.0.2](https://github.com/bearcove/merde/compare/merde_time-v8.0.1...merde_time-v8.0.2) - 2024-11-20 - -### Other - -- Fix deser/ser impls in merde_time after phasing out JsonSerialize trait - -## [8.0.1](https://github.com/bearcove/merde/compare/merde_time-v8.0.0...merde_time-v8.0.1) - 2024-11-20 - -### Other - -- updated the following local packages: merde_core - -## [8.0.0](https://github.com/bearcove/merde/compare/merde_time-v4.0.17...merde_time-v8.0.0) - 2024-11-04 - -### Other - -- Introduce Serialize trait -- Also run tests on macOS ([#99](https://github.com/bearcove/merde/pull/99)) - -## [4.0.17](https://github.com/bearcove/merde/compare/merde_time-v4.0.16...merde_time-v4.0.17) - 2024-10-07 - -### Other - -- updated the following local packages: merde_json - -## [4.0.16](https://github.com/bearcove/merde/compare/merde_time-v4.0.15...merde_time-v4.0.16) - 2024-10-06 - -### Other - -- updated the following local packages: merde_core, merde_json - -## [4.0.15](https://github.com/bearcove/merde/compare/merde_time-v4.0.14...merde_time-v4.0.15) - 2024-10-06 - -### Other - -- updated the following local packages: merde_core, merde_json - -## [4.0.14](https://github.com/bearcove/merde/compare/merde_time-v4.0.13...merde_time-v4.0.14) - 2024-10-04 - -### Other - -- updated the following local packages: merde_json - -## [4.0.13](https://github.com/bearcove/merde/compare/merde_time-v4.0.12...merde_time-v4.0.13) - 2024-10-04 - -### Other - -- updated the following local packages: merde_core, merde_json - -## [4.0.12](https://github.com/bearcove/merde/compare/merde_time-v4.0.11...merde_time-v4.0.12) - 2024-10-04 - -### Other - -- updated the following local packages: merde_core, merde_json - -## [4.0.11](https://github.com/bearcove/merde/compare/merde_time-v4.0.10...merde_time-v4.0.11) - 2024-09-22 - -### Other - -- Remove ValueDeserialize macros -- Port more things to deserialize -- Fix all tests -- add lifetimes to errors aw yiss - -## [4.0.10](https://github.com/bearcove/merde/compare/merde_time-v4.0.9...merde_time-v4.0.10) - 2024-09-20 - -### Other - -- updated the following local packages: merde_core, merde_json - -## [4.0.9](https://github.com/bearcove/merde/compare/merde_time-v4.0.8...merde_time-v4.0.9) - 2024-09-17 - -### Other - -- updated the following local packages: merde_core - -## [4.0.8](https://github.com/bearcove/merde/compare/merde_time-v4.0.7...merde_time-v4.0.8) - 2024-09-17 - -### Other - -- updated the following local packages: merde_core - -## [4.0.7](https://github.com/bearcove/merde/compare/merde_time-v4.0.6...merde_time-v4.0.7) - 2024-09-17 - -### Other - -- updated the following local packages: merde_core - -## [4.0.6](https://github.com/bearcove/merde/compare/merde_time-v4.0.5...merde_time-v4.0.6) - 2024-09-17 - -### Other - -- Add/fix logo attribution - -## [4.0.5](https://github.com/bearcove/merde/compare/merde_time-v4.0.4...merde_time-v4.0.5) - 2024-09-16 - -### Other - -- updated the following local packages: merde_core - -## [4.0.4](https://github.com/bearcove/merde/compare/merde_time-v4.0.3...merde_time-v4.0.4) - 2024-09-15 - -### Other - -- updated the following local packages: merde_core, merde_json - -## [4.0.3](https://github.com/bearcove/merde/compare/merde_time-v4.0.2...merde_time-v4.0.3) - 2024-09-14 - -### Other - -- Make merde_time flags make sense - -## [4.0.2](https://github.com/bearcove/merde/compare/merde_time-v4.0.1...merde_time-v4.0.2) - 2024-09-14 - -### Other - -- updated the following local packages: merde_core - -## [4.0.1](https://github.com/bearcove/merde/compare/merde_time-v4.0.0...merde_time-v4.0.1) - 2024-09-14 - -### Other - -- updated the following local packages: merde_core - -## [3.0.1](https://github.com/bearcove/merde/compare/merde_time-v3.0.0...merde_time-v3.0.1) - 2024-09-12 - -### Other - -- Re-export OffsetDateTime diff --git a/merde_time/Cargo.toml b/merde_time/Cargo.toml deleted file mode 100644 index a88ade1..0000000 --- a/merde_time/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -edition = "2021" -name = "merde_time" -version = "8.0.3" -authors = ["Amos Wenger "] -description = "Wrapper date-time types for merde" -license = "Apache-2.0 OR MIT" -readme = "README.md" -repository = "https://github.com/bearcove/merde" -keywords = ["merde", "serialization", "deserialization"] -categories = ["encoding", "parser-implementations"] - -[dependencies] -merde_core = { version = "8.1.1", path = "../merde_core", optional = true } -merde_json = { version = "8.0.2", path = "../merde_json", optional = true } -time = "0.3.36" - -[dev-dependencies] -merde_json = { path = "../merde_json" } -time = { version = "0.3.36", features = ["macros"] } - -[features] -default = [] -full = ["merde", "serialize", "deserialize"] -merde = ["dep:merde_core"] -json = [] -serialize = ["time/formatting"] -deserialize = ["merde", "time/parsing"] diff --git a/merde_time/README.md b/merde_time/README.md deleted file mode 100644 index 250a96b..0000000 --- a/merde_time/README.md +++ /dev/null @@ -1,14 +0,0 @@ -[![license: MIT/Apache-2.0](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](LICENSE-MIT) -[![crates.io](https://img.shields.io/crates/v/merde_time.svg)](https://crates.io/crates/merde_time) -[![docs.rs](https://docs.rs/merde_time/badge.svg)](https://docs.rs/merde_time) - -# merde_time - -![The merde logo: a glorious poop floating above a pair of hands](https://github.com/user-attachments/assets/763d60e0-5101-48af-bc72-f96f516a5d0f) - -_Logo by [MisiasArt](https://misiasart.com)_ - -Provides an `Rfc3339` wrapper type that implements: - - * `Deserialize` from the [merde_core](https://crates.io/crates/merde_core) crate - * `JsonSerialize` from the [merde_json](https://crates.io/crates/merde_json) crate