vrc/model/
assets.rs

1//! Avatars & worlds
2
3use serde::{Deserialize, Serialize};
4use strum::AsRefStr;
5use time::{OffsetDateTime, serde::rfc3339};
6use url::Url;
7
8/// If a world has been released publicly for example
9#[derive(
10	Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, AsRefStr,
11)]
12#[serde(rename_all = "lowercase")]
13pub enum ReleaseStatus {
14	/// Publicly released
15	Public,
16	/// Not released at all
17	Private,
18	/// Not findable but also not private
19	Hidden,
20}
21
22/// Information about what platform the unity package supports
23#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
24#[serde(rename_all = "camelCase")]
25pub struct UnityPackageSupports {
26	/// The platform that the package is for (`android` / `standalonewindows`)
27	pub platform: String,
28	/// The unity version
29	pub unity_version: String,
30}
31
32/// Information about an Unity package
33#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
34#[serde(rename_all = "camelCase")]
35pub struct UnityPackage {
36	/// The ID of the package
37	pub id: crate::id::UnityPackage,
38	#[serde(flatten)]
39	/// Which unity versions the package supports
40	pub supports: UnityPackageSupports,
41}
42
43/// Information about a VRC world
44#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
45#[serde(rename_all = "camelCase")]
46pub struct WorldData {
47	/// The ID of the world creator
48	pub author_id: crate::id::User,
49	/// The display name of the author
50	pub author_name: String,
51	/// How many players normally can fit into an instance of this world
52	pub capacity: u16,
53	/// When the world was initially uploaded
54	#[serde(rename = "created_at", with = "rfc3339")]
55	pub created_at: OffsetDateTime,
56	/// How many times the world has been added to favorites
57	pub favorites: u64,
58	/// How trending the world is
59	pub heat: u32,
60	/// The ID of the world
61	pub id: crate::id::World,
62	/// An image for displaying the world
63	pub image_url: Url,
64	/// When the world was published to labs
65	#[serde(
66		default,
67		deserialize_with = "crate::deserialize_optional_date",
68		serialize_with = "rfc3339::option::serialize"
69	)]
70	pub labs_publication_date: Option<OffsetDateTime>,
71	/// The name of the world
72	pub name: String,
73	/// How many users are in instances of the world
74	pub occupants: u32,
75	/// Seems to always be `vrchat`
76	pub organization: String,
77	/// How popular the world is
78	pub popularity: u32,
79	/// A `YouTube` ID that's supposed to be used for a preview of the world
80	///
81	/// Many creators seem to use random videos here though
82	// If fails, need serde_with none on null
83	#[serde(default)]
84	pub preview_youtube_id: Option<String>,
85	/// When the world was published
86	#[serde(
87		default,
88		deserialize_with = "crate::deserialize_optional_date",
89		serialize_with = "rfc3339::option::serialize"
90	)]
91	pub publication_date: Option<OffsetDateTime>,
92	/// The release status of the world
93	pub release_status: ReleaseStatus,
94	/// The tags of the world
95	pub tags: Vec<String>,
96	/// A preview image of the world
97	pub thumbnail_image_url: Url,
98	/// When the world was last updated
99	#[serde(rename = "updated_at", with = "rfc3339")]
100	pub updated_at: OffsetDateTime,
101	/// How many times the world has been visited total
102	pub visits: u64,
103}
104
105/// Limited information about a world
106#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
107#[serde(rename_all = "camelCase")]
108pub struct WorldListing {
109	/// Base world data
110	#[serde(flatten)]
111	pub base: WorldData,
112	/// Minimal listing of unity packages support
113	pub unity_packages: Vec<UnityPackageSupports>,
114}
115
116/// Extended information about a world
117#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
118#[serde(rename_all = "camelCase")]
119pub struct World {
120	/// Base world data
121	#[serde(flatten)]
122	pub base: WorldData,
123	/// If the world is featured or not
124	pub featured: bool,
125	/// List of instances
126	pub instances: Vec<(crate::id::Instance, u16)>,
127	/// How many users are in private sessions of the world
128	pub private_occupants: u32,
129	/// How many users are in public sessions of the world
130	pub public_occupants: u32,
131	/// Listing of unity packages support
132	pub unity_packages: Vec<UnityPackage>,
133	/// The incrementing version of the world
134	pub version: u32,
135}
136
137/// Information about a VRC avatar
138#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
139#[serde(rename_all = "camelCase")]
140pub struct Avatar {
141	// TODO: Model
142	/// The ID of the avatar
143	pub id: crate::id::Avatar,
144}