Fix naming that triggers clippy::upper_case_acronyms lint

Rename
- ParseMode::{HTML => Html}
- ApiError::{
    InvalidQueryID => InvalidQueryId,
    ButtonURLInvalid => ButtonUrlInvalid,
    WrongFileID => WrongFileId,
    WebhookRequireHTTPS => WebhookRequireHttps,
    WrongHTTPurl => WrongHttpUrl,
  }
This commit is contained in:
Waffle 2021-02-06 19:23:16 +03:00
parent ec58a59903
commit 8befcffe26
3 changed files with 10 additions and 9 deletions

View file

@ -299,7 +299,7 @@ pub enum ApiError {
rename = "Bad Request: query is too old and response timeout expired or query id is \
invalid"
)]
InvalidQueryID,
InvalidQueryId,
/// Occurs when bot tries to send InlineKeyboardMarkup with invalid button
/// url.
@ -309,7 +309,7 @@ pub enum ApiError {
///
/// [`SendMessage`]: crate::payloads::SendMessage
#[serde(rename = "Bad Request: BUTTON_URL_INVALID")]
ButtonURLInvalid,
ButtonUrlInvalid,
/// Occurs when bot tries to send button with data size more than 64 bytes.
///
@ -339,7 +339,7 @@ pub enum ApiError {
///
/// [`GetFile`]: crate::payloads::GetFile
#[serde(rename = "Bad Request: wrong file id")]
WrongFileID,
WrongFileId,
/// Occurs when bot tries to do some with group which was deactivated.
#[serde(rename = "Bad Request: group is deactivated")]
@ -413,7 +413,7 @@ pub enum ApiError {
///
/// [`SetWebhook`]: crate::payloads::SetWebhook
#[serde(rename = "Bad Request: bad webhook: HTTPS url must be provided for webhook")]
WebhookRequireHTTPS,
WebhookRequireHttps,
/// Occurs when bot tries to set webhook to port other than 80, 88, 443 or
/// 8443.
@ -509,7 +509,7 @@ pub enum ApiError {
///
/// [`SendMessage`]: crate::payloads::SendMessage
#[serde(rename = "Bad Request: wrong HTTP URL")]
WrongHTTPurl,
WrongHttpUrl,
/// Occurs when bot tries GetUpdate before the timeout. Make sure that only
/// one Updater is running.

View file

@ -82,7 +82,7 @@ mod tests {
id: String::from("id"),
audio_file_id: String::from("audio_file_id"),
caption: Some(String::from("caption")),
parse_mode: Some(ParseMode::HTML),
parse_mode: Some(ParseMode::Html),
reply_markup: Some(InlineKeyboardMarkup::default()),
input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
message_text: String::from("message_text"),

View file

@ -128,7 +128,8 @@ use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub enum ParseMode {
MarkdownV2,
HTML,
#[serde(rename = "HTML")]
Html,
#[deprecated = "This is a legacy mode, retained for backward compatibility. Use `MarkdownV2` \
instead."]
Markdown,
@ -140,7 +141,7 @@ impl TryFrom<&str> for ParseMode {
fn try_from(value: &str) -> Result<Self, Self::Error> {
let normalized = value.to_lowercase();
match normalized.as_ref() {
"html" => Ok(ParseMode::HTML),
"html" => Ok(ParseMode::Html),
"markdown" => Ok(ParseMode::Markdown),
"markdownv2" => Ok(ParseMode::MarkdownV2),
_ => Err(()),
@ -173,7 +174,7 @@ mod tests {
#[test]
fn html_serialization() {
let expected_json = String::from(r#""HTML""#);
let actual_json = serde_json::to_string(&ParseMode::HTML).unwrap();
let actual_json = serde_json::to_string(&ParseMode::Html).unwrap();
assert_eq!(expected_json, actual_json)
}