From f46a0d8150592bae3a4073f3f48bc637a1a08215 Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Sat, 27 Jul 2024 01:09:02 +0200 Subject: [PATCH] Avoid boxing Signed-off-by: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> --- docs/Group.md | 4 ++-- docs/UserExists.md | 1 + examples/online.rs | 20 +++++++++++++++----- generate.sh | 2 +- src/models/api_config.rs | 8 ++++---- src/models/avatar.rs | 4 ++-- src/models/current_user.rs | 2 +- src/models/error.rs | 2 +- src/models/file_version.rs | 6 +++--- src/models/group.rs | 6 +++--- src/models/group_instance.rs | 4 ++-- src/models/group_member.rs | 2 +- src/models/group_my_member.rs | 8 ++++---- src/models/info_push.rs | 4 ++-- src/models/info_push_data.rs | 6 +++--- src/models/info_push_data_article.rs | 2 +- src/models/info_push_data_article_content.rs | 2 +- src/models/instance.rs | 8 ++++---- src/models/success.rs | 2 +- src/models/transaction.rs | 8 ++++---- src/models/transaction_steam_info.rs | 4 ++-- src/models/user_exists.rs | 6 +++++- 22 files changed, 63 insertions(+), 48 deletions(-) diff --git a/docs/Group.md b/docs/Group.md index 2d93040..7f2859b 100644 --- a/docs/Group.md +++ b/docs/Group.md @@ -22,9 +22,9 @@ Name | Type | Description | Notes **member_count_synced_at** | Option<**String**> | | [optional] **is_verified** | Option<**bool**> | | [optional][default to false] **join_state** | Option<[**models::GroupJoinState**](GroupJoinState.md)> | | [optional] -**tags** | Option<**Vec**> | | [optional] +**tags** | Option<**Vec**> | | [optional] **transfer_target_id** | Option<**String**> | A users unique ID, usually in the form of `usr_c1644b5b-3ca4-45b4-97c6-a2a0de70d469`. Legacy players can have old IDs in the form of `8JoV9XEdpo`. The ID can never be changed. | [optional] -**galleries** | Option<[**Vec**](GroupGallery.md)> | | [optional] +**galleries** | Option<[**Vec**](GroupGallery.md)> | | [optional] **created_at** | Option<**String**> | | [optional] **updated_at** | Option<**String**> | | [optional] **last_post_created_at** | Option<**String**> | | [optional] diff --git a/docs/UserExists.md b/docs/UserExists.md index 17b947c..62fd89f 100644 --- a/docs/UserExists.md +++ b/docs/UserExists.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **user_exists** | **bool** | Status if a user exist with that username or userId. | [default to false] +**name_ok** | **bool** | Is the username valid? | [default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/examples/online.rs b/examples/online.rs index 387bcfb..0a1ad52 100644 --- a/examples/online.rs +++ b/examples/online.rs @@ -5,11 +5,21 @@ async fn main() { let mut config = apis::configuration::Configuration::default(); config.basic_auth = Some((String::from("username"), Some(String::from("password")))); - match apis::authentication_api::get_current_user(&config).await.unwrap() { - vrchatapi::models::EitherUserOrTwoFactor::CurrentUser(me) => println!("Username: {}", me.username.unwrap()), - vrchatapi::models::EitherUserOrTwoFactor::RequiresTwoFactorAuth(requires_auth) => println!("The Username requires Auth: {:?}", requires_auth.requires_two_factor_auth) + match apis::authentication_api::get_current_user(&config) + .await + .unwrap() + { + vrchatapi::models::EitherUserOrTwoFactor::CurrentUser(me) => { + println!("Username: {}", me.username.unwrap()) + } + vrchatapi::models::EitherUserOrTwoFactor::RequiresTwoFactorAuth(requires_auth) => println!( + "The Username requires Auth: {:?}", + requires_auth.requires_two_factor_auth + ), } - let online = apis::system_api::get_current_online_users(&config).await.unwrap(); + let online = apis::system_api::get_current_online_users(&config) + .await + .unwrap(); println!("Current Online Users: {}", online); -} \ No newline at end of file +} diff --git a/generate.sh b/generate.sh index b11be0f..71b49f7 100755 --- a/generate.sh +++ b/generate.sh @@ -5,7 +5,7 @@ rm src/apis src/models docs -rf ./node_modules/\@openapitools/openapi-generator-cli/main.js generate \ -g rust \ ---additional-properties=packageName=vrchatapi,supportAsync=true \ +--additional-properties=packageName=vrchatapi,supportAsync=true,avoidBoxedModels=true \ --git-user-id=vrchatapi \ --git-repo-id=vrchatapi-rust \ -o . \ diff --git a/src/models/api_config.rs b/src/models/api_config.rs index 6cfd2b5..ee49961 100644 --- a/src/models/api_config.rs +++ b/src/models/api_config.rs @@ -164,7 +164,7 @@ pub struct ApiConfig { #[serde(rename = "downloadLinkWindows")] pub download_link_windows: String, #[serde(rename = "downloadUrls")] - pub download_urls: Box, + pub download_urls: models::ApiConfigDownloadUrlList, /// Array of DynamicWorldRow objects, used by the game to display the list of world rows #[serde(rename = "dynamicWorldRows")] pub dynamic_world_rows: Vec, @@ -178,7 +178,7 @@ pub struct ApiConfig { #[serde(rename = "economyState", skip_serializing_if = "Option::is_none")] pub economy_state: Option, #[serde(rename = "events")] - pub events: Box, + pub events: models::ApiConfigEvents, /// WorldID be \"offline\" on User profiles if you are not friends with that user. #[serde(rename = "homeWorldId")] pub home_world_id: String, @@ -316,12 +316,12 @@ impl ApiConfig { disable_udon, disable_upgrade_account, download_link_windows, - download_urls: Box::new(download_urls), + download_urls, dynamic_world_rows, economy_pause_end: None, economy_pause_start: None, economy_state: None, - events: Box::new(events), + events, home_world_id, homepage_redirect_target, hub_world_id, diff --git a/src/models/avatar.rs b/src/models/avatar.rs index 77f35e0..4e07378 100644 --- a/src/models/avatar.rs +++ b/src/models/avatar.rs @@ -44,7 +44,7 @@ pub struct Avatar { #[serde(rename = "unityPackageUrl")] pub unity_package_url: String, #[serde(rename = "unityPackageUrlObject")] - pub unity_package_url_object: Box, + pub unity_package_url_object: models::AvatarUnityPackageUrlObject, #[serde(rename = "unityPackages")] pub unity_packages: Vec, #[serde(rename = "updated_at")] @@ -70,7 +70,7 @@ impl Avatar { tags, thumbnail_image_url, unity_package_url, - unity_package_url_object: Box::new(unity_package_url_object), + unity_package_url_object, unity_packages, updated_at, version, diff --git a/src/models/current_user.rs b/src/models/current_user.rs index c3b8668..80b8846 100644 --- a/src/models/current_user.rs +++ b/src/models/current_user.rs @@ -112,7 +112,7 @@ pub struct CurrentUser { #[serde(rename = "pastDisplayNames")] pub past_display_names: Vec, #[serde(rename = "presence", skip_serializing_if = "Option::is_none")] - pub presence: Option>, + pub presence: Option, #[serde(rename = "profilePicOverride")] pub profile_pic_override: String, #[serde(rename = "profilePicOverrideThumbnail")] diff --git a/src/models/error.rs b/src/models/error.rs index 7612690..07cf8d4 100644 --- a/src/models/error.rs +++ b/src/models/error.rs @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Error { #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option>, + pub error: Option, } impl Error { diff --git a/src/models/file_version.rs b/src/models/file_version.rs index befc3e0..0177d24 100644 --- a/src/models/file_version.rs +++ b/src/models/file_version.rs @@ -18,11 +18,11 @@ pub struct FileVersion { #[serde(rename = "deleted", skip_serializing_if = "Option::is_none")] pub deleted: Option, #[serde(rename = "delta", skip_serializing_if = "Option::is_none")] - pub delta: Option>, + pub delta: Option, #[serde(rename = "file", skip_serializing_if = "Option::is_none")] - pub file: Option>, + pub file: Option, #[serde(rename = "signature", skip_serializing_if = "Option::is_none")] - pub signature: Option>, + pub signature: Option, #[serde(rename = "status")] pub status: models::FileStatus, /// Incremental version counter, can only be increased. diff --git a/src/models/group.rs b/src/models/group.rs index 3b94caa..094e340 100644 --- a/src/models/group.rs +++ b/src/models/group.rs @@ -59,14 +59,14 @@ pub struct Group { pub created_at: Option, #[serde(rename = "updatedAt", skip_serializing_if = "Option::is_none")] pub updated_at: Option, - #[serde(rename = "lastPostCreatedAt", skip_serializing_if = "Option::is_none")] - pub last_post_created_at: Option, + #[serde(rename = "lastPostCreatedAt", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub last_post_created_at: Option>, #[serde(rename = "onlineMemberCount", skip_serializing_if = "Option::is_none")] pub online_member_count: Option, #[serde(rename = "membershipStatus", skip_serializing_if = "Option::is_none")] pub membership_status: Option, #[serde(rename = "myMember", skip_serializing_if = "Option::is_none")] - pub my_member: Option>, + pub my_member: Option, /// Only returned if ?includeRoles=true is specified. #[serde(rename = "roles", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] pub roles: Option>>, diff --git a/src/models/group_instance.rs b/src/models/group_instance.rs index a983594..1776155 100644 --- a/src/models/group_instance.rs +++ b/src/models/group_instance.rs @@ -17,7 +17,7 @@ pub struct GroupInstance { #[serde(rename = "location")] pub location: String, #[serde(rename = "world")] - pub world: Box, + pub world: models::World, #[serde(rename = "memberCount")] pub member_count: i32, } @@ -27,7 +27,7 @@ impl GroupInstance { GroupInstance { instance_id, location, - world: Box::new(world), + world, member_count, } } diff --git a/src/models/group_member.rs b/src/models/group_member.rs index 6ef8489..e44305d 100644 --- a/src/models/group_member.rs +++ b/src/models/group_member.rs @@ -22,7 +22,7 @@ pub struct GroupMember { #[serde(rename = "isRepresenting", skip_serializing_if = "Option::is_none")] pub is_representing: Option, #[serde(rename = "user", skip_serializing_if = "Option::is_none")] - pub user: Option>, + pub user: Option, #[serde(rename = "roleIds", skip_serializing_if = "Option::is_none")] pub role_ids: Option>, #[serde(rename = "mRoleIds", skip_serializing_if = "Option::is_none")] diff --git a/src/models/group_my_member.rs b/src/models/group_my_member.rs index 33ae2af..ab3a3c7 100644 --- a/src/models/group_my_member.rs +++ b/src/models/group_my_member.rs @@ -20,8 +20,8 @@ pub struct GroupMyMember { pub user_id: Option, #[serde(rename = "roleIds", skip_serializing_if = "Option::is_none")] pub role_ids: Option>, - #[serde(rename = "acceptedByDisplayName", skip_serializing_if = "Option::is_none")] - pub accepted_by_display_name: Option, + #[serde(rename = "acceptedByDisplayName", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub accepted_by_display_name: Option>, /// A users unique ID, usually in the form of `usr_c1644b5b-3ca4-45b4-97c6-a2a0de70d469`. Legacy players can have old IDs in the form of `8JoV9XEdpo`. The ID can never be changed. #[serde(rename = "acceptedById", skip_serializing_if = "Option::is_none")] pub accepted_by_id: Option, @@ -45,8 +45,8 @@ pub struct GroupMyMember { pub has2_fa: Option, #[serde(rename = "hasJoinedFromPurchase", skip_serializing_if = "Option::is_none")] pub has_joined_from_purchase: Option, - #[serde(rename = "lastPostReadAt", skip_serializing_if = "Option::is_none")] - pub last_post_read_at: Option, + #[serde(rename = "lastPostReadAt", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub last_post_read_at: Option>, #[serde(rename = "mRoleIds", skip_serializing_if = "Option::is_none")] pub m_role_ids: Option>, #[serde(rename = "permissions", skip_serializing_if = "Option::is_none")] diff --git a/src/models/info_push.rs b/src/models/info_push.rs index 4820756..fb1125b 100644 --- a/src/models/info_push.rs +++ b/src/models/info_push.rs @@ -23,7 +23,7 @@ pub struct InfoPush { #[serde(rename = "tags")] pub tags: Vec, #[serde(rename = "data")] - pub data: Box, + pub data: models::InfoPushData, /// Unknown usage, MD5 #[serde(rename = "hash")] pub hash: String, @@ -45,7 +45,7 @@ impl InfoPush { release_status, priority, tags, - data: Box::new(data), + data, hash, created_at, updated_at, diff --git a/src/models/info_push_data.rs b/src/models/info_push_data.rs index a1327b9..6fc629c 100644 --- a/src/models/info_push_data.rs +++ b/src/models/info_push_data.rs @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct InfoPushData { #[serde(rename = "contentList", skip_serializing_if = "Option::is_none")] - pub content_list: Option>, + pub content_list: Option, #[serde(rename = "description", skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "imageUrl", skip_serializing_if = "Option::is_none")] @@ -21,13 +21,13 @@ pub struct InfoPushData { #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, #[serde(rename = "onPressed", skip_serializing_if = "Option::is_none")] - pub on_pressed: Option>, + pub on_pressed: Option, #[serde(rename = "template", skip_serializing_if = "Option::is_none")] pub template: Option, #[serde(rename = "version", skip_serializing_if = "Option::is_none")] pub version: Option, #[serde(rename = "article", skip_serializing_if = "Option::is_none")] - pub article: Option>, + pub article: Option, } impl InfoPushData { diff --git a/src/models/info_push_data_article.rs b/src/models/info_push_data_article.rs index 0970fe1..0402ccd 100644 --- a/src/models/info_push_data_article.rs +++ b/src/models/info_push_data_article.rs @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct InfoPushDataArticle { #[serde(rename = "content", skip_serializing_if = "Option::is_none")] - pub content: Option>, + pub content: Option, } impl InfoPushDataArticle { diff --git a/src/models/info_push_data_article_content.rs b/src/models/info_push_data_article_content.rs index 1780437..815459d 100644 --- a/src/models/info_push_data_article_content.rs +++ b/src/models/info_push_data_article_content.rs @@ -16,7 +16,7 @@ pub struct InfoPushDataArticleContent { #[serde(rename = "imageUrl", skip_serializing_if = "Option::is_none")] pub image_url: Option, #[serde(rename = "onPressed", skip_serializing_if = "Option::is_none")] - pub on_pressed: Option>, + pub on_pressed: Option, } impl InfoPushDataArticleContent { diff --git a/src/models/instance.rs b/src/models/instance.rs index 4e4e107..3003b7b 100644 --- a/src/models/instance.rs +++ b/src/models/instance.rs @@ -43,7 +43,7 @@ pub struct Instance { #[serde(rename = "photonRegion")] pub photon_region: models::Region, #[serde(rename = "platforms")] - pub platforms: Box, + pub platforms: models::InstancePlatforms, #[serde(rename = "region")] pub region: models::InstanceRegion, #[serde(rename = "secureName")] @@ -80,7 +80,7 @@ pub struct Instance { #[serde(rename = "userCount")] pub user_count: i32, #[serde(rename = "world")] - pub world: Box, + pub world: models::World, /// The users field is present on instances created by the requesting user. #[serde(rename = "users", skip_serializing_if = "Option::is_none")] pub users: Option>, @@ -113,7 +113,7 @@ impl Instance { owner_id: None, permanent, photon_region, - platforms: Box::new(platforms), + platforms, region, secure_name, short_name: None, @@ -129,7 +129,7 @@ impl Instance { role_restricted: None, strict, user_count, - world: Box::new(world), + world, users: None, group_access_type: None, has_capacity_for_you: None, diff --git a/src/models/success.rs b/src/models/success.rs index 4e52df7..4335a4a 100644 --- a/src/models/success.rs +++ b/src/models/success.rs @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Success { #[serde(rename = "success", skip_serializing_if = "Option::is_none")] - pub success: Option>, + pub success: Option, } impl Success { diff --git a/src/models/transaction.rs b/src/models/transaction.rs index 8ea976e..23fa7e6 100644 --- a/src/models/transaction.rs +++ b/src/models/transaction.rs @@ -22,7 +22,7 @@ pub struct Transaction { #[serde(rename = "status")] pub status: models::TransactionStatus, #[serde(rename = "subscription")] - pub subscription: Box, + pub subscription: models::Subscription, #[serde(rename = "sandbox")] pub sandbox: bool, #[serde(rename = "created_at")] @@ -30,9 +30,9 @@ pub struct Transaction { #[serde(rename = "updated_at")] pub updated_at: String, #[serde(rename = "steam", skip_serializing_if = "Option::is_none")] - pub steam: Option>, + pub steam: Option, #[serde(rename = "agreement", skip_serializing_if = "Option::is_none")] - pub agreement: Option>, + pub agreement: Option, #[serde(rename = "error")] pub error: String, #[serde(rename = "isGift", skip_serializing_if = "Option::is_none")] @@ -48,7 +48,7 @@ impl Transaction { user_id: None, user_display_name: None, status, - subscription: Box::new(subscription), + subscription, sandbox, created_at, updated_at, diff --git a/src/models/transaction_steam_info.rs b/src/models/transaction_steam_info.rs index 8ef17cd..6468f61 100644 --- a/src/models/transaction_steam_info.rs +++ b/src/models/transaction_steam_info.rs @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct TransactionSteamInfo { #[serde(rename = "walletInfo")] - pub wallet_info: Box, + pub wallet_info: models::TransactionSteamWalletInfo, /// Steam User ID #[serde(rename = "steamId")] pub steam_id: String, @@ -31,7 +31,7 @@ pub struct TransactionSteamInfo { impl TransactionSteamInfo { pub fn new(wallet_info: models::TransactionSteamWalletInfo, steam_id: String, order_id: String, steam_url: String, trans_id: String) -> TransactionSteamInfo { TransactionSteamInfo { - wallet_info: Box::new(wallet_info), + wallet_info, steam_id, order_id, steam_url, diff --git a/src/models/user_exists.rs b/src/models/user_exists.rs index b1675a9..017b7e7 100644 --- a/src/models/user_exists.rs +++ b/src/models/user_exists.rs @@ -15,13 +15,17 @@ pub struct UserExists { /// Status if a user exist with that username or userId. #[serde(rename = "userExists")] pub user_exists: bool, + /// Is the username valid? + #[serde(rename = "nameOk")] + pub name_ok: bool, } impl UserExists { /// Status object representing if a queried user by username or userId exists or not. This model is primarily used by the `/auth/exists` endpoint, which in turn is used during registration. Please see the documentation on that endpoint for more information on usage. - pub fn new(user_exists: bool) -> UserExists { + pub fn new(user_exists: bool, name_ok: bool) -> UserExists { UserExists { user_exists, + name_ok, } } }