#![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 rthrift as 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 shared;
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Operation {
ADD = 1,
SUBTRACT = 2,
MULTIPLY = 3,
DIVIDE = 4,
}
impl Operation {
pub fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
o_prot.write_i32(*self as i32)
}
pub fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<Operation> {
let enum_value = i_prot.read_i32()?;
Operation::try_from(enum_value) }
}
impl TryFrom<i32> for Operation {
type Err = thrift::Error; fn try_from(i: i32) -> Result<Self, Self::Err> {
match i {
1 => Ok(Operation::ADD),
2 => Ok(Operation::SUBTRACT),
3 => Ok(Operation::MULTIPLY),
4 => Ok(Operation::DIVIDE),
_ => {
Err(
thrift::Error::Protocol(
ProtocolError::new(
ProtocolErrorKind::InvalidData,
format!("cannot convert enum constant {} to Operation", i)
)
)
)
},
}
}
}
pub type MyInteger = i32;
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Work {
pub num1: Option<i32>,
pub num2: Option<i32>,
pub op: Option<Operation>,
pub comment: Option<String>,
}
impl Work {
pub fn new<F1, F2, F3, F4>(num1: F1, num2: F2, op: F3, comment: F4) -> Work where F1: Into<Option<i32>>, F2: Into<Option<i32>>, F3: Into<Option<Operation>>, F4: Into<Option<String>> {
Work {
num1: num1.into(),
num2: num2.into(),
op: op.into(),
comment: comment.into(),
}
}
pub fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<Work> {
i_prot.read_struct_begin()?;
let mut f_1: Option<i32> = Some(0);
let mut f_2: Option<i32> = Some(0);
let mut f_3: Option<Operation> = None;
let mut f_4: Option<String> = 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_i32()?;
f_1 = Some(val);
},
2 => {
let val = i_prot.read_i32()?;
f_2 = Some(val);
},
3 => {
let val = Operation::read_from_in_protocol(i_prot)?;
f_3 = Some(val);
},
4 => {
let val = i_prot.read_string()?;
f_4 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = Work {
num1: f_1,
num2: f_2,
op: f_3,
comment: f_4,
};
Ok(ret)
}
pub fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("Work");
o_prot.write_struct_begin(&struct_ident)?;
if let Some(fld_var) = self.num1 {
o_prot.write_field_begin(&TFieldIdentifier::new("num1", TType::I32, 1))?;
o_prot.write_i32(fld_var)?;
o_prot.write_field_end()?;
()
} else {
()
}
if let Some(fld_var) = self.num2 {
o_prot.write_field_begin(&TFieldIdentifier::new("num2", TType::I32, 2))?;
o_prot.write_i32(fld_var)?;
o_prot.write_field_end()?;
()
} else {
()
}
if let Some(ref fld_var) = self.op {
o_prot.write_field_begin(&TFieldIdentifier::new("op", TType::I32, 3))?;
fld_var.write_to_out_protocol(o_prot)?;
o_prot.write_field_end()?;
()
} else {
()
}
if let Some(ref fld_var) = self.comment {
o_prot.write_field_begin(&TFieldIdentifier::new("comment", TType::String, 4))?;
o_prot.write_string(fld_var)?;
o_prot.write_field_end()?;
()
} else {
()
}
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
impl Default for Work {
fn default() -> Self {
Work{
num1: Some(0),
num2: Some(0),
op: None,
comment: Some("".to_owned()),
}
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct InvalidOperation {
pub what_op: Option<i32>,
pub why: Option<String>,
}
impl InvalidOperation {
pub fn new<F1, F2>(what_op: F1, why: F2) -> InvalidOperation where F1: Into<Option<i32>>, F2: Into<Option<String>> {
InvalidOperation {
what_op: what_op.into(),
why: why.into(),
}
}
pub fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<InvalidOperation> {
i_prot.read_struct_begin()?;
let mut f_1: Option<i32> = Some(0);
let mut f_2: Option<String> = Some("".to_owned());
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_i32()?;
f_1 = Some(val);
},
2 => {
let val = i_prot.read_string()?;
f_2 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = InvalidOperation {
what_op: f_1,
why: f_2,
};
Ok(ret)
}
pub fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("InvalidOperation");
o_prot.write_struct_begin(&struct_ident)?;
if let Some(fld_var) = self.what_op {
o_prot.write_field_begin(&TFieldIdentifier::new("whatOp", TType::I32, 1))?;
o_prot.write_i32(fld_var)?;
o_prot.write_field_end()?;
()
} else {
()
}
if let Some(ref fld_var) = self.why {
o_prot.write_field_begin(&TFieldIdentifier::new("why", TType::String, 2))?;
o_prot.write_string(fld_var)?;
o_prot.write_field_end()?;
()
} else {
()
}
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
impl Default for InvalidOperation {
fn default() -> Self {
InvalidOperation{
what_op: Some(0),
why: Some("".to_owned()),
}
}
}
impl Error for InvalidOperation {
fn description(&self) -> &str {
"remote service threw InvalidOperation"
}
}
impl From<InvalidOperation> for thrift::Error {
fn from(e: InvalidOperation) -> Self {
thrift::Error::User(Box::new(e))
}
}
impl Display for InvalidOperation {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
self.description().fmt(f)
}
}
pub const I_N_T32_C_O_N_S_T_A_N_T: i32 = 9853;
pub struct ConstMAPCONSTANT;
impl ConstMAPCONSTANT {
pub fn const_value() -> BTreeMap<String, String> {
{
let mut m: BTreeMap<String, String> = BTreeMap::new();
let k = "hello".to_owned();
let v = "world".to_owned();
m.insert(k, v);
let k = "goodnight".to_owned();
let v = "moon".to_owned();
m.insert(k, v);
m
}
}
}
pub trait TCalculatorSyncClient : shared::TSharedServiceSyncClient {
fn ping(&mut self) -> thrift::Result<()>;
fn add(&mut self, num1: i32, num2: i32) -> thrift::Result<i32>;
fn calculate(&mut self, logid: i32, w: Work) -> thrift::Result<i32>;
fn zip(&mut self) -> thrift::Result<()>;
}
pub trait TCalculatorSyncClientMarker {}
pub struct CalculatorSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
_i_prot: IP,
_o_prot: OP,
_sequence_number: i32,
}
impl <IP, OP> CalculatorSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
pub fn new(input_protocol: IP, output_protocol: OP) -> CalculatorSyncClient<IP, OP> {
CalculatorSyncClient { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }
}
}
impl <IP, OP> TThriftClient for CalculatorSyncClient<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> TCalculatorSyncClientMarker for CalculatorSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {}
impl <IP, OP> shared::TSharedServiceSyncClientMarker for CalculatorSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {}
impl <C: TThriftClient + TCalculatorSyncClientMarker + shared::TSharedServiceSyncClientMarker> TCalculatorSyncClient for C {
fn ping(&mut self) -> thrift::Result<()> {
(
{
self.increment_sequence_number();
let message_ident = TMessageIdentifier::new("ping", TMessageType::Call, self.sequence_number());
let call_args = PingArgs { };
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("ping", &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 = PingResult::read_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
result.ok_or()
}
}
fn add(&mut self, num1: i32, num2: i32) -> thrift::Result<i32> {
(
{
self.increment_sequence_number();
let message_ident = TMessageIdentifier::new("add", TMessageType::Call, self.sequence_number());
let call_args = AddArgs { num1: num1, num2: num2 };
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("add", &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 = AddResult::read_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
result.ok_or()
}
}
fn calculate(&mut self, logid: i32, w: Work) -> thrift::Result<i32> {
(
{
self.increment_sequence_number();
let message_ident = TMessageIdentifier::new("calculate", TMessageType::Call, self.sequence_number());
let call_args = CalculateArgs { logid: logid, w: w };
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("calculate", &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 = CalculateResult::read_from_in_protocol(self.i_prot_mut())?;
self.i_prot_mut().read_message_end()?;
result.ok_or()
}
}
fn zip(&mut self) -> thrift::Result<()> {
(
{
self.increment_sequence_number();
let message_ident = TMessageIdentifier::new("zip", TMessageType::OneWay, self.sequence_number());
let call_args = ZipArgs { };
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()
}
)?;
Ok(())
}
}
pub trait CalculatorSyncHandler : shared::SharedServiceSyncHandler {
fn handle_ping(&self) -> thrift::Result<()>;
fn handle_add(&self, num1: i32, num2: i32) -> thrift::Result<i32>;
fn handle_calculate(&self, logid: i32, w: Work) -> thrift::Result<i32>;
fn handle_zip(&self) -> thrift::Result<()>;
}
pub struct CalculatorSyncProcessor<H: CalculatorSyncHandler> {
handler: H,
}
impl <H: CalculatorSyncHandler> CalculatorSyncProcessor<H> {
pub fn new(handler: H) -> CalculatorSyncProcessor<H> {
CalculatorSyncProcessor {
handler: handler,
}
}
fn process_ping(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
TCalculatorProcessFunctions::process_ping(&self.handler, incoming_sequence_number, i_prot, o_prot)
}
fn process_add(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
TCalculatorProcessFunctions::process_add(&self.handler, incoming_sequence_number, i_prot, o_prot)
}
fn process_calculate(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
TCalculatorProcessFunctions::process_calculate(&self.handler, incoming_sequence_number, i_prot, o_prot)
}
fn process_zip(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
TCalculatorProcessFunctions::process_zip(&self.handler, incoming_sequence_number, i_prot, o_prot)
}
fn process_get_struct(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
shared::TSharedServiceProcessFunctions::process_get_struct(&self.handler, incoming_sequence_number, i_prot, o_prot)
}
}
pub struct TCalculatorProcessFunctions;
impl TCalculatorProcessFunctions {
pub fn process_ping<H: CalculatorSyncHandler>(handler: &H, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let _ = PingArgs::read_from_in_protocol(i_prot)?;
match handler.handle_ping() {
Ok(_) => {
let message_ident = TMessageIdentifier::new("ping", TMessageType::Reply, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
let ret = PingResult { };
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("ping", 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("ping", 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_add<H: CalculatorSyncHandler>(handler: &H, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let args = AddArgs::read_from_in_protocol(i_prot)?;
match handler.handle_add(args.num1, args.num2) {
Ok(handler_return) => {
let message_ident = TMessageIdentifier::new("add", TMessageType::Reply, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
let ret = AddResult { 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("add", 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("add", 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_calculate<H: CalculatorSyncHandler>(handler: &H, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let args = CalculateArgs::read_from_in_protocol(i_prot)?;
match handler.handle_calculate(args.logid, args.w) {
Ok(handler_return) => {
let message_ident = TMessageIdentifier::new("calculate", TMessageType::Reply, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
let ret = CalculateResult { result_value: Some(handler_return), ouch: None };
ret.write_to_out_protocol(o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
},
Err(e) => {
match e {
thrift::Error::User(usr_err) => {
if usr_err.downcast_ref::<InvalidOperation>().is_some() {
let err = usr_err.downcast::<InvalidOperation>().expect("downcast already checked");
let ret_err = CalculateResult{ result_value: None, ouch: Some(*err) };
let message_ident = TMessageIdentifier::new("calculate", TMessageType::Reply, incoming_sequence_number);
o_prot.write_message_begin(&message_ident)?;
ret_err.write_to_out_protocol(o_prot)?;
o_prot.write_message_end()?;
o_prot.flush()
} else {
let ret_err = {
ApplicationError::new(
ApplicationErrorKind::Unknown,
usr_err.description()
)
};
let message_ident = TMessageIdentifier::new("calculate", 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()
}
},
thrift::Error::Application(app_err) => {
let message_ident = TMessageIdentifier::new("calculate", 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("calculate", 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_zip<H: CalculatorSyncHandler>(handler: &H, _: i32, i_prot: &mut TInputProtocol, _: &mut TOutputProtocol) -> thrift::Result<()> {
let _ = ZipArgs::read_from_in_protocol(i_prot)?;
match handler.handle_zip() {
Ok(_) => {
Ok(())
},
Err(e) => {
match e {
thrift::Error::Application(app_err) => {
Err(thrift::Error::Application(app_err))
},
_ => {
let ret_err = {
ApplicationError::new(
ApplicationErrorKind::Unknown,
e.description()
)
};
Err(thrift::Error::Application(ret_err))
},
}
},
}
}
}
impl <H: CalculatorSyncHandler> TProcessor for CalculatorSyncProcessor<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 {
"ping" => {
self.process_ping(message_ident.sequence_number, i_prot, o_prot)
},
"add" => {
self.process_add(message_ident.sequence_number, i_prot, o_prot)
},
"calculate" => {
self.process_calculate(message_ident.sequence_number, i_prot, o_prot)
},
"zip" => {
self.process_zip(message_ident.sequence_number, i_prot, o_prot)
},
"getStruct" => {
self.process_get_struct(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 PingArgs {
}
impl PingArgs {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<PingArgs> {
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 = PingArgs {};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("ping_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 PingResult {
}
impl PingResult {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<PingResult> {
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 = PingResult {};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("PingResult");
o_prot.write_struct_begin(&struct_ident)?;
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
fn ok_or(self) -> thrift::Result<()> {
Ok(())
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct AddArgs {
num1: i32,
num2: i32,
}
impl AddArgs {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<AddArgs> {
i_prot.read_struct_begin()?;
let mut f_1: Option<i32> = None;
let mut f_2: Option<i32> = 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_i32()?;
f_1 = Some(val);
},
2 => {
let val = i_prot.read_i32()?;
f_2 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
verify_required_field_exists("AddArgs.num1", &f_1)?;
verify_required_field_exists("AddArgs.num2", &f_2)?;
let ret = AddArgs {
num1: f_1.expect("auto-generated code should have checked for presence of required fields"),
num2: f_2.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("add_args");
o_prot.write_struct_begin(&struct_ident)?;
o_prot.write_field_begin(&TFieldIdentifier::new("num1", TType::I32, 1))?;
o_prot.write_i32(self.num1)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("num2", TType::I32, 2))?;
o_prot.write_i32(self.num2)?;
o_prot.write_field_end()?;
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct AddResult {
result_value: Option<i32>,
}
impl AddResult {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<AddResult> {
i_prot.read_struct_begin()?;
let mut f_0: Option<i32> = 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_i32()?;
f_0 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = AddResult {
result_value: f_0,
};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("AddResult");
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::I32, 0))?;
o_prot.write_i32(fld_var)?;
o_prot.write_field_end()?;
()
} else {
()
}
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
fn ok_or(self) -> thrift::Result<i32> {
if self.result_value.is_some() {
Ok(self.result_value.unwrap())
} else {
Err(
thrift::Error::Application(
ApplicationError::new(
ApplicationErrorKind::MissingResult,
"no result received for Add"
)
)
)
}
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct CalculateArgs {
logid: i32,
w: Work,
}
impl CalculateArgs {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<CalculateArgs> {
i_prot.read_struct_begin()?;
let mut f_1: Option<i32> = None;
let mut f_2: Option<Work> = 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_i32()?;
f_1 = Some(val);
},
2 => {
let val = Work::read_from_in_protocol(i_prot)?;
f_2 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
verify_required_field_exists("CalculateArgs.logid", &f_1)?;
verify_required_field_exists("CalculateArgs.w", &f_2)?;
let ret = CalculateArgs {
logid: f_1.expect("auto-generated code should have checked for presence of required fields"),
w: f_2.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("calculate_args");
o_prot.write_struct_begin(&struct_ident)?;
o_prot.write_field_begin(&TFieldIdentifier::new("logid", TType::I32, 1))?;
o_prot.write_i32(self.logid)?;
o_prot.write_field_end()?;
o_prot.write_field_begin(&TFieldIdentifier::new("w", TType::Struct, 2))?;
self.w.write_to_out_protocol(o_prot)?;
o_prot.write_field_end()?;
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct CalculateResult {
result_value: Option<i32>,
ouch: Option<InvalidOperation>,
}
impl CalculateResult {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<CalculateResult> {
i_prot.read_struct_begin()?;
let mut f_0: Option<i32> = None;
let mut f_1: Option<InvalidOperation> = 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_i32()?;
f_0 = Some(val);
},
1 => {
let val = InvalidOperation::read_from_in_protocol(i_prot)?;
f_1 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = CalculateResult {
result_value: f_0,
ouch: f_1,
};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("CalculateResult");
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::I32, 0))?;
o_prot.write_i32(fld_var)?;
o_prot.write_field_end()?;
()
} else {
()
}
if let Some(ref fld_var) = self.ouch {
o_prot.write_field_begin(&TFieldIdentifier::new("ouch", TType::Struct, 1))?;
fld_var.write_to_out_protocol(o_prot)?;
o_prot.write_field_end()?;
()
} else {
()
}
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
fn ok_or(self) -> thrift::Result<i32> {
if self.ouch.is_some() {
Err(thrift::Error::User(Box::new(self.ouch.unwrap())))
} else if self.result_value.is_some() {
Ok(self.result_value.unwrap())
} else {
Err(
thrift::Error::Application(
ApplicationError::new(
ApplicationErrorKind::MissingResult,
"no result received for Calculate"
)
)
)
}
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct ZipArgs {
}
impl ZipArgs {
fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<ZipArgs> {
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 = ZipArgs {};
Ok(ret)
}
fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("zip_args");
o_prot.write_struct_begin(&struct_ident)?;
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}