1 // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
2 
3 //! Non-generated version of required structures provided by the protobuf.
4 //! This version is used when the `protobuf` feature is turned off.
5 
6 #![allow(missing_docs)]
7 
8 #[derive(PartialEq, Clone, Default, Debug)]
9 pub struct LabelPair {
10     name: String,
11     value: String,
12 }
13 
14 impl LabelPair {
15     #[deprecated(note = "Use default()", since = "0.5.1")]
new() -> LabelPair16     pub fn new() -> LabelPair {
17         Default::default()
18     }
19 
20     #[deprecated(
21         note = "This method is protobuf specific and will be removed in a future version",
22         since = "0.5.1"
23     )]
clear_name(&mut self)24     pub fn clear_name(&mut self) {
25         self.name.clear();
26     }
27 
set_name(&mut self, v: String)28     pub fn set_name(&mut self, v: String) {
29         self.name = v;
30     }
31 
get_name(&self) -> &str32     pub fn get_name(&self) -> &str {
33         &self.name
34     }
35 
set_value(&mut self, v: String)36     pub fn set_value(&mut self, v: String) {
37         self.value = v;
38     }
39 
get_value(&self) -> &str40     pub fn get_value(&self) -> &str {
41         &self.value
42     }
43 }
44 
45 #[derive(PartialEq, Clone, Default, Debug)]
46 pub struct Gauge {
47     value: f64,
48 }
49 
50 impl Gauge {
51     #[deprecated(note = "Use default()", since = "0.5.1")]
new() -> Gauge52     pub fn new() -> Gauge {
53         Default::default()
54     }
55 
set_value(&mut self, v: f64)56     pub fn set_value(&mut self, v: f64) {
57         self.value = v;
58     }
59 
get_value(&self) -> f6460     pub fn get_value(&self) -> f64 {
61         self.value
62     }
63 }
64 
65 #[derive(PartialEq, Clone, Default, Debug)]
66 pub struct Counter {
67     value: f64,
68 }
69 
70 impl Counter {
71     #[deprecated(note = "Use default()", since = "0.5.1")]
new() -> Counter72     pub fn new() -> Counter {
73         Default::default()
74     }
75 
76     // Param is passed by value, moved
set_value(&mut self, v: f64)77     pub fn set_value(&mut self, v: f64) {
78         self.value = v;
79     }
80 
get_value(&self) -> f6481     pub fn get_value(&self) -> f64 {
82         self.value
83     }
84 }
85 
86 #[derive(PartialEq, Clone, Default, Debug)]
87 pub struct Quantile {
88     quantile: f64,
89     value: f64,
90 }
91 
92 impl Quantile {
93     #[deprecated(note = "Use default()", since = "0.5.1")]
new() -> Quantile94     pub fn new() -> Quantile {
95         Default::default()
96     }
97 
set_quantile(&mut self, v: f64)98     pub fn set_quantile(&mut self, v: f64) {
99         self.quantile = v;
100     }
101 
get_quantile(&self) -> f64102     pub fn get_quantile(&self) -> f64 {
103         self.quantile
104     }
105 
set_value(&mut self, v: f64)106     pub fn set_value(&mut self, v: f64) {
107         self.value = v;
108     }
109 
get_value(&self) -> f64110     pub fn get_value(&self) -> f64 {
111         self.value
112     }
113 }
114 
115 #[derive(PartialEq, Clone, Default, Debug)]
116 pub struct Summary {
117     sample_count: u64,
118     sample_sum: f64,
119     quantile: Vec<Quantile>,
120 }
121 
122 impl Summary {
123     #[deprecated(note = "Use default()", since = "0.5.1")]
new() -> Summary124     pub fn new() -> Summary {
125         Default::default()
126     }
127 
set_sample_count(&mut self, v: u64)128     pub fn set_sample_count(&mut self, v: u64) {
129         self.sample_count = v;
130     }
131 
get_sample_count(&self) -> u64132     pub fn get_sample_count(&self) -> u64 {
133         self.sample_count
134     }
135 
set_sample_sum(&mut self, v: f64)136     pub fn set_sample_sum(&mut self, v: f64) {
137         self.sample_sum = v;
138     }
139 
get_sample_sum(&self) -> f64140     pub fn get_sample_sum(&self) -> f64 {
141         self.sample_sum
142     }
143 
set_quantile(&mut self, v: Vec<Quantile>)144     pub fn set_quantile(&mut self, v: Vec<Quantile>) {
145         self.quantile = v;
146     }
147 
get_quantile(&self) -> &[Quantile]148     pub fn get_quantile(&self) -> &[Quantile] {
149         &self.quantile
150     }
151 }
152 
153 #[derive(PartialEq, Clone, Default, Debug)]
154 pub struct Untyped {
155     value: f64,
156 }
157 
158 impl Untyped {
159     #[deprecated(note = "Use default()", since = "0.5.1")]
new() -> Untyped160     pub fn new() -> Untyped {
161         Default::default()
162     }
163 
164     #[deprecated(
165         note = "Untyped struct is protobuf specific and will be removed in a future version",
166         since = "0.5.1"
167     )]
set_value(&mut self, v: f64)168     pub fn set_value(&mut self, v: f64) {
169         self.value = v;
170     }
171 
172     #[deprecated(
173         note = "Untyped struct is protobuf specific and will be removed in a future version",
174         since = "0.5.1"
175     )]
get_value(&self) -> f64176     pub fn get_value(&self) -> f64 {
177         self.value
178     }
179 }
180 
181 #[derive(PartialEq, Clone, Default, Debug)]
182 pub struct Histogram {
183     sample_count: u64,
184     sample_sum: f64,
185     bucket: Vec<Bucket>,
186 }
187 
188 impl Histogram {
189     #[deprecated(note = "Use default()", since = "0.5.1")]
new() -> Histogram190     pub fn new() -> Histogram {
191         Default::default()
192     }
193 
set_sample_count(&mut self, v: u64)194     pub fn set_sample_count(&mut self, v: u64) {
195         self.sample_count = v;
196     }
197 
get_sample_count(&self) -> u64198     pub fn get_sample_count(&self) -> u64 {
199         self.sample_count
200     }
201 
set_sample_sum(&mut self, v: f64)202     pub fn set_sample_sum(&mut self, v: f64) {
203         self.sample_sum = v;
204     }
205 
get_sample_sum(&self) -> f64206     pub fn get_sample_sum(&self) -> f64 {
207         self.sample_sum
208     }
209 
set_bucket(&mut self, v: Vec<Bucket>)210     pub fn set_bucket(&mut self, v: Vec<Bucket>) {
211         self.bucket = v;
212     }
213 
get_bucket(&self) -> &[Bucket]214     pub fn get_bucket(&self) -> &[Bucket] {
215         &self.bucket
216     }
217 }
218 
219 #[derive(PartialEq, Clone, Default, Debug)]
220 pub struct Bucket {
221     cumulative_count: u64,
222     upper_bound: f64,
223 }
224 
225 impl Bucket {
226     #[deprecated(note = "Use default()", since = "0.5.1")]
new() -> Bucket227     pub fn new() -> Bucket {
228         Default::default()
229     }
230 
set_cumulative_count(&mut self, v: u64)231     pub fn set_cumulative_count(&mut self, v: u64) {
232         self.cumulative_count = v;
233     }
234 
get_cumulative_count(&self) -> u64235     pub fn get_cumulative_count(&self) -> u64 {
236         self.cumulative_count
237     }
238 
set_upper_bound(&mut self, v: f64)239     pub fn set_upper_bound(&mut self, v: f64) {
240         self.upper_bound = v;
241     }
242 
get_upper_bound(&self) -> f64243     pub fn get_upper_bound(&self) -> f64 {
244         self.upper_bound
245     }
246 }
247 
248 #[derive(PartialEq, Clone, Default, Debug)]
249 pub struct Metric {
250     // message fields
251     label: Vec<LabelPair>,
252     gauge: Gauge,
253     counter: Counter,
254     summary: Summary,
255     untyped: Untyped,
256     histogram: Histogram,
257     timestamp_ms: i64,
258 }
259 
260 impl Metric {
261     #[deprecated(note = "Use default()", since = "0.5.1")]
new() -> Metric262     pub fn new() -> Metric {
263         Default::default()
264     }
265 
set_label(&mut self, v: Vec<LabelPair>)266     pub fn set_label(&mut self, v: Vec<LabelPair>) {
267         self.label = v;
268     }
269 
mut_label(&mut self) -> &mut [LabelPair]270     pub fn mut_label(&mut self) -> &mut [LabelPair] {
271         &mut self.label
272     }
273 
take_label(&mut self) -> Vec<LabelPair>274     pub fn take_label(&mut self) -> Vec<LabelPair> {
275         ::std::mem::replace(&mut self.label, Vec::new())
276     }
277 
get_label(&self) -> &[LabelPair]278     pub fn get_label(&self) -> &[LabelPair] {
279         &self.label
280     }
281 
set_gauge(&mut self, v: Gauge)282     pub fn set_gauge(&mut self, v: Gauge) {
283         self.gauge = v;
284     }
285 
get_gauge(&self) -> &Gauge286     pub fn get_gauge(&self) -> &Gauge {
287         &self.gauge
288     }
289 
set_counter(&mut self, v: Counter)290     pub fn set_counter(&mut self, v: Counter) {
291         self.counter = v;
292     }
293 
get_counter(&self) -> &Counter294     pub fn get_counter(&self) -> &Counter {
295         &self.counter
296     }
297 
set_summary(&mut self, v: Summary)298     pub fn set_summary(&mut self, v: Summary) {
299         self.summary = v;
300     }
301 
get_summary(&self) -> &Summary302     pub fn get_summary(&self) -> &Summary {
303         &self.summary
304     }
305 
306     #[deprecated(
307         note = "This method is protobuf specific and will be removed in a future version",
308         since = "0.5.1"
309     )]
set_untyped(&mut self, v: Untyped)310     pub fn set_untyped(&mut self, v: Untyped) {
311         self.untyped = v;
312     }
313 
314     #[deprecated(
315         note = "This method is protobuf specific and will be removed in a future version",
316         since = "0.5.1"
317     )]
get_untyped(&self) -> &Untyped318     pub fn get_untyped(&self) -> &Untyped {
319         &self.untyped
320     }
321 
set_histogram(&mut self, v: Histogram)322     pub fn set_histogram(&mut self, v: Histogram) {
323         self.histogram = v;
324     }
325 
get_histogram(&self) -> &Histogram326     pub fn get_histogram(&self) -> &Histogram {
327         &self.histogram
328     }
329 
set_timestamp_ms(&mut self, v: i64)330     pub fn set_timestamp_ms(&mut self, v: i64) {
331         self.timestamp_ms = v;
332     }
333 
get_timestamp_ms(&self) -> i64334     pub fn get_timestamp_ms(&self) -> i64 {
335         self.timestamp_ms
336     }
337 }
338 
339 #[derive(Clone, PartialEq, Eq, Debug, Hash, Copy)]
340 pub enum MetricType {
341     COUNTER,
342     GAUGE,
343     SUMMARY,
344     UNTYPED,
345     HISTOGRAM,
346 }
347 
348 impl Default for MetricType {
default() -> Self349     fn default() -> Self {
350         MetricType::COUNTER
351     }
352 }
353 
354 #[derive(PartialEq, Clone, Default, Debug)]
355 pub struct MetricFamily {
356     name: String,
357     help: String,
358     field_type: MetricType,
359     metric: Vec<Metric>,
360 }
361 
362 impl MetricFamily {
363     #[deprecated(note = "Use default()", since = "0.5.1")]
new() -> MetricFamily364     pub fn new() -> MetricFamily {
365         Default::default()
366     }
367 
clear_name(&mut self)368     pub fn clear_name(&mut self) {
369         self.name.clear();
370     }
371 
set_name(&mut self, v: String)372     pub fn set_name(&mut self, v: String) {
373         self.name = v;
374     }
375 
get_name(&self) -> &str376     pub fn get_name(&self) -> &str {
377         &self.name
378     }
379 
set_help(&mut self, v: String)380     pub fn set_help(&mut self, v: String) {
381         self.help = v;
382     }
383 
get_help(&self) -> &str384     pub fn get_help(&self) -> &str {
385         &self.help
386     }
387 
set_field_type(&mut self, v: MetricType)388     pub fn set_field_type(&mut self, v: MetricType) {
389         self.field_type = v;
390     }
391 
get_field_type(&self) -> MetricType392     pub fn get_field_type(&self) -> MetricType {
393         self.field_type
394     }
395 
396     #[deprecated(
397         note = "This method is protobuf specific and will be removed in a future version",
398         since = "0.5.1"
399     )]
clear_metric(&mut self)400     pub fn clear_metric(&mut self) {
401         self.metric.clear();
402     }
403 
set_metric(&mut self, v: Vec<Metric>)404     pub fn set_metric(&mut self, v: Vec<Metric>) {
405         self.metric = v;
406     }
407 
mut_metric(&mut self) -> &mut Vec<Metric>408     pub fn mut_metric(&mut self) -> &mut Vec<Metric> {
409         &mut self.metric
410     }
411 
take_metric(&mut self) -> Vec<Metric>412     pub fn take_metric(&mut self) -> Vec<Metric> {
413         ::std::mem::replace(&mut self.metric, Vec::new())
414     }
415 
get_metric(&self) -> &[Metric]416     pub fn get_metric(&self) -> &[Metric] {
417         &self.metric
418     }
419 }
420