#![allow(unused_imports)]
#![allow(unused_extern_crates)]
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments, type_complexity))]
#![cfg_attr(rustfmt, rustfmt_skip)]
extern crate ordered_float;
extern crate thrift;
extern crate try_from;
use ordered_float::OrderedFloat;
use std::cell::RefCell;
use std::collections::{BTreeMap, BTreeSet};
use std::convert::From;
use std::default::Default;
use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::rc::Rc;
use try_from::TryFrom;
use thrift::{ApplicationError, ApplicationErrorKind, ProtocolError, ProtocolErrorKind, TThriftClient};
use thrift::protocol::{TFieldIdentifier, TListIdentifier, TMapIdentifier, TMessageIdentifier, TMessageType, TInputProtocol, TOutputProtocol, TSetIdentifier, TStructIdentifier, TType};
use thrift::protocol::field_id;
use thrift::protocol::verify_expected_message_type;
use thrift::protocol::verify_expected_sequence_number;
use thrift::protocol::verify_expected_service_call;
use thrift::protocol::verify_required_field_exists;
use thrift::server::TProcessor;
use common_type_s_d_k_data_types;
use input_manager_s_d_k_data_types;
pub trait TInputManagerServiceSyncClient {
fn get_connected_gamepads(&mut self) -> thrift::Result<Vec<input_manager_s_d_k_data_types::GamepadInfo>>;
fn set_gamepad_vibration(&mut self, device_id: String, motor1_value: i8, motor1_time: i8, motor2_value: i8, motor2_time: i8) -> thrift::Result<bool>;
fn set_gamepad_light(&mut self, device_id: String, r_value: i8, g_value: i8, b_value: i8) -> thrift::Result<bool>;
fn set_ruyi_controller_status(&mut self, channel: i8, enable_r: bool, enable_g: bool, enable_b: bool, enable_motor1: bool, enable_motor2: bool, shutdown: bool, r_value: i8, g_value: i8, b_value: i8, motor1_value: i8, motor1_time: i8, motor2_value: i8, motor2_time: i8) -> thrift::Result<bool>;
}
pub trait TInputManagerServiceSyncClientMarker {}
pub struct InputManagerServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
_i_prot: IP,
_o_prot: OP,
_sequence_number: i32,
}
impl <IP, OP> InputManagerServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
pub fn new(input_protocol: IP, output_protocol: OP) -> InputManagerServiceSyncClient<IP, OP> {
InputManagerServiceSyncClient { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }
}
}
impl <IP, OP> TThriftClient for InputManagerServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
fn i_prot_mut(&mut self) -> &mut TInputProtocol { &mut self._i_prot }
fn o_prot_mut(&mut self) -> &mut TOutputProtocol { &mut self._o_prot }
fn sequence_number(&self) -> i32 { self._sequence_number }
fn increment_sequence_number(&mut self) -> i32 { self._sequence_number += 1; self._sequence_number }
}
impl <IP, OP> TInputManagerServiceSyncClientMarker for InputManagerServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {}
impl <C: TThriftClient + TInputManagerServiceSyncClientMarker> TInputManagerServiceSyncClient for C {
fn get_connected_gamepads(&mut self) -> thrift::Result<Vec<input_manager_s_d_k_data_types::GamepadInfo>> {
(
{
self.increment_sequence_number();
let message_ident = TMessageIdentifier::new("GetConnectedGamepads", TMessageType::Call, self.sequence_number());
let call_args = InputManagerServiceGetConnectedGamepadsArgs { };
self.o_prot_mut().write_message_begin(&message_ident)?;
call_args.write_to_out_protocol(self.o_prot_mut())?;
self.o_prot_mut().write_message_end()?;
self.o_prot_mut().flush()
}
)?;
{
let message_ident = self.i_prot_mut().read_message_begin()?;
verify_expected_sequence_number(self.sequence_number(), message_ident.sequence_number)?;
verify_expected_service_call("GetConnectedGamepads", &message_ident.name)?;
if message_ident.message_type == TMessageType::Exception {
let remote_error = thrift::Error::read_application_error_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
return Err(thrift::Error::Application(remote_error))
}
verify_expected_message_type(TMessageType::Reply, message_ident.message_type)?;
let result = InputManagerServiceGetConnectedGamepadsResult::read_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
result.ok_or()
}
}
fn set_gamepad_vibration(&mut self, device_id: String, motor1_value: i8, motor1_time: i8, motor2_value: i8, motor2_time: i8) -> thrift::Result<bool> {
(
{
self.increment_sequence_number();
let message_ident = TMessageIdentifier::new("SetGamepadVibration", TMessageType::Call, self.sequence_number());
let call_args = InputManagerServiceSetGamepadVibrationArgs { device_id: device_id, motor1_value: motor1_value, motor1_time: motor1_time, motor2_value: motor2_value, motor2_time: motor2_time };
self.o_prot_mut().write_message_begin(&message_ident)?;
call_args.write_to_out_protocol(self.o_prot_mut())?;
self.o_prot_mut().write_message_end()?;
self.o_prot_mut().flush()
}
)?;
{
let message_ident = self.i_prot_mut().read_message_begin()?;
verify_expected_sequence_number(self.sequence_number(), message_ident.sequence_number)?;
verify_expected_service_call("SetGamepadVibration", &message_ident.name)?;
if message_ident.message_type == TMessageType::Exception {
let remote_error = thrift::Error::read_application_error_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
return Err(thrift::Error::Application(remote_error))
}
verify_expected_message_type(TMessageType::Reply, message_ident.message_type)?;
let result = InputManagerServiceSetGamepadVibrationResult::read_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
result.ok_or()
}
}
fn set_gamepad_light(&mut self, device_id: String, r_value: i8, g_value: i8, b_value: i8) -> thrift::Result<bool> {
(
{
self.increment_sequence_number();
let message_ident = TMessageIdentifier::new("SetGamepadLight", TMessageType::Call, self.sequence_number());
let call_args = InputManagerServiceSetGamepadLightArgs { device_id: device_id, r_value: r_value, g_value: g_value, b_value: b_value };
self.o_prot_mut().write_message_begin(&message_ident)?;
call_args.write_to_out_protocol(self.o_prot_mut())?;
self.o_prot_mut().write_message_end()?;
self.o_prot_mut().flush()
}
)?;
{
let message_ident = self.i_prot_mut().read_message_begin()?;
verify_expected_sequence_number(self.sequence_number(), message_ident.sequence_number)?;
verify_expected_service_call("SetGamepadLight", &message_ident.name)?;
if message_ident.message_type == TMessageType::Exception {
let remote_error = thrift::Error::read_application_error_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
return Err(thrift::Error::Application(remote_error))
}
verify_expected_message_type(TMessageType::Reply, message_ident.message_type)?;
let result = InputManagerServiceSetGamepadLightResult::read_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
result.ok_or()
}
}
fn set_ruyi_controller_status(&mut self, channel: i8, enable_r: bool, enable_g: bool, enable_b: bool, enable_motor1: bool, enable_motor2: bool, shutdown: bool, r_value: i8, g_value: i8, b_value: i8, motor1_value: i8, motor1_time: i8, motor2_value: i8, motor2_time: i8) -> thrift::Result<bool> {
(
{
self.increment_sequence_number();
let message_ident = TMessageIdentifier::new("SetRuyiControllerStatus", TMessageType::Call, self.sequence_number());
let call_args = InputManagerServiceSetRuyiControllerStatusArgs { channel: channel, enable_r: enable_r, enable_g: enable_g, enable_b: enable_b, enable_motor1: enable_motor1, enable_motor2: enable_motor2, shutdown: shutdown, r_value: r_value, g_value: g_value, b_value: b_value, motor1_value: motor1_value, motor1_time: motor1_time, motor2_value: motor2_value, motor2_time: motor2_time };
self.o_prot_mut().write_message_begin(&message_ident)?;
call_args.write_to_out_protocol(self.o_prot_mut())?;
self.o_prot_mut().write_message_end()?;
self.o_prot_mut().flush()
}
)?;
{
let message_ident = self.i_prot_mut().read_message_begin()?;
verify_expected_sequence_number(self.sequence_number(), message_ident.sequence_number)?;
verify_expected_service_call("SetRuyiControllerStatus", &message_ident.name)?;
if message_ident.message_type == TMessageType::Exception {
let remote_error = thrift::Error::read_application_error_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
return Err(thrift::Error::Application(remote_error))
}
verify_expected_message_type(TMessageType::Reply, message_ident.message_type)?;
let result = InputManagerServiceSetRuyiControllerStatusResult::read_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
result.ok_or()
}
}
}
pub trait InputManagerServiceSyncHandler {
fn handle_get_connected_gamepads(&self) -> thrift::Result<Vec<input_manager_s_d_k_data_types::GamepadInfo>>;
fn handle_set_gamepad_vibration(&self, device_id: String, motor1_value: i8, motor1_time: i8, motor2_value: i8, motor2_time: i8) -> thrift::Result<bool>;
fn handle_set_gamepad_light(&self, device_id: String, r_value: i8, g_value: i8, b_value: i8) -> thrift::Result<bool>;
fn handle_set_ruyi_controller_status(&self, channel: i8, enable_r: bool, enable_g: bool, enable_b: bool, enable_motor1: bool, enable_motor2: bool, shutdown: bool, r_value: i8, g_value: i8, b_value: i8, motor1_value: i8, motor1_time: i8, motor2_value: i8, motor2_time: i8) -> thrift::Result<bool>;
}
pub struct InputManagerServiceSyncProcessor<H: InputManagerServiceSyncHandler> {
handler: H,
}
impl <H: InputManagerServiceSyncHandler> InputManagerServiceSyncProcessor<H> {
pub fn new(handler: H) -> InputManagerServiceSyncProcessor<H> {
InputManagerServiceSyncProcessor {
handler,
}
}
fn process_get_connected_gamepads(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
TInputManagerServiceProcessFunctions::process_get_connected_gamepads(&self.handler, incoming_sequence_number, i_prot, o_prot)
}
fn process_set_gamepad_vibration(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
TInputManagerServiceProcessFunctions::process_set_gamepad_vibration(&self.handler, incoming_sequence_number, i_prot, o_prot)
}
fn process_set_gamepad_light(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
TInputManagerServiceProcessFunctions::process_set_gamepad_light(&self.handler, incoming_sequence_number, i_prot, o_prot)
}
fn process_set_ruyi_controller_status(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
TInputManagerServiceProcessFunctions::process_set_ruyi_controller_status(&self.handler, incoming_sequence_number, i_prot, o_prot)
}
}
pub struct TInputManagerServiceProcessFunctions;
impl TInputManagerServiceProcessFunctions {
pub fn process_get_connected_gamepads<H: InputManagerServiceSyncHandler>(handler: &H, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let _ = InputManagerServiceGetConnectedGamepadsArgs::read_from_in_protocol(i_prot)?;
match handler.handle_get_connected_gamepads() {
Ok(handler_return) => {
let message_ident = TMessageIdentifier::new("GetConnectedGamepads", TMessageType::Reply, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
let ret = InputManagerServiceGetConnectedGamepadsResult { result_value: Some(handler_return) };
ret.write_to_out_protocol(o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
Err(e) => {
match e {
thrift::Error::Application(app_err) => {
let message_ident = TMessageIdentifier::new("GetConnectedGamepads", TMessageType::Exception, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
thrift::Error::write_application_error_to_out_protocol(&app_err, o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
_ => {
let ret_err = {
ApplicationError::new(
ApplicationErrorKind::Unknown,
e.description()
)
};
let message_ident = TMessageIdentifier::new("GetConnectedGamepads", TMessageType::Exception, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
thrift::Error::write_application_error_to_out_protocol(&ret_err, o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
}
},
}
}
pub fn process_set_gamepad_vibration<H: InputManagerServiceSyncHandler>(handler: &H, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let args = InputManagerServiceSetGamepadVibrationArgs::read_from_in_protocol(i_prot)?;
match handler.handle_set_gamepad_vibration(args.device_id, args.motor1_value, args.motor1_time, args.motor2_value, args.motor2_time) {
Ok(handler_return) => {
let message_ident = TMessageIdentifier::new("SetGamepadVibration", TMessageType::Reply, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
let ret = InputManagerServiceSetGamepadVibrationResult { result_value: Some(handler_return) };
ret.write_to_out_protocol(o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
Err(e) => {
match e {
thrift::Error::Application(app_err) => {
let message_ident = TMessageIdentifier::new("SetGamepadVibration", TMessageType::Exception, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
thrift::Error::write_application_error_to_out_protocol(&app_err, o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
_ => {
let ret_err = {
ApplicationError::new(
ApplicationErrorKind::Unknown,
e.description()
)
};
let message_ident = TMessageIdentifier::new("SetGamepadVibration", TMessageType::Exception, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
thrift::Error::write_application_error_to_out_protocol(&ret_err, o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
}
},
}
}
pub fn process_set_gamepad_light<H: InputManagerServiceSyncHandler>(handler: &H, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let args = InputManagerServiceSetGamepadLightArgs::read_from_in_protocol(i_prot)?;
match handler.handle_set_gamepad_light(args.device_id, args.r_value, args.g_value, args.b_value) {
Ok(handler_return) => {
let message_ident = TMessageIdentifier::new("SetGamepadLight", TMessageType::Reply, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
let ret = InputManagerServiceSetGamepadLightResult { result_value: Some(handler_return) };
ret.write_to_out_protocol(o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
Err(e) => {
match e {
thrift::Error::Application(app_err) => {
let message_ident = TMessageIdentifier::new("SetGamepadLight", TMessageType::Exception, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
thrift::Error::write_application_error_to_out_protocol(&app_err, o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
_ => {
let ret_err = {
ApplicationError::new(
ApplicationErrorKind::Unknown,
e.description()
)
};
let message_ident = TMessageIdentifier::new("SetGamepadLight", TMessageType::Exception, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
thrift::Error::write_application_error_to_out_protocol(&ret_err, o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
}
},
}
}
pub fn process_set_ruyi_controller_status<H: InputManagerServiceSyncHandler>(handler: &H, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let args = InputManagerServiceSetRuyiControllerStatusArgs::read_from_in_protocol(i_prot)?;
match handler.handle_set_ruyi_controller_status(args.channel, args.enable_r, args.enable_g, args.enable_b, args.enable_motor1, args.enable_motor2, args.shutdown, args.r_value, args.g_value, args.b_value, args.motor1_value, args.motor1_time, args.motor2_value, args.motor2_time) {
Ok(handler_return) => {
let message_ident = TMessageIdentifier::new("SetRuyiControllerStatus", TMessageType::Reply, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
let ret = InputManagerServiceSetRuyiControllerStatusResult { result_value: Some(handler_return) };
ret.write_to_out_protocol(o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
Err(e) => {
match e {
thrift::Error::Application(app_err) => {
let message_ident = TMessageIdentifier::new("SetRuyiControllerStatus", TMessageType::Exception, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
thrift::Error::write_application_error_to_out_protocol(&app_err, o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
_ => {
let ret_err = {
ApplicationError::new(
ApplicationErrorKind::Unknown,
e.description()
)
};
let message_ident = TMessageIdentifier::new("SetRuyiControllerStatus", TMessageType::Exception, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
thrift::Error::write_application_error_to_out_protocol(&ret_err, o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
}
},
}
}
}
impl <H: InputManagerServiceSyncHandler> TProcessor for InputManagerServiceSyncProcessor<H> {
fn process(&self, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let message_ident = i_prot.read_message_begin()?;
let res = match &*message_ident.name {
"GetConnectedGamepads" => {
self.process_get_connected_gamepads(message_ident.sequence_number, i_prot, o_prot)
},
"SetGamepadVibration" => {
self.process_set_gamepad_vibration(message_ident.sequence_number, i_prot, o_prot)
},
"SetGamepadLight" => {
self.process_set_gamepad_light(message_ident.sequence_number, i_prot, o_prot)
},
"SetRuyiControllerStatus" => {
self.process_set_ruyi_controller_status(message_ident.sequence_number, i_prot, o_prot)
},
method => {
Err(
thrift::Error::Application(
ApplicationError::new(
ApplicationErrorKind::UnknownMethod,
format!("unknown method {}", method)
)
)
)
},
};
thrift::server::handle_process_result(&message_ident, res, o_prot)
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct InputManagerServiceGetConnectedGamepadsArgs {
}
impl InputManagerServiceGetConnectedGamepadsArgs {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<InputManagerServiceGetConnectedGamepadsArgs> {
i_prot.read_struct_begin()?;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
let field_id = field_id(&field_ident)?;
match field_id {
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = InputManagerServiceGetConnectedGamepadsArgs {};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("GetConnectedGamepads_args");
o_prot.write_struct_begin(&struct_ident)?;
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct InputManagerServiceGetConnectedGamepadsResult {
result_value: Option<Vec<input_manager_s_d_k_data_types::GamepadInfo>>,
}
impl InputManagerServiceGetConnectedGamepadsResult {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<InputManagerServiceGetConnectedGamepadsResult> {
i_prot.read_struct_begin()?;
let mut f_0: Option<Vec<input_manager_s_d_k_data_types::GamepadInfo>> = None;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
let field_id = field_id(&field_ident)?;
match field_id {
0 => {
let list_ident = i_prot.read_list_begin()?;
let mut val: Vec<input_manager_s_d_k_data_types::GamepadInfo> = Vec::with_capacity(list_ident.size as usize);
for _ in 0..list_ident.size {
let list_elem_0 = input_manager_s_d_k_data_types::GamepadInfo::read_from_in_protocol(i_prot)?;
val.push(list_elem_0);
}
i_prot.read_list_end()?;
f_0 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = InputManagerServiceGetConnectedGamepadsResult {
result_value: f_0,
};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("InputManagerServiceGetConnectedGamepadsResult");
o_prot.write_struct_begin(&struct_ident)?;
if let Some(ref fld_var) = self.result_value {
o_prot.write_field_begin(&TFieldIdentifier::new("result_value", TType::List, 0))?;
o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
for e in fld_var {
e.write_to_out_protocol(o_prot)?;
o_prot.write_list_end()?;
}
o_prot.write_field_end()?;
()
} else {
()
}
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
fn ok_or(self) -> thrift::Result<Vec<input_manager_s_d_k_data_types::GamepadInfo>> {
if self.result_value.is_some() {
Ok(self.result_value.unwrap())
} else {
Err(
thrift::Error::Application(
ApplicationError::new(
ApplicationErrorKind::MissingResult,
"no result received for InputManagerServiceGetConnectedGamepads"
)
)
)
}
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct InputManagerServiceSetGamepadVibrationArgs {
device_id: String,
motor1_value: i8,
motor1_time: i8,
motor2_value: i8,
motor2_time: i8,
}
impl InputManagerServiceSetGamepadVibrationArgs {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<InputManagerServiceSetGamepadVibrationArgs> {
i_prot.read_struct_begin()?;
let mut f_1: Option<String> = None;
let mut f_2: Option<i8> = None;
let mut f_3: Option<i8> = None;
let mut f_4: Option<i8> = None;
let mut f_5: Option<i8> = None;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
let field_id = field_id(&field_ident)?;
match field_id {
1 => {
let val = i_prot.read_string()?;
f_1 = Some(val);
},
2 => {
let val = i_prot.read_i8()?;
f_2 = Some(val);
},
3 => {
let val = i_prot.read_i8()?;
f_3 = Some(val);
},
4 => {
let val = i_prot.read_i8()?;
f_4 = Some(val);
},
5 => {
let val = i_prot.read_i8()?;
f_5 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
verify_required_field_exists("InputManagerServiceSetGamepadVibrationArgs.device_id", &f_1)?;
verify_required_field_exists("InputManagerServiceSetGamepadVibrationArgs.motor1_value", &f_2)?;
verify_required_field_exists("InputManagerServiceSetGamepadVibrationArgs.motor1_time", &f_3)?;
verify_required_field_exists("InputManagerServiceSetGamepadVibrationArgs.motor2_value", &f_4)?;
verify_required_field_exists("InputManagerServiceSetGamepadVibrationArgs.motor2_time", &f_5)?;
let ret = InputManagerServiceSetGamepadVibrationArgs {
device_id: f_1.expect("auto-generated code should have checked for presence of required fields"),
motor1_value: f_2.expect("auto-generated code should have checked for presence of required fields"),
motor1_time: f_3.expect("auto-generated code should have checked for presence of required fields"),
motor2_value: f_4.expect("auto-generated code should have checked for presence of required fields"),
motor2_time: f_5.expect("auto-generated code should have checked for presence of required fields"),
};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("SetGamepadVibration_args");
o_prot.write_struct_begin(&struct_ident)?;
o_prot.write_field_begin(&TFieldIdentifier::new("deviceId", TType::String, 1))?;
o_prot.write_string(&self.device_id)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("motor1Value", TType::I08, 2))?;
o_prot.write_i8(self.motor1_value)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("motor1Time", TType::I08, 3))?;
o_prot.write_i8(self.motor1_time)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("motor2Value", TType::I08, 4))?;
o_prot.write_i8(self.motor2_value)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("motor2Time", TType::I08, 5))?;
o_prot.write_i8(self.motor2_time)?;
o_prot.write_field_end()?;
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct InputManagerServiceSetGamepadVibrationResult {
result_value: Option<bool>,
}
impl InputManagerServiceSetGamepadVibrationResult {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<InputManagerServiceSetGamepadVibrationResult> {
i_prot.read_struct_begin()?;
let mut f_0: Option<bool> = None;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
let field_id = field_id(&field_ident)?;
match field_id {
0 => {
let val = i_prot.read_bool()?;
f_0 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = InputManagerServiceSetGamepadVibrationResult {
result_value: f_0,
};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("InputManagerServiceSetGamepadVibrationResult");
o_prot.write_struct_begin(&struct_ident)?;
if let Some(fld_var) = self.result_value {
o_prot.write_field_begin(&TFieldIdentifier::new("result_value", TType::Bool, 0))?;
o_prot.write_bool(fld_var)?;
o_prot.write_field_end()?;
()
} else {
()
}
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
fn ok_or(self) -> thrift::Result<bool> {
if self.result_value.is_some() {
Ok(self.result_value.unwrap())
} else {
Err(
thrift::Error::Application(
ApplicationError::new(
ApplicationErrorKind::MissingResult,
"no result received for InputManagerServiceSetGamepadVibration"
)
)
)
}
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct InputManagerServiceSetGamepadLightArgs {
device_id: String,
r_value: i8,
g_value: i8,
b_value: i8,
}
impl InputManagerServiceSetGamepadLightArgs {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<InputManagerServiceSetGamepadLightArgs> {
i_prot.read_struct_begin()?;
let mut f_1: Option<String> = None;
let mut f_2: Option<i8> = None;
let mut f_3: Option<i8> = None;
let mut f_4: Option<i8> = None;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
let field_id = field_id(&field_ident)?;
match field_id {
1 => {
let val = i_prot.read_string()?;
f_1 = Some(val);
},
2 => {
let val = i_prot.read_i8()?;
f_2 = Some(val);
},
3 => {
let val = i_prot.read_i8()?;
f_3 = Some(val);
},
4 => {
let val = i_prot.read_i8()?;
f_4 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
verify_required_field_exists("InputManagerServiceSetGamepadLightArgs.device_id", &f_1)?;
verify_required_field_exists("InputManagerServiceSetGamepadLightArgs.r_value", &f_2)?;
verify_required_field_exists("InputManagerServiceSetGamepadLightArgs.g_value", &f_3)?;
verify_required_field_exists("InputManagerServiceSetGamepadLightArgs.b_value", &f_4)?;
let ret = InputManagerServiceSetGamepadLightArgs {
device_id: f_1.expect("auto-generated code should have checked for presence of required fields"),
r_value: f_2.expect("auto-generated code should have checked for presence of required fields"),
g_value: f_3.expect("auto-generated code should have checked for presence of required fields"),
b_value: f_4.expect("auto-generated code should have checked for presence of required fields"),
};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("SetGamepadLight_args");
o_prot.write_struct_begin(&struct_ident)?;
o_prot.write_field_begin(&TFieldIdentifier::new("deviceId", TType::String, 1))?;
o_prot.write_string(&self.device_id)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("RValue", TType::I08, 2))?;
o_prot.write_i8(self.r_value)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("GValue", TType::I08, 3))?;
o_prot.write_i8(self.g_value)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("BValue", TType::I08, 4))?;
o_prot.write_i8(self.b_value)?;
o_prot.write_field_end()?;
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct InputManagerServiceSetGamepadLightResult {
result_value: Option<bool>,
}
impl InputManagerServiceSetGamepadLightResult {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<InputManagerServiceSetGamepadLightResult> {
i_prot.read_struct_begin()?;
let mut f_0: Option<bool> = None;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
let field_id = field_id(&field_ident)?;
match field_id {
0 => {
let val = i_prot.read_bool()?;
f_0 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = InputManagerServiceSetGamepadLightResult {
result_value: f_0,
};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("InputManagerServiceSetGamepadLightResult");
o_prot.write_struct_begin(&struct_ident)?;
if let Some(fld_var) = self.result_value {
o_prot.write_field_begin(&TFieldIdentifier::new("result_value", TType::Bool, 0))?;
o_prot.write_bool(fld_var)?;
o_prot.write_field_end()?;
()
} else {
()
}
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
fn ok_or(self) -> thrift::Result<bool> {
if self.result_value.is_some() {
Ok(self.result_value.unwrap())
} else {
Err(
thrift::Error::Application(
ApplicationError::new(
ApplicationErrorKind::MissingResult,
"no result received for InputManagerServiceSetGamepadLight"
)
)
)
}
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct InputManagerServiceSetRuyiControllerStatusArgs {
channel: i8,
enable_r: bool,
enable_g: bool,
enable_b: bool,
enable_motor1: bool,
enable_motor2: bool,
shutdown: bool,
r_value: i8,
g_value: i8,
b_value: i8,
motor1_value: i8,
motor1_time: i8,
motor2_value: i8,
motor2_time: i8,
}
impl InputManagerServiceSetRuyiControllerStatusArgs {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<InputManagerServiceSetRuyiControllerStatusArgs> {
i_prot.read_struct_begin()?;
let mut f_1: Option<i8> = None;
let mut f_2: Option<bool> = None;
let mut f_3: Option<bool> = None;
let mut f_4: Option<bool> = None;
let mut f_5: Option<bool> = None;
let mut f_6: Option<bool> = None;
let mut f_7: Option<bool> = None;
let mut f_8: Option<i8> = None;
let mut f_9: Option<i8> = None;
let mut f_10: Option<i8> = None;
let mut f_11: Option<i8> = None;
let mut f_12: Option<i8> = None;
let mut f_13: Option<i8> = None;
let mut f_14: Option<i8> = None;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
let field_id = field_id(&field_ident)?;
match field_id {
1 => {
let val = i_prot.read_i8()?;
f_1 = Some(val);
},
2 => {
let val = i_prot.read_bool()?;
f_2 = Some(val);
},
3 => {
let val = i_prot.read_bool()?;
f_3 = Some(val);
},
4 => {
let val = i_prot.read_bool()?;
f_4 = Some(val);
},
5 => {
let val = i_prot.read_bool()?;
f_5 = Some(val);
},
6 => {
let val = i_prot.read_bool()?;
f_6 = Some(val);
},
7 => {
let val = i_prot.read_bool()?;
f_7 = Some(val);
},
8 => {
let val = i_prot.read_i8()?;
f_8 = Some(val);
},
9 => {
let val = i_prot.read_i8()?;
f_9 = Some(val);
},
10 => {
let val = i_prot.read_i8()?;
f_10 = Some(val);
},
11 => {
let val = i_prot.read_i8()?;
f_11 = Some(val);
},
12 => {
let val = i_prot.read_i8()?;
f_12 = Some(val);
},
13 => {
let val = i_prot.read_i8()?;
f_13 = Some(val);
},
14 => {
let val = i_prot.read_i8()?;
f_14 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.channel", &f_1)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.enable_r", &f_2)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.enable_g", &f_3)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.enable_b", &f_4)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.enable_motor1", &f_5)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.enable_motor2", &f_6)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.shutdown", &f_7)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.r_value", &f_8)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.g_value", &f_9)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.b_value", &f_10)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.motor1_value", &f_11)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.motor1_time", &f_12)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.motor2_value", &f_13)?;
verify_required_field_exists("InputManagerServiceSetRuyiControllerStatusArgs.motor2_time", &f_14)?;
let ret = InputManagerServiceSetRuyiControllerStatusArgs {
channel: f_1.expect("auto-generated code should have checked for presence of required fields"),
enable_r: f_2.expect("auto-generated code should have checked for presence of required fields"),
enable_g: f_3.expect("auto-generated code should have checked for presence of required fields"),
enable_b: f_4.expect("auto-generated code should have checked for presence of required fields"),
enable_motor1: f_5.expect("auto-generated code should have checked for presence of required fields"),
enable_motor2: f_6.expect("auto-generated code should have checked for presence of required fields"),
shutdown: f_7.expect("auto-generated code should have checked for presence of required fields"),
r_value: f_8.expect("auto-generated code should have checked for presence of required fields"),
g_value: f_9.expect("auto-generated code should have checked for presence of required fields"),
b_value: f_10.expect("auto-generated code should have checked for presence of required fields"),
motor1_value: f_11.expect("auto-generated code should have checked for presence of required fields"),
motor1_time: f_12.expect("auto-generated code should have checked for presence of required fields"),
motor2_value: f_13.expect("auto-generated code should have checked for presence of required fields"),
motor2_time: f_14.expect("auto-generated code should have checked for presence of required fields"),
};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("SetRuyiControllerStatus_args");
o_prot.write_struct_begin(&struct_ident)?;
o_prot.write_field_begin(&TFieldIdentifier::new("channel", TType::I08, 1))?;
o_prot.write_i8(self.channel)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("enableR", TType::Bool, 2))?;
o_prot.write_bool(self.enable_r)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("enableG", TType::Bool, 3))?;
o_prot.write_bool(self.enable_g)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("enableB", TType::Bool, 4))?;
o_prot.write_bool(self.enable_b)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("enableMotor1", TType::Bool, 5))?;
o_prot.write_bool(self.enable_motor1)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("enableMotor2", TType::Bool, 6))?;
o_prot.write_bool(self.enable_motor2)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("shutdown", TType::Bool, 7))?;
o_prot.write_bool(self.shutdown)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("RValue", TType::I08, 8))?;
o_prot.write_i8(self.r_value)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("GValue", TType::I08, 9))?;
o_prot.write_i8(self.g_value)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("BValue", TType::I08, 10))?;
o_prot.write_i8(self.b_value)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("motor1Value", TType::I08, 11))?;
o_prot.write_i8(self.motor1_value)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("motor1Time", TType::I08, 12))?;
o_prot.write_i8(self.motor1_time)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("motor2Value", TType::I08, 13))?;
o_prot.write_i8(self.motor2_value)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("motor2Time", TType::I08, 14))?;
o_prot.write_i8(self.motor2_time)?;
o_prot.write_field_end()?;
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct InputManagerServiceSetRuyiControllerStatusResult {
result_value: Option<bool>,
}
impl InputManagerServiceSetRuyiControllerStatusResult {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<InputManagerServiceSetRuyiControllerStatusResult> {
i_prot.read_struct_begin()?;
let mut f_0: Option<bool> = None;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
let field_id = field_id(&field_ident)?;
match field_id {
0 => {
let val = i_prot.read_bool()?;
f_0 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = InputManagerServiceSetRuyiControllerStatusResult {
result_value: f_0,
};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("InputManagerServiceSetRuyiControllerStatusResult");
o_prot.write_struct_begin(&struct_ident)?;
if let Some(fld_var) = self.result_value {
o_prot.write_field_begin(&TFieldIdentifier::new("result_value", TType::Bool, 0))?;
o_prot.write_bool(fld_var)?;
o_prot.write_field_end()?;
()
} else {
()
}
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
fn ok_or(self) -> thrift::Result<bool> {
if self.result_value.is_some() {
Ok(self.result_value.unwrap())
} else {
Err(
thrift::Error::Application(
ApplicationError::new(
ApplicationErrorKind::MissingResult,
"no result received for InputManagerServiceSetRuyiControllerStatus"
)
)
)
}
}
}