diff --git a/Cargo.toml b/Cargo.toml index 16a62e2..8346775 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "splits-io-api" -version = "0.3.0" +version = "0.3.1" authors = ["Christopher Serr "] edition = "2021" documentation = "https://docs.rs/splits-io-api/" @@ -21,22 +21,23 @@ include = [ [dependencies] http = "0.2.0" -serde = { version = "1.0.99", features = ["derive"] } -serde_json = "1.0.40" +serde = "1.0.189" +serde_derive = "1.0.189" +serde_json = "1.0.107" snafu = { version = "0.7.1", default-features = false, features = ["std"] } url = "2.1.0" uuid = { version = "1.1.2", default-features = false, features = ["serde"] } -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +[target.'cfg(not(target_family = "wasm"))'.dependencies] hyper = { version = "0.14.1", default-features = false, features = ["tcp", "client", "http2"] } -[target.'cfg(all(any(target_os = "linux", target_family = "windows", target_os = "macos"), any(target_arch = "x86", target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64")))'.dependencies] -hyper-rustls = { version = "0.23.0", default-features = false, features = ["native-tokio", "http2", "tls12"] } +[target.'cfg(all(any(target_os = "linux", target_family = "windows", target_os = "macos"), any(target_arch = "arm", target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64", target_arch = "loongarch64", all(target_arch = "mips", target_endian = "little"), all(target_arch = "mips64", target_endian = "little"), all(target_arch = "powerpc", target_endian = "big"), target_arch = "powerpc64", target_arch = "riscv64", target_arch = "s390x")))'.dependencies] +hyper-rustls = { version = "0.24.1", default-features = false, features = ["native-tokio", "http2", "tls12"] } -[target.'cfg(all(not(target_arch = "wasm32"), not(all(any(target_os = "linux", target_family = "windows", target_os = "macos"), any(target_arch = "x86", target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64")))))'.dependencies] +[target.'cfg(all(not(target_family = "wasm"), not(all(any(target_os = "linux", target_family = "windows", target_os = "macos"), any(target_arch = "arm", target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64", target_arch = "loongarch64", all(target_arch = "mips", target_endian = "little"), all(target_arch = "mips64", target_endian = "little"), all(target_arch = "powerpc", target_endian = "big"), target_arch = "powerpc64", target_arch = "riscv64", target_arch = "s390x")))))'.dependencies] hyper-tls = "0.5.0" -[target.'cfg(target_arch = "wasm32")'.dependencies] +[target.'cfg(target_family = "wasm")'.dependencies] js-sys = "0.3.31" wasm-bindgen = "0.2.51" wasm-bindgen-futures = "0.4.4" diff --git a/src/lib.rs b/src/lib.rs index 183167e..908751c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -178,7 +178,7 @@ async fn get_json( serde_json::from_reader(reader).context(JsonSnafu) } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] struct ApiError { #[serde(alias = "message")] error: Box, diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 44a654d..900f929 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -1,9 +1,9 @@ -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] mod native; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(target_family = "wasm"))] pub use self::native::*; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] mod wasm; -#[cfg(target_arch = "wasm32")] +#[cfg(target_family = "wasm")] pub use self::wasm::*; diff --git a/src/platform/native.rs b/src/platform/native.rs index 84b95f8..d0f375b 100644 --- a/src/platform/native.rs +++ b/src/platform/native.rs @@ -4,20 +4,34 @@ use hyper::body::Buf; #[cfg(all( any(target_os = "linux", target_family = "windows", target_os = "macos"), any( - target_arch = "x86", - target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "loongarch64", + all(target_arch = "mips", target_endian = "little"), + all(target_arch = "mips64", target_endian = "little"), + all(target_arch = "powerpc", target_endian = "big"), + target_arch = "powerpc64", + target_arch = "riscv64", + target_arch = "s390x", ), ))] use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder}; #[cfg(not(all( any(target_os = "linux", target_family = "windows", target_os = "macos"), any( - target_arch = "x86", - target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "loongarch64", + all(target_arch = "mips", target_endian = "little"), + all(target_arch = "mips64", target_endian = "little"), + all(target_arch = "powerpc", target_endian = "big"), + target_arch = "powerpc64", + target_arch = "riscv64", + target_arch = "s390x", ), )))] use hyper_tls::HttpsConnector; @@ -42,10 +56,17 @@ impl Client { #[cfg(all( any(target_os = "linux", target_family = "windows", target_os = "macos"), any( - target_arch = "x86", - target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "loongarch64", + all(target_arch = "mips", target_endian = "little"), + all(target_arch = "mips64", target_endian = "little"), + all(target_arch = "powerpc", target_endian = "big"), + target_arch = "powerpc64", + target_arch = "riscv64", + target_arch = "s390x", ), ))] let https = HttpsConnectorBuilder::new() @@ -56,10 +77,17 @@ impl Client { #[cfg(not(all( any(target_os = "linux", target_family = "windows", target_os = "macos"), any( - target_arch = "x86", - target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "loongarch64", + all(target_arch = "mips", target_endian = "little"), + all(target_arch = "mips64", target_endian = "little"), + all(target_arch = "powerpc", target_endian = "big"), + target_arch = "powerpc64", + target_arch = "riscv64", + target_arch = "s390x", ), )))] let https = HttpsConnector::new(); diff --git a/src/race.rs b/src/race.rs index 4b813f5..69117a5 100644 --- a/src/race.rs +++ b/src/race.rs @@ -159,7 +159,7 @@ pub async fn get(client: &Client, id: Uuid) -> Result { } /// The settings for a Race. -#[derive(Default, serde::Serialize)] +#[derive(Default, serde_derive::Serialize)] pub struct Settings<'a> { /// The ID of the Game that is being raced. #[serde(skip_serializing_if = "Option::is_none")] @@ -176,8 +176,10 @@ pub struct Settings<'a> { } /// The type of update to perform on the given property. +#[derive(Default)] pub enum Update { /// Keep the previous value of the property. + #[default] Keep, /// Clear the value of the property. Clear, @@ -191,12 +193,6 @@ impl Update { } } -impl Default for Update { - fn default() -> Self { - Update::Keep - } -} - impl serde::Serialize for Update { fn serialize(&self, serializer: S) -> Result where @@ -210,7 +206,7 @@ impl serde::Serialize for Update { } /// The new properties to use for a Race when performing an update. -#[derive(Default, serde::Serialize)] +#[derive(Default, serde_derive::Serialize)] pub struct UpdateSettings<'a> { /// The update to perform for the ID of the Game that is being raced. #[serde(skip_serializing_if = "Update::is_keep")] @@ -305,7 +301,7 @@ pub enum JoinAs<'a> { Ghost(&'a str), } -#[derive(serde::Serialize)] +#[derive(serde_derive::Serialize)] struct JoinToken<'a> { #[serde(skip_serializing_if = "Option::is_none")] join_token: Option<&'a str>, @@ -313,7 +309,7 @@ struct JoinToken<'a> { entry: Option>, } -#[derive(serde::Serialize)] +#[derive(serde_derive::Serialize)] struct JoinEntry<'a> { run_id: &'a str, } @@ -376,22 +372,22 @@ pub async fn leave(client: &Client, race_id: Uuid, entry_id: Uuid) -> Result<(), Ok(()) } -#[derive(serde::Serialize)] +#[derive(serde_derive::Serialize)] struct UpdateEntry { entry: T, } -#[derive(serde::Serialize)] +#[derive(serde_derive::Serialize)] struct ReadyState { readied_at: Option<&'static str>, } -#[derive(serde::Serialize)] +#[derive(serde_derive::Serialize)] struct FinishState { finished_at: Option<&'static str>, } -#[derive(serde::Serialize)] +#[derive(serde_derive::Serialize)] struct ForfeitState { forfeited_at: Option<&'static str>, } @@ -599,12 +595,12 @@ pub async fn get_chat(client: &Client, id: Uuid) -> Result, Err Ok(chat_messages) } -#[derive(serde::Serialize)] +#[derive(serde_derive::Serialize)] struct SendMessage<'a> { chat_message: SendMessageBody<'a>, } -#[derive(serde::Serialize)] +#[derive(serde_derive::Serialize)] struct SendMessageBody<'a> { body: &'a str, } diff --git a/src/run.rs b/src/run.rs index 66c411c..70a230a 100644 --- a/src/run.rs +++ b/src/run.rs @@ -91,20 +91,20 @@ pub async fn get(client: &Client, id: &str, historic: bool) -> Result, claim_token: Box, presigned_request: PresignedRequest, } -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] struct PresignedRequest { uri: Box, fields: PresignedRequestFields, } -#[derive(Debug, serde::Deserialize, serde::Serialize)] +#[derive(Debug, serde_derive::Deserialize, serde_derive::Serialize)] struct PresignedRequestFields { key: Box, policy: Box, diff --git a/src/schema.rs b/src/schema.rs index 89ffefb..a14a67d 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -3,7 +3,7 @@ use uuid::Uuid; /// A Category is a ruleset for a Game (Any%, 100%, MST, etc.) and an optional container for Runs. /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#category) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct Category { /// The time and date at which this category was created on Splits.io. This field conforms to /// ISO 8601. @@ -20,7 +20,7 @@ pub struct Category { /// A Chat Message is a shortform message sent by a user to a Race /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#chat-message) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct ChatMessage { /// The contents of the message. pub body: Box, @@ -39,7 +39,7 @@ pub struct ChatMessage { /// An Entry represents a Runner's participation in a Race or a ghost of a past Run. /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#entry) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct Entry { /// The time and date at which this Entry was created on Splits.io. This field conforms to ISO /// 8601. @@ -77,7 +77,7 @@ pub struct Entry { /// A Game is a collection of information about a game, and a container for Categories. /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#game) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct Game { /// The known speedrun categories for this game. pub categories: Option>, @@ -100,7 +100,7 @@ pub struct Game { /// Information about a past attempt associated with a Run. /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#history) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct RunItemHistories { /// The corresponding attempt number this attempt was. pub attempt_number: u32, @@ -113,7 +113,7 @@ pub struct RunItemHistories { /// A Run maps 1:1 to an uploaded splits file. /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#run) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct Run { /// The number of run attempts recorded by the timer that generated the run's source file, if /// supported by the source timer. @@ -178,7 +178,7 @@ pub struct Run { /// A Runner is a user who has at least one run tied to their account. /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#runner) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct Runner { /// The avatar of the user. #[serde(default)] @@ -204,7 +204,7 @@ pub struct Runner { /// Information about a past attempt of a segment. /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#history) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct SegmentItemHistories { /// The corresponding attempt number this attempt was. pub attempt_number: u32, @@ -217,7 +217,7 @@ pub struct SegmentItemHistories { /// A Segment maps to a single piece of a run, also called a split. /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#segment) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct Segment { /// Gametime duration in milliseconds of the segment. #[serde(default)] @@ -284,7 +284,7 @@ pub struct Segment { /// A Race is a live competition between multiple Runners who share a start time for their run. /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#race) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct Race { /// Any attachments supplied by the race creator for the benefit of other entrants (e.g. for /// randomizers). @@ -324,7 +324,7 @@ pub struct Race { /// A file that is attached to a Race. /// /// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#attachment) -#[derive(Debug, serde::Deserialize)] +#[derive(Debug, serde_derive::Deserialize)] pub struct Attachment { /// The unique ID of the attachment. pub id: Uuid, @@ -337,7 +337,7 @@ pub struct Attachment { } /// The permission set for a Race. -#[derive(Copy, Clone, Debug, serde::Deserialize, serde::Serialize)] +#[derive(Copy, Clone, Debug, serde_derive::Deserialize, serde_derive::Serialize)] #[serde(rename_all = "snake_case")] pub enum Visibility { /// Anyone can join the race. diff --git a/src/wrapper.rs b/src/wrapper.rs index c9e52d0..93287f6 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -1,76 +1,76 @@ use crate::{Category, ChatMessage, Entry, Game, Race, Run, Runner}; -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsRun { pub run: Run, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsRunner { pub runner: Runner, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsGame { pub game: Game, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsCategory { pub category: Category, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsRace { pub race: Race, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsEntry { pub entry: Entry, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsChatMessage { pub chat_message: ChatMessage, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsRuns { pub runs: Vec, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsPBs { pub pbs: Vec, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsRunners { pub runners: Vec, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsGames { pub games: Vec, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsCategories { pub categories: Vec, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsRaces { pub races: Vec, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsEntries { pub entries: Vec, } -#[derive(serde::Deserialize)] +#[derive(serde_derive::Deserialize)] pub struct ContainsChatMessages { pub chat_messages: Vec, }