Rename StickerType

- Rename `StickerType` => `InputSticker`
- Rename `{CreateNewStickerSet,AddStickerToSet}::sticker_type}` => `sticker`

This just makes more sense.
This commit is contained in:
Waffle 2020-11-04 16:00:40 +03:00
parent a138d6824b
commit 9d887e51bb
5 changed files with 24 additions and 17 deletions

View file

@ -42,6 +42,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Rename `StickerType` => `InputSticker`, `{CreateNewStickerSet,AddStickerToSet}::sticker_type}` => `sticker` ([#23][pr23])
- Use `_: IntoIterator<Item = T>` bound instead of `_: Into<Vec<T>>` in telegram methods which accept collections ([#21][pr21])
- Make `MessageDice::dice` pub ([#20][pr20])
- Merge `ApiErrorKind` and `KnownApiErrorKind` into `ApiError` ([#13][pr13]) - Merge `ApiErrorKind` and `KnownApiErrorKind` into `ApiError` ([#13][pr13])
- Refactor ChatMember ([#9][pr9]) - Refactor ChatMember ([#9][pr9])
- Replace a bunch of `Option<_>` fields with `ChatMemberKind` - Replace a bunch of `Option<_>` fields with `ChatMemberKind`
@ -55,6 +58,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[pr9]: https://github.com/teloxide/teloxide-core/pull/9 [pr9]: https://github.com/teloxide/teloxide-core/pull/9
[pr13]: https://github.com/teloxide/teloxide-core/pull/13 [pr13]: https://github.com/teloxide/teloxide-core/pull/13
[pr20]: https://github.com/teloxide/teloxide-core/pull/20
[pr21]: https://github.com/teloxide/teloxide-core/pull/21
[pr23]: https://github.com/teloxide/teloxide-core/pull/23
### Removed ### Removed

View file

@ -21,7 +21,7 @@ use crate::{
}, },
types::{ types::{
BotCommand, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia, BotCommand, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia,
LabeledPrice, ParseMode, StickerType, TargetMessage, LabeledPrice, ParseMode, InputSticker, TargetMessage,
}, },
Bot, Bot,
}; };
@ -1366,7 +1366,7 @@ impl Bot {
user_id: i32, user_id: i32,
name: N, name: N,
title: T, title: T,
sticker_type: StickerType, sticker_type: InputSticker,
emojis: E, emojis: E,
) -> CreateNewStickerSet ) -> CreateNewStickerSet
where where
@ -1389,7 +1389,7 @@ impl Bot {
&self, &self,
user_id: i32, user_id: i32,
name: N, name: N,
sticker_type: StickerType, sticker_type: InputSticker,
emojis: E, emojis: E,
) -> AddStickerToSet ) -> AddStickerToSet
where where

View file

@ -8,7 +8,7 @@ use crate::{
use crate::{ use crate::{
requests::{RequestOld, ResponseResult}, requests::{RequestOld, ResponseResult},
types::StickerType, types::InputSticker,
}; };
/// Use this method to add a new sticker to a set created by the bot. /// Use this method to add a new sticker to a set created by the bot.
@ -22,7 +22,7 @@ pub struct AddStickerToSet {
pub user_id: i32, pub user_id: i32,
pub name: String, pub name: String,
#[serde(flatten)] #[serde(flatten)]
pub sticker_type: StickerType, pub sticker_type: InputSticker,
pub emojis: String, pub emojis: String,
pub mask_position: Option<MaskPosition>, pub mask_position: Option<MaskPosition>,
} }
@ -41,7 +41,7 @@ impl AddStickerToSet {
bot: Bot, bot: Bot,
user_id: i32, user_id: i32,
name: N, name: N,
sticker_type: StickerType, sticker_type: InputSticker,
emojis: E, emojis: E,
) -> Self ) -> Self
where where
@ -73,7 +73,7 @@ impl AddStickerToSet {
self self
} }
pub fn sticker_type(mut self, val: StickerType) -> Self { pub fn sticker_type(mut self, val: InputSticker) -> Self {
self.sticker_type = val; self.sticker_type = val;
self self
} }

View file

@ -3,7 +3,7 @@ use serde::Serialize;
use crate::{ use crate::{
net, net,
requests::{RequestOld, ResponseResult}, requests::{RequestOld, ResponseResult},
types::{MaskPosition, StickerType, True}, types::{MaskPosition, InputSticker, True},
Bot, Bot,
}; };
@ -20,7 +20,7 @@ pub struct CreateNewStickerSet {
pub name: String, pub name: String,
pub title: String, pub title: String,
#[serde(flatten)] #[serde(flatten)]
pub sticker_type: StickerType, pub sticker: InputSticker,
pub emojis: String, pub emojis: String,
pub contains_masks: Option<bool>, pub contains_masks: Option<bool>,
pub mask_position: Option<MaskPosition>, pub mask_position: Option<MaskPosition>,
@ -42,7 +42,7 @@ impl CreateNewStickerSet {
user_id: i32, user_id: i32,
name: N, name: N,
title: T, title: T,
sticker_type: StickerType, sticker_type: InputSticker,
emojis: E, emojis: E,
) -> Self ) -> Self
where where
@ -55,7 +55,7 @@ impl CreateNewStickerSet {
user_id, user_id,
name: name.into(), name: name.into(),
title: title.into(), title: title.into(),
sticker_type, sticker: sticker_type,
emojis: emojis.into(), emojis: emojis.into(),
contains_masks: None, contains_masks: None,
mask_position: None, mask_position: None,
@ -91,8 +91,8 @@ impl CreateNewStickerSet {
self self
} }
pub fn sticker_type(mut self, val: StickerType) -> Self { pub fn sticker_type(mut self, val: InputSticker) -> Self {
self.sticker_type = val; self.sticker = val;
self self
} }

View file

@ -2,9 +2,10 @@ use serde::Serialize;
use crate::types::InputFile; use crate::types::InputFile;
/// Sticker file that may be uploaded to telegram.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize)] #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum StickerType { pub enum InputSticker {
/// PNG image with the sticker, must be up to 512 kilobytes in size, /// PNG image with the sticker, must be up to 512 kilobytes in size,
/// dimensions must not exceed 512px, and either width or height must be /// dimensions must not exceed 512px, and either width or height must be
/// exactly 512px. /// exactly 512px.
@ -27,8 +28,8 @@ pub enum StickerType {
Tgs { tgs_sticker: InputFile }, Tgs { tgs_sticker: InputFile },
} }
impl StickerType { impl InputSticker {
/// Create png-`StickerType`. /// Create png-`InputSticker`.
/// ///
/// See [`StickerType::Png`] for more /// See [`StickerType::Png`] for more
/// ///
@ -37,7 +38,7 @@ impl StickerType {
Self::Png { png_sticker } Self::Png { png_sticker }
} }
/// Create tgs-`StickerType`. /// Create tgs-`InputSticker`.
/// ///
/// See [`StickerType::Tgs`] for more /// See [`StickerType::Tgs`] for more
/// ///