diff --git a/Cargo.toml b/Cargo.toml index c96fc03..5d2044a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/api_params.rs b/src/api_params.rs index 787bf78..44a8524 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -52,48 +52,28 @@ impl From 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), + Document(MaybeCached), + Gif(MaybeCached), + Mpeg4Gif(MaybeCached), + Photo(MaybeCached), + Sticker(InlineQueryResultCachedSticker), + Video(MaybeCached), + Voice(MaybeCached), 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 { + Cached(T1), + NotCached(T2), } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]