-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix serialization of InlineQueryResult #230
Changes from 2 commits
52417ad
c43fab7
c44be58
f74e99f
e82ab3f
020354d
c490230
75c5ed2
6eb243b
48edd68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,44 +55,79 @@ impl From<String> for FileUpload { | |
#[serde(tag = "type")] | ||
ayrat555 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub enum InlineQueryResult { | ||
#[serde(rename = "audio")] | ||
CachedAudio(InlineQueryResultCachedAudio), | ||
AudioOrCachedAudio(InlineQueryResultAudioOrCachedAudio), | ||
EdJoPaTo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[serde(rename = "document")] | ||
CachedDocument(InlineQueryResultCachedDocument), | ||
DocumentOrCachedDocument(InlineQueryResultDocumentOrCachedDocument), | ||
#[serde(rename = "gif")] | ||
CachedGif(InlineQueryResultCachedGif), | ||
GifOrCachedGif(InlineQueryResultGifOrCachedGif), | ||
#[serde(rename = "mpeg4_gif")] | ||
CachedMpeg4Gif(InlineQueryResultCachedMpeg4Gif), | ||
Mpeg4GifOrCachedMpeg4Gif(InlineQueryResultMpeg4GifOrCachedMpeg4Gif), | ||
#[serde(rename = "photo")] | ||
CachedPhoto(InlineQueryResultCachedPhoto), | ||
PhotoOrCachedPhoto(InlineQueryResultPhotoOrCachedPhoto), | ||
#[serde(rename = "sticker")] | ||
CachedSticker(InlineQueryResultCachedSticker), | ||
ayrat555 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[serde(rename = "video")] | ||
CachedVideo(InlineQueryResultCachedVideo), | ||
VideoOrCachedVideo(InlineQueryResultVideoOrCachedVideo), | ||
#[serde(rename = "voice")] | ||
CachedVoice(InlineQueryResultCachedVoice), | ||
VoiceOrCachedVoice(InlineQueryResultVoiceOrCachedVoice), | ||
#[serde(rename = "article")] | ||
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")] | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(untagged)] | ||
pub enum InlineQueryResultAudioOrCachedAudio { | ||
CachedAudio(InlineQueryResultCachedAudio), | ||
Audio(InlineQueryResultAudio), | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a bunch of repetition 🤔 But also not that much that a macro might be really worth it. Can there be a generic type? Is that useful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes. but I will be able to experiment on this only on weekend. you can push to this pr as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @EdJoPaTo actually creating enum was easier than I thought. It seems you don't have to provide types for generics in enum 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the Either enum! Just not entirely sure how well it can be used in code. It also shows up randomly in the docs with not much docs so its kinda vague… Maybe naming it Generally its used when creating the inline query results to be shown so the user knows whether its cached or not and picks one of them. So they know which struct to pick. Not sure how to improve the handling of that. Maybe with |
||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(untagged)] | ||
pub enum InlineQueryResultDocumentOrCachedDocument { | ||
CachedDocument(InlineQueryResultCachedDocument), | ||
Document(InlineQueryResultDocument), | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(untagged)] | ||
pub enum InlineQueryResultGifOrCachedGif { | ||
CachedGif(InlineQueryResultCachedGif), | ||
Gif(InlineQueryResultGif), | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(untagged)] | ||
pub enum InlineQueryResultMpeg4GifOrCachedMpeg4Gif { | ||
CachedMpeg4Gif(InlineQueryResultCachedMpeg4Gif), | ||
Mpeg4Gif(InlineQueryResultMpeg4Gif), | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(untagged)] | ||
pub enum InlineQueryResultPhotoOrCachedPhoto { | ||
CachedPhoto(InlineQueryResultCachedPhoto), | ||
Photo(InlineQueryResultPhoto), | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(untagged)] | ||
pub enum InlineQueryResultVideoOrCachedVideo { | ||
CachedVideo(InlineQueryResultCachedVideo), | ||
Video(InlineQueryResultVideo), | ||
#[serde(rename = "voice")] | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(untagged)] | ||
pub enum InlineQueryResultVoiceOrCachedVoice { | ||
CachedVoice(InlineQueryResultCachedVoice), | ||
Voice(InlineQueryResultVoice), | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Veetaha might interest this. There is also elastio/bon#212 which might be similar / related. 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a regression on nightly only. It was worked around in a
3.0.2
version. I think you can upgrade to this version without a migrationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be its own PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there is a dependabot PR #229
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To extend to that, this only fails on nightly so I would just ignore this for this PR and remove this change. A bon patch is there, and I could also see
rust_analyzer
being added to the list of well known values. So a change in this repo seems in the wrong place either way.