fix: add pedantic lints
This commit is contained in:
parent
81280200f7
commit
cbeb14f3fd
41 changed files with 520 additions and 447 deletions
|
|
@ -16,7 +16,7 @@ use serde_with::serde_as;
|
|||
use time::{Date, OffsetDateTime};
|
||||
|
||||
use self::{paginator::Paginator, richtext::RichText};
|
||||
use crate::{error::Error, param::Country, serializer::DateYmd, util};
|
||||
use crate::{error::Error, param::Country, serializer::DateYmd, validate};
|
||||
|
||||
/*
|
||||
#COMMON
|
||||
|
|
@ -110,22 +110,10 @@ impl UrlTarget {
|
|||
/// Validate the YouTube ID from the URL target
|
||||
pub(crate) fn validate(&self) -> Result<(), Error> {
|
||||
match self {
|
||||
UrlTarget::Video { id, .. } => match util::VIDEO_ID_REGEX.is_match(id) {
|
||||
true => Ok(()),
|
||||
false => Err(Error::Other("invalid video id".into())),
|
||||
},
|
||||
UrlTarget::Channel { id } => match util::CHANNEL_ID_REGEX.is_match(id) {
|
||||
true => Ok(()),
|
||||
false => Err(Error::Other("invalid channel id".into())),
|
||||
},
|
||||
UrlTarget::Playlist { id } => match util::PLAYLIST_ID_REGEX.is_match(id) {
|
||||
true => Ok(()),
|
||||
false => Err(Error::Other("invalid playlist id".into())),
|
||||
},
|
||||
UrlTarget::Album { id } => match util::ALBUM_ID_REGEX.is_match(id) {
|
||||
true => Ok(()),
|
||||
false => Err(Error::Other("invalid album id".into())),
|
||||
},
|
||||
UrlTarget::Video { id, .. } => validate::video_id(id),
|
||||
UrlTarget::Channel { id } => validate::channel_id(id),
|
||||
UrlTarget::Playlist { id } => validate::playlist_id(id),
|
||||
UrlTarget::Album { id } => validate::album_id(id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ impl TextComponent {
|
|||
/// Get the text from the component
|
||||
pub fn get_text(&self) -> &str {
|
||||
match self {
|
||||
TextComponent::Text(text) => text,
|
||||
TextComponent::Web { text, .. } => text,
|
||||
TextComponent::YouTube { text, .. } => text,
|
||||
TextComponent::Text(text)
|
||||
| TextComponent::Web { text, .. }
|
||||
| TextComponent::YouTube { text, .. } => text,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ impl TextComponent {
|
|||
pub fn get_url(&self, yt_host: &str) -> String {
|
||||
match self {
|
||||
TextComponent::Text(_) => String::new(),
|
||||
TextComponent::Web { url, .. } => url.to_owned(),
|
||||
TextComponent::Web { url, .. } => url.clone(),
|
||||
TextComponent::YouTube { target, .. } => target.to_url_yt_host(yt_host),
|
||||
}
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ impl TextComponent {
|
|||
impl ToPlaintext for TextComponent {
|
||||
fn to_plaintext_yt_host(&self, yt_host: &str) -> String {
|
||||
match self {
|
||||
TextComponent::Text(text) => text.to_owned(),
|
||||
TextComponent::Text(text) => text.clone(),
|
||||
_ => self.get_url(yt_host),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue