diff --git a/build/build-sdk-images/rust/Dockerfile b/build/build-sdk-images/rust/Dockerfile index 80e7ccf3ee..9a3303ef1a 100644 --- a/build/build-sdk-images/rust/Dockerfile +++ b/build/build-sdk-images/rust/Dockerfile @@ -22,7 +22,7 @@ RUN apt-get update && \ ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=1.43.1 + RUST_VERSION=1.45.0 ENV RUST_ARCH=x86_64-unknown-linux-gnu \ RUSTUP_SHA256=c9837990bce0faab4f6f52604311a19bb8d2cde989bea6a7b605c8e526db6f02 RUN wget -q https://static.rust-lang.org/rustup/archive/1.11.0/${RUST_ARCH}/rustup-init && \ @@ -35,8 +35,8 @@ RUN wget -q https://static.rust-lang.org/rustup/archive/1.11.0/${RUST_ARCH}/rust rustc --version; # install rust tooling for SDK generation -RUN cargo install protobuf-codegen --vers 2.0.2 -RUN cargo install grpcio-compiler --vers 0.3.0 +RUN cargo install protobuf-codegen --vers 2.16.2 +RUN cargo install grpcio-compiler --vers 0.6.0 RUN wget -q https://cmake.org/files/v3.14/cmake-3.14.1-Linux-x86_64.sh RUN mkdir /opt/cmake diff --git a/build/includes/sdk.mk b/build/includes/sdk.mk index b26215b4b6..e0f4dcc5b6 100644 --- a/build/includes/sdk.mk +++ b/build/includes/sdk.mk @@ -167,8 +167,12 @@ run-sdk-conformance-test-go: run-sdk-conformance-test-rust: # run without feature flags $(MAKE) run-sdk-conformance-test SDK_FOLDER=rust GRPC_PORT=9004 HTTP_PORT=9104 + # run without feature flags and with RUN_ASYNC=true + DOCKER_RUN_ARGS="$(DOCKER_RUN_ARGS) -e RUN_ASYNC=true" $(MAKE) run-sdk-conformance-test SDK_FOLDER=rust GRPC_PORT=9004 HTTP_PORT=9104 # run with feature flags enabled $(MAKE) run-sdk-conformance-test SDK_FOLDER=rust GRPC_PORT=9004 HTTP_PORT=9104 FEATURE_GATES=PlayerTracking=true TESTS=$(DEFAULT_CONFORMANCE_TESTS),$(ALPHA_CONFORMANCE_TESTS) + # run with feature flags enabled and with RUN_ASYNC=true + DOCKER_RUN_ARGS="$(DOCKER_RUN_ARGS) -e RUN_ASYNC=true" $(MAKE) run-sdk-conformance-test SDK_FOLDER=rust GRPC_PORT=9004 HTTP_PORT=9104 FEATURE_GATES=PlayerTracking=true TESTS=$(DEFAULT_CONFORMANCE_TESTS),$(ALPHA_CONFORMANCE_TESTS) run-sdk-conformance-test-rest: # run without feature flags diff --git a/sdks/rust/Cargo.toml b/sdks/rust/Cargo.toml index ad3adb8125..c1f8de34f6 100644 --- a/sdks/rust/Cargo.toml +++ b/sdks/rust/Cargo.toml @@ -15,10 +15,15 @@ [package] name = "agones" version = "0.1.0" +edition = "2018" + +[features] +openssl = ["grpcio/openssl"] +openssl-vendored = ["grpcio/openssl-vendored"] [dependencies] -grpcio = "0.3.0" -grpcio-proto = "0.3.0" -protobuf = "2.0.2" -futures = "^0.1.15" -error-chain = "0.11.0" +grpcio = "0.6.0" +protobuf = "2.16.2" +futures = { version = "0.3", features = ["compat"] } +futures01 = "0.1" +error-chain = "0.12.3" diff --git a/sdks/rust/src/alpha.rs b/sdks/rust/src/alpha.rs index af9c68fd36..10f4c39dfd 100644 --- a/sdks/rust/src/alpha.rs +++ b/sdks/rust/src/alpha.rs @@ -16,9 +16,9 @@ use std::sync::Arc; use grpcio; -use errors::*; -use grpc::alpha; -use grpc::alpha_grpc; +use super::errors::*; +use super::grpc::alpha; +use super::grpc::alpha_grpc; /// Alpha is an instance of the Agones Alpha SDK pub struct Alpha { @@ -103,6 +103,101 @@ impl Alpha { .map(|pl| pl.list.into())?; Ok(res) } + + /// This returns the last player capacity that was set through the SDK. + /// If the player capacity is set from outside the SDK, use sdk.get_gameserver() instead. + pub async fn get_player_capacity_async(&self) -> Result { + let req = alpha::Empty::new(); + let count = self + .client + .get_player_capacity_async(&req)? + .await + .map(|c| c.count)?; + Ok(count) + } + + /// This changes the player capacity to a new value. + pub async fn set_player_capacity_async(&self, capacity: i64) -> Result<()> { + let mut c = alpha::Count::new(); + c.set_count(capacity); + let res = self + .client + .set_player_capacity_async(&c)? + .await + .map(|_| ())?; + Ok(res) + } + + /// This function increases the SDK’s stored player count by one, and appends this playerID to GameServer.status.players.ids. + /// Returns true and adds the playerID to the list of playerIDs if the playerIDs was not already in the list of connected playerIDs. + pub async fn player_connect_async(&self, id: S) -> Result + where + S: Into, + { + let mut p = alpha::PlayerID::new(); + p.set_playerID(id.into()); + let res = self + .client + .player_connect_async(&p)? + .await + .map(|b| b.bool)?; + Ok(res) + } + + /// This function decreases the SDK’s stored player count by one, and removes the playerID from GameServer.status.players.ids. + /// Will return true and remove the supplied playerID from the list of connected playerIDs if the playerID value exists within the list. + pub async fn player_disconnect_async(&self, id: S) -> Result + where + S: Into, + { + let mut p = alpha::PlayerID::new(); + p.set_playerID(id.into()); + let res = self + .client + .player_disconnect_async(&p)? + .await + .map(|b| b.bool)?; + Ok(res) + } + + /// Returns the current player count. + pub async fn get_player_count_async(&self) -> Result { + let req = alpha::Empty::new(); + let count = self + .client + .get_player_count_async(&req)? + .await + .map(|c| c.count)?; + Ok(count) + } + + /// This returns if the playerID is currently connected to the GameServer. + /// This is always accurate, even if the value hasn’t been updated to the GameServer status yet. + pub async fn is_player_connected_async(&self, id: S) -> Result + where + S: Into, + { + let mut p = alpha::PlayerID::new(); + p.set_playerID(id.into()); + let res = self + .client + .is_player_connected_async(&p)? + .await + .map(|b| b.bool)?; + Ok(res) + } + + /// This returns the list of the currently connected player ids. + /// This is always accurate, even if the value has not been updated to the Game Server status yet. + pub async fn get_connected_players_async(&self) -> Result> { + let req = alpha::Empty::new(); + let res = self + .client + .get_connected_players_async(&req)? + .await + .map(|pl| pl.list.into())?; + Ok(res) + } } impl Clone for Alpha { diff --git a/sdks/rust/src/grpc/alpha.rs b/sdks/rust/src/grpc/alpha.rs index 6c076f4ac7..d1ac1197ee 100644 --- a/sdks/rust/src/grpc/alpha.rs +++ b/sdks/rust/src/grpc/alpha.rs @@ -13,14 +13,15 @@ // limitations under the License. // This code was autogenerated. Do not edit directly. -// This file is generated by rust-protobuf 2.0.2. Do not edit +// This file is generated by rust-protobuf 2.16.2. Do not edit // @generated -// https://github.com/Manishearth/rust-clippy/issues/702 +// https://github.com/rust-lang/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] -#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_attributes)] +#![rustfmt::skip] #![allow(box_pointers)] #![allow(dead_code)] @@ -29,18 +30,25 @@ #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![allow(trivial_casts)] -#![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] +//! Generated file from `alpha.proto` -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; +/// Generated files are compatible only with the same version +/// of protobuf runtime. +// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_16_2; #[derive(PartialEq,Clone,Default)] pub struct Empty { // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Empty { + fn default() -> &'a Empty { + ::default_instance() + } } impl Empty { @@ -54,7 +62,7 @@ impl ::protobuf::Message for Empty { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -75,7 +83,7 @@ impl ::protobuf::Message for Empty { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -92,13 +100,13 @@ impl ::protobuf::Message for Empty { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -111,30 +119,20 @@ impl ::protobuf::Message for Empty { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let fields = ::std::vec::Vec::new(); - ::protobuf::reflect::MessageDescriptor::new::( - "Empty", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let fields = ::std::vec::Vec::new(); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Empty", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static Empty { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Empty, - }; - unsafe { - instance.get(Empty::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Empty::new) } } @@ -145,14 +143,14 @@ impl ::protobuf::Clear for Empty { } impl ::std::fmt::Debug for Empty { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Empty { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -161,8 +159,14 @@ pub struct Count { // message fields pub count: i64, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Count { + fn default() -> &'a Count { + ::default_instance() + } } impl Count { @@ -172,6 +176,10 @@ impl Count { // int64 count = 1; + + pub fn get_count(&self) -> i64 { + self.count + } pub fn clear_count(&mut self) { self.count = 0; } @@ -180,10 +188,6 @@ impl Count { pub fn set_count(&mut self, v: i64) { self.count = v; } - - pub fn get_count(&self) -> i64 { - self.count - } } impl ::protobuf::Message for Count { @@ -191,7 +195,7 @@ impl ::protobuf::Message for Count { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -222,7 +226,7 @@ impl ::protobuf::Message for Count { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if self.count != 0 { os.write_int64(1, self.count)?; } @@ -242,13 +246,13 @@ impl ::protobuf::Message for Count { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -261,54 +265,44 @@ impl ::protobuf::Message for Count { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( - "count", - |m: &Count| { &m.count }, - |m: &mut Count| { &mut m.count }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Count", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "count", + |m: &Count| { &m.count }, + |m: &mut Count| { &mut m.count }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Count", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static Count { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Count, - }; - unsafe { - instance.get(Count::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Count::new) } } impl ::protobuf::Clear for Count { fn clear(&mut self) { - self.clear_count(); + self.count = 0; self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Count { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Count { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -317,8 +311,14 @@ pub struct Bool { // message fields pub bool: bool, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Bool { + fn default() -> &'a Bool { + ::default_instance() + } } impl Bool { @@ -328,6 +328,10 @@ impl Bool { // bool bool = 1; + + pub fn get_bool(&self) -> bool { + self.bool + } pub fn clear_bool(&mut self) { self.bool = false; } @@ -336,10 +340,6 @@ impl Bool { pub fn set_bool(&mut self, v: bool) { self.bool = v; } - - pub fn get_bool(&self) -> bool { - self.bool - } } impl ::protobuf::Message for Bool { @@ -347,7 +347,7 @@ impl ::protobuf::Message for Bool { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -378,7 +378,7 @@ impl ::protobuf::Message for Bool { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if self.bool != false { os.write_bool(1, self.bool)?; } @@ -398,13 +398,13 @@ impl ::protobuf::Message for Bool { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -417,54 +417,44 @@ impl ::protobuf::Message for Bool { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>( - "bool", - |m: &Bool| { &m.bool }, - |m: &mut Bool| { &mut m.bool }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Bool", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "bool", + |m: &Bool| { &m.bool }, + |m: &mut Bool| { &mut m.bool }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Bool", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static Bool { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Bool, - }; - unsafe { - instance.get(Bool::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Bool::new) } } impl ::protobuf::Clear for Bool { fn clear(&mut self) { - self.clear_bool(); + self.bool = false; self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Bool { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Bool { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -473,8 +463,14 @@ pub struct PlayerID { // message fields pub playerID: ::std::string::String, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a PlayerID { + fn default() -> &'a PlayerID { + ::default_instance() + } } impl PlayerID { @@ -484,6 +480,10 @@ impl PlayerID { // string playerID = 1; + + pub fn get_playerID(&self) -> &str { + &self.playerID + } pub fn clear_playerID(&mut self) { self.playerID.clear(); } @@ -503,10 +503,6 @@ impl PlayerID { pub fn take_playerID(&mut self) -> ::std::string::String { ::std::mem::replace(&mut self.playerID, ::std::string::String::new()) } - - pub fn get_playerID(&self) -> &str { - &self.playerID - } } impl ::protobuf::Message for PlayerID { @@ -514,7 +510,7 @@ impl ::protobuf::Message for PlayerID { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -541,7 +537,7 @@ impl ::protobuf::Message for PlayerID { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if !self.playerID.is_empty() { os.write_string(1, &self.playerID)?; } @@ -561,13 +557,13 @@ impl ::protobuf::Message for PlayerID { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -580,54 +576,44 @@ impl ::protobuf::Message for PlayerID { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "playerID", - |m: &PlayerID| { &m.playerID }, - |m: &mut PlayerID| { &mut m.playerID }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "PlayerID", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "playerID", + |m: &PlayerID| { &m.playerID }, + |m: &mut PlayerID| { &mut m.playerID }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "PlayerID", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static PlayerID { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const PlayerID, - }; - unsafe { - instance.get(PlayerID::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(PlayerID::new) } } impl ::protobuf::Clear for PlayerID { fn clear(&mut self) { - self.clear_playerID(); + self.playerID.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for PlayerID { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for PlayerID { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -636,8 +622,14 @@ pub struct PlayerIDList { // message fields pub list: ::protobuf::RepeatedField<::std::string::String>, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a PlayerIDList { + fn default() -> &'a PlayerIDList { + ::default_instance() + } } impl PlayerIDList { @@ -647,6 +639,10 @@ impl PlayerIDList { // repeated string list = 1; + + pub fn get_list(&self) -> &[::std::string::String] { + &self.list + } pub fn clear_list(&mut self) { self.list.clear(); } @@ -665,10 +661,6 @@ impl PlayerIDList { pub fn take_list(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { ::std::mem::replace(&mut self.list, ::protobuf::RepeatedField::new()) } - - pub fn get_list(&self) -> &[::std::string::String] { - &self.list - } } impl ::protobuf::Message for PlayerIDList { @@ -676,7 +668,7 @@ impl ::protobuf::Message for PlayerIDList { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -703,7 +695,7 @@ impl ::protobuf::Message for PlayerIDList { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { for v in &self.list { os.write_string(1, &v)?; }; @@ -723,13 +715,13 @@ impl ::protobuf::Message for PlayerIDList { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -742,54 +734,44 @@ impl ::protobuf::Message for PlayerIDList { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "list", - |m: &PlayerIDList| { &m.list }, - |m: &mut PlayerIDList| { &mut m.list }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "PlayerIDList", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "list", + |m: &PlayerIDList| { &m.list }, + |m: &mut PlayerIDList| { &mut m.list }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "PlayerIDList", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static PlayerIDList { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const PlayerIDList, - }; - unsafe { - instance.get(PlayerIDList::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(PlayerIDList::new) } } impl ::protobuf::Clear for PlayerIDList { fn clear(&mut self) { - self.clear_list(); + self.list.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for PlayerIDList { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for PlayerIDList { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -956,19 +938,14 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \x04\x02\0\x03\x12\x04\x88\x01\x1b\x1cb\x06proto3\ "; -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; +static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() } pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) } diff --git a/sdks/rust/src/grpc/alpha_grpc.rs b/sdks/rust/src/grpc/alpha_grpc.rs index 78ff246e5e..ec73ce3261 100644 --- a/sdks/rust/src/grpc/alpha_grpc.rs +++ b/sdks/rust/src/grpc/alpha_grpc.rs @@ -18,7 +18,7 @@ // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] @@ -82,6 +82,7 @@ const METHOD_SDK_GET_CONNECTED_PLAYERS: ::grpcio::Method ::grpcio::Result<::grpcio::ClientUnaryReceiver> { self.get_connected_players_async_opt(req, ::grpcio::CallOption::default()) } - pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { + pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { self.client.spawn(f) } } pub trait Sdk { - fn player_connect(&self, ctx: ::grpcio::RpcContext, req: super::alpha::PlayerID, sink: ::grpcio::UnarySink); - fn player_disconnect(&self, ctx: ::grpcio::RpcContext, req: super::alpha::PlayerID, sink: ::grpcio::UnarySink); - fn set_player_capacity(&self, ctx: ::grpcio::RpcContext, req: super::alpha::Count, sink: ::grpcio::UnarySink); - fn get_player_capacity(&self, ctx: ::grpcio::RpcContext, req: super::alpha::Empty, sink: ::grpcio::UnarySink); - fn get_player_count(&self, ctx: ::grpcio::RpcContext, req: super::alpha::Empty, sink: ::grpcio::UnarySink); - fn is_player_connected(&self, ctx: ::grpcio::RpcContext, req: super::alpha::PlayerID, sink: ::grpcio::UnarySink); - fn get_connected_players(&self, ctx: ::grpcio::RpcContext, req: super::alpha::Empty, sink: ::grpcio::UnarySink); + fn player_connect(&mut self, ctx: ::grpcio::RpcContext, req: super::alpha::PlayerID, sink: ::grpcio::UnarySink); + fn player_disconnect(&mut self, ctx: ::grpcio::RpcContext, req: super::alpha::PlayerID, sink: ::grpcio::UnarySink); + fn set_player_capacity(&mut self, ctx: ::grpcio::RpcContext, req: super::alpha::Count, sink: ::grpcio::UnarySink); + fn get_player_capacity(&mut self, ctx: ::grpcio::RpcContext, req: super::alpha::Empty, sink: ::grpcio::UnarySink); + fn get_player_count(&mut self, ctx: ::grpcio::RpcContext, req: super::alpha::Empty, sink: ::grpcio::UnarySink); + fn is_player_connected(&mut self, ctx: ::grpcio::RpcContext, req: super::alpha::PlayerID, sink: ::grpcio::UnarySink); + fn get_connected_players(&mut self, ctx: ::grpcio::RpcContext, req: super::alpha::Empty, sink: ::grpcio::UnarySink); } pub fn create_sdk(s: S) -> ::grpcio::Service { let mut builder = ::grpcio::ServiceBuilder::new(); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_PLAYER_CONNECT, move |ctx, req, resp| { instance.player_connect(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_PLAYER_DISCONNECT, move |ctx, req, resp| { instance.player_disconnect(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_SET_PLAYER_CAPACITY, move |ctx, req, resp| { instance.set_player_capacity(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_GET_PLAYER_CAPACITY, move |ctx, req, resp| { instance.get_player_capacity(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_GET_PLAYER_COUNT, move |ctx, req, resp| { instance.get_player_count(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_IS_PLAYER_CONNECTED, move |ctx, req, resp| { instance.is_player_connected(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s; builder = builder.add_unary_handler(&METHOD_SDK_GET_CONNECTED_PLAYERS, move |ctx, req, resp| { instance.get_connected_players(ctx, req, resp) }); diff --git a/sdks/rust/src/grpc/sdk.rs b/sdks/rust/src/grpc/sdk.rs index 6053b7d69a..4a00ef2b99 100644 --- a/sdks/rust/src/grpc/sdk.rs +++ b/sdks/rust/src/grpc/sdk.rs @@ -13,14 +13,15 @@ // limitations under the License. // This code was autogenerated. Do not edit directly. -// This file is generated by rust-protobuf 2.0.2. Do not edit +// This file is generated by rust-protobuf 2.16.2. Do not edit // @generated -// https://github.com/Manishearth/rust-clippy/issues/702 +// https://github.com/rust-lang/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] -#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_attributes)] +#![rustfmt::skip] #![allow(box_pointers)] #![allow(dead_code)] @@ -29,18 +30,25 @@ #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![allow(trivial_casts)] -#![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] +//! Generated file from `sdk.proto` -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; +/// Generated files are compatible only with the same version +/// of protobuf runtime. +// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_16_2; #[derive(PartialEq,Clone,Default)] pub struct Empty { // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Empty { + fn default() -> &'a Empty { + ::default_instance() + } } impl Empty { @@ -54,7 +62,7 @@ impl ::protobuf::Message for Empty { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -75,7 +83,7 @@ impl ::protobuf::Message for Empty { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -92,13 +100,13 @@ impl ::protobuf::Message for Empty { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -111,30 +119,20 @@ impl ::protobuf::Message for Empty { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let fields = ::std::vec::Vec::new(); - ::protobuf::reflect::MessageDescriptor::new::( - "Empty", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let fields = ::std::vec::Vec::new(); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Empty", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static Empty { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Empty, - }; - unsafe { - instance.get(Empty::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Empty::new) } } @@ -145,14 +143,14 @@ impl ::protobuf::Clear for Empty { } impl ::std::fmt::Debug for Empty { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Empty { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -162,8 +160,14 @@ pub struct KeyValue { pub key: ::std::string::String, pub value: ::std::string::String, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a KeyValue { + fn default() -> &'a KeyValue { + ::default_instance() + } } impl KeyValue { @@ -173,6 +177,10 @@ impl KeyValue { // string key = 1; + + pub fn get_key(&self) -> &str { + &self.key + } pub fn clear_key(&mut self) { self.key.clear(); } @@ -193,12 +201,12 @@ impl KeyValue { ::std::mem::replace(&mut self.key, ::std::string::String::new()) } - pub fn get_key(&self) -> &str { - &self.key - } - // string value = 2; + + pub fn get_value(&self) -> &str { + &self.value + } pub fn clear_value(&mut self) { self.value.clear(); } @@ -218,10 +226,6 @@ impl KeyValue { pub fn take_value(&mut self) -> ::std::string::String { ::std::mem::replace(&mut self.value, ::std::string::String::new()) } - - pub fn get_value(&self) -> &str { - &self.value - } } impl ::protobuf::Message for KeyValue { @@ -229,7 +233,7 @@ impl ::protobuf::Message for KeyValue { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -262,7 +266,7 @@ impl ::protobuf::Message for KeyValue { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if !self.key.is_empty() { os.write_string(1, &self.key)?; } @@ -285,13 +289,13 @@ impl ::protobuf::Message for KeyValue { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -304,60 +308,50 @@ impl ::protobuf::Message for KeyValue { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "key", - |m: &KeyValue| { &m.key }, - |m: &mut KeyValue| { &mut m.key }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "value", - |m: &KeyValue| { &m.value }, - |m: &mut KeyValue| { &mut m.value }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "KeyValue", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "key", + |m: &KeyValue| { &m.key }, + |m: &mut KeyValue| { &mut m.key }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "value", + |m: &KeyValue| { &m.value }, + |m: &mut KeyValue| { &mut m.value }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "KeyValue", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static KeyValue { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const KeyValue, - }; - unsafe { - instance.get(KeyValue::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(KeyValue::new) } } impl ::protobuf::Clear for KeyValue { fn clear(&mut self) { - self.clear_key(); - self.clear_value(); + self.key.clear(); + self.value.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for KeyValue { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for KeyValue { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -366,8 +360,14 @@ pub struct Duration { // message fields pub seconds: i64, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Duration { + fn default() -> &'a Duration { + ::default_instance() + } } impl Duration { @@ -377,6 +377,10 @@ impl Duration { // int64 seconds = 1; + + pub fn get_seconds(&self) -> i64 { + self.seconds + } pub fn clear_seconds(&mut self) { self.seconds = 0; } @@ -385,10 +389,6 @@ impl Duration { pub fn set_seconds(&mut self, v: i64) { self.seconds = v; } - - pub fn get_seconds(&self) -> i64 { - self.seconds - } } impl ::protobuf::Message for Duration { @@ -396,7 +396,7 @@ impl ::protobuf::Message for Duration { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -427,7 +427,7 @@ impl ::protobuf::Message for Duration { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if self.seconds != 0 { os.write_int64(1, self.seconds)?; } @@ -447,13 +447,13 @@ impl ::protobuf::Message for Duration { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -466,54 +466,44 @@ impl ::protobuf::Message for Duration { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( - "seconds", - |m: &Duration| { &m.seconds }, - |m: &mut Duration| { &mut m.seconds }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Duration", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "seconds", + |m: &Duration| { &m.seconds }, + |m: &mut Duration| { &mut m.seconds }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Duration", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static Duration { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Duration, - }; - unsafe { - instance.get(Duration::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Duration::new) } } impl ::protobuf::Clear for Duration { fn clear(&mut self) { - self.clear_seconds(); + self.seconds = 0; self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Duration { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Duration { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -524,8 +514,14 @@ pub struct GameServer { pub spec: ::protobuf::SingularPtrField, pub status: ::protobuf::SingularPtrField, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GameServer { + fn default() -> &'a GameServer { + ::default_instance() + } } impl GameServer { @@ -535,6 +531,10 @@ impl GameServer { // .agones.dev.sdk.GameServer.ObjectMeta object_meta = 1; + + pub fn get_object_meta(&self) -> &GameServer_ObjectMeta { + self.object_meta.as_ref().unwrap_or_else(|| ::default_instance()) + } pub fn clear_object_meta(&mut self) { self.object_meta.clear(); } @@ -562,12 +562,12 @@ impl GameServer { self.object_meta.take().unwrap_or_else(|| GameServer_ObjectMeta::new()) } - pub fn get_object_meta(&self) -> &GameServer_ObjectMeta { - self.object_meta.as_ref().unwrap_or_else(|| GameServer_ObjectMeta::default_instance()) - } - // .agones.dev.sdk.GameServer.Spec spec = 2; + + pub fn get_spec(&self) -> &GameServer_Spec { + self.spec.as_ref().unwrap_or_else(|| ::default_instance()) + } pub fn clear_spec(&mut self) { self.spec.clear(); } @@ -595,12 +595,12 @@ impl GameServer { self.spec.take().unwrap_or_else(|| GameServer_Spec::new()) } - pub fn get_spec(&self) -> &GameServer_Spec { - self.spec.as_ref().unwrap_or_else(|| GameServer_Spec::default_instance()) - } - // .agones.dev.sdk.GameServer.Status status = 3; + + pub fn get_status(&self) -> &GameServer_Status { + self.status.as_ref().unwrap_or_else(|| ::default_instance()) + } pub fn clear_status(&mut self) { self.status.clear(); } @@ -627,10 +627,6 @@ impl GameServer { pub fn take_status(&mut self) -> GameServer_Status { self.status.take().unwrap_or_else(|| GameServer_Status::new()) } - - pub fn get_status(&self) -> &GameServer_Status { - self.status.as_ref().unwrap_or_else(|| GameServer_Status::default_instance()) - } } impl ::protobuf::Message for GameServer { @@ -653,7 +649,7 @@ impl ::protobuf::Message for GameServer { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -695,7 +691,7 @@ impl ::protobuf::Message for GameServer { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let Some(ref v) = self.object_meta.as_ref() { os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; @@ -727,13 +723,13 @@ impl ::protobuf::Message for GameServer { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -746,66 +742,56 @@ impl ::protobuf::Message for GameServer { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "object_meta", - |m: &GameServer| { &m.object_meta }, - |m: &mut GameServer| { &mut m.object_meta }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "spec", - |m: &GameServer| { &m.spec }, - |m: &mut GameServer| { &mut m.spec }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "status", - |m: &GameServer| { &m.status }, - |m: &mut GameServer| { &mut m.status }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "GameServer", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "object_meta", + |m: &GameServer| { &m.object_meta }, + |m: &mut GameServer| { &mut m.object_meta }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "spec", + |m: &GameServer| { &m.spec }, + |m: &mut GameServer| { &mut m.spec }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "status", + |m: &GameServer| { &m.status }, + |m: &mut GameServer| { &mut m.status }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "GameServer", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static GameServer { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const GameServer, - }; - unsafe { - instance.get(GameServer::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(GameServer::new) } } impl ::protobuf::Clear for GameServer { fn clear(&mut self) { - self.clear_object_meta(); - self.clear_spec(); - self.clear_status(); + self.object_meta.clear(); + self.spec.clear(); + self.status.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for GameServer { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for GameServer { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -822,8 +808,14 @@ pub struct GameServer_ObjectMeta { pub annotations: ::std::collections::HashMap<::std::string::String, ::std::string::String>, pub labels: ::std::collections::HashMap<::std::string::String, ::std::string::String>, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GameServer_ObjectMeta { + fn default() -> &'a GameServer_ObjectMeta { + ::default_instance() + } } impl GameServer_ObjectMeta { @@ -833,6 +825,10 @@ impl GameServer_ObjectMeta { // string name = 1; + + pub fn get_name(&self) -> &str { + &self.name + } pub fn clear_name(&mut self) { self.name.clear(); } @@ -853,12 +849,12 @@ impl GameServer_ObjectMeta { ::std::mem::replace(&mut self.name, ::std::string::String::new()) } - pub fn get_name(&self) -> &str { - &self.name - } - // string namespace = 2; + + pub fn get_namespace(&self) -> &str { + &self.namespace + } pub fn clear_namespace(&mut self) { self.namespace.clear(); } @@ -879,12 +875,12 @@ impl GameServer_ObjectMeta { ::std::mem::replace(&mut self.namespace, ::std::string::String::new()) } - pub fn get_namespace(&self) -> &str { - &self.namespace - } - // string uid = 3; + + pub fn get_uid(&self) -> &str { + &self.uid + } pub fn clear_uid(&mut self) { self.uid.clear(); } @@ -905,12 +901,12 @@ impl GameServer_ObjectMeta { ::std::mem::replace(&mut self.uid, ::std::string::String::new()) } - pub fn get_uid(&self) -> &str { - &self.uid - } - // string resource_version = 4; + + pub fn get_resource_version(&self) -> &str { + &self.resource_version + } pub fn clear_resource_version(&mut self) { self.resource_version.clear(); } @@ -931,12 +927,12 @@ impl GameServer_ObjectMeta { ::std::mem::replace(&mut self.resource_version, ::std::string::String::new()) } - pub fn get_resource_version(&self) -> &str { - &self.resource_version - } - // int64 generation = 5; + + pub fn get_generation(&self) -> i64 { + self.generation + } pub fn clear_generation(&mut self) { self.generation = 0; } @@ -946,12 +942,12 @@ impl GameServer_ObjectMeta { self.generation = v; } - pub fn get_generation(&self) -> i64 { - self.generation - } - // int64 creation_timestamp = 6; + + pub fn get_creation_timestamp(&self) -> i64 { + self.creation_timestamp + } pub fn clear_creation_timestamp(&mut self) { self.creation_timestamp = 0; } @@ -961,12 +957,12 @@ impl GameServer_ObjectMeta { self.creation_timestamp = v; } - pub fn get_creation_timestamp(&self) -> i64 { - self.creation_timestamp - } - // int64 deletion_timestamp = 7; + + pub fn get_deletion_timestamp(&self) -> i64 { + self.deletion_timestamp + } pub fn clear_deletion_timestamp(&mut self) { self.deletion_timestamp = 0; } @@ -976,12 +972,12 @@ impl GameServer_ObjectMeta { self.deletion_timestamp = v; } - pub fn get_deletion_timestamp(&self) -> i64 { - self.deletion_timestamp - } - // repeated .agones.dev.sdk.GameServer.ObjectMeta.AnnotationsEntry annotations = 8; + + pub fn get_annotations(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { + &self.annotations + } pub fn clear_annotations(&mut self) { self.annotations.clear(); } @@ -1001,12 +997,12 @@ impl GameServer_ObjectMeta { ::std::mem::replace(&mut self.annotations, ::std::collections::HashMap::new()) } - pub fn get_annotations(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { - &self.annotations - } - // repeated .agones.dev.sdk.GameServer.ObjectMeta.LabelsEntry labels = 9; + + pub fn get_labels(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { + &self.labels + } pub fn clear_labels(&mut self) { self.labels.clear(); } @@ -1025,10 +1021,6 @@ impl GameServer_ObjectMeta { pub fn take_labels(&mut self) -> ::std::collections::HashMap<::std::string::String, ::std::string::String> { ::std::mem::replace(&mut self.labels, ::std::collections::HashMap::new()) } - - pub fn get_labels(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { - &self.labels - } } impl ::protobuf::Message for GameServer_ObjectMeta { @@ -1036,7 +1028,7 @@ impl ::protobuf::Message for GameServer_ObjectMeta { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -1119,7 +1111,7 @@ impl ::protobuf::Message for GameServer_ObjectMeta { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if !self.name.is_empty() { os.write_string(1, &self.name)?; } @@ -1159,13 +1151,13 @@ impl ::protobuf::Message for GameServer_ObjectMeta { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -1178,102 +1170,92 @@ impl ::protobuf::Message for GameServer_ObjectMeta { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "name", - |m: &GameServer_ObjectMeta| { &m.name }, - |m: &mut GameServer_ObjectMeta| { &mut m.name }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "namespace", - |m: &GameServer_ObjectMeta| { &m.namespace }, - |m: &mut GameServer_ObjectMeta| { &mut m.namespace }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "uid", - |m: &GameServer_ObjectMeta| { &m.uid }, - |m: &mut GameServer_ObjectMeta| { &mut m.uid }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "resource_version", - |m: &GameServer_ObjectMeta| { &m.resource_version }, - |m: &mut GameServer_ObjectMeta| { &mut m.resource_version }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( - "generation", - |m: &GameServer_ObjectMeta| { &m.generation }, - |m: &mut GameServer_ObjectMeta| { &mut m.generation }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( - "creation_timestamp", - |m: &GameServer_ObjectMeta| { &m.creation_timestamp }, - |m: &mut GameServer_ObjectMeta| { &mut m.creation_timestamp }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( - "deletion_timestamp", - |m: &GameServer_ObjectMeta| { &m.deletion_timestamp }, - |m: &mut GameServer_ObjectMeta| { &mut m.deletion_timestamp }, - )); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( - "annotations", - |m: &GameServer_ObjectMeta| { &m.annotations }, - |m: &mut GameServer_ObjectMeta| { &mut m.annotations }, - )); - fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( - "labels", - |m: &GameServer_ObjectMeta| { &m.labels }, - |m: &mut GameServer_ObjectMeta| { &mut m.labels }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "GameServer_ObjectMeta", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + |m: &GameServer_ObjectMeta| { &m.name }, + |m: &mut GameServer_ObjectMeta| { &mut m.name }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "namespace", + |m: &GameServer_ObjectMeta| { &m.namespace }, + |m: &mut GameServer_ObjectMeta| { &mut m.namespace }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "uid", + |m: &GameServer_ObjectMeta| { &m.uid }, + |m: &mut GameServer_ObjectMeta| { &mut m.uid }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "resource_version", + |m: &GameServer_ObjectMeta| { &m.resource_version }, + |m: &mut GameServer_ObjectMeta| { &mut m.resource_version }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "generation", + |m: &GameServer_ObjectMeta| { &m.generation }, + |m: &mut GameServer_ObjectMeta| { &mut m.generation }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "creation_timestamp", + |m: &GameServer_ObjectMeta| { &m.creation_timestamp }, + |m: &mut GameServer_ObjectMeta| { &mut m.creation_timestamp }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "deletion_timestamp", + |m: &GameServer_ObjectMeta| { &m.deletion_timestamp }, + |m: &mut GameServer_ObjectMeta| { &mut m.deletion_timestamp }, + )); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( + "annotations", + |m: &GameServer_ObjectMeta| { &m.annotations }, + |m: &mut GameServer_ObjectMeta| { &mut m.annotations }, + )); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeString>( + "labels", + |m: &GameServer_ObjectMeta| { &m.labels }, + |m: &mut GameServer_ObjectMeta| { &mut m.labels }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "GameServer.ObjectMeta", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static GameServer_ObjectMeta { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const GameServer_ObjectMeta, - }; - unsafe { - instance.get(GameServer_ObjectMeta::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(GameServer_ObjectMeta::new) } } impl ::protobuf::Clear for GameServer_ObjectMeta { fn clear(&mut self) { - self.clear_name(); - self.clear_namespace(); - self.clear_uid(); - self.clear_resource_version(); - self.clear_generation(); - self.clear_creation_timestamp(); - self.clear_deletion_timestamp(); - self.clear_annotations(); - self.clear_labels(); + self.name.clear(); + self.namespace.clear(); + self.uid.clear(); + self.resource_version.clear(); + self.generation = 0; + self.creation_timestamp = 0; + self.deletion_timestamp = 0; + self.annotations.clear(); + self.labels.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for GameServer_ObjectMeta { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for GameServer_ObjectMeta { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -1282,8 +1264,14 @@ pub struct GameServer_Spec { // message fields pub health: ::protobuf::SingularPtrField, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GameServer_Spec { + fn default() -> &'a GameServer_Spec { + ::default_instance() + } } impl GameServer_Spec { @@ -1293,6 +1281,10 @@ impl GameServer_Spec { // .agones.dev.sdk.GameServer.Spec.Health health = 1; + + pub fn get_health(&self) -> &GameServer_Spec_Health { + self.health.as_ref().unwrap_or_else(|| ::default_instance()) + } pub fn clear_health(&mut self) { self.health.clear(); } @@ -1319,10 +1311,6 @@ impl GameServer_Spec { pub fn take_health(&mut self) -> GameServer_Spec_Health { self.health.take().unwrap_or_else(|| GameServer_Spec_Health::new()) } - - pub fn get_health(&self) -> &GameServer_Spec_Health { - self.health.as_ref().unwrap_or_else(|| GameServer_Spec_Health::default_instance()) - } } impl ::protobuf::Message for GameServer_Spec { @@ -1335,7 +1323,7 @@ impl ::protobuf::Message for GameServer_Spec { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -1363,7 +1351,7 @@ impl ::protobuf::Message for GameServer_Spec { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let Some(ref v) = self.health.as_ref() { os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; @@ -1385,13 +1373,13 @@ impl ::protobuf::Message for GameServer_Spec { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -1404,54 +1392,44 @@ impl ::protobuf::Message for GameServer_Spec { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "health", - |m: &GameServer_Spec| { &m.health }, - |m: &mut GameServer_Spec| { &mut m.health }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "GameServer_Spec", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "health", + |m: &GameServer_Spec| { &m.health }, + |m: &mut GameServer_Spec| { &mut m.health }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "GameServer.Spec", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static GameServer_Spec { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const GameServer_Spec, - }; - unsafe { - instance.get(GameServer_Spec::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(GameServer_Spec::new) } } impl ::protobuf::Clear for GameServer_Spec { fn clear(&mut self) { - self.clear_health(); + self.health.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for GameServer_Spec { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for GameServer_Spec { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -1463,8 +1441,14 @@ pub struct GameServer_Spec_Health { pub failure_threshold: i32, pub initial_delay_seconds: i32, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GameServer_Spec_Health { + fn default() -> &'a GameServer_Spec_Health { + ::default_instance() + } } impl GameServer_Spec_Health { @@ -1474,6 +1458,10 @@ impl GameServer_Spec_Health { // bool disabled = 1; + + pub fn get_disabled(&self) -> bool { + self.disabled + } pub fn clear_disabled(&mut self) { self.disabled = false; } @@ -1483,12 +1471,12 @@ impl GameServer_Spec_Health { self.disabled = v; } - pub fn get_disabled(&self) -> bool { - self.disabled - } - // int32 period_seconds = 2; + + pub fn get_period_seconds(&self) -> i32 { + self.period_seconds + } pub fn clear_period_seconds(&mut self) { self.period_seconds = 0; } @@ -1498,12 +1486,12 @@ impl GameServer_Spec_Health { self.period_seconds = v; } - pub fn get_period_seconds(&self) -> i32 { - self.period_seconds - } - // int32 failure_threshold = 3; + + pub fn get_failure_threshold(&self) -> i32 { + self.failure_threshold + } pub fn clear_failure_threshold(&mut self) { self.failure_threshold = 0; } @@ -1513,12 +1501,12 @@ impl GameServer_Spec_Health { self.failure_threshold = v; } - pub fn get_failure_threshold(&self) -> i32 { - self.failure_threshold - } - // int32 initial_delay_seconds = 4; + + pub fn get_initial_delay_seconds(&self) -> i32 { + self.initial_delay_seconds + } pub fn clear_initial_delay_seconds(&mut self) { self.initial_delay_seconds = 0; } @@ -1527,10 +1515,6 @@ impl GameServer_Spec_Health { pub fn set_initial_delay_seconds(&mut self, v: i32) { self.initial_delay_seconds = v; } - - pub fn get_initial_delay_seconds(&self) -> i32 { - self.initial_delay_seconds - } } impl ::protobuf::Message for GameServer_Spec_Health { @@ -1538,7 +1522,7 @@ impl ::protobuf::Message for GameServer_Spec_Health { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -1599,7 +1583,7 @@ impl ::protobuf::Message for GameServer_Spec_Health { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if self.disabled != false { os.write_bool(1, self.disabled)?; } @@ -1628,13 +1612,13 @@ impl ::protobuf::Message for GameServer_Spec_Health { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -1647,72 +1631,62 @@ impl ::protobuf::Message for GameServer_Spec_Health { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>( - "disabled", - |m: &GameServer_Spec_Health| { &m.disabled }, - |m: &mut GameServer_Spec_Health| { &mut m.disabled }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( - "period_seconds", - |m: &GameServer_Spec_Health| { &m.period_seconds }, - |m: &mut GameServer_Spec_Health| { &mut m.period_seconds }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( - "failure_threshold", - |m: &GameServer_Spec_Health| { &m.failure_threshold }, - |m: &mut GameServer_Spec_Health| { &mut m.failure_threshold }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( - "initial_delay_seconds", - |m: &GameServer_Spec_Health| { &m.initial_delay_seconds }, - |m: &mut GameServer_Spec_Health| { &mut m.initial_delay_seconds }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "GameServer_Spec_Health", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "disabled", + |m: &GameServer_Spec_Health| { &m.disabled }, + |m: &mut GameServer_Spec_Health| { &mut m.disabled }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "period_seconds", + |m: &GameServer_Spec_Health| { &m.period_seconds }, + |m: &mut GameServer_Spec_Health| { &mut m.period_seconds }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "failure_threshold", + |m: &GameServer_Spec_Health| { &m.failure_threshold }, + |m: &mut GameServer_Spec_Health| { &mut m.failure_threshold }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "initial_delay_seconds", + |m: &GameServer_Spec_Health| { &m.initial_delay_seconds }, + |m: &mut GameServer_Spec_Health| { &mut m.initial_delay_seconds }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "GameServer.Spec.Health", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static GameServer_Spec_Health { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const GameServer_Spec_Health, - }; - unsafe { - instance.get(GameServer_Spec_Health::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(GameServer_Spec_Health::new) } } impl ::protobuf::Clear for GameServer_Spec_Health { fn clear(&mut self) { - self.clear_disabled(); - self.clear_period_seconds(); - self.clear_failure_threshold(); - self.clear_initial_delay_seconds(); + self.disabled = false; + self.period_seconds = 0; + self.failure_threshold = 0; + self.initial_delay_seconds = 0; self.unknown_fields.clear(); } } impl ::std::fmt::Debug for GameServer_Spec_Health { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for GameServer_Spec_Health { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -1724,8 +1698,14 @@ pub struct GameServer_Status { pub ports: ::protobuf::RepeatedField, pub players: ::protobuf::SingularPtrField, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GameServer_Status { + fn default() -> &'a GameServer_Status { + ::default_instance() + } } impl GameServer_Status { @@ -1735,6 +1715,10 @@ impl GameServer_Status { // string state = 1; + + pub fn get_state(&self) -> &str { + &self.state + } pub fn clear_state(&mut self) { self.state.clear(); } @@ -1755,12 +1739,12 @@ impl GameServer_Status { ::std::mem::replace(&mut self.state, ::std::string::String::new()) } - pub fn get_state(&self) -> &str { - &self.state - } - // string address = 2; + + pub fn get_address(&self) -> &str { + &self.address + } pub fn clear_address(&mut self) { self.address.clear(); } @@ -1781,12 +1765,12 @@ impl GameServer_Status { ::std::mem::replace(&mut self.address, ::std::string::String::new()) } - pub fn get_address(&self) -> &str { - &self.address - } - // repeated .agones.dev.sdk.GameServer.Status.Port ports = 3; + + pub fn get_ports(&self) -> &[GameServer_Status_Port] { + &self.ports + } pub fn clear_ports(&mut self) { self.ports.clear(); } @@ -1806,12 +1790,12 @@ impl GameServer_Status { ::std::mem::replace(&mut self.ports, ::protobuf::RepeatedField::new()) } - pub fn get_ports(&self) -> &[GameServer_Status_Port] { - &self.ports - } - // .agones.dev.sdk.GameServer.Status.PlayerStatus players = 4; + + pub fn get_players(&self) -> &GameServer_Status_PlayerStatus { + self.players.as_ref().unwrap_or_else(|| ::default_instance()) + } pub fn clear_players(&mut self) { self.players.clear(); } @@ -1838,10 +1822,6 @@ impl GameServer_Status { pub fn take_players(&mut self) -> GameServer_Status_PlayerStatus { self.players.take().unwrap_or_else(|| GameServer_Status_PlayerStatus::new()) } - - pub fn get_players(&self) -> &GameServer_Status_PlayerStatus { - self.players.as_ref().unwrap_or_else(|| GameServer_Status_PlayerStatus::default_instance()) - } } impl ::protobuf::Message for GameServer_Status { @@ -1859,7 +1839,7 @@ impl ::protobuf::Message for GameServer_Status { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -1906,7 +1886,7 @@ impl ::protobuf::Message for GameServer_Status { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if !self.state.is_empty() { os.write_string(1, &self.state)?; } @@ -1939,13 +1919,13 @@ impl ::protobuf::Message for GameServer_Status { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -1958,72 +1938,62 @@ impl ::protobuf::Message for GameServer_Status { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "state", - |m: &GameServer_Status| { &m.state }, - |m: &mut GameServer_Status| { &mut m.state }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "address", - |m: &GameServer_Status| { &m.address }, - |m: &mut GameServer_Status| { &mut m.address }, - )); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "ports", - |m: &GameServer_Status| { &m.ports }, - |m: &mut GameServer_Status| { &mut m.ports }, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "players", - |m: &GameServer_Status| { &m.players }, - |m: &mut GameServer_Status| { &mut m.players }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "GameServer_Status", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "state", + |m: &GameServer_Status| { &m.state }, + |m: &mut GameServer_Status| { &mut m.state }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "address", + |m: &GameServer_Status| { &m.address }, + |m: &mut GameServer_Status| { &mut m.address }, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "ports", + |m: &GameServer_Status| { &m.ports }, + |m: &mut GameServer_Status| { &mut m.ports }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "players", + |m: &GameServer_Status| { &m.players }, + |m: &mut GameServer_Status| { &mut m.players }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "GameServer.Status", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static GameServer_Status { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const GameServer_Status, - }; - unsafe { - instance.get(GameServer_Status::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(GameServer_Status::new) } } impl ::protobuf::Clear for GameServer_Status { fn clear(&mut self) { - self.clear_state(); - self.clear_address(); - self.clear_ports(); - self.clear_players(); + self.state.clear(); + self.address.clear(); + self.ports.clear(); + self.players.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for GameServer_Status { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for GameServer_Status { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -2033,8 +2003,14 @@ pub struct GameServer_Status_Port { pub name: ::std::string::String, pub port: i32, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GameServer_Status_Port { + fn default() -> &'a GameServer_Status_Port { + ::default_instance() + } } impl GameServer_Status_Port { @@ -2044,6 +2020,10 @@ impl GameServer_Status_Port { // string name = 1; + + pub fn get_name(&self) -> &str { + &self.name + } pub fn clear_name(&mut self) { self.name.clear(); } @@ -2064,12 +2044,12 @@ impl GameServer_Status_Port { ::std::mem::replace(&mut self.name, ::std::string::String::new()) } - pub fn get_name(&self) -> &str { - &self.name - } - // int32 port = 2; + + pub fn get_port(&self) -> i32 { + self.port + } pub fn clear_port(&mut self) { self.port = 0; } @@ -2078,10 +2058,6 @@ impl GameServer_Status_Port { pub fn set_port(&mut self, v: i32) { self.port = v; } - - pub fn get_port(&self) -> i32 { - self.port - } } impl ::protobuf::Message for GameServer_Status_Port { @@ -2089,7 +2065,7 @@ impl ::protobuf::Message for GameServer_Status_Port { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -2126,7 +2102,7 @@ impl ::protobuf::Message for GameServer_Status_Port { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if !self.name.is_empty() { os.write_string(1, &self.name)?; } @@ -2149,13 +2125,13 @@ impl ::protobuf::Message for GameServer_Status_Port { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -2168,60 +2144,50 @@ impl ::protobuf::Message for GameServer_Status_Port { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "name", - |m: &GameServer_Status_Port| { &m.name }, - |m: &mut GameServer_Status_Port| { &mut m.name }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( - "port", - |m: &GameServer_Status_Port| { &m.port }, - |m: &mut GameServer_Status_Port| { &mut m.port }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "GameServer_Status_Port", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + |m: &GameServer_Status_Port| { &m.name }, + |m: &mut GameServer_Status_Port| { &mut m.name }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "port", + |m: &GameServer_Status_Port| { &m.port }, + |m: &mut GameServer_Status_Port| { &mut m.port }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "GameServer.Status.Port", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static GameServer_Status_Port { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const GameServer_Status_Port, - }; - unsafe { - instance.get(GameServer_Status_Port::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(GameServer_Status_Port::new) } } impl ::protobuf::Clear for GameServer_Status_Port { fn clear(&mut self) { - self.clear_name(); - self.clear_port(); + self.name.clear(); + self.port = 0; self.unknown_fields.clear(); } } impl ::std::fmt::Debug for GameServer_Status_Port { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for GameServer_Status_Port { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -2232,8 +2198,14 @@ pub struct GameServer_Status_PlayerStatus { pub capacity: i64, pub ids: ::protobuf::RepeatedField<::std::string::String>, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a GameServer_Status_PlayerStatus { + fn default() -> &'a GameServer_Status_PlayerStatus { + ::default_instance() + } } impl GameServer_Status_PlayerStatus { @@ -2243,6 +2215,10 @@ impl GameServer_Status_PlayerStatus { // int64 count = 1; + + pub fn get_count(&self) -> i64 { + self.count + } pub fn clear_count(&mut self) { self.count = 0; } @@ -2252,12 +2228,12 @@ impl GameServer_Status_PlayerStatus { self.count = v; } - pub fn get_count(&self) -> i64 { - self.count - } - // int64 capacity = 2; + + pub fn get_capacity(&self) -> i64 { + self.capacity + } pub fn clear_capacity(&mut self) { self.capacity = 0; } @@ -2267,12 +2243,12 @@ impl GameServer_Status_PlayerStatus { self.capacity = v; } - pub fn get_capacity(&self) -> i64 { - self.capacity - } - // repeated string ids = 3; + + pub fn get_ids(&self) -> &[::std::string::String] { + &self.ids + } pub fn clear_ids(&mut self) { self.ids.clear(); } @@ -2291,10 +2267,6 @@ impl GameServer_Status_PlayerStatus { pub fn take_ids(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { ::std::mem::replace(&mut self.ids, ::protobuf::RepeatedField::new()) } - - pub fn get_ids(&self) -> &[::std::string::String] { - &self.ids - } } impl ::protobuf::Message for GameServer_Status_PlayerStatus { @@ -2302,7 +2274,7 @@ impl ::protobuf::Message for GameServer_Status_PlayerStatus { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -2349,7 +2321,7 @@ impl ::protobuf::Message for GameServer_Status_PlayerStatus { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if self.count != 0 { os.write_int64(1, self.count)?; } @@ -2375,13 +2347,13 @@ impl ::protobuf::Message for GameServer_Status_PlayerStatus { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { self } @@ -2394,66 +2366,56 @@ impl ::protobuf::Message for GameServer_Status_PlayerStatus { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( - "count", - |m: &GameServer_Status_PlayerStatus| { &m.count }, - |m: &mut GameServer_Status_PlayerStatus| { &mut m.count }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( - "capacity", - |m: &GameServer_Status_PlayerStatus| { &m.capacity }, - |m: &mut GameServer_Status_PlayerStatus| { &mut m.capacity }, - )); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "ids", - |m: &GameServer_Status_PlayerStatus| { &m.ids }, - |m: &mut GameServer_Status_PlayerStatus| { &mut m.ids }, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "GameServer_Status_PlayerStatus", - fields, - file_descriptor_proto() - ) - }) - } + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "count", + |m: &GameServer_Status_PlayerStatus| { &m.count }, + |m: &mut GameServer_Status_PlayerStatus| { &mut m.count }, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "capacity", + |m: &GameServer_Status_PlayerStatus| { &m.capacity }, + |m: &mut GameServer_Status_PlayerStatus| { &mut m.capacity }, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "ids", + |m: &GameServer_Status_PlayerStatus| { &m.ids }, + |m: &mut GameServer_Status_PlayerStatus| { &mut m.ids }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "GameServer.Status.PlayerStatus", + fields, + file_descriptor_proto() + ) + }) } fn default_instance() -> &'static GameServer_Status_PlayerStatus { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const GameServer_Status_PlayerStatus, - }; - unsafe { - instance.get(GameServer_Status_PlayerStatus::new) - } + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(GameServer_Status_PlayerStatus::new) } } impl ::protobuf::Clear for GameServer_Status_PlayerStatus { fn clear(&mut self) { - self.clear_count(); - self.clear_capacity(); - self.clear_ids(); + self.count = 0; + self.capacity = 0; + self.ids.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for GameServer_Status_PlayerStatus { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for GameServer_Status_PlayerStatus { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -2719,19 +2681,14 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \x04\x9f\x01\x1f\x20b\x06proto3\ "; -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; +static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() } pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) } diff --git a/sdks/rust/src/grpc/sdk_grpc.rs b/sdks/rust/src/grpc/sdk_grpc.rs index f9b1d6b39f..6288776f67 100644 --- a/sdks/rust/src/grpc/sdk_grpc.rs +++ b/sdks/rust/src/grpc/sdk_grpc.rs @@ -18,7 +18,7 @@ // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] @@ -96,6 +96,7 @@ const METHOD_SDK_RESERVE: ::grpcio::Method ::grpcio::Result<::grpcio::ClientUnaryReceiver> { self.reserve_async_opt(req, ::grpcio::CallOption::default()) } - pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { + pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { self.client.spawn(f) } } pub trait Sdk { - fn ready(&self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); - fn allocate(&self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); - fn shutdown(&self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); - fn health(&self, ctx: ::grpcio::RpcContext, stream: ::grpcio::RequestStream, sink: ::grpcio::ClientStreamingSink); - fn get_game_server(&self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); - fn watch_game_server(&self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::ServerStreamingSink); - fn set_label(&self, ctx: ::grpcio::RpcContext, req: super::sdk::KeyValue, sink: ::grpcio::UnarySink); - fn set_annotation(&self, ctx: ::grpcio::RpcContext, req: super::sdk::KeyValue, sink: ::grpcio::UnarySink); - fn reserve(&self, ctx: ::grpcio::RpcContext, req: super::sdk::Duration, sink: ::grpcio::UnarySink); + fn ready(&mut self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); + fn allocate(&mut self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); + fn shutdown(&mut self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); + fn health(&mut self, ctx: ::grpcio::RpcContext, stream: ::grpcio::RequestStream, sink: ::grpcio::ClientStreamingSink); + fn get_game_server(&mut self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::UnarySink); + fn watch_game_server(&mut self, ctx: ::grpcio::RpcContext, req: super::sdk::Empty, sink: ::grpcio::ServerStreamingSink); + fn set_label(&mut self, ctx: ::grpcio::RpcContext, req: super::sdk::KeyValue, sink: ::grpcio::UnarySink); + fn set_annotation(&mut self, ctx: ::grpcio::RpcContext, req: super::sdk::KeyValue, sink: ::grpcio::UnarySink); + fn reserve(&mut self, ctx: ::grpcio::RpcContext, req: super::sdk::Duration, sink: ::grpcio::UnarySink); } pub fn create_sdk(s: S) -> ::grpcio::Service { let mut builder = ::grpcio::ServiceBuilder::new(); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_READY, move |ctx, req, resp| { instance.ready(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_ALLOCATE, move |ctx, req, resp| { instance.allocate(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_SHUTDOWN, move |ctx, req, resp| { instance.shutdown(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_client_streaming_handler(&METHOD_SDK_HEALTH, move |ctx, req, resp| { instance.health(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_GET_GAME_SERVER, move |ctx, req, resp| { instance.get_game_server(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_server_streaming_handler(&METHOD_SDK_WATCH_GAME_SERVER, move |ctx, req, resp| { instance.watch_game_server(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_SET_LABEL, move |ctx, req, resp| { instance.set_label(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s.clone(); builder = builder.add_unary_handler(&METHOD_SDK_SET_ANNOTATION, move |ctx, req, resp| { instance.set_annotation(ctx, req, resp) }); - let instance = s.clone(); + let mut instance = s; builder = builder.add_unary_handler(&METHOD_SDK_RESERVE, move |ctx, req, resp| { instance.reserve(ctx, req, resp) }); diff --git a/sdks/rust/src/lib.rs b/sdks/rust/src/lib.rs index 7f649871bf..3cc88ad0c6 100644 --- a/sdks/rust/src/lib.rs +++ b/sdks/rust/src/lib.rs @@ -15,10 +15,6 @@ //! the Rust game server SDK #[macro_use] extern crate error_chain; -extern crate futures; -extern crate grpcio; -extern crate grpcio_proto; -extern crate protobuf; pub mod alpha; pub mod errors; diff --git a/sdks/rust/src/sdk.rs b/sdks/rust/src/sdk.rs index 0b59bea948..12d9ec0609 100644 --- a/sdks/rust/src/sdk.rs +++ b/sdks/rust/src/sdk.rs @@ -17,20 +17,25 @@ use std::sync::{Arc, Mutex}; use std::thread::sleep; use std::time::Duration; -use futures::{Future, Sink, Stream}; +use futures::future::TryFutureExt; +use futures::prelude::*; +use futures::FutureExt; +use futures01::future::Future; + use grpcio; use protobuf::Message; -use alpha::*; -use errors::*; -use grpc::sdk; -use grpc::sdk_grpc; -use types::*; +use super::alpha::*; +use super::errors::*; +use super::grpc::sdk; +use super::grpc::sdk_grpc; +use super::types::*; /// SDK is an instance of the Agones SDK pub struct Sdk { client: Arc, health: Arc>>>, + health_receiver: Arc>>>, alpha: Arc, } @@ -66,10 +71,12 @@ impl Sdk { } } - let (sender, _) = cli.health()?; + // Keep both sender and receiver as RPC is canceled when sender or receiver is dropped + let (sender, receiver) = cli.health()?; Ok(Sdk { client: Arc::new(cli), health: Arc::new(Mutex::new(Some(sender))), + health_receiver: Arc::new(Mutex::new(Some(receiver))), alpha: Arc::new(alpha), }) } @@ -113,11 +120,16 @@ impl Sdk { .into()), ); } - let h: grpcio::ClientCStreamSender = h.unwrap().into(); + let mut h = h.unwrap(); let req = sdk::Empty::new(); - match h.send((req, grpcio::WriteFlags::default())).wait() { - Ok(h) => { + let result = h + .send((req, grpcio::WriteFlags::default())) + .boxed_local() + .compat() + .wait(); + match result { + Ok(_) => { self.health = Arc::new(Mutex::new(Some(h))); (self, Ok(())) } @@ -176,20 +188,162 @@ impl Sdk { F: FnMut(GameServer) -> (), { let req = sdk::Empty::new(); - let mut receiver = self - .client - .watch_game_server(&req)? - .map(|e| GameServer::from_message(e)); + let mut receiver = self.client.watch_game_server(&req)?; + loop { + let res = receiver.try_next().boxed_local().compat().wait(); + match res { + Ok(res) => match res { + Some(res) => watcher(GameServer::from_message(res)), + None => break, + }, + Err(e) => { + return Err(e.into()); + } + } + } + Ok(()) + } + + /// Starts a new SDK instance, and connects to localhost on port 9357. + /// Blocks until connection and handshake are made. + /// Times out after ~30 seconds. + pub async fn new_async() -> Result { + let port = env::var("AGONES_SDK_GRPC_PORT").unwrap_or("9357".to_string()); + let addr = format!("localhost:{}", port); + let env = Arc::new(grpcio::EnvBuilder::new().build()); + let ch = grpcio::ChannelBuilder::new(env) + .keepalive_timeout(Duration::new(30, 0)) + .connect(&addr); + let cli = sdk_grpc::SdkClient::new(ch.clone()); + let alpha = Alpha::new(ch); + let req = sdk::Empty::new(); + + // Unfortunately there isn't a native way to block until connected + // so we had to roll our own. + let mut counter = 0; loop { - match receiver.into_future().wait() { - Ok((Some(game_server), r)) => { - watcher(game_server); - receiver = r; + counter += 1; + match cli.get_game_server_async(&req)?.await { + Ok(_) => break, + Err(e) => { + if counter > 30 { + return Err(ErrorKind::Grpc(e).into()); + } + sleep(Duration::from_secs(1)); + continue; } - Ok((None, _)) => break, - Err((e, _)) => return Err(e.into()), } } + + // Keep both sender and receiver as RPC is canceled when sender or receiver is dropped + let (sender, receiver) = cli.health()?; + Ok(Sdk { + client: Arc::new(cli), + health: Arc::new(Mutex::new(Some(sender))), + health_receiver: Arc::new(Mutex::new(Some(receiver))), + alpha: Arc::new(alpha), + }) + } + + /// Marks the Game Server as ready to receive connections + pub async fn ready_async(&self) -> Result<()> { + let req = sdk::Empty::default_instance(); + let res = self.client.ready_async(req)?.await.map(|_| ())?; + Ok(res) + } + + /// Allocate the Game Server + pub async fn allocate_async(&self) -> Result<()> { + let req = sdk::Empty::default_instance(); + let res = self.client.allocate_async(req)?.await.map(|_| ())?; + Ok(res) + } + + /// Marks the Game Server as ready to shutdown + pub async fn shutdown_async(&self) -> Result<()> { + let req = sdk::Empty::default_instance(); + let res = self.client.shutdown_async(req)?.await.map(|_| ())?; + Ok(res) + } + + /// Sends a ping to the health check to indicate that this server is healthy + pub async fn health_async(&mut self) -> Result<()> { + // Avoid `cannot move out of borrowed content` compile error for self.health + let h = self.health.lock().unwrap().take(); + if h.is_none() { + return Err(ErrorKind::HealthPingConnectionFailure( + "failed to hold client stream for health ping".to_string(), + ) + .into()); + } + let mut h = h.unwrap(); + + let req = sdk::Empty::new(); + match h.send((req, grpcio::WriteFlags::default())).await { + Ok(_) => { + self.health = Arc::new(Mutex::new(Some(h))); + Ok(()) + } + Err(e) => Err(ErrorKind::Grpc(e).into()), + } + } + + /// Set a Label value on the backing GameServer record that is stored in Kubernetes + pub async fn set_label_async(&self, key: S, value: S) -> Result<()> + where + S: Into, + { + let mut kv = sdk::KeyValue::new(); + kv.set_key(key.into()); + kv.set_value(value.into()); + let res = self.client.set_label_async(&kv)?.await.map(|_| ())?; + Ok(res) + } + + /// Set a Annotation value on the backing Gameserver record that is stored in Kubernetes + pub async fn set_annotation_async(&self, key: S, value: S) -> Result<()> + where + S: Into, + { + let mut kv = sdk::KeyValue::new(); + kv.set_key(key.into()); + kv.set_value(value.into()); + let res = self.client.set_annotation_async(&kv)?.await.map(|_| ())?; + Ok(res) + } + + /// Returns most of the backing GameServer configuration and Status + pub async fn get_gameserver_async(&self) -> Result { + let req = sdk::Empty::new(); + let res = self + .client + .get_game_server_async(&req)? + .await + .map(|e| GameServer::from_message(e))?; + Ok(res) + } + + /// Reserve marks the Game Server as Reserved for a given duration, at which point + /// it will return the GameServer to a Ready state. + /// Do note, the smallest unit available in the time.Duration argument is a second. + pub async fn reserve_async(&self, duration: Duration) -> Result<()> { + let mut d = sdk::Duration::new(); + d.set_seconds(duration.as_secs() as i64); + + let res = self.client.reserve_async(&d)?.await.map(|_| ())?; + Ok(res) + } + + /// Watch the backing GameServer configuration on updated + pub async fn watch_gameserver_async(&self, mut watcher: F) -> Result<()> + where + F: FnMut(GameServer) -> (), + { + let req = sdk::Empty::new(); + let mut receiver = self.client.watch_game_server(&req)?; + while let Some(e) = receiver.try_next().await? { + watcher(GameServer::from_message(e)); + } Ok(()) } } @@ -199,6 +353,7 @@ impl Clone for Sdk { Self { client: Arc::clone(&self.client), health: self.health.clone(), + health_receiver: self.health_receiver.clone(), alpha: Arc::clone(&self.alpha), } } diff --git a/sdks/rust/src/types.rs b/sdks/rust/src/types.rs index cf3937901e..cd75162eef 100644 --- a/sdks/rust/src/types.rs +++ b/sdks/rust/src/types.rs @@ -13,7 +13,7 @@ // limitations under the License. use std::collections::HashMap; -use grpc::sdk; +use super::grpc::sdk; #[derive(PartialEq, Clone, Default)] pub struct GameServer { diff --git a/test/sdk/rust/Cargo.toml b/test/sdk/rust/Cargo.toml index 03236343fc..52d3b921d3 100644 --- a/test/sdk/rust/Cargo.toml +++ b/test/sdk/rust/Cargo.toml @@ -18,6 +18,8 @@ [package] name = "rust-simple" version = "0.2.0" +edition = "2018" [dependencies] -agones = { path = "../../../sdks/rust" } \ No newline at end of file +agones = { path = "../../../sdks/rust" } +async-std = "1.6.2" diff --git a/test/sdk/rust/src/main.rs b/test/sdk/rust/src/main.rs index 1a60de49a7..0121d0de9b 100644 --- a/test/sdk/rust/src/main.rs +++ b/test/sdk/rust/src/main.rs @@ -19,6 +19,8 @@ use std::result::Result; use std::thread; use std::time::Duration; +use async_std::task; + macro_rules! enclose { ( ($( $x:ident ),*) $y:expr ) => { { @@ -44,6 +46,16 @@ fn main() { } fn run() -> Result<(), String> { + let env_run_async = env::var("RUN_ASYNC").unwrap_or("false".to_string()); + if env_run_async.contains("true") { + println!("RUN_ASYNC is set to true, so run test for async functions"); + run_async() + } else { + run_sync() + } +} + +fn run_sync() -> Result<(), String> { println!("Creating SDK instance"); let sdk = agones::Sdk::new().map_err(|_| "Could not connect to the sidecar. Exiting!")?; @@ -63,6 +75,7 @@ fn run() -> Result<(), String> { } }}); + #[allow(unused_mut)] let _watch = thread::spawn(enclose! {(sdk) move || { println!("Starting to watch GameServer updates..."); let mut once = true; @@ -72,7 +85,7 @@ fn run() -> Result<(), String> { if once { println!("Setting an annotation"); let uid = gameserver.object_meta.clone().unwrap().uid.clone(); - sdk.set_annotation("test-annotation", &uid.to_string()); + let _ = sdk.set_annotation("test-annotation", &uid.to_string()); once = false; } }); @@ -198,3 +211,188 @@ fn run_player_tracking_features(sdk: &agones::Sdk) -> Result<(), String> { Ok(()) } + +fn run_async() -> Result<(), String> { + let sdk = task::block_on(async { agones::Sdk::new_async().await }) + .map_err(|_| "Could not connect to the sidecar. Exiting!")?; + + task::spawn(enclose! {(sdk) async move { + loop { + match sdk.health_async().await { + Ok(_) => { + println!("Health ping sent"); + } + Err(e) => { + println!("Health ping failed : {:?}", e); + } + } + task::sleep(Duration::from_secs(2)).await; + } + }}); + + #[allow(unused_mut)] + task::spawn(enclose! {(sdk) async move { + println!("Starting to watch GameServer updates..."); + let mut once = true; + let _ = sdk.watch_gameserver_async(|gameserver| { + println!( + "GameServer Update, name: {}", + gameserver.object_meta.clone().unwrap().name + ); + println!( + "GameServer Update, state: {}", + gameserver.status.clone().unwrap().state + ); + if once { + println!("Setting an annotation"); + let uid = gameserver.object_meta.clone().unwrap().uid.clone(); + #[allow(unused_mut)] + task::spawn(enclose! {(sdk) async move { + let _ = sdk.set_annotation_async("test-annotation", &uid.to_string()) + .await; + }}); + once = false; + } + }) + .await; + }}); + + task::block_on(task::sleep(Duration::from_secs(2))); + + #[allow(unused_mut)] + let handle: task::JoinHandle> = task::spawn(enclose! {(sdk) async move { + println!("Marking server as ready..."); + sdk.ready_async() + .await + .map_err(|e| format!("Could not run Ready(): {}. Exiting!", e))?; + + println!("...marked Ready"); + + println!("Reserving for 5 seconds"); + sdk.reserve_async(Duration::new(5, 0)) + .await + .map_err(|e| format!("Could not run Reserve(): {}. Exiting!", e))?; + println!("...Reserved"); + + println!("Allocate game server ..."); + sdk.allocate_async() + .await + .map_err(|e| format!("Could not run Allocate(): {}. Exiting!", e))?; + + println!("...marked Allocated"); + + println!("Getting GameServer details..."); + let gameserver = sdk + .get_gameserver_async() + .await + .map_err(|e| format!("Could not run GameServer(): {}. Exiting!", e))?; + + println!( + "GameServer name: {}", + gameserver.object_meta.clone().unwrap().name + ); + + println!("Setting a label"); + let creation_ts = gameserver.object_meta.clone().unwrap().creation_timestamp; + sdk.set_label_async("test-label", &creation_ts.to_string()) + .await + .map_err(|e| format!("Could not run SetLabel(): {}. Exiting!", e))?; + + let feature_gates = env::var("FEATURE_GATES").unwrap_or("".to_string()); + if feature_gates.contains("PlayerTracking=true") { + run_player_tracking_features_async(&sdk).await?; + } + + for i in 0..1 { + let time = i * 5; + println!("Running for {} seconds", time); + + task::sleep(Duration::from_secs(5)).await; + } + + println!("Shutting down..."); + sdk.shutdown_async() + .await + .map_err(|e| format!("Could not run Shutdown: {}. Exiting!", e))?; + println!("...marked for Shutdown"); + Ok(()) + }}); + task::block_on(handle).map_err(|e| format!("{}", e))?; + + Ok(()) +} + +async fn run_player_tracking_features_async(sdk: &agones::Sdk) -> Result<(), String> { + println!("Setting player capacity..."); + sdk.alpha() + .set_player_capacity_async(10) + .await + .map_err(|e| format!("Could not run SetPlayerCapacity(): {}. Exiting!", e))?; + + println!("Getting player capacity..."); + let capacity = sdk + .alpha() + .get_player_capacity_async() + .await + .map_err(|e| format!("Could not run GetPlayerCapacity(): {}. Exiting!", e))?; + println!("Player capacity: {}", capacity); + + println!("Increasing the player count..."); + let player_id = "1234".to_string(); + let added = sdk + .alpha() + .player_connect_async(&player_id) + .await + .map_err(|e| format!("Could not run PlayerConnect(): {}. Exiting!", e))?; + if added { + println!("Added player"); + } else { + panic!("Failed to add player. Exiting!"); + } + + let connected = sdk + .alpha() + .is_player_connected_async(&player_id) + .await + .map_err(|e| format!("Could not run IsPlayerConnected(): {}. Exiting!", e))?; + if connected { + println!("{} is connected", player_id); + } else { + panic!("{} is not connected. Exiting!", player_id); + } + + let player_ids = sdk + .alpha() + .get_connected_players_async() + .await + .map_err(|e| format!("Could not run GetConnectedPlayers(): {}. Exiting!", e))?; + println!("Connected players: {:?}", player_ids); + + let player_count = sdk + .alpha() + .get_player_count_async() + .await + .map_err(|e| format!("Could not run GetConnectedPlayers(): {}. Exiting!", e))?; + println!("Current player count: {}", player_count); + + println!("Decreasing the player count..."); + let removed = sdk + .alpha() + .player_disconnect_async(&player_id) + .await + .map_err(|e| format!("Could not run PlayerDisconnect(): {}. Exiting!", e))?; + if removed { + println!("Removed player"); + } else { + panic!("Failed to remove player. Exiting!"); + } + + let player_count = sdk + .alpha() + .get_player_count_async() + .await + .map_err(|e| format!("Could not GetPlayerCount(): {}. Exiting!", e))?; + println!("Current player count: {}", player_count); + + Ok(()) +}