Input: Change all Youtube-dl functions to take AsRef<str> (#70)

Unifies the API on all ytdl functions to remove some friction in passing in Strings, Cows, strs, and so on.

Closes #57.
This commit is contained in:
Clarity
2021-05-03 03:23:03 +08:00
committed by Kyle Simpson
parent bc9a78e050
commit 3c9b421fb4
2 changed files with 9 additions and 8 deletions

View File

@@ -32,8 +32,8 @@ const YOUTUBE_DL_COMMAND: &str = if cfg!(feature = "youtube-dlc") {
/// Uses `youtube-dlc` if the `"youtube-dlc"` feature is enabled.
///
/// [`Restartable::ytdl`]: crate::input::restartable::Restartable::ytdl
pub async fn ytdl(uri: &str) -> Result<Input> {
_ytdl(uri, &[]).await
pub async fn ytdl(uri: impl AsRef<str>) -> Result<Input> {
_ytdl(uri.as_ref(), &[]).await
}
pub(crate) async fn _ytdl(uri: &str, pre_args: &[&str]) -> Result<Input> {
@@ -170,6 +170,6 @@ pub(crate) async fn _ytdl_metadata(uri: &str) -> Result<Metadata> {
/// Uses `youtube-dlc` if the `"youtube-dlc"` feature is enabled.
///
/// [`Restartable::ytdl_search`]: crate::input::restartable::Restartable::ytdl_search
pub async fn ytdl_search(name: &str) -> Result<Input> {
ytdl(&format!("ytsearch1:{}", name)).await
pub async fn ytdl_search(name: impl AsRef<str>) -> Result<Input> {
ytdl(&format!("ytsearch1:{}", name.as_ref())).await
}