mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 17:52:12 +01:00
Fix deserialization of some unit structures
This commit is contained in:
parent
b7c1cd9494
commit
e986c89a61
8 changed files with 33 additions and 6 deletions
|
@ -43,9 +43,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `Voice::duration`
|
||||
- `RequestError::MigrateToChatId` single fields type to `ChatId` ([#859][pr859])
|
||||
- `RequestError::RetryAfter` single fields type to `Seconds` ([#859][pr859])
|
||||
- `CallbackGame`, `ForumTopicClosed`, `ForumTopicReopened`, `GeneralForumTopicHidden`, `GeneralForumTopicUnhidden` and `WriteAccessAllowed` structures
|
||||
are now defined as named (`struct S {}`) instead of unit (`struct S;`) in order to fix their deserialization ([#876][pr876])
|
||||
|
||||
[pr852]: https://github.com/teloxide/teloxide/pull/853
|
||||
[pr859]: https://github.com/teloxide/teloxide/pull/859
|
||||
[pr876]: https://github.com/teloxide/teloxide/pull/876
|
||||
|
||||
### Deprecated
|
||||
|
||||
|
|
|
@ -9,4 +9,4 @@ use serde::{Deserialize, Serialize};
|
|||
///
|
||||
/// [@Botfather]: https://t.me/botfather
|
||||
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct CallbackGame;
|
||||
pub struct CallbackGame {}
|
||||
|
|
|
@ -6,4 +6,4 @@ use serde::{Deserialize, Serialize};
|
|||
/// [The official docs](https://core.telegram.org/bots/api#forumtopicclosed).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ForumTopicClosed;
|
||||
pub struct ForumTopicClosed {}
|
||||
|
|
|
@ -6,4 +6,4 @@ use serde::{Deserialize, Serialize};
|
|||
/// [The official docs](https://core.telegram.org/bots/api#forumtopicreopened).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ForumTopicReopened;
|
||||
pub struct ForumTopicReopened {}
|
||||
|
|
|
@ -6,4 +6,4 @@ use serde::{Deserialize, Serialize};
|
|||
/// [The official docs](https://core.telegram.org/bots/api#generalforumtopichidden).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct GeneralForumTopicHidden;
|
||||
pub struct GeneralForumTopicHidden {}
|
||||
|
|
|
@ -6,4 +6,4 @@ use serde::{Deserialize, Serialize};
|
|||
/// [The official docs](https://core.telegram.org/bots/api#generalforumtopicunhidden).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct GeneralForumTopicUnhidden;
|
||||
pub struct GeneralForumTopicUnhidden {}
|
||||
|
|
|
@ -1933,4 +1933,28 @@ mod tests {
|
|||
let msg: Message = serde_json::from_str(json).unwrap();
|
||||
assert_matches!(msg.kind, MessageKind::Empty {})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_874() {
|
||||
let json = r#"{
|
||||
"chat": {
|
||||
"id": -1001840751935,
|
||||
"is_forum": true,
|
||||
"title": "AI",
|
||||
"type": "supergroup"
|
||||
},
|
||||
"date": 1682191229,
|
||||
"forum_topic_closed": {},
|
||||
"from": {
|
||||
"first_name": "Владислав",
|
||||
"id": 112455916,
|
||||
"is_bot": false,
|
||||
"language_code": "en",
|
||||
"username": "scv977"
|
||||
},
|
||||
"message_id": 62
|
||||
}"#;
|
||||
|
||||
let _: Message = serde_json::from_str(json).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,4 +6,4 @@ use serde::{Deserialize, Serialize};
|
|||
/// [The official docs](https://core.telegram.org/bots/api#writeaccessallowed).
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct WriteAccessAllowed;
|
||||
pub struct WriteAccessAllowed {}
|
||||
|
|
Loading…
Reference in a new issue