mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
Merge pull request #994 from Desiders/fix-audio-duration-type
Fix audio duration type
This commit is contained in:
commit
83fc16d9f4
3 changed files with 7 additions and 9 deletions
|
@ -50,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Use `UserId` instead of `i64` for `user_id` in `html::user_mention` and `markdown::user_mention` ([PR 896](https://github.com/teloxide/teloxide/pull/896))
|
- Use `UserId` instead of `i64` for `user_id` in `html::user_mention` and `markdown::user_mention` ([PR 896](https://github.com/teloxide/teloxide/pull/896))
|
||||||
- Greatly improved the speed of graceful shutdown (`^C`) ([PR 938](https://github.com/teloxide/teloxide/pull/938))
|
- Greatly improved the speed of graceful shutdown (`^C`) ([PR 938](https://github.com/teloxide/teloxide/pull/938))
|
||||||
- Fix typos in docstrings ([PR 953](https://github.com/teloxide/teloxide/pull/953))
|
- Fix typos in docstrings ([PR 953](https://github.com/teloxide/teloxide/pull/953))
|
||||||
|
- Use `Seconds` instead of `String` in `InlineQueryResultAudio` for `audio_duration` ([PR 994](https://github.com/teloxide/teloxide/pull/994))
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -356,10 +356,10 @@ mod tests {
|
||||||
})),
|
})),
|
||||||
caption_entities: None,
|
caption_entities: None,
|
||||||
performer: Some(String::from("performer")),
|
performer: Some(String::from("performer")),
|
||||||
audio_duration: Some("1".into()),
|
audio_duration: Some(Seconds::from_seconds(1)),
|
||||||
});
|
});
|
||||||
|
|
||||||
let expected_json = r#"{"type":"audio","id":"id","audio_url":"http://audio_url/","title":"title","caption":"caption","parse_mode":"HTML","performer":"performer","audio_duration":"1","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#;
|
let expected_json = r#"{"type":"audio","id":"id","audio_url":"http://audio_url/","title":"title","caption":"caption","parse_mode":"HTML","performer":"performer","audio_duration":1,"reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#;
|
||||||
let actual_json = serde_json::to_string(&structure).unwrap();
|
let actual_json = serde_json::to_string(&structure).unwrap();
|
||||||
|
|
||||||
assert_eq!(expected_json, actual_json);
|
assert_eq!(expected_json, actual_json);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
|
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode, Seconds};
|
||||||
|
|
||||||
/// Represents a link to an MP3 audio file. By default, this audio file will be
|
/// Represents a link to an MP3 audio file. By default, this audio file will be
|
||||||
/// sent by the user.
|
/// sent by the user.
|
||||||
|
@ -40,7 +40,7 @@ pub struct InlineQueryResultAudio {
|
||||||
pub performer: Option<String>,
|
pub performer: Option<String>,
|
||||||
|
|
||||||
/// Audio duration in seconds.
|
/// Audio duration in seconds.
|
||||||
pub audio_duration: Option<String>,
|
pub audio_duration: Option<Seconds>,
|
||||||
|
|
||||||
/// [Inline keyboard] attached to the message.
|
/// [Inline keyboard] attached to the message.
|
||||||
///
|
///
|
||||||
|
@ -123,11 +123,8 @@ impl InlineQueryResultAudio {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn audio_duration<S>(mut self, val: S) -> Self
|
pub fn audio_duration(mut self, val: Seconds) -> Self {
|
||||||
where
|
self.audio_duration = Some(val);
|
||||||
S: Into<String>,
|
|
||||||
{
|
|
||||||
self.audio_duration = Some(val.into());
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue