1#![allow(unused_imports)]
5#![allow(unused_extern_crates)]
6#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments, type_complexity))]
7#![cfg_attr(rustfmt, rustfmt_skip)]
8
9extern crate ordered_float;
10extern crate thrift;
11extern crate try_from;
12
13use ordered_float::OrderedFloat;
14use std::cell::RefCell;
15use std::collections::{BTreeMap, BTreeSet};
16use std::convert::From;
17use std::default::Default;
18use std::error::Error;
19use std::fmt;
20use std::fmt::{Display, Formatter};
21use std::rc::Rc;
22use try_from::TryFrom;
23
24use thrift::{ApplicationError, ApplicationErrorKind, ProtocolError, ProtocolErrorKind, TThriftClient};
25use thrift::protocol::{TFieldIdentifier, TListIdentifier, TMapIdentifier, TMessageIdentifier, TMessageType, TInputProtocol, TOutputProtocol, TSetIdentifier, TStructIdentifier, TType};
26use thrift::protocol::field_id;
27use thrift::protocol::verify_expected_message_type;
28use thrift::protocol::verify_expected_sequence_number;
29use thrift::protocol::verify_expected_service_call;
30use thrift::protocol::verify_required_field_exists;
31use thrift::server::TProcessor;
32
33use http_s_d_k_data_types;
34
35pub trait THttpServiceSyncClient {
40 fn subscribe(&mut self, message: http_s_d_k_data_types::SubscribeRequest) -> thrift::Result<http_s_d_k_data_types::SubscribeReply>;
41}
42
43pub trait THttpServiceSyncClientMarker {}
44
45pub struct HttpServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
46 _i_prot: IP,
47 _o_prot: OP,
48 _sequence_number: i32,
49}
50
51impl <IP, OP> HttpServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
52 pub fn new(input_protocol: IP, output_protocol: OP) -> HttpServiceSyncClient<IP, OP> {
53 HttpServiceSyncClient { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }
54 }
55}
56
57impl <IP, OP> TThriftClient for HttpServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
58 fn i_prot_mut(&mut self) -> &mut TInputProtocol { &mut self._i_prot }
59 fn o_prot_mut(&mut self) -> &mut TOutputProtocol { &mut self._o_prot }
60 fn sequence_number(&self) -> i32 { self._sequence_number }
61 fn increment_sequence_number(&mut self) -> i32 { self._sequence_number += 1; self._sequence_number }
62}
63
64impl <IP, OP> THttpServiceSyncClientMarker for HttpServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {}
65
66impl <C: TThriftClient + THttpServiceSyncClientMarker> THttpServiceSyncClient for C {
67 fn subscribe(&mut self, message: http_s_d_k_data_types::SubscribeRequest) -> thrift::Result<http_s_d_k_data_types::SubscribeReply> {
68 (
69 {
70 self.increment_sequence_number();
71 let message_ident = TMessageIdentifier::new("Subscribe", TMessageType::Call, self.sequence_number());
72 let call_args = HttpServiceSubscribeArgs { message: message };
73 self.o_prot_mut().write_message_begin(&message_ident)?;
74 call_args.write_to_out_protocol(self.o_prot_mut())?;
75 self.o_prot_mut().write_message_end()?;
76 self.o_prot_mut().flush()
77 }
78 )?;
79 {
80 let message_ident = self.i_prot_mut().read_message_begin()?;
81 verify_expected_sequence_number(self.sequence_number(), message_ident.sequence_number)?;
82 verify_expected_service_call("Subscribe", &message_ident.name)?;
83 if message_ident.message_type == TMessageType::Exception {
84 let remote_error = thrift::Error::read_application_error_from_in_protocol(self.i_prot_mut())?;
85 self.i_prot_mut().read_message_end()?;
86 return Err(thrift::Error::Application(remote_error))
87 }
88 verify_expected_message_type(TMessageType::Reply, message_ident.message_type)?;
89 let result = HttpServiceSubscribeResult::read_from_in_protocol(self.i_prot_mut())?;
90 self.i_prot_mut().read_message_end()?;
91 result.ok_or()
92 }
93 }
94}
95
96pub trait HttpServiceSyncHandler {
101 fn handle_subscribe(&self, message: http_s_d_k_data_types::SubscribeRequest) -> thrift::Result<http_s_d_k_data_types::SubscribeReply>;
102}
103
104pub struct HttpServiceSyncProcessor<H: HttpServiceSyncHandler> {
105 handler: H,
106}
107
108impl <H: HttpServiceSyncHandler> HttpServiceSyncProcessor<H> {
109 pub fn new(handler: H) -> HttpServiceSyncProcessor<H> {
110 HttpServiceSyncProcessor {
111 handler,
112 }
113 }
114 fn process_subscribe(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
115 THttpServiceProcessFunctions::process_subscribe(&self.handler, incoming_sequence_number, i_prot, o_prot)
116 }
117}
118
119pub struct THttpServiceProcessFunctions;
120
121impl THttpServiceProcessFunctions {
122 pub fn process_subscribe<H: HttpServiceSyncHandler>(handler: &H, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
123 let args = HttpServiceSubscribeArgs::read_from_in_protocol(i_prot)?;
124 match handler.handle_subscribe(args.message) {
125 Ok(handler_return) => {
126 let message_ident = TMessageIdentifier::new("Subscribe", TMessageType::Reply, incoming_sequence_number);
127 o_prot.write_message_begin(&message_ident)?;
128 let ret = HttpServiceSubscribeResult { result_value: Some(handler_return) };
129 ret.write_to_out_protocol(o_prot)?;
130 o_prot.write_message_end()?;
131 o_prot.flush()
132 },
133 Err(e) => {
134 match e {
135 thrift::Error::Application(app_err) => {
136 let message_ident = TMessageIdentifier::new("Subscribe", TMessageType::Exception, incoming_sequence_number);
137 o_prot.write_message_begin(&message_ident)?;
138 thrift::Error::write_application_error_to_out_protocol(&app_err, o_prot)?;
139 o_prot.write_message_end()?;
140 o_prot.flush()
141 },
142 _ => {
143 let ret_err = {
144 ApplicationError::new(
145 ApplicationErrorKind::Unknown,
146 e.description()
147 )
148 };
149 let message_ident = TMessageIdentifier::new("Subscribe", TMessageType::Exception, incoming_sequence_number);
150 o_prot.write_message_begin(&message_ident)?;
151 thrift::Error::write_application_error_to_out_protocol(&ret_err, o_prot)?;
152 o_prot.write_message_end()?;
153 o_prot.flush()
154 },
155 }
156 },
157 }
158 }
159}
160
161impl <H: HttpServiceSyncHandler> TProcessor for HttpServiceSyncProcessor<H> {
162 fn process(&self, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
163 let message_ident = i_prot.read_message_begin()?;
164 let res = match &*message_ident.name {
165 "Subscribe" => {
166 self.process_subscribe(message_ident.sequence_number, i_prot, o_prot)
167 },
168 method => {
169 Err(
170 thrift::Error::Application(
171 ApplicationError::new(
172 ApplicationErrorKind::UnknownMethod,
173 format!("unknown method {}", method)
174 )
175 )
176 )
177 },
178 };
179 thrift::server::handle_process_result(&message_ident, res, o_prot)
180 }
181}
182
183#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
188struct HttpServiceSubscribeArgs {
189 message: http_s_d_k_data_types::SubscribeRequest,
190}
191
192impl HttpServiceSubscribeArgs {
193 fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<HttpServiceSubscribeArgs> {
194 i_prot.read_struct_begin()?;
195 let mut f_1: Option<http_s_d_k_data_types::SubscribeRequest> = None;
196 loop {
197 let field_ident = i_prot.read_field_begin()?;
198 if field_ident.field_type == TType::Stop {
199 break;
200 }
201 let field_id = field_id(&field_ident)?;
202 match field_id {
203 1 => {
204 let val = http_s_d_k_data_types::SubscribeRequest::read_from_in_protocol(i_prot)?;
205 f_1 = Some(val);
206 },
207 _ => {
208 i_prot.skip(field_ident.field_type)?;
209 },
210 };
211 i_prot.read_field_end()?;
212 }
213 i_prot.read_struct_end()?;
214 verify_required_field_exists("HttpServiceSubscribeArgs.message", &f_1)?;
215 let ret = HttpServiceSubscribeArgs {
216 message: f_1.expect("auto-generated code should have checked for presence of required fields"),
217 };
218 Ok(ret)
219 }
220 fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
221 let struct_ident = TStructIdentifier::new("Subscribe_args");
222 o_prot.write_struct_begin(&struct_ident)?;
223 o_prot.write_field_begin(&TFieldIdentifier::new("message", TType::Struct, 1))?;
224 self.message.write_to_out_protocol(o_prot)?;
225 o_prot.write_field_end()?;
226 o_prot.write_field_stop()?;
227 o_prot.write_struct_end()
228 }
229}
230
231#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
236struct HttpServiceSubscribeResult {
237 result_value: Option<http_s_d_k_data_types::SubscribeReply>,
238}
239
240impl HttpServiceSubscribeResult {
241 fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<HttpServiceSubscribeResult> {
242 i_prot.read_struct_begin()?;
243 let mut f_0: Option<http_s_d_k_data_types::SubscribeReply> = None;
244 loop {
245 let field_ident = i_prot.read_field_begin()?;
246 if field_ident.field_type == TType::Stop {
247 break;
248 }
249 let field_id = field_id(&field_ident)?;
250 match field_id {
251 0 => {
252 let val = http_s_d_k_data_types::SubscribeReply::read_from_in_protocol(i_prot)?;
253 f_0 = Some(val);
254 },
255 _ => {
256 i_prot.skip(field_ident.field_type)?;
257 },
258 };
259 i_prot.read_field_end()?;
260 }
261 i_prot.read_struct_end()?;
262 let ret = HttpServiceSubscribeResult {
263 result_value: f_0,
264 };
265 Ok(ret)
266 }
267 fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
268 let struct_ident = TStructIdentifier::new("HttpServiceSubscribeResult");
269 o_prot.write_struct_begin(&struct_ident)?;
270 if let Some(ref fld_var) = self.result_value {
271 o_prot.write_field_begin(&TFieldIdentifier::new("result_value", TType::Struct, 0))?;
272 fld_var.write_to_out_protocol(o_prot)?;
273 o_prot.write_field_end()?;
274 ()
275 } else {
276 ()
277 }
278 o_prot.write_field_stop()?;
279 o_prot.write_struct_end()
280 }
281 fn ok_or(self) -> thrift::Result<http_s_d_k_data_types::SubscribeReply> {
282 if self.result_value.is_some() {
283 Ok(self.result_value.unwrap())
284 } else {
285 Err(
286 thrift::Error::Application(
287 ApplicationError::new(
288 ApplicationErrorKind::MissingResult,
289 "no result received for HttpServiceSubscribe"
290 )
291 )
292 )
293 }
294 }
295}
296