From 6f2dac66950a08bbd8b0c4fd803e1ef8dc84b0b2 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Tue, 25 Apr 2023 17:32:30 +0200 Subject: [PATCH] Split up schemas.rs --- src/api/auth/login.rs | 3 +- src/api/auth/register.rs | 7 +- src/api/mod.rs | 2 + src/api/policies/instance/instance.rs | 6 +- src/api/schemas.rs | 605 +++++++++----------------- src/api/types.rs | 217 +++++++++ src/instance.rs | 8 +- 7 files changed, 425 insertions(+), 423 deletions(-) create mode 100644 src/api/types.rs diff --git a/src/api/auth/login.rs b/src/api/auth/login.rs index a11db3c..bc37b25 100644 --- a/src/api/auth/login.rs +++ b/src/api/auth/login.rs @@ -3,7 +3,8 @@ pub mod login { use serde_json::{from_str, json}; use crate::api::limits::LimitType; - use crate::api::schemas::schemas::{ErrorResponse, LoginResult, LoginSchema}; + use crate::api::schemas::LoginSchema; + use crate::api::types::{ErrorResponse, LoginResult}; use crate::errors::InstanceServerError; use crate::instance::Instance; diff --git a/src/api/auth/register.rs b/src/api/auth/register.rs index 2e0db06..650b8cf 100644 --- a/src/api/auth/register.rs +++ b/src/api/auth/register.rs @@ -3,10 +3,7 @@ pub mod register { use serde_json::json; use crate::{ - api::{ - limits::LimitType, - schemas::schemas::{ErrorResponse, RegisterSchema}, - }, + api::{limits::LimitType, schemas::RegisterSchema, types::ErrorResponse}, errors::InstanceServerError, instance::{Instance, Token}, }; @@ -67,7 +64,7 @@ pub mod register { #[cfg(test)] mod test { - use crate::api::schemas::schemas::{AuthEmail, AuthPassword, AuthUsername, RegisterSchema}; + use crate::api::schemas::{AuthEmail, AuthPassword, AuthUsername, RegisterSchema}; use crate::errors::InstanceServerError; use crate::instance::Instance; use crate::limit::LimitedRequester; diff --git a/src/api/mod.rs b/src/api/mod.rs index f619259..a9902d6 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,7 +1,9 @@ pub mod auth; pub mod policies; pub mod schemas; +pub mod types; pub use policies::instance::instance::*; pub use policies::instance::limits::*; pub use schemas::*; +pub use types::*; diff --git a/src/api/policies/instance/instance.rs b/src/api/policies/instance/instance.rs index 2eaac5b..7f69670 100644 --- a/src/api/policies/instance/instance.rs +++ b/src/api/policies/instance/instance.rs @@ -3,7 +3,7 @@ pub mod instance { use serde_json::from_str; use crate::errors::InstanceServerError; - use crate::{api::schemas::schemas::InstancePoliciesSchema, instance::Instance}; + use crate::{api::types::InstancePolicies, instance::Instance}; impl Instance { /** @@ -13,7 +13,7 @@ pub mod instance { */ pub async fn instance_policies_schema( &self, - ) -> Result { + ) -> Result { let client = Client::new(); let endpoint_url = self.urls.get_api().to_string() + "/policies/instance/"; let request = match client.get(&endpoint_url).send().await { @@ -33,7 +33,7 @@ pub mod instance { } let body = request.text().await.unwrap(); - let instance_policies_schema: InstancePoliciesSchema = from_str(&body).unwrap(); + let instance_policies_schema: InstancePolicies = from_str(&body).unwrap(); Ok(instance_policies_schema) } } diff --git a/src/api/schemas.rs b/src/api/schemas.rs index 0feb280..33091a6 100644 --- a/src/api/schemas.rs +++ b/src/api/schemas.rs @@ -1,465 +1,250 @@ -pub mod schemas { - use regex::Regex; - use serde::{Deserialize, Serialize}; - use std::{collections::HashMap, fmt}; +use regex::Regex; +use serde::{Deserialize, Serialize}; - use crate::{api::limits::Limits, errors::FieldFormatError, URLBundle}; +use crate::errors::FieldFormatError; +/** +A struct that represents a well-formed email address. + */ +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct AuthEmail { + pub email: String, +} + +impl AuthEmail { /** - A struct that represents a well-formed email address. - */ - #[derive(Clone, PartialEq, Eq, Debug)] - pub struct AuthEmail { - pub email: String, - } - - impl AuthEmail { - /** - Returns a new [`Result`]. - ## Arguments - The email address you want to validate. - ## Errors - You will receive a [`FieldFormatError`], if: - - The email address is not in a valid format. - - */ - pub fn new(email: String) -> Result { - let regex = Regex::new(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$").unwrap(); - if !regex.is_match(email.clone().as_str()) { - return Err(FieldFormatError::EmailError); - } - return Ok(AuthEmail { email }); - } - } - - /** - A struct that represents a well-formed username. + Returns a new [`Result`]. ## Arguments - Please use new() to create a new instance of this struct. + The email address you want to validate. + ## Errors + You will receive a [`FieldFormatError`], if: + - The email address is not in a valid format. + + */ + pub fn new(email: String) -> Result { + let regex = Regex::new(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$").unwrap(); + if !regex.is_match(email.clone().as_str()) { + return Err(FieldFormatError::EmailError); + } + return Ok(AuthEmail { email }); + } +} + +/** +A struct that represents a well-formed username. +## Arguments +Please use new() to create a new instance of this struct. +## Errors +You will receive a [`FieldFormatError`], if: +- The username is not between 2 and 32 characters. + */ +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct AuthUsername { + pub username: String, +} + +impl AuthUsername { + /** + Returns a new [`Result`]. + ## Arguments + The username you want to validate. ## Errors You will receive a [`FieldFormatError`], if: - The username is not between 2 and 32 characters. */ - #[derive(Clone, PartialEq, Eq, Debug)] - pub struct AuthUsername { - pub username: String, - } - - impl AuthUsername { - /** - Returns a new [`Result`]. - ## Arguments - The username you want to validate. - ## Errors - You will receive a [`FieldFormatError`], if: - - The username is not between 2 and 32 characters. - */ - pub fn new(username: String) -> Result { - if username.len() < 2 || username.len() > 32 { - return Err(FieldFormatError::UsernameError); - } else { - return Ok(AuthUsername { username }); - } + pub fn new(username: String) -> Result { + if username.len() < 2 || username.len() > 32 { + return Err(FieldFormatError::UsernameError); + } else { + return Ok(AuthUsername { username }); } } +} +/** +A struct that represents a well-formed password. +## Arguments +Please use new() to create a new instance of this struct. +## Errors +You will receive a [`FieldFormatError`], if: +- The password is not between 1 and 72 characters. + */ +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct AuthPassword { + pub password: String, +} + +impl AuthPassword { /** - A struct that represents a well-formed password. + Returns a new [`Result`]. ## Arguments - Please use new() to create a new instance of this struct. + The password you want to validate. ## Errors You will receive a [`FieldFormatError`], if: - The password is not between 1 and 72 characters. */ - #[derive(Clone, PartialEq, Eq, Debug)] - pub struct AuthPassword { - pub password: String, - } - - impl AuthPassword { - /** - Returns a new [`Result`]. - ## Arguments - The password you want to validate. - ## Errors - You will receive a [`FieldFormatError`], if: - - The password is not between 1 and 72 characters. - */ - pub fn new(password: String) -> Result { - if password.len() < 1 || password.len() > 72 { - return Err(FieldFormatError::PasswordError); - } else { - return Ok(AuthPassword { password }); - } + pub fn new(password: String) -> Result { + if password.len() < 1 || password.len() > 72 { + return Err(FieldFormatError::PasswordError); + } else { + return Ok(AuthPassword { password }); } } +} +/** +A struct that represents a well-formed register request. +## Arguments +Please use new() to create a new instance of this struct. +## Errors +You will receive a [`FieldFormatError`], if: +- The username is not between 2 and 32 characters. +- The password is not between 1 and 72 characters. + */ + +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +pub struct RegisterSchema { + username: String, + password: Option, + consent: bool, + email: Option, + fingerprint: Option, + invite: Option, + date_of_birth: Option, + gift_code_sku_id: Option, + captcha_key: Option, + promotional_email_opt_in: Option, +} + +impl RegisterSchema { /** - A struct that represents a well-formed register request. + Returns a new [`Result`]. ## Arguments - Please use new() to create a new instance of this struct. + All but "String::username" and "bool::consent" are optional. + ## Errors You will receive a [`FieldFormatError`], if: - - The username is not between 2 and 32 characters. - - The password is not between 1 and 72 characters. - */ + - The username is less than 2 or more than 32 characters in length + - You supply a `password` which is less than 1 or more than 72 characters in length. - #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] - #[serde(rename_all = "snake_case")] - pub struct RegisterSchema { - username: String, - password: Option, + These constraints have been defined [in the Spacebar-API](https://docs.spacebar.chat/routes/) + */ + pub fn new( + username: AuthUsername, + password: Option, consent: bool, - email: Option, + email: Option, fingerprint: Option, invite: Option, date_of_birth: Option, gift_code_sku_id: Option, captcha_key: Option, promotional_email_opt_in: Option, - } + ) -> Result { + let username = username.username; - impl RegisterSchema { - /** - Returns a new [`Result`]. - ## Arguments - All but "String::username" and "bool::consent" are optional. - - ## Errors - You will receive a [`FieldFormatError`], if: - - The username is less than 2 or more than 32 characters in length - - You supply a `password` which is less than 1 or more than 72 characters in length. - - These constraints have been defined [in the Spacebar-API](https://docs.spacebar.chat/routes/) - */ - pub fn new( - username: AuthUsername, - password: Option, - consent: bool, - email: Option, - fingerprint: Option, - invite: Option, - date_of_birth: Option, - gift_code_sku_id: Option, - captcha_key: Option, - promotional_email_opt_in: Option, - ) -> Result { - let username = username.username; - - let email_addr; - if email.is_some() { - email_addr = Some(email.unwrap().email); - } else { - email_addr = None; - } - - let has_password; - if password.is_some() { - has_password = Some(password.unwrap().password); - } else { - has_password = None; - } - - if !consent { - return Err(FieldFormatError::ConsentError); - } - - return Ok(RegisterSchema { - username, - password: has_password, - consent, - email: email_addr, - fingerprint, - invite, - date_of_birth, - gift_code_sku_id, - captcha_key, - promotional_email_opt_in, - }); + let email_addr; + if email.is_some() { + email_addr = Some(email.unwrap().email); + } else { + email_addr = None; } - } + let has_password; + if password.is_some() { + has_password = Some(password.unwrap().password); + } else { + has_password = None; + } + + if !consent { + return Err(FieldFormatError::ConsentError); + } + + return Ok(RegisterSchema { + username, + password: has_password, + consent, + email: email_addr, + fingerprint, + invite, + date_of_birth, + gift_code_sku_id, + captcha_key, + promotional_email_opt_in, + }); + } +} + +/** +A struct that represents a well-formed login request. +## Arguments +Please use new() to create a new instance of this struct. +## Errors +You will receive a [`FieldFormatError`], if: +- The username is not between 2 and 32 characters. +- The password is not between 1 and 72 characters. + */ +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +pub struct LoginSchema { + login: String, + password: String, + undelete: Option, + captcha_key: Option, + login_source: Option, + gift_code_sku_id: Option, +} + +impl LoginSchema { /** - A struct that represents a well-formed login request. + Returns a new [`Result`]. ## Arguments - Please use new() to create a new instance of this struct. + login: The username you want to login with. + password: The password you want to login with. + undelete: Honestly no idea what this is for. + captcha_key: The captcha key you want to login with. + login_source: The login source. + gift_code_sku_id: The gift code sku id. ## Errors You will receive a [`FieldFormatError`], if: - - The username is not between 2 and 32 characters. - - The password is not between 1 and 72 characters. - */ - #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] - #[serde(rename_all = "snake_case")] - pub struct LoginSchema { - login: String, + - The username is less than 2 or more than 32 characters in length + */ + pub fn new( + login: AuthUsername, password: String, undelete: Option, captcha_key: Option, login_source: Option, gift_code_sku_id: Option, + ) -> Result { + let login = login.username; + return Ok(LoginSchema { + login, + password, + undelete, + captcha_key, + login_source, + gift_code_sku_id, + }); } +} - impl LoginSchema { - /** - Returns a new [`Result`]. - ## Arguments - login: The username you want to login with. - password: The password you want to login with. - undelete: Honestly no idea what this is for. - captcha_key: The captcha key you want to login with. - login_source: The login source. - gift_code_sku_id: The gift code sku id. - ## Errors - You will receive a [`FieldFormatError`], if: - - The username is less than 2 or more than 32 characters in length - */ - pub fn new( - login: AuthUsername, - password: String, - undelete: Option, - captcha_key: Option, - login_source: Option, - gift_code_sku_id: Option, - ) -> Result { - let login = login.username; - return Ok(LoginSchema { - login, - password, - undelete, - captcha_key, - login_source, - gift_code_sku_id, - }); - } - } - - #[derive(Debug, Serialize, Deserialize)] - pub struct LoginResult { - token: String, - settings: UserSettings, - } - - #[derive(Debug, Serialize, Deserialize)] - pub struct UserSettings { - afk_timeout: i32, - allow_accessibility_detection: bool, - animate_emoji: bool, - animate_stickers: i32, - contact_sync_enabled: bool, - convert_emoticons: bool, - custom_status: Option, - default_guilds_restricted: bool, - detect_platform_accounts: bool, - developer_mode: bool, - disable_games_tab: bool, - enable_tts_command: bool, - explicit_content_filter: i32, - friend_source_flags: FriendSourceFlags, - friend_discovery_flags: Option, - gateway_connected: bool, - gif_auto_play: bool, - guild_folders: Vec, - guild_positions: Vec, - inline_attachment_media: bool, - inline_embed_media: bool, - locale: String, - message_display_compact: bool, - native_phone_integration_enabled: bool, - render_embeds: bool, - render_reactions: bool, - restricted_guilds: Vec, - show_current_game: bool, - status: String, - stream_notifications_enabled: bool, - theme: String, - timezone_offset: i32, - view_nsfw_guilds: bool, - } - - #[derive(Debug, Serialize, Deserialize)] - pub struct FriendSourceFlags { - all: Option, - mutual_friends: Option, - mutual_guilds: Option, - } - - #[derive(Debug, Serialize, Deserialize)] - pub struct GuildFolder { - id: String, - guild_ids: Vec, - name: String, - } - - #[derive(Debug, Serialize, Deserialize)] - #[serde(rename_all = "snake_case")] - pub struct TotpSchema { - code: String, - ticket: String, - gift_code_sku_id: Option, - login_source: Option, - } - - /** - Represents the result you get from GET: /api/instance/policies/. - */ - #[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, - } - - impl InstancePoliciesSchema { - pub fn new( - instance_name: String, - instance_description: Option, - front_page: Option, - tos_page: Option, - correspondence_email: Option, - correspondence_user_id: Option, - image: Option, - instance_id: Option, - ) -> Self { - InstancePoliciesSchema { - instance_name, - instance_description, - front_page, - tos_page, - correspondence_email, - correspondence_user_id, - image, - instance_id, - } - } - } - - impl fmt::Display for InstancePoliciesSchema { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "InstancePoliciesSchema {{ instance_name: {}, instance_description: {}, front_page: {}, tos_page: {}, correspondence_email: {}, correspondence_user_id: {}, image: {}, instance_id: {} }}", - self.instance_name, - self.instance_description.clone().unwrap_or("None".to_string()), - self.front_page.clone().unwrap_or("None".to_string()), - self.tos_page.clone().unwrap_or("None".to_string()), - self.correspondence_email.clone().unwrap_or("None".to_string()), - self.correspondence_user_id.clone().unwrap_or("None".to_string()), - self.image.clone().unwrap_or("None".to_string()), - self.instance_id.clone().unwrap_or("None".to_string()), - ) - } - } - - #[derive(Serialize, Deserialize, Debug)] - pub struct ErrorResponse { - pub code: i32, - pub message: String, - pub errors: IntermittentError, - } - - #[derive(Serialize, Deserialize, Debug)] - pub struct IntermittentError { - #[serde(flatten)] - pub errors: std::collections::HashMap, - } - - #[derive(Serialize, Deserialize, Debug, Default)] - pub struct ErrorField { - #[serde(default)] - pub _errors: Vec, - } - - #[derive(Serialize, Deserialize, Debug)] - pub struct Error { - pub message: String, - pub code: String, - } - - #[derive(Serialize, Deserialize, Debug)] - pub struct UserObject { - id: String, - username: String, - discriminator: String, - avatar: Option, - bot: Option, - system: Option, - mfa_enabled: Option, - banner: Option, - accent_color: Option, - locale: String, - verified: Option, - email: Option, - flags: i8, - premium_type: Option, - public_flags: Option, - } - - #[derive(Debug)] - pub struct User { - logged_in: bool, - belongs_to: URLBundle, - token: String, - rate_limits: Limits, - pub settings: UserSettings, - pub object: UserObject, - } - - impl User { - pub fn is_logged_in(&self) -> bool { - if self.logged_in == true { - true - } else { - false - } - } - - pub fn belongs_to(&self) -> URLBundle { - return self.belongs_to.clone(); - } - - pub fn token(&self) -> String { - return self.token.clone(); - } - - pub fn set_logged_in(&mut self, bool: bool) { - self.logged_in = bool; - } - - pub fn set_token(&mut self, token: String) { - self.token = token; - } - - pub fn new( - logged_in: bool, - belongs_to: URLBundle, - token: String, - rate_limits: Limits, - settings: UserSettings, - object: UserObject, - ) -> User { - User { - logged_in, - belongs_to, - token, - rate_limits, - settings, - object, - } - } - } +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub struct TotpSchema { + code: String, + ticket: String, + gift_code_sku_id: Option, + login_source: Option, } // I know that some of these tests are... really really basic and unneccessary, but sometimes, I // just feel like writing tests, so there you go :) -@bitfl0wer #[cfg(test)] mod schemas_tests { - use super::schemas::*; + use super::*; use crate::errors::FieldFormatError; #[test] diff --git a/src/api/types.rs b/src/api/types.rs new file mode 100644 index 0000000..1f281f0 --- /dev/null +++ b/src/api/types.rs @@ -0,0 +1,217 @@ +use std::fmt; + +use serde::{Deserialize, Serialize}; + +use crate::{api::limits::Limits, URLBundle}; + +#[derive(Debug, Serialize, Deserialize)] +pub struct LoginResult { + token: String, + settings: UserSettings, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct UserSettings { + afk_timeout: i32, + allow_accessibility_detection: bool, + animate_emoji: bool, + animate_stickers: i32, + contact_sync_enabled: bool, + convert_emoticons: bool, + custom_status: Option, + default_guilds_restricted: bool, + detect_platform_accounts: bool, + developer_mode: bool, + disable_games_tab: bool, + enable_tts_command: bool, + explicit_content_filter: i32, + friend_source_flags: FriendSourceFlags, + friend_discovery_flags: Option, + gateway_connected: bool, + gif_auto_play: bool, + guild_folders: Vec, + guild_positions: Vec, + inline_attachment_media: bool, + inline_embed_media: bool, + locale: String, + message_display_compact: bool, + native_phone_integration_enabled: bool, + render_embeds: bool, + render_reactions: bool, + restricted_guilds: Vec, + show_current_game: bool, + status: String, + stream_notifications_enabled: bool, + theme: String, + timezone_offset: i32, + view_nsfw_guilds: bool, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct FriendSourceFlags { + all: Option, + mutual_friends: Option, + mutual_guilds: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct GuildFolder { + id: String, + guild_ids: Vec, + name: String, +} + +/** +Represents the result you get from GET: /api/instance/policies/. +*/ +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +pub struct InstancePolicies { + instance_name: String, + instance_description: Option, + front_page: Option, + tos_page: Option, + correspondence_email: Option, + correspondence_user_id: Option, + image: Option, + instance_id: Option, +} + +impl InstancePolicies { + pub fn new( + instance_name: String, + instance_description: Option, + front_page: Option, + tos_page: Option, + correspondence_email: Option, + correspondence_user_id: Option, + image: Option, + instance_id: Option, + ) -> Self { + InstancePolicies { + instance_name, + instance_description, + front_page, + tos_page, + correspondence_email, + correspondence_user_id, + image, + instance_id, + } + } +} + +impl fmt::Display for InstancePolicies { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "InstancePoliciesSchema {{ instance_name: {}, instance_description: {}, front_page: {}, tos_page: {}, correspondence_email: {}, correspondence_user_id: {}, image: {}, instance_id: {} }}", + self.instance_name, + self.instance_description.clone().unwrap_or("None".to_string()), + self.front_page.clone().unwrap_or("None".to_string()), + self.tos_page.clone().unwrap_or("None".to_string()), + self.correspondence_email.clone().unwrap_or("None".to_string()), + self.correspondence_user_id.clone().unwrap_or("None".to_string()), + self.image.clone().unwrap_or("None".to_string()), + self.instance_id.clone().unwrap_or("None".to_string()), + ) + } +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct ErrorResponse { + pub code: i32, + pub message: String, + pub errors: IntermittentError, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct IntermittentError { + #[serde(flatten)] + pub errors: std::collections::HashMap, +} + +#[derive(Serialize, Deserialize, Debug, Default)] +pub struct ErrorField { + #[serde(default)] + pub _errors: Vec, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct Error { + pub message: String, + pub code: String, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct UserObject { + id: String, + username: String, + discriminator: String, + avatar: Option, + bot: Option, + system: Option, + mfa_enabled: Option, + banner: Option, + accent_color: Option, + locale: String, + verified: Option, + email: Option, + flags: i8, + premium_type: Option, + public_flags: Option, +} + +#[derive(Debug)] +pub struct User { + logged_in: bool, + belongs_to: URLBundle, + token: String, + rate_limits: Limits, + pub settings: UserSettings, + pub object: UserObject, +} + +impl User { + pub fn is_logged_in(&self) -> bool { + if self.logged_in == true { + true + } else { + false + } + } + + pub fn belongs_to(&self) -> URLBundle { + return self.belongs_to.clone(); + } + + pub fn token(&self) -> String { + return self.token.clone(); + } + + pub fn set_logged_in(&mut self, bool: bool) { + self.logged_in = bool; + } + + pub fn set_token(&mut self, token: String) { + self.token = token; + } + + pub fn new( + logged_in: bool, + belongs_to: URLBundle, + token: String, + rate_limits: Limits, + settings: UserSettings, + object: UserObject, + ) -> User { + User { + logged_in, + belongs_to, + token, + rate_limits, + settings, + object, + } + } +} diff --git a/src/instance.rs b/src/instance.rs index d606b42..7f2bb9e 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -1,5 +1,5 @@ -use crate::api::limits::{Limit, LimitType, Limits}; -use crate::api::schemas::schemas::{InstancePoliciesSchema, User}; +use crate::api::limits::Limits; +use crate::api::types::{InstancePolicies, User}; use crate::errors::{FieldFormatError, InstanceServerError}; use crate::limit::LimitedRequester; use crate::URLBundle; @@ -13,7 +13,7 @@ The [`Instance`] what you will be using to perform all sorts of actions on the S */ pub struct Instance { pub urls: URLBundle, - pub instance_info: InstancePoliciesSchema, + pub instance_info: InstancePolicies, pub requester: LimitedRequester, pub limits: Limits, //pub gateway: Gateway, @@ -34,7 +34,7 @@ impl Instance { let users: HashMap = HashMap::new(); let mut instance = Instance { urls: urls.clone(), - instance_info: InstancePoliciesSchema::new( + instance_info: InstancePolicies::new( // This is okay, because the instance_info will be overwritten by the instance_policies_schema() function. "".to_string(), None,