From 5434639cca9ce8e2c885e94769e6310889e9d7f3 Mon Sep 17 00:00:00 2001 From: LasterAlex Date: Sun, 13 Oct 2024 23:04:49 +0300 Subject: [PATCH 1/2] Fixed newtype serialization in multipart requests --- CHANGELOG.md | 1 + .../src/serde_multipart/serializers.rs | 22 +++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab2c37d5..533652ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Now Vec in requests serializes into [number] instead of [ {message_id: number} ], `forward_messages`, `copy_messages` and `delete_messages` now work properly +- Now `ThreadId` is able to serialize in multipart requests ## 0.13.0 - 2024-08-16 diff --git a/crates/teloxide-core/src/serde_multipart/serializers.rs b/crates/teloxide-core/src/serde_multipart/serializers.rs index a8ded25e..66454041 100644 --- a/crates/teloxide-core/src/serde_multipart/serializers.rs +++ b/crates/teloxide-core/src/serde_multipart/serializers.rs @@ -374,6 +374,17 @@ impl Serializer for PartSerializer { Ok(JsonPartSerializer { buf: String::new(), state: PartSerializerStructState::Empty }) } + fn serialize_newtype_struct( + self, + _: &'static str, + value: &T, + ) -> Result + where + T: Serialize, + { + value.serialize(self) + } + // Unimplemented fn serialize_none(self) -> Result { @@ -391,17 +402,6 @@ impl Serializer for PartSerializer { unimplemented!() } - fn serialize_newtype_struct( - self, - _: &'static str, - _: &T, - ) -> Result - where - T: Serialize, - { - unimplemented!() - } - fn serialize_newtype_variant( self, _name: &'static str, From eb855158c54ad8d65e13745119ada2ab85300daa Mon Sep 17 00:00:00 2001 From: LasterAlex Date: Mon, 14 Oct 2024 01:02:19 +0300 Subject: [PATCH 2/2] Linked pr --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 533652ea..ec172462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Now Vec in requests serializes into [number] instead of [ {message_id: number} ], `forward_messages`, `copy_messages` and `delete_messages` now work properly -- Now `ThreadId` is able to serialize in multipart requests +- Now `ThreadId` is able to serialize in multipart requests ([PR 1179](https://github.com/teloxide/teloxide/pull/1179)) ## 0.13.0 - 2024-08-16