From c6aa3f97f42fdb5ccd165aac804554f3f9401ca3 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 27 Feb 2022 15:55:17 +0100 Subject: [PATCH] Add deprecation hint to service name usages Signed-off-by: trivernis --- src/api_core/common.rs | 8 ++++++++ tests/client/test_adding_tags.rs | 1 + tests/client/test_adding_urls.rs | 1 + 3 files changed, 10 insertions(+) diff --git a/src/api_core/common.rs b/src/api_core/common.rs index 3b6b3cb..3af1702 100644 --- a/src/api_core/common.rs +++ b/src/api_core/common.rs @@ -16,15 +16,23 @@ impl BasicServiceInfo { #[derive(Clone, Debug, Serialize, Deserialize, Hash, PartialOrd, PartialEq, Ord, Eq)] pub enum ServiceIdentifier { + /// Try to avoid using this variant as it will be removed from the interface + /// in the future Name(String), + /// The key variant of a service which should be the preferred variant. Key(String), } impl ServiceIdentifier { + /// Deprecation: use [ServiceIdentifier::key] instead. + #[deprecated( + note = "Deprecation in the official interface was mentioned. Use the service keys instead." + )] pub fn name(name: S) -> Self { Self::Name(name.to_string()) } + /// Constructs a new type of the key variant. pub fn key(key: S) -> Self { Self::Key(key.to_string()) } diff --git a/tests/client/test_adding_tags.rs b/tests/client/test_adding_tags.rs index 467d08f..c2797f8 100644 --- a/tests/client/test_adding_tags.rs +++ b/tests/client/test_adding_tags.rs @@ -19,6 +19,7 @@ async fn it_cleans_tags() { #[tokio::test] async fn it_adds_tags() { + #![allow(deprecated)] let client = common::get_client(); let request = AddTagsRequestBuilder::default() .add_hash("0000000000000000000000000000000000000000000000000000000000000000") // valid hash, I hope no files are affected diff --git a/tests/client/test_adding_urls.rs b/tests/client/test_adding_urls.rs index b262f9d..ef0939a 100644 --- a/tests/client/test_adding_urls.rs +++ b/tests/client/test_adding_urls.rs @@ -26,6 +26,7 @@ async fn it_returns_url_information() { #[tokio::test] async fn it_adds_urls() { + #![allow(deprecated)] let client = common::get_client(); let request = AddUrlRequestBuilder::default() .url("https://www.pixiv.net/member_illust.php?illust_id=83406361&mode=medium")