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 media_s_d_k_data_types;
34
35pub trait TMediaServiceSyncClient {
40 fn send_msg(&mut self, request: media_s_d_k_data_types::RequestMsg, broadcast: bool) -> thrift::Result<media_s_d_k_data_types::_int>;
41}
42
43pub trait TMediaServiceSyncClientMarker {}
44
45pub struct MediaServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
46 _i_prot: IP,
47 _o_prot: OP,
48 _sequence_number: i32,
49}
50
51impl <IP, OP> MediaServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
52 pub fn new(input_protocol: IP, output_protocol: OP) -> MediaServiceSyncClient<IP, OP> {
53 MediaServiceSyncClient { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }
54 }
55}
56
57impl <IP, OP> TThriftClient for MediaServiceSyncClient<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> TMediaServiceSyncClientMarker for MediaServiceSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {}
65
66impl <C: TThriftClient + TMediaServiceSyncClientMarker> TMediaServiceSyncClient for C {
67 fn send_msg(&mut self, request: media_s_d_k_data_types::RequestMsg, broadcast: bool) -> thrift::Result<media_s_d_k_data_types::_int> {
68 (
69 {
70 self.increment_sequence_number();
71 let message_ident = TMessageIdentifier::new("SendMsg", TMessageType::Call, self.sequence_number());
72 let call_args = MediaServiceSendMsgArgs { request: request, broadcast: broadcast };
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("SendMsg", &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 = MediaServiceSendMsgResult::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 MediaServiceSyncHandler {
101 fn handle_send_msg(&self, request: media_s_d_k_data_types::RequestMsg, broadcast: bool) -> thrift::Result<media_s_d_k_data_types::_int>;
102}
103
104pub struct MediaServiceSyncProcessor<H: MediaServiceSyncHandler> {
105 handler: H,
106}
107
108impl <H: MediaServiceSyncHandler> MediaServiceSyncProcessor<H> {
109 pub fn new(handler: H) -> MediaServiceSyncProcessor<H> {
110 MediaServiceSyncProcessor {
111 handler,
112 }
113 }
114 fn process_send_msg(&self, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
115 TMediaServiceProcessFunctions::process_send_msg(&self.handler, incoming_sequence_number, i_prot, o_prot)
116 }
117}
118
119pub struct TMediaServiceProcessFunctions;
120
121impl TMediaServiceProcessFunctions {
122 pub fn process_send_msg<H: MediaServiceSyncHandler>(handler: &H, incoming_sequence_number: i32, i_prot: &mut TInputProtocol, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
123 let args = MediaServiceSendMsgArgs::read_from_in_protocol(i_prot)?;
124 match handler.handle_send_msg(args.request, args.broadcast) {
125 Ok(handler_return) => {
126 let message_ident = TMessageIdentifier::new("SendMsg", TMessageType::Reply, incoming_sequence_number);
127 o_prot.write_message_begin(&message_ident)?;
128 let ret = MediaServiceSendMsgResult { 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("SendMsg", 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("SendMsg", 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: MediaServiceSyncHandler> TProcessor for MediaServiceSyncProcessor<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 "SendMsg" => {
166 self.process_send_msg(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 MediaServiceSendMsgArgs {
189 request: media_s_d_k_data_types::RequestMsg,
190 broadcast: bool,
191}
192
193impl MediaServiceSendMsgArgs {
194 fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<MediaServiceSendMsgArgs> {
195 i_prot.read_struct_begin()?;
196 let mut f_1: Option<media_s_d_k_data_types::RequestMsg> = None;
197 let mut f_2: Option<bool> = None;
198 loop {
199 let field_ident = i_prot.read_field_begin()?;
200 if field_ident.field_type == TType::Stop {
201 break;
202 }
203 let field_id = field_id(&field_ident)?;
204 match field_id {
205 1 => {
206 let val = media_s_d_k_data_types::RequestMsg::read_from_in_protocol(i_prot)?;
207 f_1 = Some(val);
208 },
209 2 => {
210 let val = i_prot.read_bool()?;
211 f_2 = Some(val);
212 },
213 _ => {
214 i_prot.skip(field_ident.field_type)?;
215 },
216 };
217 i_prot.read_field_end()?;
218 }
219 i_prot.read_struct_end()?;
220 verify_required_field_exists("MediaServiceSendMsgArgs.request", &f_1)?;
221 verify_required_field_exists("MediaServiceSendMsgArgs.broadcast", &f_2)?;
222 let ret = MediaServiceSendMsgArgs {
223 request: f_1.expect("auto-generated code should have checked for presence of required fields"),
224 broadcast: f_2.expect("auto-generated code should have checked for presence of required fields"),
225 };
226 Ok(ret)
227 }
228 fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
229 let struct_ident = TStructIdentifier::new("SendMsg_args");
230 o_prot.write_struct_begin(&struct_ident)?;
231 o_prot.write_field_begin(&TFieldIdentifier::new("request", TType::Struct, 1))?;
232 self.request.write_to_out_protocol(o_prot)?;
233 o_prot.write_field_end()?;
234 o_prot.write_field_begin(&TFieldIdentifier::new("broadcast", TType::Bool, 2))?;
235 o_prot.write_bool(self.broadcast)?;
236 o_prot.write_field_end()?;
237 o_prot.write_field_stop()?;
238 o_prot.write_struct_end()
239 }
240}
241
242#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
247struct MediaServiceSendMsgResult {
248 result_value: Option<media_s_d_k_data_types::_int>,
249}
250
251impl MediaServiceSendMsgResult {
252 fn read_from_in_protocol(i_prot: &mut TInputProtocol) -> thrift::Result<MediaServiceSendMsgResult> {
253 i_prot.read_struct_begin()?;
254 let mut f_0: Option<media_s_d_k_data_types::_int> = None;
255 loop {
256 let field_ident = i_prot.read_field_begin()?;
257 if field_ident.field_type == TType::Stop {
258 break;
259 }
260 let field_id = field_id(&field_ident)?;
261 match field_id {
262 0 => {
263 let val = i_prot.read_i32()?;
264 f_0 = Some(val);
265 },
266 _ => {
267 i_prot.skip(field_ident.field_type)?;
268 },
269 };
270 i_prot.read_field_end()?;
271 }
272 i_prot.read_struct_end()?;
273 let ret = MediaServiceSendMsgResult {
274 result_value: f_0,
275 };
276 Ok(ret)
277 }
278 fn write_to_out_protocol(&self, o_prot: &mut TOutputProtocol) -> thrift::Result<()> {
279 let struct_ident = TStructIdentifier::new("MediaServiceSendMsgResult");
280 o_prot.write_struct_begin(&struct_ident)?;
281 if let Some(fld_var) = self.result_value {
282 o_prot.write_field_begin(&TFieldIdentifier::new("result_value", TType::I32, 0))?;
283 o_prot.write_i32(fld_var)?;
284 o_prot.write_field_end()?;
285 ()
286 } else {
287 ()
288 }
289 o_prot.write_field_stop()?;
290 o_prot.write_struct_end()
291 }
292 fn ok_or(self) -> thrift::Result<media_s_d_k_data_types::_int> {
293 if self.result_value.is_some() {
294 Ok(self.result_value.unwrap())
295 } else {
296 Err(
297 thrift::Error::Application(
298 ApplicationError::new(
299 ApplicationErrorKind::MissingResult,
300 "no result received for MediaServiceSendMsg"
301 )
302 )
303 )
304 }
305 }
306}
307