Skip to content

Commit bae0b2b

Browse files
authored
Remove Clippy suppressed warnings about enum sizes (#29)
1 parent 976b184 commit bae0b2b

File tree

12 files changed

+171
-180
lines changed

12 files changed

+171
-180
lines changed

src/types/definitions/gift.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -891,12 +891,13 @@ impl Method for GetUserGifts {
891891
/// Describes a gift received and owned by a user or a chat.
892892
#[derive(Clone, Debug, derive_more::From, Deserialize, PartialEq, Serialize)]
893893
#[serde(tag = "type", rename_all = "snake_case")]
894-
#[allow(clippy::large_enum_variant)]
895894
pub enum OwnedGift {
896895
/// A regular gift owned by a user or a chat.
897-
Regular(OwnedGiftRegular),
896+
#[from(OwnedGiftRegular)]
897+
Regular(Box<OwnedGiftRegular>),
898898
/// A unique gift received and owned by a user or a chat.
899-
Unique(OwnedGiftUnique),
899+
#[from(OwnedGiftUnique)]
900+
Unique(Box<OwnedGiftUnique>),
900901
}
901902

902903
/// Describes a regular gift owned by a user or a chat.

src/types/definitions/inline_mode/result/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ mod video;
3434
mod voice;
3535

3636
/// Represents a result of an inline query.
37-
#[allow(clippy::large_enum_variant)]
3837
#[derive(Clone, Debug, derive_more::From, Deserialize, PartialEq, Serialize)]
3938
#[serde(try_from = "RawInlineQueryResult", into = "RawInlineQueryResult")]
4039
pub enum InlineQueryResult {

src/types/definitions/media/paid.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ impl PaidMediaInfo {
8282
/// Describes paid media.
8383
#[derive(Clone, Debug, derive_more::From, Deserialize, PartialEq, PartialOrd, Serialize)]
8484
#[serde(from = "RawPaidMedia", into = "RawPaidMedia")]
85-
#[allow(clippy::large_enum_variant)]
8685
pub enum PaidMedia {
8786
/// The paid media is a photo.
8887
Photo(Vec<PhotoSize>),
8988
/// The paid media isn't available before the payment.
9089
Preview(PaidMediaPreview),
9190
/// The paid media is a video.
92-
Video(Video),
91+
#[from(Video)]
92+
Video(Box<Video>),
9393
}
9494

9595
/// The paid media isn't available before the payment.
@@ -139,7 +139,6 @@ impl PaidMediaPreview {
139139
#[serde_with::skip_serializing_none]
140140
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
141141
#[serde(rename_all = "snake_case", tag = "type")]
142-
#[allow(clippy::large_enum_variant)]
143142
enum RawPaidMedia {
144143
Photo {
145144
photo: Vec<PhotoSize>,
@@ -150,7 +149,7 @@ enum RawPaidMedia {
150149
width: Option<Integer>,
151150
},
152151
Video {
153-
video: Video,
152+
video: Box<Video>,
154153
},
155154
}
156155

src/types/definitions/message/data/mod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ mod raw;
5151

5252
/// Represents a message data.
5353
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
54-
#[allow(clippy::large_enum_variant)]
5554
#[serde(rename_all = "snake_case")]
5655
pub enum MessageData {
5756
/// Information about the animation.
@@ -134,11 +133,11 @@ pub enum MessageData {
134133
)]
135134
ForumTopicReopened,
136135
/// Information about the game.
137-
Game(Game),
136+
Game(Box<Game>),
138137
/// A service message about a sent or received regular gift.
139-
Gift(GiftInfo),
138+
Gift(Box<GiftInfo>),
140139
/// A service message about upgrade of a gift was purchased after the gift was sent.
141-
GiftUpgradeSent(GiftInfo),
140+
GiftUpgradeSent(Box<GiftInfo>),
142141
/// The 'General' forum topic hidden.
143142
#[serde(
144143
deserialize_with = "RawDataEmpty::deserialize_value",
@@ -203,7 +202,7 @@ pub enum MessageData {
203202
/// A service message about a refunded payment, information about the payment.
204203
RefundedPayment(RefundedPayment),
205204
/// Information about the sticker.
206-
Sticker(Sticker),
205+
Sticker(Box<Sticker>),
207206
/// A forwarded story.
208207
Story(Story),
209208
/// Service message: a suggested post was approved.
@@ -217,7 +216,7 @@ pub enum MessageData {
217216
/// Service message: payment for a suggested post was refunded.
218217
SuggestedPostRefunded(SuggestedPostRefunded),
219218
/// Information about the successful payment.
220-
SuccessfulPayment(SuccessfulPayment),
219+
SuccessfulPayment(Box<SuccessfulPayment>),
221220
/// The supergroup has been created.
222221
///
223222
/// This field can‘t be received in a message coming through updates,
@@ -231,7 +230,7 @@ pub enum MessageData {
231230
)]
232231
SupergroupChatCreated,
233232
/// A service message about a sent or received unique gift.
234-
UniqueGift(UniqueGiftInfo),
233+
UniqueGift(Box<UniqueGiftInfo>),
235234
/// A user was shared with the bot.
236235
UsersShared(MessageDataUsersShared),
237236
/// Information about the venue.
@@ -260,7 +259,7 @@ pub enum MessageData {
260259
WriteAccessAllowed(MessageDataWriteAccess),
261260
/// Describes the audio.
262261
#[serde(untagged)]
263-
Audio(MessageDataAudio),
262+
Audio(Box<MessageDataAudio>),
264263
/// Describes the document.
265264
#[serde(untagged)]
266265
Document(MessageDataDocument),
@@ -276,7 +275,7 @@ pub enum MessageData {
276275
Text(Text),
277276
/// Describes the video.
278277
#[serde(untagged)]
279-
Video(MessageDataVideo),
278+
Video(Box<MessageDataVideo>),
280279
/// Describes the voice.
281280
#[serde(untagged)]
282281
Voice(MessageDataVoice),

src/types/definitions/message/mod.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ mod sender;
1313

1414
/// Represents a result of `EditMessage*` requests.
1515
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
16-
#[allow(clippy::large_enum_variant)]
1716
#[serde(untagged)]
1817
pub enum EditMessageResult {
1918
/// Returned if edited message is sent by the bot.
20-
Message(Message),
19+
Message(Box<Message>),
2120
/// Returned if edited message is NOT sent by the bot.
2221
Bool(bool),
2322
}
@@ -208,28 +207,13 @@ impl Message {
208207

209208
/// Returns a text of the message (includes caption).
210209
pub fn get_text(&self) -> Option<&Text> {
211-
match self.data {
212-
MessageData::Text(ref text)
213-
| MessageData::Audio(MessageDataAudio {
214-
caption: Some(ref text),
215-
..
216-
})
217-
| MessageData::Document(MessageDataDocument {
218-
caption: Some(ref text),
219-
..
220-
})
221-
| MessageData::Photo(MessageDataPhoto {
222-
caption: Some(ref text),
223-
..
224-
})
225-
| MessageData::Video(MessageDataVideo {
226-
caption: Some(ref text),
227-
..
228-
})
229-
| MessageData::Voice(MessageDataVoice {
230-
caption: Some(ref text),
231-
..
232-
}) => Some(text),
210+
match &self.data {
211+
MessageData::Text(text) => Some(text),
212+
MessageData::Audio(audio) => audio.caption.as_ref(),
213+
MessageData::Document(doc) => doc.caption.as_ref(),
214+
MessageData::Photo(photo) => photo.caption.as_ref(),
215+
MessageData::Video(video) => video.caption.as_ref(),
216+
MessageData::Voice(voice) => voice.caption.as_ref(),
233217
_ => None,
234218
}
235219
}

src/types/definitions/message/sender.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::types::{Chat, ChatPeerId, ChatUsername, User, UserPeerId, UserUsernam
44

55
/// Represents a sender of a message.
66
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
7-
#[allow(clippy::large_enum_variant)]
87
#[serde(untagged, from = "RawMessageSender", into = "RawMessageSender")]
98
pub enum MessageSender {
109
/// For messages sent by a chat.

src/types/definitions/passport/data.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,6 @@ impl EncryptedPassportElementUtilityBill {
792792
/// Represents an information about documents
793793
/// or other Telegram Passport elements shared with a bot by a user.
794794
#[derive(Clone, Debug, derive_more::From, Deserialize, PartialEq, PartialOrd, Serialize)]
795-
#[allow(clippy::large_enum_variant)]
796795
#[serde(rename_all = "snake_case")]
797796
#[serde(tag = "type")]
798797
pub enum EncryptedPassportElement {

src/types/definitions/payment/transaction.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ impl TransactionPartnerUserParameters {
387387
/// Describes the source of a transaction, or its recipient for outgoing transactions.
388388
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
389389
#[serde(from = "RawTransactionPartner", into = "RawTransactionPartner")]
390-
#[allow(clippy::large_enum_variant)]
391390
pub enum TransactionPartner {
392391
/// Describes the affiliate program that issued the affiliate commission received via this transaction.
393392
AffiliateProgram(TransactionPartnerAffiliateProgramParameters),
@@ -411,7 +410,6 @@ pub enum TransactionPartner {
411410
#[serde_with::skip_serializing_none]
412411
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
413412
#[serde(tag = "type", rename_all = "snake_case")]
414-
#[allow(clippy::large_enum_variant)]
415413
enum RawTransactionPartner {
416414
AffiliateProgram(TransactionPartnerAffiliateProgramParameters),
417415
Chat(TransactionPartnerChatParameters),

0 commit comments

Comments
 (0)