mick_jaeger/protocol/
jaeger.rs

1// Copied from https://github.com/open-telemetry/opentelemetry-rust/blob/master/opentelemetry-jaeger/src/thrift/jaeger.rs
2// Covered by the license of https://github.com/open-telemetry/opentelemetry-rust (Apache2)
3
4// Autogenerated by Thrift Compiler (0.13.0)
5// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
6
7#![allow(unused_imports)]
8#![allow(unused_extern_crates)]
9#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments, clippy::type_complexity))]
10#![cfg_attr(rustfmt, rustfmt_skip)]
11
12extern crate thrift;
13
14use thrift::OrderedFloat;
15use std::cell::RefCell;
16use std::collections::{BTreeMap, BTreeSet};
17use std::convert::{From, TryFrom};
18use std::default::Default;
19use std::error::Error;
20use std::fmt;
21use std::fmt::{Display, Formatter};
22use std::rc::Rc;
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
33#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub enum TagType {
35  String = 0,
36  Double = 1,
37  Bool = 2,
38  Long = 3,
39  Binary = 4,
40}
41
42impl TagType {
43  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
44    o_prot.write_i32(*self as i32)
45  }
46  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<TagType> {
47    let enum_value = i_prot.read_i32()?;
48    TagType::try_from(enum_value)  }
49}
50
51impl TryFrom<i32> for TagType {
52  type Error = thrift::Error;  fn try_from(i: i32) -> Result<Self, Self::Error> {
53    match i {
54      0 => Ok(TagType::String),
55      1 => Ok(TagType::Double),
56      2 => Ok(TagType::Bool),
57      3 => Ok(TagType::Long),
58      4 => Ok(TagType::Binary),
59      _ => {
60        Err(
61          thrift::Error::Protocol(
62            ProtocolError::new(
63              ProtocolErrorKind::InvalidData,
64              format!("cannot convert enum constant {} to TagType", i)
65            )
66          )
67        )
68      },
69    }
70  }
71}
72
73#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
74pub enum SpanRefType {
75  ChildOf = 0,
76  FollowsFrom = 1,
77}
78
79impl SpanRefType {
80  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
81    o_prot.write_i32(*self as i32)
82  }
83  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<SpanRefType> {
84    let enum_value = i_prot.read_i32()?;
85    SpanRefType::try_from(enum_value)  }
86}
87
88impl TryFrom<i32> for SpanRefType {
89  type Error = thrift::Error;  fn try_from(i: i32) -> Result<Self, Self::Error> {
90    match i {
91      0 => Ok(SpanRefType::ChildOf),
92      1 => Ok(SpanRefType::FollowsFrom),
93      _ => {
94        Err(
95          thrift::Error::Protocol(
96            ProtocolError::new(
97              ProtocolErrorKind::InvalidData,
98              format!("cannot convert enum constant {} to SpanRefType", i)
99            )
100          )
101        )
102      },
103    }
104  }
105}
106
107//
108// Tag
109//
110
111#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
112pub struct Tag {
113  pub key: String,
114  pub v_type: TagType,
115  pub v_str: Option<String>,
116  pub v_double: Option<OrderedFloat<f64>>,
117  pub v_bool: Option<bool>,
118  pub v_long: Option<i64>,
119  pub v_binary: Option<Vec<u8>>,
120}
121
122impl Tag {
123  pub fn new<F3, F4, F5, F6, F7>(key: String, v_type: TagType, v_str: F3, v_double: F4, v_bool: F5, v_long: F6, v_binary: F7) -> Tag where F3: Into<Option<String>>, F4: Into<Option<OrderedFloat<f64>>>, F5: Into<Option<bool>>, F6: Into<Option<i64>>, F7: Into<Option<Vec<u8>>> {
124    Tag {
125      key,
126      v_type,
127      v_str: v_str.into(),
128      v_double: v_double.into(),
129      v_bool: v_bool.into(),
130      v_long: v_long.into(),
131      v_binary: v_binary.into(),
132    }
133  }
134  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<Tag> {
135    i_prot.read_struct_begin()?;
136    let mut f_1: Option<String> = None;
137    let mut f_2: Option<TagType> = None;
138    let mut f_3: Option<String> = None;
139    let mut f_4: Option<OrderedFloat<f64>> = None;
140    let mut f_5: Option<bool> = None;
141    let mut f_6: Option<i64> = None;
142    let mut f_7: Option<Vec<u8>> = None;
143    loop {
144      let field_ident = i_prot.read_field_begin()?;
145      if field_ident.field_type == TType::Stop {
146        break;
147      }
148      let field_id = field_id(&field_ident)?;
149      match field_id {
150        1 => {
151          let val = i_prot.read_string()?;
152          f_1 = Some(val);
153        },
154        2 => {
155          let val = TagType::read_from_in_protocol(i_prot)?;
156          f_2 = Some(val);
157        },
158        3 => {
159          let val = i_prot.read_string()?;
160          f_3 = Some(val);
161        },
162        4 => {
163          let val = OrderedFloat::from(i_prot.read_double()?);
164          f_4 = Some(val);
165        },
166        5 => {
167          let val = i_prot.read_bool()?;
168          f_5 = Some(val);
169        },
170        6 => {
171          let val = i_prot.read_i64()?;
172          f_6 = Some(val);
173        },
174        7 => {
175          let val = i_prot.read_bytes()?;
176          f_7 = Some(val);
177        },
178        _ => {
179          i_prot.skip(field_ident.field_type)?;
180        },
181      };
182      i_prot.read_field_end()?;
183    }
184    i_prot.read_struct_end()?;
185    verify_required_field_exists("Tag.key", &f_1)?;
186    verify_required_field_exists("Tag.v_type", &f_2)?;
187    let ret = Tag {
188      key: f_1.expect("auto-generated code should have checked for presence of required fields"),
189      v_type: f_2.expect("auto-generated code should have checked for presence of required fields"),
190      v_str: f_3,
191      v_double: f_4,
192      v_bool: f_5,
193      v_long: f_6,
194      v_binary: f_7,
195    };
196    Ok(ret)
197  }
198  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
199    let struct_ident = TStructIdentifier::new("Tag");
200    o_prot.write_struct_begin(&struct_ident)?;
201    o_prot.write_field_begin(&TFieldIdentifier::new("key", TType::String, 1))?;
202    o_prot.write_string(&self.key)?;
203    o_prot.write_field_end()?;
204    o_prot.write_field_begin(&TFieldIdentifier::new("vType", TType::I32, 2))?;
205    self.v_type.write_to_out_protocol(o_prot)?;
206    o_prot.write_field_end()?;
207    if let Some(ref fld_var) = self.v_str {
208      o_prot.write_field_begin(&TFieldIdentifier::new("vStr", TType::String, 3))?;
209      o_prot.write_string(fld_var)?;
210      o_prot.write_field_end()?;
211      ()
212    } else {
213      ()
214    }
215    if let Some(fld_var) = self.v_double {
216      o_prot.write_field_begin(&TFieldIdentifier::new("vDouble", TType::Double, 4))?;
217      o_prot.write_double(fld_var.into())?;
218      o_prot.write_field_end()?;
219      ()
220    } else {
221      ()
222    }
223    if let Some(fld_var) = self.v_bool {
224      o_prot.write_field_begin(&TFieldIdentifier::new("vBool", TType::Bool, 5))?;
225      o_prot.write_bool(fld_var)?;
226      o_prot.write_field_end()?;
227      ()
228    } else {
229      ()
230    }
231    if let Some(fld_var) = self.v_long {
232      o_prot.write_field_begin(&TFieldIdentifier::new("vLong", TType::I64, 6))?;
233      o_prot.write_i64(fld_var)?;
234      o_prot.write_field_end()?;
235      ()
236    } else {
237      ()
238    }
239    if let Some(ref fld_var) = self.v_binary {
240      o_prot.write_field_begin(&TFieldIdentifier::new("vBinary", TType::String, 7))?;
241      o_prot.write_bytes(fld_var)?;
242      o_prot.write_field_end()?;
243      ()
244    } else {
245      ()
246    }
247    o_prot.write_field_stop()?;
248    o_prot.write_struct_end()
249  }
250}
251
252//
253// Log
254//
255
256#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
257pub struct Log {
258  pub timestamp: i64,
259  pub fields: Vec<Tag>,
260}
261
262impl Log {
263  pub fn new(timestamp: i64, fields: Vec<Tag>) -> Log {
264    Log {
265      timestamp,
266      fields,
267    }
268  }
269  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<Log> {
270    i_prot.read_struct_begin()?;
271    let mut f_1: Option<i64> = None;
272    let mut f_2: Option<Vec<Tag>> = None;
273    loop {
274      let field_ident = i_prot.read_field_begin()?;
275      if field_ident.field_type == TType::Stop {
276        break;
277      }
278      let field_id = field_id(&field_ident)?;
279      match field_id {
280        1 => {
281          let val = i_prot.read_i64()?;
282          f_1 = Some(val);
283        },
284        2 => {
285          let list_ident = i_prot.read_list_begin()?;
286          let mut val: Vec<Tag> = Vec::with_capacity(list_ident.size as usize);
287          for _ in 0..list_ident.size {
288            let list_elem_0 = Tag::read_from_in_protocol(i_prot)?;
289            val.push(list_elem_0);
290          }
291          i_prot.read_list_end()?;
292          f_2 = Some(val);
293        },
294        _ => {
295          i_prot.skip(field_ident.field_type)?;
296        },
297      };
298      i_prot.read_field_end()?;
299    }
300    i_prot.read_struct_end()?;
301    verify_required_field_exists("Log.timestamp", &f_1)?;
302    verify_required_field_exists("Log.fields", &f_2)?;
303    let ret = Log {
304      timestamp: f_1.expect("auto-generated code should have checked for presence of required fields"),
305      fields: f_2.expect("auto-generated code should have checked for presence of required fields"),
306    };
307    Ok(ret)
308  }
309  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
310    let struct_ident = TStructIdentifier::new("Log");
311    o_prot.write_struct_begin(&struct_ident)?;
312    o_prot.write_field_begin(&TFieldIdentifier::new("timestamp", TType::I64, 1))?;
313    o_prot.write_i64(self.timestamp)?;
314    o_prot.write_field_end()?;
315    o_prot.write_field_begin(&TFieldIdentifier::new("fields", TType::List, 2))?;
316    o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, self.fields.len() as i32))?;
317    for e in &self.fields {
318      e.write_to_out_protocol(o_prot)?;
319      o_prot.write_list_end()?;
320    }
321    o_prot.write_field_end()?;
322    o_prot.write_field_stop()?;
323    o_prot.write_struct_end()
324  }
325}
326
327//
328// SpanRef
329//
330
331#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
332pub struct SpanRef {
333  pub ref_type: SpanRefType,
334  pub trace_id_low: i64,
335  pub trace_id_high: i64,
336  pub span_id: i64,
337}
338
339impl SpanRef {
340  pub fn new(ref_type: SpanRefType, trace_id_low: i64, trace_id_high: i64, span_id: i64) -> SpanRef {
341    SpanRef {
342      ref_type,
343      trace_id_low,
344      trace_id_high,
345      span_id,
346    }
347  }
348  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<SpanRef> {
349    i_prot.read_struct_begin()?;
350    let mut f_1: Option<SpanRefType> = None;
351    let mut f_2: Option<i64> = None;
352    let mut f_3: Option<i64> = None;
353    let mut f_4: Option<i64> = None;
354    loop {
355      let field_ident = i_prot.read_field_begin()?;
356      if field_ident.field_type == TType::Stop {
357        break;
358      }
359      let field_id = field_id(&field_ident)?;
360      match field_id {
361        1 => {
362          let val = SpanRefType::read_from_in_protocol(i_prot)?;
363          f_1 = Some(val);
364        },
365        2 => {
366          let val = i_prot.read_i64()?;
367          f_2 = Some(val);
368        },
369        3 => {
370          let val = i_prot.read_i64()?;
371          f_3 = Some(val);
372        },
373        4 => {
374          let val = i_prot.read_i64()?;
375          f_4 = Some(val);
376        },
377        _ => {
378          i_prot.skip(field_ident.field_type)?;
379        },
380      };
381      i_prot.read_field_end()?;
382    }
383    i_prot.read_struct_end()?;
384    verify_required_field_exists("SpanRef.ref_type", &f_1)?;
385    verify_required_field_exists("SpanRef.trace_id_low", &f_2)?;
386    verify_required_field_exists("SpanRef.trace_id_high", &f_3)?;
387    verify_required_field_exists("SpanRef.span_id", &f_4)?;
388    let ret = SpanRef {
389      ref_type: f_1.expect("auto-generated code should have checked for presence of required fields"),
390      trace_id_low: f_2.expect("auto-generated code should have checked for presence of required fields"),
391      trace_id_high: f_3.expect("auto-generated code should have checked for presence of required fields"),
392      span_id: f_4.expect("auto-generated code should have checked for presence of required fields"),
393    };
394    Ok(ret)
395  }
396  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
397    let struct_ident = TStructIdentifier::new("SpanRef");
398    o_prot.write_struct_begin(&struct_ident)?;
399    o_prot.write_field_begin(&TFieldIdentifier::new("refType", TType::I32, 1))?;
400    self.ref_type.write_to_out_protocol(o_prot)?;
401    o_prot.write_field_end()?;
402    o_prot.write_field_begin(&TFieldIdentifier::new("traceIdLow", TType::I64, 2))?;
403    o_prot.write_i64(self.trace_id_low)?;
404    o_prot.write_field_end()?;
405    o_prot.write_field_begin(&TFieldIdentifier::new("traceIdHigh", TType::I64, 3))?;
406    o_prot.write_i64(self.trace_id_high)?;
407    o_prot.write_field_end()?;
408    o_prot.write_field_begin(&TFieldIdentifier::new("spanId", TType::I64, 4))?;
409    o_prot.write_i64(self.span_id)?;
410    o_prot.write_field_end()?;
411    o_prot.write_field_stop()?;
412    o_prot.write_struct_end()
413  }
414}
415
416//
417// Span
418//
419
420#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
421pub struct Span {
422  pub trace_id_low: i64,
423  pub trace_id_high: i64,
424  pub span_id: i64,
425  pub parent_span_id: i64,
426  pub operation_name: String,
427  pub references: Option<Vec<SpanRef>>,
428  pub flags: i32,
429  pub start_time: i64,
430  pub duration: i64,
431  pub tags: Option<Vec<Tag>>,
432  pub logs: Option<Vec<Log>>,
433}
434
435impl Span {
436  pub fn new<F6, F10, F11>(trace_id_low: i64, trace_id_high: i64, span_id: i64, parent_span_id: i64, operation_name: String, references: F6, flags: i32, start_time: i64, duration: i64, tags: F10, logs: F11) -> Span where F6: Into<Option<Vec<SpanRef>>>, F10: Into<Option<Vec<Tag>>>, F11: Into<Option<Vec<Log>>> {
437    Span {
438      trace_id_low,
439      trace_id_high,
440      span_id,
441      parent_span_id,
442      operation_name,
443      references: references.into(),
444      flags,
445      start_time,
446      duration,
447      tags: tags.into(),
448      logs: logs.into(),
449    }
450  }
451  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<Span> {
452    i_prot.read_struct_begin()?;
453    let mut f_1: Option<i64> = None;
454    let mut f_2: Option<i64> = None;
455    let mut f_3: Option<i64> = None;
456    let mut f_4: Option<i64> = None;
457    let mut f_5: Option<String> = None;
458    let mut f_6: Option<Vec<SpanRef>> = None;
459    let mut f_7: Option<i32> = None;
460    let mut f_8: Option<i64> = None;
461    let mut f_9: Option<i64> = None;
462    let mut f_10: Option<Vec<Tag>> = None;
463    let mut f_11: Option<Vec<Log>> = None;
464    loop {
465      let field_ident = i_prot.read_field_begin()?;
466      if field_ident.field_type == TType::Stop {
467        break;
468      }
469      let field_id = field_id(&field_ident)?;
470      match field_id {
471        1 => {
472          let val = i_prot.read_i64()?;
473          f_1 = Some(val);
474        },
475        2 => {
476          let val = i_prot.read_i64()?;
477          f_2 = Some(val);
478        },
479        3 => {
480          let val = i_prot.read_i64()?;
481          f_3 = Some(val);
482        },
483        4 => {
484          let val = i_prot.read_i64()?;
485          f_4 = Some(val);
486        },
487        5 => {
488          let val = i_prot.read_string()?;
489          f_5 = Some(val);
490        },
491        6 => {
492          let list_ident = i_prot.read_list_begin()?;
493          let mut val: Vec<SpanRef> = Vec::with_capacity(list_ident.size as usize);
494          for _ in 0..list_ident.size {
495            let list_elem_1 = SpanRef::read_from_in_protocol(i_prot)?;
496            val.push(list_elem_1);
497          }
498          i_prot.read_list_end()?;
499          f_6 = Some(val);
500        },
501        7 => {
502          let val = i_prot.read_i32()?;
503          f_7 = Some(val);
504        },
505        8 => {
506          let val = i_prot.read_i64()?;
507          f_8 = Some(val);
508        },
509        9 => {
510          let val = i_prot.read_i64()?;
511          f_9 = Some(val);
512        },
513        10 => {
514          let list_ident = i_prot.read_list_begin()?;
515          let mut val: Vec<Tag> = Vec::with_capacity(list_ident.size as usize);
516          for _ in 0..list_ident.size {
517            let list_elem_2 = Tag::read_from_in_protocol(i_prot)?;
518            val.push(list_elem_2);
519          }
520          i_prot.read_list_end()?;
521          f_10 = Some(val);
522        },
523        11 => {
524          let list_ident = i_prot.read_list_begin()?;
525          let mut val: Vec<Log> = Vec::with_capacity(list_ident.size as usize);
526          for _ in 0..list_ident.size {
527            let list_elem_3 = Log::read_from_in_protocol(i_prot)?;
528            val.push(list_elem_3);
529          }
530          i_prot.read_list_end()?;
531          f_11 = Some(val);
532        },
533        _ => {
534          i_prot.skip(field_ident.field_type)?;
535        },
536      };
537      i_prot.read_field_end()?;
538    }
539    i_prot.read_struct_end()?;
540    verify_required_field_exists("Span.trace_id_low", &f_1)?;
541    verify_required_field_exists("Span.trace_id_high", &f_2)?;
542    verify_required_field_exists("Span.span_id", &f_3)?;
543    verify_required_field_exists("Span.parent_span_id", &f_4)?;
544    verify_required_field_exists("Span.operation_name", &f_5)?;
545    verify_required_field_exists("Span.flags", &f_7)?;
546    verify_required_field_exists("Span.start_time", &f_8)?;
547    verify_required_field_exists("Span.duration", &f_9)?;
548    let ret = Span {
549      trace_id_low: f_1.expect("auto-generated code should have checked for presence of required fields"),
550      trace_id_high: f_2.expect("auto-generated code should have checked for presence of required fields"),
551      span_id: f_3.expect("auto-generated code should have checked for presence of required fields"),
552      parent_span_id: f_4.expect("auto-generated code should have checked for presence of required fields"),
553      operation_name: f_5.expect("auto-generated code should have checked for presence of required fields"),
554      references: f_6,
555      flags: f_7.expect("auto-generated code should have checked for presence of required fields"),
556      start_time: f_8.expect("auto-generated code should have checked for presence of required fields"),
557      duration: f_9.expect("auto-generated code should have checked for presence of required fields"),
558      tags: f_10,
559      logs: f_11,
560    };
561    Ok(ret)
562  }
563  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
564    let struct_ident = TStructIdentifier::new("Span");
565    o_prot.write_struct_begin(&struct_ident)?;
566    o_prot.write_field_begin(&TFieldIdentifier::new("traceIdLow", TType::I64, 1))?;
567    o_prot.write_i64(self.trace_id_low)?;
568    o_prot.write_field_end()?;
569    o_prot.write_field_begin(&TFieldIdentifier::new("traceIdHigh", TType::I64, 2))?;
570    o_prot.write_i64(self.trace_id_high)?;
571    o_prot.write_field_end()?;
572    o_prot.write_field_begin(&TFieldIdentifier::new("spanId", TType::I64, 3))?;
573    o_prot.write_i64(self.span_id)?;
574    o_prot.write_field_end()?;
575    o_prot.write_field_begin(&TFieldIdentifier::new("parentSpanId", TType::I64, 4))?;
576    o_prot.write_i64(self.parent_span_id)?;
577    o_prot.write_field_end()?;
578    o_prot.write_field_begin(&TFieldIdentifier::new("operationName", TType::String, 5))?;
579    o_prot.write_string(&self.operation_name)?;
580    o_prot.write_field_end()?;
581    if let Some(ref fld_var) = self.references {
582      o_prot.write_field_begin(&TFieldIdentifier::new("references", TType::List, 6))?;
583      o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
584      for e in fld_var {
585        e.write_to_out_protocol(o_prot)?;
586        o_prot.write_list_end()?;
587      }
588      o_prot.write_field_end()?;
589      ()
590    } else {
591      ()
592    }
593    o_prot.write_field_begin(&TFieldIdentifier::new("flags", TType::I32, 7))?;
594    o_prot.write_i32(self.flags)?;
595    o_prot.write_field_end()?;
596    o_prot.write_field_begin(&TFieldIdentifier::new("startTime", TType::I64, 8))?;
597    o_prot.write_i64(self.start_time)?;
598    o_prot.write_field_end()?;
599    o_prot.write_field_begin(&TFieldIdentifier::new("duration", TType::I64, 9))?;
600    o_prot.write_i64(self.duration)?;
601    o_prot.write_field_end()?;
602    if let Some(ref fld_var) = self.tags {
603      o_prot.write_field_begin(&TFieldIdentifier::new("tags", TType::List, 10))?;
604      o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
605      for e in fld_var {
606        e.write_to_out_protocol(o_prot)?;
607        o_prot.write_list_end()?;
608      }
609      o_prot.write_field_end()?;
610      ()
611    } else {
612      ()
613    }
614    if let Some(ref fld_var) = self.logs {
615      o_prot.write_field_begin(&TFieldIdentifier::new("logs", TType::List, 11))?;
616      o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
617      for e in fld_var {
618        e.write_to_out_protocol(o_prot)?;
619        o_prot.write_list_end()?;
620      }
621      o_prot.write_field_end()?;
622      ()
623    } else {
624      ()
625    }
626    o_prot.write_field_stop()?;
627    o_prot.write_struct_end()
628  }
629}
630
631//
632// Process
633//
634
635#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
636pub struct Process {
637  pub service_name: String,
638  pub tags: Option<Vec<Tag>>,
639}
640
641impl Process {
642  pub fn new<F2>(service_name: String, tags: F2) -> Process where F2: Into<Option<Vec<Tag>>> {
643    Process {
644      service_name,
645      tags: tags.into(),
646    }
647  }
648  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<Process> {
649    i_prot.read_struct_begin()?;
650    let mut f_1: Option<String> = None;
651    let mut f_2: Option<Vec<Tag>> = None;
652    loop {
653      let field_ident = i_prot.read_field_begin()?;
654      if field_ident.field_type == TType::Stop {
655        break;
656      }
657      let field_id = field_id(&field_ident)?;
658      match field_id {
659        1 => {
660          let val = i_prot.read_string()?;
661          f_1 = Some(val);
662        },
663        2 => {
664          let list_ident = i_prot.read_list_begin()?;
665          let mut val: Vec<Tag> = Vec::with_capacity(list_ident.size as usize);
666          for _ in 0..list_ident.size {
667            let list_elem_4 = Tag::read_from_in_protocol(i_prot)?;
668            val.push(list_elem_4);
669          }
670          i_prot.read_list_end()?;
671          f_2 = Some(val);
672        },
673        _ => {
674          i_prot.skip(field_ident.field_type)?;
675        },
676      };
677      i_prot.read_field_end()?;
678    }
679    i_prot.read_struct_end()?;
680    verify_required_field_exists("Process.service_name", &f_1)?;
681    let ret = Process {
682      service_name: f_1.expect("auto-generated code should have checked for presence of required fields"),
683      tags: f_2,
684    };
685    Ok(ret)
686  }
687  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
688    let struct_ident = TStructIdentifier::new("Process");
689    o_prot.write_struct_begin(&struct_ident)?;
690    o_prot.write_field_begin(&TFieldIdentifier::new("serviceName", TType::String, 1))?;
691    o_prot.write_string(&self.service_name)?;
692    o_prot.write_field_end()?;
693    if let Some(ref fld_var) = self.tags {
694      o_prot.write_field_begin(&TFieldIdentifier::new("tags", TType::List, 2))?;
695      o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
696      for e in fld_var {
697        e.write_to_out_protocol(o_prot)?;
698        o_prot.write_list_end()?;
699      }
700      o_prot.write_field_end()?;
701      ()
702    } else {
703      ()
704    }
705    o_prot.write_field_stop()?;
706    o_prot.write_struct_end()
707  }
708}
709
710//
711// Batch
712//
713
714#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
715pub struct Batch {
716  pub process: Process,
717  pub spans: Vec<Span>,
718}
719
720impl Batch {
721  pub fn new(process: Process, spans: Vec<Span>) -> Batch {
722    Batch {
723      process,
724      spans,
725    }
726  }
727  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<Batch> {
728    i_prot.read_struct_begin()?;
729    let mut f_1: Option<Process> = None;
730    let mut f_2: Option<Vec<Span>> = None;
731    loop {
732      let field_ident = i_prot.read_field_begin()?;
733      if field_ident.field_type == TType::Stop {
734        break;
735      }
736      let field_id = field_id(&field_ident)?;
737      match field_id {
738        1 => {
739          let val = Process::read_from_in_protocol(i_prot)?;
740          f_1 = Some(val);
741        },
742        2 => {
743          let list_ident = i_prot.read_list_begin()?;
744          let mut val: Vec<Span> = Vec::with_capacity(list_ident.size as usize);
745          for _ in 0..list_ident.size {
746            let list_elem_5 = Span::read_from_in_protocol(i_prot)?;
747            val.push(list_elem_5);
748          }
749          i_prot.read_list_end()?;
750          f_2 = Some(val);
751        },
752        _ => {
753          i_prot.skip(field_ident.field_type)?;
754        },
755      };
756      i_prot.read_field_end()?;
757    }
758    i_prot.read_struct_end()?;
759    verify_required_field_exists("Batch.process", &f_1)?;
760    verify_required_field_exists("Batch.spans", &f_2)?;
761    let ret = Batch {
762      process: f_1.expect("auto-generated code should have checked for presence of required fields"),
763      spans: f_2.expect("auto-generated code should have checked for presence of required fields"),
764    };
765    Ok(ret)
766  }
767  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
768    let struct_ident = TStructIdentifier::new("Batch");
769    o_prot.write_struct_begin(&struct_ident)?;
770    o_prot.write_field_begin(&TFieldIdentifier::new("process", TType::Struct, 1))?;
771    self.process.write_to_out_protocol(o_prot)?;
772    o_prot.write_field_end()?;
773    o_prot.write_field_begin(&TFieldIdentifier::new("spans", TType::List, 2))?;
774    o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, self.spans.len() as i32))?;
775    for e in &self.spans {
776      e.write_to_out_protocol(o_prot)?;
777      o_prot.write_list_end()?;
778    }
779    o_prot.write_field_end()?;
780    o_prot.write_field_stop()?;
781    o_prot.write_struct_end()
782  }
783}
784
785//
786// BatchSubmitResponse
787//
788
789#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
790pub struct BatchSubmitResponse {
791  pub ok: bool,
792}
793
794impl BatchSubmitResponse {
795  pub fn new(ok: bool) -> BatchSubmitResponse {
796    BatchSubmitResponse {
797      ok,
798    }
799  }
800  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<BatchSubmitResponse> {
801    i_prot.read_struct_begin()?;
802    let mut f_1: Option<bool> = None;
803    loop {
804      let field_ident = i_prot.read_field_begin()?;
805      if field_ident.field_type == TType::Stop {
806        break;
807      }
808      let field_id = field_id(&field_ident)?;
809      match field_id {
810        1 => {
811          let val = i_prot.read_bool()?;
812          f_1 = Some(val);
813        },
814        _ => {
815          i_prot.skip(field_ident.field_type)?;
816        },
817      };
818      i_prot.read_field_end()?;
819    }
820    i_prot.read_struct_end()?;
821    verify_required_field_exists("BatchSubmitResponse.ok", &f_1)?;
822    let ret = BatchSubmitResponse {
823      ok: f_1.expect("auto-generated code should have checked for presence of required fields"),
824    };
825    Ok(ret)
826  }
827  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
828    let struct_ident = TStructIdentifier::new("BatchSubmitResponse");
829    o_prot.write_struct_begin(&struct_ident)?;
830    o_prot.write_field_begin(&TFieldIdentifier::new("ok", TType::Bool, 1))?;
831    o_prot.write_bool(self.ok)?;
832    o_prot.write_field_end()?;
833    o_prot.write_field_stop()?;
834    o_prot.write_struct_end()
835  }
836}
837
838//
839// Collector service client
840//
841
842pub trait TCollectorSyncClient {
843  fn submit_batches(&mut self, batches: Vec<Batch>) -> thrift::Result<Vec<BatchSubmitResponse>>;
844}
845
846pub trait TCollectorSyncClientMarker {}
847
848pub struct CollectorSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
849  _i_prot: IP,
850  _o_prot: OP,
851  _sequence_number: i32,
852}
853
854impl <IP, OP> CollectorSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
855  pub fn new(input_protocol: IP, output_protocol: OP) -> CollectorSyncClient<IP, OP> {
856    CollectorSyncClient { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }
857  }
858}
859
860impl <IP, OP> TThriftClient for CollectorSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {
861  fn i_prot_mut(&mut self) -> &mut dyn TInputProtocol { &mut self._i_prot }
862  fn o_prot_mut(&mut self) -> &mut dyn TOutputProtocol { &mut self._o_prot }
863  fn sequence_number(&self) -> i32 { self._sequence_number }
864  fn increment_sequence_number(&mut self) -> i32 { self._sequence_number += 1; self._sequence_number }
865}
866
867impl <IP, OP> TCollectorSyncClientMarker for CollectorSyncClient<IP, OP> where IP: TInputProtocol, OP: TOutputProtocol {}
868
869impl <C: TThriftClient + TCollectorSyncClientMarker> TCollectorSyncClient for C {
870  fn submit_batches(&mut self, batches: Vec<Batch>) -> thrift::Result<Vec<BatchSubmitResponse>> {
871    (
872      {
873        self.increment_sequence_number();
874        let message_ident = TMessageIdentifier::new("submitBatches", TMessageType::Call, self.sequence_number());
875        let call_args = CollectorSubmitBatchesArgs { batches };
876        self.o_prot_mut().write_message_begin(&message_ident)?;
877        call_args.write_to_out_protocol(self.o_prot_mut())?;
878        self.o_prot_mut().write_message_end()?;
879        self.o_prot_mut().flush()
880      }
881    )?;
882    {
883      let message_ident = self.i_prot_mut().read_message_begin()?;
884      verify_expected_sequence_number(self.sequence_number(), message_ident.sequence_number)?;
885      verify_expected_service_call("submitBatches", &message_ident.name)?;
886      if message_ident.message_type == TMessageType::Exception {
887        let remote_error = thrift::Error::read_application_error_from_in_protocol(self.i_prot_mut())?;
888        self.i_prot_mut().read_message_end()?;
889        return Err(thrift::Error::Application(remote_error))
890      }
891      verify_expected_message_type(TMessageType::Reply, message_ident.message_type)?;
892      let result = CollectorSubmitBatchesResult::read_from_in_protocol(self.i_prot_mut())?;
893      self.i_prot_mut().read_message_end()?;
894      result.ok_or()
895    }
896  }
897}
898
899//
900// Collector service processor
901//
902
903pub trait CollectorSyncHandler {
904  fn handle_submit_batches(&self, batches: Vec<Batch>) -> thrift::Result<Vec<BatchSubmitResponse>>;
905}
906
907pub struct CollectorSyncProcessor<H: CollectorSyncHandler> {
908  handler: H,
909}
910
911impl <H: CollectorSyncHandler> CollectorSyncProcessor<H> {
912  pub fn new(handler: H) -> CollectorSyncProcessor<H> {
913    CollectorSyncProcessor {
914      handler,
915    }
916  }
917  fn process_submit_batches(&self, incoming_sequence_number: i32, i_prot: &mut dyn TInputProtocol, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
918    TCollectorProcessFunctions::process_submit_batches(&self.handler, incoming_sequence_number, i_prot, o_prot)
919  }
920}
921
922pub struct TCollectorProcessFunctions;
923
924impl TCollectorProcessFunctions {
925  pub fn process_submit_batches<H: CollectorSyncHandler>(handler: &H, incoming_sequence_number: i32, i_prot: &mut dyn TInputProtocol, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
926    let args = CollectorSubmitBatchesArgs::read_from_in_protocol(i_prot)?;
927    match handler.handle_submit_batches(args.batches) {
928      Ok(handler_return) => {
929        let message_ident = TMessageIdentifier::new("submitBatches", TMessageType::Reply, incoming_sequence_number);
930        o_prot.write_message_begin(&message_ident)?;
931        let ret = CollectorSubmitBatchesResult { result_value: Some(handler_return) };
932        ret.write_to_out_protocol(o_prot)?;
933        o_prot.write_message_end()?;
934        o_prot.flush()
935      },
936      Err(e) => {
937        match e {
938          thrift::Error::Application(app_err) => {
939            let message_ident = TMessageIdentifier::new("submitBatches", TMessageType::Exception, incoming_sequence_number);
940            o_prot.write_message_begin(&message_ident)?;
941            thrift::Error::write_application_error_to_out_protocol(&app_err, o_prot)?;
942            o_prot.write_message_end()?;
943            o_prot.flush()
944          },
945          _ => {
946            let ret_err = {
947              ApplicationError::new(
948                ApplicationErrorKind::Unknown,
949                e.to_string()
950              )
951            };
952            let message_ident = TMessageIdentifier::new("submitBatches", TMessageType::Exception, incoming_sequence_number);
953            o_prot.write_message_begin(&message_ident)?;
954            thrift::Error::write_application_error_to_out_protocol(&ret_err, o_prot)?;
955            o_prot.write_message_end()?;
956            o_prot.flush()
957          },
958        }
959      },
960    }
961  }
962}
963
964impl <H: CollectorSyncHandler> TProcessor for CollectorSyncProcessor<H> {
965  fn process(&self, i_prot: &mut dyn TInputProtocol, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
966    let message_ident = i_prot.read_message_begin()?;
967    let res = match &*message_ident.name {
968      "submitBatches" => {
969        self.process_submit_batches(message_ident.sequence_number, i_prot, o_prot)
970      },
971      method => {
972        Err(
973          thrift::Error::Application(
974            ApplicationError::new(
975              ApplicationErrorKind::UnknownMethod,
976              format!("unknown method {}", method)
977            )
978          )
979        )
980      },
981    };
982    thrift::server::handle_process_result(&message_ident, res, o_prot)
983  }
984}
985
986//
987// CollectorSubmitBatchesArgs
988//
989
990#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
991struct CollectorSubmitBatchesArgs {
992  batches: Vec<Batch>,
993}
994
995impl CollectorSubmitBatchesArgs {
996  fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<CollectorSubmitBatchesArgs> {
997    i_prot.read_struct_begin()?;
998    let mut f_1: Option<Vec<Batch>> = None;
999    loop {
1000      let field_ident = i_prot.read_field_begin()?;
1001      if field_ident.field_type == TType::Stop {
1002        break;
1003      }
1004      let field_id = field_id(&field_ident)?;
1005      match field_id {
1006        1 => {
1007          let list_ident = i_prot.read_list_begin()?;
1008          let mut val: Vec<Batch> = Vec::with_capacity(list_ident.size as usize);
1009          for _ in 0..list_ident.size {
1010            let list_elem_6 = Batch::read_from_in_protocol(i_prot)?;
1011            val.push(list_elem_6);
1012          }
1013          i_prot.read_list_end()?;
1014          f_1 = Some(val);
1015        },
1016        _ => {
1017          i_prot.skip(field_ident.field_type)?;
1018        },
1019      };
1020      i_prot.read_field_end()?;
1021    }
1022    i_prot.read_struct_end()?;
1023    verify_required_field_exists("CollectorSubmitBatchesArgs.batches", &f_1)?;
1024    let ret = CollectorSubmitBatchesArgs {
1025      batches: f_1.expect("auto-generated code should have checked for presence of required fields"),
1026    };
1027    Ok(ret)
1028  }
1029  fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
1030    let struct_ident = TStructIdentifier::new("submitBatches_args");
1031    o_prot.write_struct_begin(&struct_ident)?;
1032    o_prot.write_field_begin(&TFieldIdentifier::new("batches", TType::List, 1))?;
1033    o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, self.batches.len() as i32))?;
1034    for e in &self.batches {
1035      e.write_to_out_protocol(o_prot)?;
1036      o_prot.write_list_end()?;
1037    }
1038    o_prot.write_field_end()?;
1039    o_prot.write_field_stop()?;
1040    o_prot.write_struct_end()
1041  }
1042}
1043
1044//
1045// CollectorSubmitBatchesResult
1046//
1047
1048#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1049struct CollectorSubmitBatchesResult {
1050  result_value: Option<Vec<BatchSubmitResponse>>,
1051}
1052
1053impl CollectorSubmitBatchesResult {
1054  fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<CollectorSubmitBatchesResult> {
1055    i_prot.read_struct_begin()?;
1056    let mut f_0: Option<Vec<BatchSubmitResponse>> = None;
1057    loop {
1058      let field_ident = i_prot.read_field_begin()?;
1059      if field_ident.field_type == TType::Stop {
1060        break;
1061      }
1062      let field_id = field_id(&field_ident)?;
1063      match field_id {
1064        0 => {
1065          let list_ident = i_prot.read_list_begin()?;
1066          let mut val: Vec<BatchSubmitResponse> = Vec::with_capacity(list_ident.size as usize);
1067          for _ in 0..list_ident.size {
1068            let list_elem_7 = BatchSubmitResponse::read_from_in_protocol(i_prot)?;
1069            val.push(list_elem_7);
1070          }
1071          i_prot.read_list_end()?;
1072          f_0 = Some(val);
1073        },
1074        _ => {
1075          i_prot.skip(field_ident.field_type)?;
1076        },
1077      };
1078      i_prot.read_field_end()?;
1079    }
1080    i_prot.read_struct_end()?;
1081    let ret = CollectorSubmitBatchesResult {
1082      result_value: f_0,
1083    };
1084    Ok(ret)
1085  }
1086  fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
1087    let struct_ident = TStructIdentifier::new("CollectorSubmitBatchesResult");
1088    o_prot.write_struct_begin(&struct_ident)?;
1089    if let Some(ref fld_var) = self.result_value {
1090      o_prot.write_field_begin(&TFieldIdentifier::new("result_value", TType::List, 0))?;
1091      o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
1092      for e in fld_var {
1093        e.write_to_out_protocol(o_prot)?;
1094        o_prot.write_list_end()?;
1095      }
1096      o_prot.write_field_end()?;
1097      ()
1098    } else {
1099      ()
1100    }
1101    o_prot.write_field_stop()?;
1102    o_prot.write_struct_end()
1103  }
1104  fn ok_or(self) -> thrift::Result<Vec<BatchSubmitResponse>> {
1105    if self.result_value.is_some() {
1106      Ok(self.result_value.unwrap())
1107    } else {
1108      Err(
1109        thrift::Error::Application(
1110          ApplicationError::new(
1111            ApplicationErrorKind::MissingResult,
1112            "no result received for CollectorSubmitBatches"
1113          )
1114        )
1115      )
1116    }
1117  }
1118}
1119