From f6fce684c1568851ad1fde14a3f70919c0ed7fef Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 16 Apr 2023 22:16:22 +0200 Subject: [PATCH 1/4] Rename client to instance --- src/client.rs | 10 ---------- src/instance.rs | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 10 deletions(-) delete mode 100644 src/client.rs create mode 100644 src/instance.rs diff --git a/src/client.rs b/src/client.rs deleted file mode 100644 index 2033808..0000000 --- a/src/client.rs +++ /dev/null @@ -1,10 +0,0 @@ -use crate::gateway::Gateway; -use crate::limit::LimitedRequester; - -struct ClientBuilder {} - -/* impl ClientBuilder { - fn build() -> Client {} -} */ - -struct Client {} diff --git a/src/instance.rs b/src/instance.rs new file mode 100644 index 0000000..b2f6f91 --- /dev/null +++ b/src/instance.rs @@ -0,0 +1,14 @@ +use crate::api::schemas::schemas::InstancePoliciesSchema; +use crate::gateway::Gateway; +use crate::limit::LimitedRequester; +use crate::URLBundle; + +use std::collections::HashMap; + +#[derive(Debug)] +pub struct Instance { + main_url: String, + urls: URLBundle, + instance_info: InstancePoliciesSchema, + requester: LimitedRequester, +} From 4c9ddc456929c0c24263eb0c18070c56b2cdab70 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 16 Apr 2023 22:16:39 +0200 Subject: [PATCH 2/4] Add PartialEq and Eq derives --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ee1ae54..838f31b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,11 @@ mod api; -mod client; mod gateway; +mod instance; mod limit; mod voice; use url::{ParseError, Url}; -#[derive(Clone, Default, Debug)] +#[derive(Clone, Default, Debug, PartialEq, Eq)] /// A URLBundle is a struct which bundles together the API-, Gateway- and CDN-URLs of a Spacebar /// instance. From fde38bc3581330cfb5a278385a8577c0f9b4e03d Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 16 Apr 2023 22:18:51 +0200 Subject: [PATCH 3/4] remove impl LoginSchema, add InstancePolicies --- src/api/schemas.rs | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/api/schemas.rs b/src/api/schemas.rs index c53f183..5e86a33 100644 --- a/src/api/schemas.rs +++ b/src/api/schemas.rs @@ -114,26 +114,6 @@ pub mod schemas { gift_code_sku_id: Option, } - impl LoginSchema { - pub fn new( - login: String, - password: String, - undelete: Option, - captcha_key: Option, - login_source: Option, - gift_code_sku_id: Option, - ) -> LoginSchema { - LoginSchema { - login, - password, - undelete, - captcha_key, - login_source, - gift_code_sku_id, - } - } - } - #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub struct TotpSchema { @@ -142,6 +122,19 @@ pub mod schemas { gift_code_sku_id: Option, login_source: Option, } + + #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] + #[serde(rename_all = "camelCase")] + pub struct InstancePoliciesSchema { + instance_name: String, + instance_description: Option, + front_page: Option, + tos_page: Option, + correspondence_email: Option, + correspondence_user_ID: Option, + image: Option, + instance_ID: Option, + } } // I know that some of these tests are... really really basic and unneccessary, but sometimes, I From 1319ca173697d6535432e7a6f7b0f8fb3f0908e6 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 16 Apr 2023 22:50:51 +0200 Subject: [PATCH 4/4] use camel case --- src/api/schemas.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/schemas.rs b/src/api/schemas.rs index 5e86a33..df44cfc 100644 --- a/src/api/schemas.rs +++ b/src/api/schemas.rs @@ -131,9 +131,9 @@ pub mod schemas { front_page: Option, tos_page: Option, correspondence_email: Option, - correspondence_user_ID: Option, + correspondence_user_id: Option, image: Option, - instance_ID: Option, + instance_id: Option, } }