Skip to content

Commit

Permalink
fix: fix serialization of InlineQueryResult (#230)
Browse files Browse the repository at this point in the history
* fix: fix serialization of InlineQueryResult

* fix rust analyzer

* code review comment

* forgotten rename

* `Either` enum

* fix clippy

* code review comment

* Update src/api_params.rs

Co-authored-by: EdJoPaTo <rfc-conform-git-commit-email@funny-long-domain-label-everyone-hates-as-it-is-too-long.edjopato.de>

* Update src/api_params.rs

Co-authored-by: EdJoPaTo <rfc-conform-git-commit-email@funny-long-domain-label-everyone-hates-as-it-is-too-long.edjopato.de>

* remove renames

---------

Co-authored-by: EdJoPaTo <rfc-conform-git-commit-email@funny-long-domain-label-everyone-hates-as-it-is-too-long.edjopato.de>
  • Loading branch information
ayrat555 and EdJoPaTo authored Nov 26, 2024
1 parent 8a8bf59 commit 1a6b10f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 36 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async-telegram-trait = ["dep:async-trait"]

[lints.rust]
unsafe_code = "forbid"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(rust_analyzer)'] }
[lints.clippy]
pedantic = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }
Expand Down
52 changes: 16 additions & 36 deletions src/api_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,48 +52,28 @@ impl From<String> for FileUpload {
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(tag = "type")]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum InlineQueryResult {
#[serde(rename = "audio")]
CachedAudio(InlineQueryResultCachedAudio),
#[serde(rename = "document")]
CachedDocument(InlineQueryResultCachedDocument),
#[serde(rename = "gif")]
CachedGif(InlineQueryResultCachedGif),
#[serde(rename = "mpeg4_gif")]
CachedMpeg4Gif(InlineQueryResultCachedMpeg4Gif),
#[serde(rename = "photo")]
CachedPhoto(InlineQueryResultCachedPhoto),
#[serde(rename = "sticker")]
CachedSticker(InlineQueryResultCachedSticker),
#[serde(rename = "video")]
CachedVideo(InlineQueryResultCachedVideo),
#[serde(rename = "voice")]
CachedVoice(InlineQueryResultCachedVoice),
#[serde(rename = "article")]
Audio(MaybeCached<InlineQueryResultCachedAudio, InlineQueryResultAudio>),
Document(MaybeCached<InlineQueryResultCachedDocument, InlineQueryResultDocument>),
Gif(MaybeCached<InlineQueryResultCachedGif, InlineQueryResultGif>),
Mpeg4Gif(MaybeCached<InlineQueryResultCachedMpeg4Gif, InlineQueryResultMpeg4Gif>),
Photo(MaybeCached<InlineQueryResultCachedPhoto, InlineQueryResultPhoto>),
Sticker(InlineQueryResultCachedSticker),
Video(MaybeCached<InlineQueryResultCachedVideo, InlineQueryResultVideo>),
Voice(MaybeCached<InlineQueryResultCachedVoice, InlineQueryResultVoice>),
Article(InlineQueryResultArticle),
#[serde(rename = "audio")]
Audio(InlineQueryResultAudio),
#[serde(rename = "contract")]
Contact(InlineQueryResultContact),
#[serde(rename = "game")]
Game(InlineQueryResultGame),
#[serde(rename = "document")]
Document(InlineQueryResultDocument),
#[serde(rename = "gif")]
Gif(InlineQueryResultGif),
#[serde(rename = "location")]
Location(InlineQueryResultLocation),
#[serde(rename = "mpeg4_gif")]
Mpeg4Gif(InlineQueryResultMpeg4Gif),
#[serde(rename = "photo")]
Photo(InlineQueryResultPhoto),
#[serde(rename = "venue")]
Venue(InlineQueryResultVenue),
#[serde(rename = "video")]
Video(InlineQueryResultVideo),
#[serde(rename = "voice")]
Voice(InlineQueryResultVoice),
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(untagged)]
pub enum MaybeCached<T1, T2> {
Cached(T1),
NotCached(T2),
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
Expand Down

0 comments on commit 1a6b10f

Please sign in to comment.