Skip to main content

google_cloud_trace_v2/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate google_cloud_rpc;
25extern crate serde;
26extern crate serde_json;
27extern crate serde_with;
28extern crate std;
29extern crate tracing;
30extern crate wkt;
31
32mod debug;
33mod deserialize;
34mod serialize;
35
36/// A span represents a single operation within a trace. Spans can be
37/// nested to form a trace tree. Often, a trace contains a root span
38/// that describes the end-to-end latency, and one or more subspans for
39/// its sub-operations.
40///
41/// A trace can also contain multiple root spans, or none at all.
42/// Spans do not need to be contiguous. There might be
43/// gaps or overlaps between spans in a trace.
44#[derive(Clone, Default, PartialEq)]
45#[non_exhaustive]
46pub struct Span {
47    /// Required. The resource name of the span in the following format:
48    ///
49    /// * `projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]`
50    ///
51    /// `[TRACE_ID]` is a unique identifier for a trace within a project;
52    /// it is a 32-character hexadecimal encoding of a 16-byte array. It should
53    /// not be zero.
54    ///
55    /// `[SPAN_ID]` is a unique identifier for a span within a trace; it
56    /// is a 16-character hexadecimal encoding of an 8-byte array. It should not
57    /// be zero.
58    /// .
59    pub name: std::string::String,
60
61    /// Required. The `[SPAN_ID]` portion of the span's resource name.
62    pub span_id: std::string::String,
63
64    /// The `[SPAN_ID]` of this span's parent span. If this is a root span,
65    /// then this field must be empty.
66    pub parent_span_id: std::string::String,
67
68    /// Required. A description of the span's operation (up to 128 bytes).
69    /// Cloud Trace displays the description in the
70    /// Cloud console.
71    /// For example, the display name can be a qualified method name or a file name
72    /// and a line number where the operation is called. A best practice is to use
73    /// the same display name within an application and at the same call point.
74    /// This makes it easier to correlate spans in different traces.
75    pub display_name: std::option::Option<crate::model::TruncatableString>,
76
77    /// Required. The start time of the span. On the client side, this is the time
78    /// kept by the local machine where the span execution starts. On the server
79    /// side, this is the time when the server's application handler starts
80    /// running.
81    pub start_time: std::option::Option<wkt::Timestamp>,
82
83    /// Required. The end time of the span. On the client side, this is the time
84    /// kept by the local machine where the span execution ends. On the server
85    /// side, this is the time when the server application handler stops running.
86    pub end_time: std::option::Option<wkt::Timestamp>,
87
88    /// A set of attributes on the span. You can have up to 32 attributes per
89    /// span.
90    pub attributes: std::option::Option<crate::model::span::Attributes>,
91
92    /// Stack trace captured at the start of the span.
93    pub stack_trace: std::option::Option<crate::model::StackTrace>,
94
95    /// A set of time events. You can have up to 32 annotations and 128 message
96    /// events per span.
97    pub time_events: std::option::Option<crate::model::span::TimeEvents>,
98
99    /// Links associated with the span. You can have up to 128 links per Span.
100    pub links: std::option::Option<crate::model::span::Links>,
101
102    /// Optional. The final status for this span.
103    pub status: std::option::Option<google_cloud_rpc::model::Status>,
104
105    /// Optional. Set this parameter to indicate whether this span is in
106    /// the same process as its parent. If you do not set this parameter,
107    /// Trace is unable to take advantage of this helpful information.
108    pub same_process_as_parent_span: std::option::Option<wkt::BoolValue>,
109
110    /// Optional. The number of child spans that were generated while this span
111    /// was active. If set, allows implementation to detect missing child spans.
112    pub child_span_count: std::option::Option<wkt::Int32Value>,
113
114    /// Optional. Distinguishes between spans generated in a particular context.
115    /// For example, two spans with the same name may be distinguished using
116    /// `CLIENT` (caller) and `SERVER` (callee) to identify an RPC call.
117    pub span_kind: crate::model::span::SpanKind,
118
119    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
120}
121
122impl Span {
123    /// Creates a new default instance.
124    pub fn new() -> Self {
125        std::default::Default::default()
126    }
127
128    /// Sets the value of [name][crate::model::Span::name].
129    ///
130    /// # Example
131    /// ```ignore,no_run
132    /// # use google_cloud_trace_v2::model::Span;
133    /// let x = Span::new().set_name("example");
134    /// ```
135    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
136        self.name = v.into();
137        self
138    }
139
140    /// Sets the value of [span_id][crate::model::Span::span_id].
141    ///
142    /// # Example
143    /// ```ignore,no_run
144    /// # use google_cloud_trace_v2::model::Span;
145    /// let x = Span::new().set_span_id("example");
146    /// ```
147    pub fn set_span_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
148        self.span_id = v.into();
149        self
150    }
151
152    /// Sets the value of [parent_span_id][crate::model::Span::parent_span_id].
153    ///
154    /// # Example
155    /// ```ignore,no_run
156    /// # use google_cloud_trace_v2::model::Span;
157    /// let x = Span::new().set_parent_span_id("example");
158    /// ```
159    pub fn set_parent_span_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
160        self.parent_span_id = v.into();
161        self
162    }
163
164    /// Sets the value of [display_name][crate::model::Span::display_name].
165    ///
166    /// # Example
167    /// ```ignore,no_run
168    /// # use google_cloud_trace_v2::model::Span;
169    /// use google_cloud_trace_v2::model::TruncatableString;
170    /// let x = Span::new().set_display_name(TruncatableString::default()/* use setters */);
171    /// ```
172    pub fn set_display_name<T>(mut self, v: T) -> Self
173    where
174        T: std::convert::Into<crate::model::TruncatableString>,
175    {
176        self.display_name = std::option::Option::Some(v.into());
177        self
178    }
179
180    /// Sets or clears the value of [display_name][crate::model::Span::display_name].
181    ///
182    /// # Example
183    /// ```ignore,no_run
184    /// # use google_cloud_trace_v2::model::Span;
185    /// use google_cloud_trace_v2::model::TruncatableString;
186    /// let x = Span::new().set_or_clear_display_name(Some(TruncatableString::default()/* use setters */));
187    /// let x = Span::new().set_or_clear_display_name(None::<TruncatableString>);
188    /// ```
189    pub fn set_or_clear_display_name<T>(mut self, v: std::option::Option<T>) -> Self
190    where
191        T: std::convert::Into<crate::model::TruncatableString>,
192    {
193        self.display_name = v.map(|x| x.into());
194        self
195    }
196
197    /// Sets the value of [start_time][crate::model::Span::start_time].
198    ///
199    /// # Example
200    /// ```ignore,no_run
201    /// # use google_cloud_trace_v2::model::Span;
202    /// use wkt::Timestamp;
203    /// let x = Span::new().set_start_time(Timestamp::default()/* use setters */);
204    /// ```
205    pub fn set_start_time<T>(mut self, v: T) -> Self
206    where
207        T: std::convert::Into<wkt::Timestamp>,
208    {
209        self.start_time = std::option::Option::Some(v.into());
210        self
211    }
212
213    /// Sets or clears the value of [start_time][crate::model::Span::start_time].
214    ///
215    /// # Example
216    /// ```ignore,no_run
217    /// # use google_cloud_trace_v2::model::Span;
218    /// use wkt::Timestamp;
219    /// let x = Span::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
220    /// let x = Span::new().set_or_clear_start_time(None::<Timestamp>);
221    /// ```
222    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
223    where
224        T: std::convert::Into<wkt::Timestamp>,
225    {
226        self.start_time = v.map(|x| x.into());
227        self
228    }
229
230    /// Sets the value of [end_time][crate::model::Span::end_time].
231    ///
232    /// # Example
233    /// ```ignore,no_run
234    /// # use google_cloud_trace_v2::model::Span;
235    /// use wkt::Timestamp;
236    /// let x = Span::new().set_end_time(Timestamp::default()/* use setters */);
237    /// ```
238    pub fn set_end_time<T>(mut self, v: T) -> Self
239    where
240        T: std::convert::Into<wkt::Timestamp>,
241    {
242        self.end_time = std::option::Option::Some(v.into());
243        self
244    }
245
246    /// Sets or clears the value of [end_time][crate::model::Span::end_time].
247    ///
248    /// # Example
249    /// ```ignore,no_run
250    /// # use google_cloud_trace_v2::model::Span;
251    /// use wkt::Timestamp;
252    /// let x = Span::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
253    /// let x = Span::new().set_or_clear_end_time(None::<Timestamp>);
254    /// ```
255    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
256    where
257        T: std::convert::Into<wkt::Timestamp>,
258    {
259        self.end_time = v.map(|x| x.into());
260        self
261    }
262
263    /// Sets the value of [attributes][crate::model::Span::attributes].
264    ///
265    /// # Example
266    /// ```ignore,no_run
267    /// # use google_cloud_trace_v2::model::Span;
268    /// use google_cloud_trace_v2::model::span::Attributes;
269    /// let x = Span::new().set_attributes(Attributes::default()/* use setters */);
270    /// ```
271    pub fn set_attributes<T>(mut self, v: T) -> Self
272    where
273        T: std::convert::Into<crate::model::span::Attributes>,
274    {
275        self.attributes = std::option::Option::Some(v.into());
276        self
277    }
278
279    /// Sets or clears the value of [attributes][crate::model::Span::attributes].
280    ///
281    /// # Example
282    /// ```ignore,no_run
283    /// # use google_cloud_trace_v2::model::Span;
284    /// use google_cloud_trace_v2::model::span::Attributes;
285    /// let x = Span::new().set_or_clear_attributes(Some(Attributes::default()/* use setters */));
286    /// let x = Span::new().set_or_clear_attributes(None::<Attributes>);
287    /// ```
288    pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
289    where
290        T: std::convert::Into<crate::model::span::Attributes>,
291    {
292        self.attributes = v.map(|x| x.into());
293        self
294    }
295
296    /// Sets the value of [stack_trace][crate::model::Span::stack_trace].
297    ///
298    /// # Example
299    /// ```ignore,no_run
300    /// # use google_cloud_trace_v2::model::Span;
301    /// use google_cloud_trace_v2::model::StackTrace;
302    /// let x = Span::new().set_stack_trace(StackTrace::default()/* use setters */);
303    /// ```
304    pub fn set_stack_trace<T>(mut self, v: T) -> Self
305    where
306        T: std::convert::Into<crate::model::StackTrace>,
307    {
308        self.stack_trace = std::option::Option::Some(v.into());
309        self
310    }
311
312    /// Sets or clears the value of [stack_trace][crate::model::Span::stack_trace].
313    ///
314    /// # Example
315    /// ```ignore,no_run
316    /// # use google_cloud_trace_v2::model::Span;
317    /// use google_cloud_trace_v2::model::StackTrace;
318    /// let x = Span::new().set_or_clear_stack_trace(Some(StackTrace::default()/* use setters */));
319    /// let x = Span::new().set_or_clear_stack_trace(None::<StackTrace>);
320    /// ```
321    pub fn set_or_clear_stack_trace<T>(mut self, v: std::option::Option<T>) -> Self
322    where
323        T: std::convert::Into<crate::model::StackTrace>,
324    {
325        self.stack_trace = v.map(|x| x.into());
326        self
327    }
328
329    /// Sets the value of [time_events][crate::model::Span::time_events].
330    ///
331    /// # Example
332    /// ```ignore,no_run
333    /// # use google_cloud_trace_v2::model::Span;
334    /// use google_cloud_trace_v2::model::span::TimeEvents;
335    /// let x = Span::new().set_time_events(TimeEvents::default()/* use setters */);
336    /// ```
337    pub fn set_time_events<T>(mut self, v: T) -> Self
338    where
339        T: std::convert::Into<crate::model::span::TimeEvents>,
340    {
341        self.time_events = std::option::Option::Some(v.into());
342        self
343    }
344
345    /// Sets or clears the value of [time_events][crate::model::Span::time_events].
346    ///
347    /// # Example
348    /// ```ignore,no_run
349    /// # use google_cloud_trace_v2::model::Span;
350    /// use google_cloud_trace_v2::model::span::TimeEvents;
351    /// let x = Span::new().set_or_clear_time_events(Some(TimeEvents::default()/* use setters */));
352    /// let x = Span::new().set_or_clear_time_events(None::<TimeEvents>);
353    /// ```
354    pub fn set_or_clear_time_events<T>(mut self, v: std::option::Option<T>) -> Self
355    where
356        T: std::convert::Into<crate::model::span::TimeEvents>,
357    {
358        self.time_events = v.map(|x| x.into());
359        self
360    }
361
362    /// Sets the value of [links][crate::model::Span::links].
363    ///
364    /// # Example
365    /// ```ignore,no_run
366    /// # use google_cloud_trace_v2::model::Span;
367    /// use google_cloud_trace_v2::model::span::Links;
368    /// let x = Span::new().set_links(Links::default()/* use setters */);
369    /// ```
370    pub fn set_links<T>(mut self, v: T) -> Self
371    where
372        T: std::convert::Into<crate::model::span::Links>,
373    {
374        self.links = std::option::Option::Some(v.into());
375        self
376    }
377
378    /// Sets or clears the value of [links][crate::model::Span::links].
379    ///
380    /// # Example
381    /// ```ignore,no_run
382    /// # use google_cloud_trace_v2::model::Span;
383    /// use google_cloud_trace_v2::model::span::Links;
384    /// let x = Span::new().set_or_clear_links(Some(Links::default()/* use setters */));
385    /// let x = Span::new().set_or_clear_links(None::<Links>);
386    /// ```
387    pub fn set_or_clear_links<T>(mut self, v: std::option::Option<T>) -> Self
388    where
389        T: std::convert::Into<crate::model::span::Links>,
390    {
391        self.links = v.map(|x| x.into());
392        self
393    }
394
395    /// Sets the value of [status][crate::model::Span::status].
396    ///
397    /// # Example
398    /// ```ignore,no_run
399    /// # use google_cloud_trace_v2::model::Span;
400    /// use google_cloud_rpc::model::Status;
401    /// let x = Span::new().set_status(Status::default()/* use setters */);
402    /// ```
403    pub fn set_status<T>(mut self, v: T) -> Self
404    where
405        T: std::convert::Into<google_cloud_rpc::model::Status>,
406    {
407        self.status = std::option::Option::Some(v.into());
408        self
409    }
410
411    /// Sets or clears the value of [status][crate::model::Span::status].
412    ///
413    /// # Example
414    /// ```ignore,no_run
415    /// # use google_cloud_trace_v2::model::Span;
416    /// use google_cloud_rpc::model::Status;
417    /// let x = Span::new().set_or_clear_status(Some(Status::default()/* use setters */));
418    /// let x = Span::new().set_or_clear_status(None::<Status>);
419    /// ```
420    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
421    where
422        T: std::convert::Into<google_cloud_rpc::model::Status>,
423    {
424        self.status = v.map(|x| x.into());
425        self
426    }
427
428    /// Sets the value of [same_process_as_parent_span][crate::model::Span::same_process_as_parent_span].
429    ///
430    /// # Example
431    /// ```ignore,no_run
432    /// # use google_cloud_trace_v2::model::Span;
433    /// use wkt::BoolValue;
434    /// let x = Span::new().set_same_process_as_parent_span(BoolValue::default()/* use setters */);
435    /// ```
436    pub fn set_same_process_as_parent_span<T>(mut self, v: T) -> Self
437    where
438        T: std::convert::Into<wkt::BoolValue>,
439    {
440        self.same_process_as_parent_span = std::option::Option::Some(v.into());
441        self
442    }
443
444    /// Sets or clears the value of [same_process_as_parent_span][crate::model::Span::same_process_as_parent_span].
445    ///
446    /// # Example
447    /// ```ignore,no_run
448    /// # use google_cloud_trace_v2::model::Span;
449    /// use wkt::BoolValue;
450    /// let x = Span::new().set_or_clear_same_process_as_parent_span(Some(BoolValue::default()/* use setters */));
451    /// let x = Span::new().set_or_clear_same_process_as_parent_span(None::<BoolValue>);
452    /// ```
453    pub fn set_or_clear_same_process_as_parent_span<T>(mut self, v: std::option::Option<T>) -> Self
454    where
455        T: std::convert::Into<wkt::BoolValue>,
456    {
457        self.same_process_as_parent_span = v.map(|x| x.into());
458        self
459    }
460
461    /// Sets the value of [child_span_count][crate::model::Span::child_span_count].
462    ///
463    /// # Example
464    /// ```ignore,no_run
465    /// # use google_cloud_trace_v2::model::Span;
466    /// use wkt::Int32Value;
467    /// let x = Span::new().set_child_span_count(Int32Value::default()/* use setters */);
468    /// ```
469    pub fn set_child_span_count<T>(mut self, v: T) -> Self
470    where
471        T: std::convert::Into<wkt::Int32Value>,
472    {
473        self.child_span_count = std::option::Option::Some(v.into());
474        self
475    }
476
477    /// Sets or clears the value of [child_span_count][crate::model::Span::child_span_count].
478    ///
479    /// # Example
480    /// ```ignore,no_run
481    /// # use google_cloud_trace_v2::model::Span;
482    /// use wkt::Int32Value;
483    /// let x = Span::new().set_or_clear_child_span_count(Some(Int32Value::default()/* use setters */));
484    /// let x = Span::new().set_or_clear_child_span_count(None::<Int32Value>);
485    /// ```
486    pub fn set_or_clear_child_span_count<T>(mut self, v: std::option::Option<T>) -> Self
487    where
488        T: std::convert::Into<wkt::Int32Value>,
489    {
490        self.child_span_count = v.map(|x| x.into());
491        self
492    }
493
494    /// Sets the value of [span_kind][crate::model::Span::span_kind].
495    ///
496    /// # Example
497    /// ```ignore,no_run
498    /// # use google_cloud_trace_v2::model::Span;
499    /// use google_cloud_trace_v2::model::span::SpanKind;
500    /// let x0 = Span::new().set_span_kind(SpanKind::Internal);
501    /// let x1 = Span::new().set_span_kind(SpanKind::Server);
502    /// let x2 = Span::new().set_span_kind(SpanKind::Client);
503    /// ```
504    pub fn set_span_kind<T: std::convert::Into<crate::model::span::SpanKind>>(
505        mut self,
506        v: T,
507    ) -> Self {
508        self.span_kind = v.into();
509        self
510    }
511}
512
513impl wkt::message::Message for Span {
514    fn typename() -> &'static str {
515        "type.googleapis.com/google.devtools.cloudtrace.v2.Span"
516    }
517}
518
519/// Defines additional types related to [Span].
520pub mod span {
521    #[allow(unused_imports)]
522    use super::*;
523
524    /// A set of attributes as key-value pairs.
525    #[derive(Clone, Default, PartialEq)]
526    #[non_exhaustive]
527    pub struct Attributes {
528        /// A set of attributes. Each attribute's key can be up to 128 bytes
529        /// long. The value can be a string up to 256 bytes, a signed 64-bit integer,
530        /// or the boolean values `true` or `false`. For example:
531        ///
532        /// ```norust
533        /// "/instance_id": { "string_value": { "value": "my-instance" } }
534        /// "/http/request_bytes": { "int_value": 300 }
535        /// "abc.com/myattribute": { "bool_value": false }
536        /// ```
537        pub attribute_map:
538            std::collections::HashMap<std::string::String, crate::model::AttributeValue>,
539
540        /// The number of attributes that were discarded. Attributes can be discarded
541        /// because their keys are too long or because there are too many attributes.
542        /// If this value is 0 then all attributes are valid.
543        pub dropped_attributes_count: i32,
544
545        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
546    }
547
548    impl Attributes {
549        /// Creates a new default instance.
550        pub fn new() -> Self {
551            std::default::Default::default()
552        }
553
554        /// Sets the value of [attribute_map][crate::model::span::Attributes::attribute_map].
555        ///
556        /// # Example
557        /// ```ignore,no_run
558        /// # use google_cloud_trace_v2::model::span::Attributes;
559        /// use google_cloud_trace_v2::model::AttributeValue;
560        /// let x = Attributes::new().set_attribute_map([
561        ///     ("key0", AttributeValue::default()/* use setters */),
562        ///     ("key1", AttributeValue::default()/* use (different) setters */),
563        /// ]);
564        /// ```
565        pub fn set_attribute_map<T, K, V>(mut self, v: T) -> Self
566        where
567            T: std::iter::IntoIterator<Item = (K, V)>,
568            K: std::convert::Into<std::string::String>,
569            V: std::convert::Into<crate::model::AttributeValue>,
570        {
571            use std::iter::Iterator;
572            self.attribute_map = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
573            self
574        }
575
576        /// Sets the value of [dropped_attributes_count][crate::model::span::Attributes::dropped_attributes_count].
577        ///
578        /// # Example
579        /// ```ignore,no_run
580        /// # use google_cloud_trace_v2::model::span::Attributes;
581        /// let x = Attributes::new().set_dropped_attributes_count(42);
582        /// ```
583        pub fn set_dropped_attributes_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
584            self.dropped_attributes_count = v.into();
585            self
586        }
587    }
588
589    impl wkt::message::Message for Attributes {
590        fn typename() -> &'static str {
591            "type.googleapis.com/google.devtools.cloudtrace.v2.Span.Attributes"
592        }
593    }
594
595    /// A time-stamped annotation or message event in the Span.
596    #[derive(Clone, Default, PartialEq)]
597    #[non_exhaustive]
598    pub struct TimeEvent {
599        /// The timestamp indicating the time the event occurred.
600        pub time: std::option::Option<wkt::Timestamp>,
601
602        /// A `TimeEvent` can contain either an `Annotation` object or a
603        /// `MessageEvent` object, but not both.
604        pub value: std::option::Option<crate::model::span::time_event::Value>,
605
606        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
607    }
608
609    impl TimeEvent {
610        /// Creates a new default instance.
611        pub fn new() -> Self {
612            std::default::Default::default()
613        }
614
615        /// Sets the value of [time][crate::model::span::TimeEvent::time].
616        ///
617        /// # Example
618        /// ```ignore,no_run
619        /// # use google_cloud_trace_v2::model::span::TimeEvent;
620        /// use wkt::Timestamp;
621        /// let x = TimeEvent::new().set_time(Timestamp::default()/* use setters */);
622        /// ```
623        pub fn set_time<T>(mut self, v: T) -> Self
624        where
625            T: std::convert::Into<wkt::Timestamp>,
626        {
627            self.time = std::option::Option::Some(v.into());
628            self
629        }
630
631        /// Sets or clears the value of [time][crate::model::span::TimeEvent::time].
632        ///
633        /// # Example
634        /// ```ignore,no_run
635        /// # use google_cloud_trace_v2::model::span::TimeEvent;
636        /// use wkt::Timestamp;
637        /// let x = TimeEvent::new().set_or_clear_time(Some(Timestamp::default()/* use setters */));
638        /// let x = TimeEvent::new().set_or_clear_time(None::<Timestamp>);
639        /// ```
640        pub fn set_or_clear_time<T>(mut self, v: std::option::Option<T>) -> Self
641        where
642            T: std::convert::Into<wkt::Timestamp>,
643        {
644            self.time = v.map(|x| x.into());
645            self
646        }
647
648        /// Sets the value of [value][crate::model::span::TimeEvent::value].
649        ///
650        /// Note that all the setters affecting `value` are mutually
651        /// exclusive.
652        ///
653        /// # Example
654        /// ```ignore,no_run
655        /// # use google_cloud_trace_v2::model::span::TimeEvent;
656        /// use google_cloud_trace_v2::model::span::time_event::Annotation;
657        /// let x = TimeEvent::new().set_value(Some(
658        ///     google_cloud_trace_v2::model::span::time_event::Value::Annotation(Annotation::default().into())));
659        /// ```
660        pub fn set_value<
661            T: std::convert::Into<std::option::Option<crate::model::span::time_event::Value>>,
662        >(
663            mut self,
664            v: T,
665        ) -> Self {
666            self.value = v.into();
667            self
668        }
669
670        /// The value of [value][crate::model::span::TimeEvent::value]
671        /// if it holds a `Annotation`, `None` if the field is not set or
672        /// holds a different branch.
673        pub fn annotation(
674            &self,
675        ) -> std::option::Option<&std::boxed::Box<crate::model::span::time_event::Annotation>>
676        {
677            #[allow(unreachable_patterns)]
678            self.value.as_ref().and_then(|v| match v {
679                crate::model::span::time_event::Value::Annotation(v) => {
680                    std::option::Option::Some(v)
681                }
682                _ => std::option::Option::None,
683            })
684        }
685
686        /// Sets the value of [value][crate::model::span::TimeEvent::value]
687        /// to hold a `Annotation`.
688        ///
689        /// Note that all the setters affecting `value` are
690        /// mutually exclusive.
691        ///
692        /// # Example
693        /// ```ignore,no_run
694        /// # use google_cloud_trace_v2::model::span::TimeEvent;
695        /// use google_cloud_trace_v2::model::span::time_event::Annotation;
696        /// let x = TimeEvent::new().set_annotation(Annotation::default()/* use setters */);
697        /// assert!(x.annotation().is_some());
698        /// assert!(x.message_event().is_none());
699        /// ```
700        pub fn set_annotation<
701            T: std::convert::Into<std::boxed::Box<crate::model::span::time_event::Annotation>>,
702        >(
703            mut self,
704            v: T,
705        ) -> Self {
706            self.value = std::option::Option::Some(
707                crate::model::span::time_event::Value::Annotation(v.into()),
708            );
709            self
710        }
711
712        /// The value of [value][crate::model::span::TimeEvent::value]
713        /// if it holds a `MessageEvent`, `None` if the field is not set or
714        /// holds a different branch.
715        pub fn message_event(
716            &self,
717        ) -> std::option::Option<&std::boxed::Box<crate::model::span::time_event::MessageEvent>>
718        {
719            #[allow(unreachable_patterns)]
720            self.value.as_ref().and_then(|v| match v {
721                crate::model::span::time_event::Value::MessageEvent(v) => {
722                    std::option::Option::Some(v)
723                }
724                _ => std::option::Option::None,
725            })
726        }
727
728        /// Sets the value of [value][crate::model::span::TimeEvent::value]
729        /// to hold a `MessageEvent`.
730        ///
731        /// Note that all the setters affecting `value` are
732        /// mutually exclusive.
733        ///
734        /// # Example
735        /// ```ignore,no_run
736        /// # use google_cloud_trace_v2::model::span::TimeEvent;
737        /// use google_cloud_trace_v2::model::span::time_event::MessageEvent;
738        /// let x = TimeEvent::new().set_message_event(MessageEvent::default()/* use setters */);
739        /// assert!(x.message_event().is_some());
740        /// assert!(x.annotation().is_none());
741        /// ```
742        pub fn set_message_event<
743            T: std::convert::Into<std::boxed::Box<crate::model::span::time_event::MessageEvent>>,
744        >(
745            mut self,
746            v: T,
747        ) -> Self {
748            self.value = std::option::Option::Some(
749                crate::model::span::time_event::Value::MessageEvent(v.into()),
750            );
751            self
752        }
753    }
754
755    impl wkt::message::Message for TimeEvent {
756        fn typename() -> &'static str {
757            "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvent"
758        }
759    }
760
761    /// Defines additional types related to [TimeEvent].
762    pub mod time_event {
763        #[allow(unused_imports)]
764        use super::*;
765
766        /// Text annotation with a set of attributes.
767        #[derive(Clone, Default, PartialEq)]
768        #[non_exhaustive]
769        pub struct Annotation {
770            /// A user-supplied message describing the event. The maximum length for
771            /// the description is 256 bytes.
772            pub description: std::option::Option<crate::model::TruncatableString>,
773
774            /// A set of attributes on the annotation. You can have up to 4 attributes
775            /// per Annotation.
776            pub attributes: std::option::Option<crate::model::span::Attributes>,
777
778            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
779        }
780
781        impl Annotation {
782            /// Creates a new default instance.
783            pub fn new() -> Self {
784                std::default::Default::default()
785            }
786
787            /// Sets the value of [description][crate::model::span::time_event::Annotation::description].
788            ///
789            /// # Example
790            /// ```ignore,no_run
791            /// # use google_cloud_trace_v2::model::span::time_event::Annotation;
792            /// use google_cloud_trace_v2::model::TruncatableString;
793            /// let x = Annotation::new().set_description(TruncatableString::default()/* use setters */);
794            /// ```
795            pub fn set_description<T>(mut self, v: T) -> Self
796            where
797                T: std::convert::Into<crate::model::TruncatableString>,
798            {
799                self.description = std::option::Option::Some(v.into());
800                self
801            }
802
803            /// Sets or clears the value of [description][crate::model::span::time_event::Annotation::description].
804            ///
805            /// # Example
806            /// ```ignore,no_run
807            /// # use google_cloud_trace_v2::model::span::time_event::Annotation;
808            /// use google_cloud_trace_v2::model::TruncatableString;
809            /// let x = Annotation::new().set_or_clear_description(Some(TruncatableString::default()/* use setters */));
810            /// let x = Annotation::new().set_or_clear_description(None::<TruncatableString>);
811            /// ```
812            pub fn set_or_clear_description<T>(mut self, v: std::option::Option<T>) -> Self
813            where
814                T: std::convert::Into<crate::model::TruncatableString>,
815            {
816                self.description = v.map(|x| x.into());
817                self
818            }
819
820            /// Sets the value of [attributes][crate::model::span::time_event::Annotation::attributes].
821            ///
822            /// # Example
823            /// ```ignore,no_run
824            /// # use google_cloud_trace_v2::model::span::time_event::Annotation;
825            /// use google_cloud_trace_v2::model::span::Attributes;
826            /// let x = Annotation::new().set_attributes(Attributes::default()/* use setters */);
827            /// ```
828            pub fn set_attributes<T>(mut self, v: T) -> Self
829            where
830                T: std::convert::Into<crate::model::span::Attributes>,
831            {
832                self.attributes = std::option::Option::Some(v.into());
833                self
834            }
835
836            /// Sets or clears the value of [attributes][crate::model::span::time_event::Annotation::attributes].
837            ///
838            /// # Example
839            /// ```ignore,no_run
840            /// # use google_cloud_trace_v2::model::span::time_event::Annotation;
841            /// use google_cloud_trace_v2::model::span::Attributes;
842            /// let x = Annotation::new().set_or_clear_attributes(Some(Attributes::default()/* use setters */));
843            /// let x = Annotation::new().set_or_clear_attributes(None::<Attributes>);
844            /// ```
845            pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
846            where
847                T: std::convert::Into<crate::model::span::Attributes>,
848            {
849                self.attributes = v.map(|x| x.into());
850                self
851            }
852        }
853
854        impl wkt::message::Message for Annotation {
855            fn typename() -> &'static str {
856                "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation"
857            }
858        }
859
860        /// An event describing a message sent/received between Spans.
861        #[derive(Clone, Default, PartialEq)]
862        #[non_exhaustive]
863        pub struct MessageEvent {
864            /// Type of MessageEvent. Indicates whether the message was sent or
865            /// received.
866            pub r#type: crate::model::span::time_event::message_event::Type,
867
868            /// An identifier for the MessageEvent's message that can be used to match
869            /// `SENT` and `RECEIVED` MessageEvents.
870            pub id: i64,
871
872            /// The number of uncompressed bytes sent or received.
873            pub uncompressed_size_bytes: i64,
874
875            /// The number of compressed bytes sent or received. If missing, the
876            /// compressed size is assumed to be the same size as the uncompressed
877            /// size.
878            pub compressed_size_bytes: i64,
879
880            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
881        }
882
883        impl MessageEvent {
884            /// Creates a new default instance.
885            pub fn new() -> Self {
886                std::default::Default::default()
887            }
888
889            /// Sets the value of [r#type][crate::model::span::time_event::MessageEvent::type].
890            ///
891            /// # Example
892            /// ```ignore,no_run
893            /// # use google_cloud_trace_v2::model::span::time_event::MessageEvent;
894            /// use google_cloud_trace_v2::model::span::time_event::message_event::Type;
895            /// let x0 = MessageEvent::new().set_type(Type::Sent);
896            /// let x1 = MessageEvent::new().set_type(Type::Received);
897            /// ```
898            pub fn set_type<
899                T: std::convert::Into<crate::model::span::time_event::message_event::Type>,
900            >(
901                mut self,
902                v: T,
903            ) -> Self {
904                self.r#type = v.into();
905                self
906            }
907
908            /// Sets the value of [id][crate::model::span::time_event::MessageEvent::id].
909            ///
910            /// # Example
911            /// ```ignore,no_run
912            /// # use google_cloud_trace_v2::model::span::time_event::MessageEvent;
913            /// let x = MessageEvent::new().set_id(42);
914            /// ```
915            pub fn set_id<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
916                self.id = v.into();
917                self
918            }
919
920            /// Sets the value of [uncompressed_size_bytes][crate::model::span::time_event::MessageEvent::uncompressed_size_bytes].
921            ///
922            /// # Example
923            /// ```ignore,no_run
924            /// # use google_cloud_trace_v2::model::span::time_event::MessageEvent;
925            /// let x = MessageEvent::new().set_uncompressed_size_bytes(42);
926            /// ```
927            pub fn set_uncompressed_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
928                self.uncompressed_size_bytes = v.into();
929                self
930            }
931
932            /// Sets the value of [compressed_size_bytes][crate::model::span::time_event::MessageEvent::compressed_size_bytes].
933            ///
934            /// # Example
935            /// ```ignore,no_run
936            /// # use google_cloud_trace_v2::model::span::time_event::MessageEvent;
937            /// let x = MessageEvent::new().set_compressed_size_bytes(42);
938            /// ```
939            pub fn set_compressed_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
940                self.compressed_size_bytes = v.into();
941                self
942            }
943        }
944
945        impl wkt::message::Message for MessageEvent {
946            fn typename() -> &'static str {
947                "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent"
948            }
949        }
950
951        /// Defines additional types related to [MessageEvent].
952        pub mod message_event {
953            #[allow(unused_imports)]
954            use super::*;
955
956            /// Indicates whether the message was sent or received.
957            ///
958            /// # Working with unknown values
959            ///
960            /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
961            /// additional enum variants at any time. Adding new variants is not considered
962            /// a breaking change. Applications should write their code in anticipation of:
963            ///
964            /// - New values appearing in future releases of the client library, **and**
965            /// - New values received dynamically, without application changes.
966            ///
967            /// Please consult the [Working with enums] section in the user guide for some
968            /// guidelines.
969            ///
970            /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
971            #[derive(Clone, Debug, PartialEq)]
972            #[non_exhaustive]
973            pub enum Type {
974                /// Unknown event type.
975                Unspecified,
976                /// Indicates a sent message.
977                Sent,
978                /// Indicates a received message.
979                Received,
980                /// If set, the enum was initialized with an unknown value.
981                ///
982                /// Applications can examine the value using [Type::value] or
983                /// [Type::name].
984                UnknownValue(r#type::UnknownValue),
985            }
986
987            #[doc(hidden)]
988            pub mod r#type {
989                #[allow(unused_imports)]
990                use super::*;
991                #[derive(Clone, Debug, PartialEq)]
992                pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
993            }
994
995            impl Type {
996                /// Gets the enum value.
997                ///
998                /// Returns `None` if the enum contains an unknown value deserialized from
999                /// the string representation of enums.
1000                pub fn value(&self) -> std::option::Option<i32> {
1001                    match self {
1002                        Self::Unspecified => std::option::Option::Some(0),
1003                        Self::Sent => std::option::Option::Some(1),
1004                        Self::Received => std::option::Option::Some(2),
1005                        Self::UnknownValue(u) => u.0.value(),
1006                    }
1007                }
1008
1009                /// Gets the enum value as a string.
1010                ///
1011                /// Returns `None` if the enum contains an unknown value deserialized from
1012                /// the integer representation of enums.
1013                pub fn name(&self) -> std::option::Option<&str> {
1014                    match self {
1015                        Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
1016                        Self::Sent => std::option::Option::Some("SENT"),
1017                        Self::Received => std::option::Option::Some("RECEIVED"),
1018                        Self::UnknownValue(u) => u.0.name(),
1019                    }
1020                }
1021            }
1022
1023            impl std::default::Default for Type {
1024                fn default() -> Self {
1025                    use std::convert::From;
1026                    Self::from(0)
1027                }
1028            }
1029
1030            impl std::fmt::Display for Type {
1031                fn fmt(
1032                    &self,
1033                    f: &mut std::fmt::Formatter<'_>,
1034                ) -> std::result::Result<(), std::fmt::Error> {
1035                    wkt::internal::display_enum(f, self.name(), self.value())
1036                }
1037            }
1038
1039            impl std::convert::From<i32> for Type {
1040                fn from(value: i32) -> Self {
1041                    match value {
1042                        0 => Self::Unspecified,
1043                        1 => Self::Sent,
1044                        2 => Self::Received,
1045                        _ => Self::UnknownValue(r#type::UnknownValue(
1046                            wkt::internal::UnknownEnumValue::Integer(value),
1047                        )),
1048                    }
1049                }
1050            }
1051
1052            impl std::convert::From<&str> for Type {
1053                fn from(value: &str) -> Self {
1054                    use std::string::ToString;
1055                    match value {
1056                        "TYPE_UNSPECIFIED" => Self::Unspecified,
1057                        "SENT" => Self::Sent,
1058                        "RECEIVED" => Self::Received,
1059                        _ => Self::UnknownValue(r#type::UnknownValue(
1060                            wkt::internal::UnknownEnumValue::String(value.to_string()),
1061                        )),
1062                    }
1063                }
1064            }
1065
1066            impl serde::ser::Serialize for Type {
1067                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1068                where
1069                    S: serde::Serializer,
1070                {
1071                    match self {
1072                        Self::Unspecified => serializer.serialize_i32(0),
1073                        Self::Sent => serializer.serialize_i32(1),
1074                        Self::Received => serializer.serialize_i32(2),
1075                        Self::UnknownValue(u) => u.0.serialize(serializer),
1076                    }
1077                }
1078            }
1079
1080            impl<'de> serde::de::Deserialize<'de> for Type {
1081                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1082                where
1083                    D: serde::Deserializer<'de>,
1084                {
1085                    deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
1086                        ".google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.Type",
1087                    ))
1088                }
1089            }
1090        }
1091
1092        /// A `TimeEvent` can contain either an `Annotation` object or a
1093        /// `MessageEvent` object, but not both.
1094        #[derive(Clone, Debug, PartialEq)]
1095        #[non_exhaustive]
1096        pub enum Value {
1097            /// Text annotation with a set of attributes.
1098            Annotation(std::boxed::Box<crate::model::span::time_event::Annotation>),
1099            /// An event describing a message sent/received between Spans.
1100            MessageEvent(std::boxed::Box<crate::model::span::time_event::MessageEvent>),
1101        }
1102    }
1103
1104    /// A collection of `TimeEvent`s. A `TimeEvent` is a time-stamped annotation
1105    /// on the span, consisting of either user-supplied key:value pairs, or
1106    /// details of a message sent/received between Spans.
1107    #[derive(Clone, Default, PartialEq)]
1108    #[non_exhaustive]
1109    pub struct TimeEvents {
1110        /// A collection of `TimeEvent`s.
1111        pub time_event: std::vec::Vec<crate::model::span::TimeEvent>,
1112
1113        /// The number of dropped annotations in all the included time events.
1114        /// If the value is 0, then no annotations were dropped.
1115        pub dropped_annotations_count: i32,
1116
1117        /// The number of dropped message events in all the included time events.
1118        /// If the value is 0, then no message events were dropped.
1119        pub dropped_message_events_count: i32,
1120
1121        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1122    }
1123
1124    impl TimeEvents {
1125        /// Creates a new default instance.
1126        pub fn new() -> Self {
1127            std::default::Default::default()
1128        }
1129
1130        /// Sets the value of [time_event][crate::model::span::TimeEvents::time_event].
1131        ///
1132        /// # Example
1133        /// ```ignore,no_run
1134        /// # use google_cloud_trace_v2::model::span::TimeEvents;
1135        /// use google_cloud_trace_v2::model::span::TimeEvent;
1136        /// let x = TimeEvents::new()
1137        ///     .set_time_event([
1138        ///         TimeEvent::default()/* use setters */,
1139        ///         TimeEvent::default()/* use (different) setters */,
1140        ///     ]);
1141        /// ```
1142        pub fn set_time_event<T, V>(mut self, v: T) -> Self
1143        where
1144            T: std::iter::IntoIterator<Item = V>,
1145            V: std::convert::Into<crate::model::span::TimeEvent>,
1146        {
1147            use std::iter::Iterator;
1148            self.time_event = v.into_iter().map(|i| i.into()).collect();
1149            self
1150        }
1151
1152        /// Sets the value of [dropped_annotations_count][crate::model::span::TimeEvents::dropped_annotations_count].
1153        ///
1154        /// # Example
1155        /// ```ignore,no_run
1156        /// # use google_cloud_trace_v2::model::span::TimeEvents;
1157        /// let x = TimeEvents::new().set_dropped_annotations_count(42);
1158        /// ```
1159        pub fn set_dropped_annotations_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1160            self.dropped_annotations_count = v.into();
1161            self
1162        }
1163
1164        /// Sets the value of [dropped_message_events_count][crate::model::span::TimeEvents::dropped_message_events_count].
1165        ///
1166        /// # Example
1167        /// ```ignore,no_run
1168        /// # use google_cloud_trace_v2::model::span::TimeEvents;
1169        /// let x = TimeEvents::new().set_dropped_message_events_count(42);
1170        /// ```
1171        pub fn set_dropped_message_events_count<T: std::convert::Into<i32>>(
1172            mut self,
1173            v: T,
1174        ) -> Self {
1175            self.dropped_message_events_count = v.into();
1176            self
1177        }
1178    }
1179
1180    impl wkt::message::Message for TimeEvents {
1181        fn typename() -> &'static str {
1182            "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvents"
1183        }
1184    }
1185
1186    /// A pointer from the current span to another span in the same trace or in a
1187    /// different trace. For example, this can be used in batching operations,
1188    /// where a single batch handler processes multiple requests from different
1189    /// traces or when the handler receives a request from a different project.
1190    #[derive(Clone, Default, PartialEq)]
1191    #[non_exhaustive]
1192    pub struct Link {
1193        /// The `[TRACE_ID]` for a trace within a project.
1194        pub trace_id: std::string::String,
1195
1196        /// The `[SPAN_ID]` for a span within a trace.
1197        pub span_id: std::string::String,
1198
1199        /// The relationship of the current span relative to the linked span.
1200        pub r#type: crate::model::span::link::Type,
1201
1202        /// A set of attributes on the link. Up to 32 attributes can be
1203        /// specified per link.
1204        pub attributes: std::option::Option<crate::model::span::Attributes>,
1205
1206        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1207    }
1208
1209    impl Link {
1210        /// Creates a new default instance.
1211        pub fn new() -> Self {
1212            std::default::Default::default()
1213        }
1214
1215        /// Sets the value of [trace_id][crate::model::span::Link::trace_id].
1216        ///
1217        /// # Example
1218        /// ```ignore,no_run
1219        /// # use google_cloud_trace_v2::model::span::Link;
1220        /// let x = Link::new().set_trace_id("example");
1221        /// ```
1222        pub fn set_trace_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1223            self.trace_id = v.into();
1224            self
1225        }
1226
1227        /// Sets the value of [span_id][crate::model::span::Link::span_id].
1228        ///
1229        /// # Example
1230        /// ```ignore,no_run
1231        /// # use google_cloud_trace_v2::model::span::Link;
1232        /// let x = Link::new().set_span_id("example");
1233        /// ```
1234        pub fn set_span_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1235            self.span_id = v.into();
1236            self
1237        }
1238
1239        /// Sets the value of [r#type][crate::model::span::Link::type].
1240        ///
1241        /// # Example
1242        /// ```ignore,no_run
1243        /// # use google_cloud_trace_v2::model::span::Link;
1244        /// use google_cloud_trace_v2::model::span::link::Type;
1245        /// let x0 = Link::new().set_type(Type::ChildLinkedSpan);
1246        /// let x1 = Link::new().set_type(Type::ParentLinkedSpan);
1247        /// ```
1248        pub fn set_type<T: std::convert::Into<crate::model::span::link::Type>>(
1249            mut self,
1250            v: T,
1251        ) -> Self {
1252            self.r#type = v.into();
1253            self
1254        }
1255
1256        /// Sets the value of [attributes][crate::model::span::Link::attributes].
1257        ///
1258        /// # Example
1259        /// ```ignore,no_run
1260        /// # use google_cloud_trace_v2::model::span::Link;
1261        /// use google_cloud_trace_v2::model::span::Attributes;
1262        /// let x = Link::new().set_attributes(Attributes::default()/* use setters */);
1263        /// ```
1264        pub fn set_attributes<T>(mut self, v: T) -> Self
1265        where
1266            T: std::convert::Into<crate::model::span::Attributes>,
1267        {
1268            self.attributes = std::option::Option::Some(v.into());
1269            self
1270        }
1271
1272        /// Sets or clears the value of [attributes][crate::model::span::Link::attributes].
1273        ///
1274        /// # Example
1275        /// ```ignore,no_run
1276        /// # use google_cloud_trace_v2::model::span::Link;
1277        /// use google_cloud_trace_v2::model::span::Attributes;
1278        /// let x = Link::new().set_or_clear_attributes(Some(Attributes::default()/* use setters */));
1279        /// let x = Link::new().set_or_clear_attributes(None::<Attributes>);
1280        /// ```
1281        pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
1282        where
1283            T: std::convert::Into<crate::model::span::Attributes>,
1284        {
1285            self.attributes = v.map(|x| x.into());
1286            self
1287        }
1288    }
1289
1290    impl wkt::message::Message for Link {
1291        fn typename() -> &'static str {
1292            "type.googleapis.com/google.devtools.cloudtrace.v2.Span.Link"
1293        }
1294    }
1295
1296    /// Defines additional types related to [Link].
1297    pub mod link {
1298        #[allow(unused_imports)]
1299        use super::*;
1300
1301        /// The relationship of the current span relative to the linked span: child,
1302        /// parent, or unspecified.
1303        ///
1304        /// # Working with unknown values
1305        ///
1306        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1307        /// additional enum variants at any time. Adding new variants is not considered
1308        /// a breaking change. Applications should write their code in anticipation of:
1309        ///
1310        /// - New values appearing in future releases of the client library, **and**
1311        /// - New values received dynamically, without application changes.
1312        ///
1313        /// Please consult the [Working with enums] section in the user guide for some
1314        /// guidelines.
1315        ///
1316        /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1317        #[derive(Clone, Debug, PartialEq)]
1318        #[non_exhaustive]
1319        pub enum Type {
1320            /// The relationship of the two spans is unknown.
1321            Unspecified,
1322            /// The linked span is a child of the current span.
1323            ChildLinkedSpan,
1324            /// The linked span is a parent of the current span.
1325            ParentLinkedSpan,
1326            /// If set, the enum was initialized with an unknown value.
1327            ///
1328            /// Applications can examine the value using [Type::value] or
1329            /// [Type::name].
1330            UnknownValue(r#type::UnknownValue),
1331        }
1332
1333        #[doc(hidden)]
1334        pub mod r#type {
1335            #[allow(unused_imports)]
1336            use super::*;
1337            #[derive(Clone, Debug, PartialEq)]
1338            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1339        }
1340
1341        impl Type {
1342            /// Gets the enum value.
1343            ///
1344            /// Returns `None` if the enum contains an unknown value deserialized from
1345            /// the string representation of enums.
1346            pub fn value(&self) -> std::option::Option<i32> {
1347                match self {
1348                    Self::Unspecified => std::option::Option::Some(0),
1349                    Self::ChildLinkedSpan => std::option::Option::Some(1),
1350                    Self::ParentLinkedSpan => std::option::Option::Some(2),
1351                    Self::UnknownValue(u) => u.0.value(),
1352                }
1353            }
1354
1355            /// Gets the enum value as a string.
1356            ///
1357            /// Returns `None` if the enum contains an unknown value deserialized from
1358            /// the integer representation of enums.
1359            pub fn name(&self) -> std::option::Option<&str> {
1360                match self {
1361                    Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
1362                    Self::ChildLinkedSpan => std::option::Option::Some("CHILD_LINKED_SPAN"),
1363                    Self::ParentLinkedSpan => std::option::Option::Some("PARENT_LINKED_SPAN"),
1364                    Self::UnknownValue(u) => u.0.name(),
1365                }
1366            }
1367        }
1368
1369        impl std::default::Default for Type {
1370            fn default() -> Self {
1371                use std::convert::From;
1372                Self::from(0)
1373            }
1374        }
1375
1376        impl std::fmt::Display for Type {
1377            fn fmt(
1378                &self,
1379                f: &mut std::fmt::Formatter<'_>,
1380            ) -> std::result::Result<(), std::fmt::Error> {
1381                wkt::internal::display_enum(f, self.name(), self.value())
1382            }
1383        }
1384
1385        impl std::convert::From<i32> for Type {
1386            fn from(value: i32) -> Self {
1387                match value {
1388                    0 => Self::Unspecified,
1389                    1 => Self::ChildLinkedSpan,
1390                    2 => Self::ParentLinkedSpan,
1391                    _ => Self::UnknownValue(r#type::UnknownValue(
1392                        wkt::internal::UnknownEnumValue::Integer(value),
1393                    )),
1394                }
1395            }
1396        }
1397
1398        impl std::convert::From<&str> for Type {
1399            fn from(value: &str) -> Self {
1400                use std::string::ToString;
1401                match value {
1402                    "TYPE_UNSPECIFIED" => Self::Unspecified,
1403                    "CHILD_LINKED_SPAN" => Self::ChildLinkedSpan,
1404                    "PARENT_LINKED_SPAN" => Self::ParentLinkedSpan,
1405                    _ => Self::UnknownValue(r#type::UnknownValue(
1406                        wkt::internal::UnknownEnumValue::String(value.to_string()),
1407                    )),
1408                }
1409            }
1410        }
1411
1412        impl serde::ser::Serialize for Type {
1413            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1414            where
1415                S: serde::Serializer,
1416            {
1417                match self {
1418                    Self::Unspecified => serializer.serialize_i32(0),
1419                    Self::ChildLinkedSpan => serializer.serialize_i32(1),
1420                    Self::ParentLinkedSpan => serializer.serialize_i32(2),
1421                    Self::UnknownValue(u) => u.0.serialize(serializer),
1422                }
1423            }
1424        }
1425
1426        impl<'de> serde::de::Deserialize<'de> for Type {
1427            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1428            where
1429                D: serde::Deserializer<'de>,
1430            {
1431                deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
1432                    ".google.devtools.cloudtrace.v2.Span.Link.Type",
1433                ))
1434            }
1435        }
1436    }
1437
1438    /// A collection of links, which are references from this span to a span
1439    /// in the same or different trace.
1440    #[derive(Clone, Default, PartialEq)]
1441    #[non_exhaustive]
1442    pub struct Links {
1443        /// A collection of links.
1444        pub link: std::vec::Vec<crate::model::span::Link>,
1445
1446        /// The number of dropped links after the maximum size was enforced. If
1447        /// this value is 0, then no links were dropped.
1448        pub dropped_links_count: i32,
1449
1450        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1451    }
1452
1453    impl Links {
1454        /// Creates a new default instance.
1455        pub fn new() -> Self {
1456            std::default::Default::default()
1457        }
1458
1459        /// Sets the value of [link][crate::model::span::Links::link].
1460        ///
1461        /// # Example
1462        /// ```ignore,no_run
1463        /// # use google_cloud_trace_v2::model::span::Links;
1464        /// use google_cloud_trace_v2::model::span::Link;
1465        /// let x = Links::new()
1466        ///     .set_link([
1467        ///         Link::default()/* use setters */,
1468        ///         Link::default()/* use (different) setters */,
1469        ///     ]);
1470        /// ```
1471        pub fn set_link<T, V>(mut self, v: T) -> Self
1472        where
1473            T: std::iter::IntoIterator<Item = V>,
1474            V: std::convert::Into<crate::model::span::Link>,
1475        {
1476            use std::iter::Iterator;
1477            self.link = v.into_iter().map(|i| i.into()).collect();
1478            self
1479        }
1480
1481        /// Sets the value of [dropped_links_count][crate::model::span::Links::dropped_links_count].
1482        ///
1483        /// # Example
1484        /// ```ignore,no_run
1485        /// # use google_cloud_trace_v2::model::span::Links;
1486        /// let x = Links::new().set_dropped_links_count(42);
1487        /// ```
1488        pub fn set_dropped_links_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1489            self.dropped_links_count = v.into();
1490            self
1491        }
1492    }
1493
1494    impl wkt::message::Message for Links {
1495        fn typename() -> &'static str {
1496            "type.googleapis.com/google.devtools.cloudtrace.v2.Span.Links"
1497        }
1498    }
1499
1500    /// Type of span. Can be used to specify additional relationships between spans
1501    /// in addition to a parent/child relationship.
1502    ///
1503    /// # Working with unknown values
1504    ///
1505    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1506    /// additional enum variants at any time. Adding new variants is not considered
1507    /// a breaking change. Applications should write their code in anticipation of:
1508    ///
1509    /// - New values appearing in future releases of the client library, **and**
1510    /// - New values received dynamically, without application changes.
1511    ///
1512    /// Please consult the [Working with enums] section in the user guide for some
1513    /// guidelines.
1514    ///
1515    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1516    #[derive(Clone, Debug, PartialEq)]
1517    #[non_exhaustive]
1518    pub enum SpanKind {
1519        /// Unspecified. Do NOT use as default.
1520        /// Implementations MAY assume SpanKind.INTERNAL to be default.
1521        Unspecified,
1522        /// Indicates that the span is used internally. Default value.
1523        Internal,
1524        /// Indicates that the span covers server-side handling of an RPC or other
1525        /// remote network request.
1526        Server,
1527        /// Indicates that the span covers the client-side wrapper around an RPC or
1528        /// other remote request.
1529        Client,
1530        /// Indicates that the span describes producer sending a message to a broker.
1531        /// Unlike client and  server, there is no direct critical path latency
1532        /// relationship between producer and consumer spans (e.g. publishing a
1533        /// message to a pubsub service).
1534        Producer,
1535        /// Indicates that the span describes consumer receiving a message from a
1536        /// broker. Unlike client and  server, there is no direct critical path
1537        /// latency relationship between producer and consumer spans (e.g. receiving
1538        /// a message from a pubsub service subscription).
1539        Consumer,
1540        /// If set, the enum was initialized with an unknown value.
1541        ///
1542        /// Applications can examine the value using [SpanKind::value] or
1543        /// [SpanKind::name].
1544        UnknownValue(span_kind::UnknownValue),
1545    }
1546
1547    #[doc(hidden)]
1548    pub mod span_kind {
1549        #[allow(unused_imports)]
1550        use super::*;
1551        #[derive(Clone, Debug, PartialEq)]
1552        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1553    }
1554
1555    impl SpanKind {
1556        /// Gets the enum value.
1557        ///
1558        /// Returns `None` if the enum contains an unknown value deserialized from
1559        /// the string representation of enums.
1560        pub fn value(&self) -> std::option::Option<i32> {
1561            match self {
1562                Self::Unspecified => std::option::Option::Some(0),
1563                Self::Internal => std::option::Option::Some(1),
1564                Self::Server => std::option::Option::Some(2),
1565                Self::Client => std::option::Option::Some(3),
1566                Self::Producer => std::option::Option::Some(4),
1567                Self::Consumer => std::option::Option::Some(5),
1568                Self::UnknownValue(u) => u.0.value(),
1569            }
1570        }
1571
1572        /// Gets the enum value as a string.
1573        ///
1574        /// Returns `None` if the enum contains an unknown value deserialized from
1575        /// the integer representation of enums.
1576        pub fn name(&self) -> std::option::Option<&str> {
1577            match self {
1578                Self::Unspecified => std::option::Option::Some("SPAN_KIND_UNSPECIFIED"),
1579                Self::Internal => std::option::Option::Some("INTERNAL"),
1580                Self::Server => std::option::Option::Some("SERVER"),
1581                Self::Client => std::option::Option::Some("CLIENT"),
1582                Self::Producer => std::option::Option::Some("PRODUCER"),
1583                Self::Consumer => std::option::Option::Some("CONSUMER"),
1584                Self::UnknownValue(u) => u.0.name(),
1585            }
1586        }
1587    }
1588
1589    impl std::default::Default for SpanKind {
1590        fn default() -> Self {
1591            use std::convert::From;
1592            Self::from(0)
1593        }
1594    }
1595
1596    impl std::fmt::Display for SpanKind {
1597        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1598            wkt::internal::display_enum(f, self.name(), self.value())
1599        }
1600    }
1601
1602    impl std::convert::From<i32> for SpanKind {
1603        fn from(value: i32) -> Self {
1604            match value {
1605                0 => Self::Unspecified,
1606                1 => Self::Internal,
1607                2 => Self::Server,
1608                3 => Self::Client,
1609                4 => Self::Producer,
1610                5 => Self::Consumer,
1611                _ => Self::UnknownValue(span_kind::UnknownValue(
1612                    wkt::internal::UnknownEnumValue::Integer(value),
1613                )),
1614            }
1615        }
1616    }
1617
1618    impl std::convert::From<&str> for SpanKind {
1619        fn from(value: &str) -> Self {
1620            use std::string::ToString;
1621            match value {
1622                "SPAN_KIND_UNSPECIFIED" => Self::Unspecified,
1623                "INTERNAL" => Self::Internal,
1624                "SERVER" => Self::Server,
1625                "CLIENT" => Self::Client,
1626                "PRODUCER" => Self::Producer,
1627                "CONSUMER" => Self::Consumer,
1628                _ => Self::UnknownValue(span_kind::UnknownValue(
1629                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1630                )),
1631            }
1632        }
1633    }
1634
1635    impl serde::ser::Serialize for SpanKind {
1636        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1637        where
1638            S: serde::Serializer,
1639        {
1640            match self {
1641                Self::Unspecified => serializer.serialize_i32(0),
1642                Self::Internal => serializer.serialize_i32(1),
1643                Self::Server => serializer.serialize_i32(2),
1644                Self::Client => serializer.serialize_i32(3),
1645                Self::Producer => serializer.serialize_i32(4),
1646                Self::Consumer => serializer.serialize_i32(5),
1647                Self::UnknownValue(u) => u.0.serialize(serializer),
1648            }
1649        }
1650    }
1651
1652    impl<'de> serde::de::Deserialize<'de> for SpanKind {
1653        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1654        where
1655            D: serde::Deserializer<'de>,
1656        {
1657            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SpanKind>::new(
1658                ".google.devtools.cloudtrace.v2.Span.SpanKind",
1659            ))
1660        }
1661    }
1662}
1663
1664/// The allowed types for `[VALUE]` in a `[KEY]:[VALUE]` attribute.
1665#[derive(Clone, Default, PartialEq)]
1666#[non_exhaustive]
1667pub struct AttributeValue {
1668    /// The type of the value.
1669    pub value: std::option::Option<crate::model::attribute_value::Value>,
1670
1671    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1672}
1673
1674impl AttributeValue {
1675    /// Creates a new default instance.
1676    pub fn new() -> Self {
1677        std::default::Default::default()
1678    }
1679
1680    /// Sets the value of [value][crate::model::AttributeValue::value].
1681    ///
1682    /// Note that all the setters affecting `value` are mutually
1683    /// exclusive.
1684    ///
1685    /// # Example
1686    /// ```ignore,no_run
1687    /// # use google_cloud_trace_v2::model::AttributeValue;
1688    /// use google_cloud_trace_v2::model::attribute_value::Value;
1689    /// let x = AttributeValue::new().set_value(Some(Value::IntValue(42)));
1690    /// ```
1691    pub fn set_value<
1692        T: std::convert::Into<std::option::Option<crate::model::attribute_value::Value>>,
1693    >(
1694        mut self,
1695        v: T,
1696    ) -> Self {
1697        self.value = v.into();
1698        self
1699    }
1700
1701    /// The value of [value][crate::model::AttributeValue::value]
1702    /// if it holds a `StringValue`, `None` if the field is not set or
1703    /// holds a different branch.
1704    pub fn string_value(
1705        &self,
1706    ) -> std::option::Option<&std::boxed::Box<crate::model::TruncatableString>> {
1707        #[allow(unreachable_patterns)]
1708        self.value.as_ref().and_then(|v| match v {
1709            crate::model::attribute_value::Value::StringValue(v) => std::option::Option::Some(v),
1710            _ => std::option::Option::None,
1711        })
1712    }
1713
1714    /// Sets the value of [value][crate::model::AttributeValue::value]
1715    /// to hold a `StringValue`.
1716    ///
1717    /// Note that all the setters affecting `value` are
1718    /// mutually exclusive.
1719    ///
1720    /// # Example
1721    /// ```ignore,no_run
1722    /// # use google_cloud_trace_v2::model::AttributeValue;
1723    /// use google_cloud_trace_v2::model::TruncatableString;
1724    /// let x = AttributeValue::new().set_string_value(TruncatableString::default()/* use setters */);
1725    /// assert!(x.string_value().is_some());
1726    /// assert!(x.int_value().is_none());
1727    /// assert!(x.bool_value().is_none());
1728    /// ```
1729    pub fn set_string_value<
1730        T: std::convert::Into<std::boxed::Box<crate::model::TruncatableString>>,
1731    >(
1732        mut self,
1733        v: T,
1734    ) -> Self {
1735        self.value =
1736            std::option::Option::Some(crate::model::attribute_value::Value::StringValue(v.into()));
1737        self
1738    }
1739
1740    /// The value of [value][crate::model::AttributeValue::value]
1741    /// if it holds a `IntValue`, `None` if the field is not set or
1742    /// holds a different branch.
1743    pub fn int_value(&self) -> std::option::Option<&i64> {
1744        #[allow(unreachable_patterns)]
1745        self.value.as_ref().and_then(|v| match v {
1746            crate::model::attribute_value::Value::IntValue(v) => std::option::Option::Some(v),
1747            _ => std::option::Option::None,
1748        })
1749    }
1750
1751    /// Sets the value of [value][crate::model::AttributeValue::value]
1752    /// to hold a `IntValue`.
1753    ///
1754    /// Note that all the setters affecting `value` are
1755    /// mutually exclusive.
1756    ///
1757    /// # Example
1758    /// ```ignore,no_run
1759    /// # use google_cloud_trace_v2::model::AttributeValue;
1760    /// let x = AttributeValue::new().set_int_value(42);
1761    /// assert!(x.int_value().is_some());
1762    /// assert!(x.string_value().is_none());
1763    /// assert!(x.bool_value().is_none());
1764    /// ```
1765    pub fn set_int_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1766        self.value =
1767            std::option::Option::Some(crate::model::attribute_value::Value::IntValue(v.into()));
1768        self
1769    }
1770
1771    /// The value of [value][crate::model::AttributeValue::value]
1772    /// if it holds a `BoolValue`, `None` if the field is not set or
1773    /// holds a different branch.
1774    pub fn bool_value(&self) -> std::option::Option<&bool> {
1775        #[allow(unreachable_patterns)]
1776        self.value.as_ref().and_then(|v| match v {
1777            crate::model::attribute_value::Value::BoolValue(v) => std::option::Option::Some(v),
1778            _ => std::option::Option::None,
1779        })
1780    }
1781
1782    /// Sets the value of [value][crate::model::AttributeValue::value]
1783    /// to hold a `BoolValue`.
1784    ///
1785    /// Note that all the setters affecting `value` are
1786    /// mutually exclusive.
1787    ///
1788    /// # Example
1789    /// ```ignore,no_run
1790    /// # use google_cloud_trace_v2::model::AttributeValue;
1791    /// let x = AttributeValue::new().set_bool_value(true);
1792    /// assert!(x.bool_value().is_some());
1793    /// assert!(x.string_value().is_none());
1794    /// assert!(x.int_value().is_none());
1795    /// ```
1796    pub fn set_bool_value<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1797        self.value =
1798            std::option::Option::Some(crate::model::attribute_value::Value::BoolValue(v.into()));
1799        self
1800    }
1801}
1802
1803impl wkt::message::Message for AttributeValue {
1804    fn typename() -> &'static str {
1805        "type.googleapis.com/google.devtools.cloudtrace.v2.AttributeValue"
1806    }
1807}
1808
1809/// Defines additional types related to [AttributeValue].
1810pub mod attribute_value {
1811    #[allow(unused_imports)]
1812    use super::*;
1813
1814    /// The type of the value.
1815    #[derive(Clone, Debug, PartialEq)]
1816    #[non_exhaustive]
1817    pub enum Value {
1818        /// A string up to 256 bytes long.
1819        StringValue(std::boxed::Box<crate::model::TruncatableString>),
1820        /// A 64-bit signed integer.
1821        IntValue(i64),
1822        /// A Boolean value represented by `true` or `false`.
1823        BoolValue(bool),
1824    }
1825}
1826
1827/// A call stack appearing in a trace.
1828#[derive(Clone, Default, PartialEq)]
1829#[non_exhaustive]
1830pub struct StackTrace {
1831    /// Stack frames in this stack trace. A maximum of 128 frames are allowed.
1832    pub stack_frames: std::option::Option<crate::model::stack_trace::StackFrames>,
1833
1834    /// The hash ID is used to conserve network bandwidth for duplicate
1835    /// stack traces within a single trace.
1836    ///
1837    /// Often multiple spans will have identical stack traces.
1838    /// The first occurrence of a stack trace should contain both the
1839    /// `stackFrame` content and a value in `stackTraceHashId`.
1840    ///
1841    /// Subsequent spans within the same request can refer
1842    /// to that stack trace by only setting `stackTraceHashId`.
1843    pub stack_trace_hash_id: i64,
1844
1845    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1846}
1847
1848impl StackTrace {
1849    /// Creates a new default instance.
1850    pub fn new() -> Self {
1851        std::default::Default::default()
1852    }
1853
1854    /// Sets the value of [stack_frames][crate::model::StackTrace::stack_frames].
1855    ///
1856    /// # Example
1857    /// ```ignore,no_run
1858    /// # use google_cloud_trace_v2::model::StackTrace;
1859    /// use google_cloud_trace_v2::model::stack_trace::StackFrames;
1860    /// let x = StackTrace::new().set_stack_frames(StackFrames::default()/* use setters */);
1861    /// ```
1862    pub fn set_stack_frames<T>(mut self, v: T) -> Self
1863    where
1864        T: std::convert::Into<crate::model::stack_trace::StackFrames>,
1865    {
1866        self.stack_frames = std::option::Option::Some(v.into());
1867        self
1868    }
1869
1870    /// Sets or clears the value of [stack_frames][crate::model::StackTrace::stack_frames].
1871    ///
1872    /// # Example
1873    /// ```ignore,no_run
1874    /// # use google_cloud_trace_v2::model::StackTrace;
1875    /// use google_cloud_trace_v2::model::stack_trace::StackFrames;
1876    /// let x = StackTrace::new().set_or_clear_stack_frames(Some(StackFrames::default()/* use setters */));
1877    /// let x = StackTrace::new().set_or_clear_stack_frames(None::<StackFrames>);
1878    /// ```
1879    pub fn set_or_clear_stack_frames<T>(mut self, v: std::option::Option<T>) -> Self
1880    where
1881        T: std::convert::Into<crate::model::stack_trace::StackFrames>,
1882    {
1883        self.stack_frames = v.map(|x| x.into());
1884        self
1885    }
1886
1887    /// Sets the value of [stack_trace_hash_id][crate::model::StackTrace::stack_trace_hash_id].
1888    ///
1889    /// # Example
1890    /// ```ignore,no_run
1891    /// # use google_cloud_trace_v2::model::StackTrace;
1892    /// let x = StackTrace::new().set_stack_trace_hash_id(42);
1893    /// ```
1894    pub fn set_stack_trace_hash_id<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1895        self.stack_trace_hash_id = v.into();
1896        self
1897    }
1898}
1899
1900impl wkt::message::Message for StackTrace {
1901    fn typename() -> &'static str {
1902        "type.googleapis.com/google.devtools.cloudtrace.v2.StackTrace"
1903    }
1904}
1905
1906/// Defines additional types related to [StackTrace].
1907pub mod stack_trace {
1908    #[allow(unused_imports)]
1909    use super::*;
1910
1911    /// Represents a single stack frame in a stack trace.
1912    #[derive(Clone, Default, PartialEq)]
1913    #[non_exhaustive]
1914    pub struct StackFrame {
1915        /// The fully-qualified name that uniquely identifies the function or
1916        /// method that is active in this frame (up to 1024 bytes).
1917        pub function_name: std::option::Option<crate::model::TruncatableString>,
1918
1919        /// An un-mangled function name, if `function_name` is mangled.
1920        /// To get information about name mangling, run
1921        /// [this search](https://www.google.com/search?q=cxx+name+mangling).
1922        /// The name can be fully-qualified (up to 1024 bytes).
1923        pub original_function_name: std::option::Option<crate::model::TruncatableString>,
1924
1925        /// The name of the source file where the function call appears (up to 256
1926        /// bytes).
1927        pub file_name: std::option::Option<crate::model::TruncatableString>,
1928
1929        /// The line number in `file_name` where the function call appears.
1930        pub line_number: i64,
1931
1932        /// The column number where the function call appears, if available.
1933        /// This is important in JavaScript because of its anonymous functions.
1934        pub column_number: i64,
1935
1936        /// The binary module from where the code was loaded.
1937        pub load_module: std::option::Option<crate::model::Module>,
1938
1939        /// The version of the deployed source code (up to 128 bytes).
1940        pub source_version: std::option::Option<crate::model::TruncatableString>,
1941
1942        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1943    }
1944
1945    impl StackFrame {
1946        /// Creates a new default instance.
1947        pub fn new() -> Self {
1948            std::default::Default::default()
1949        }
1950
1951        /// Sets the value of [function_name][crate::model::stack_trace::StackFrame::function_name].
1952        ///
1953        /// # Example
1954        /// ```ignore,no_run
1955        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
1956        /// use google_cloud_trace_v2::model::TruncatableString;
1957        /// let x = StackFrame::new().set_function_name(TruncatableString::default()/* use setters */);
1958        /// ```
1959        pub fn set_function_name<T>(mut self, v: T) -> Self
1960        where
1961            T: std::convert::Into<crate::model::TruncatableString>,
1962        {
1963            self.function_name = std::option::Option::Some(v.into());
1964            self
1965        }
1966
1967        /// Sets or clears the value of [function_name][crate::model::stack_trace::StackFrame::function_name].
1968        ///
1969        /// # Example
1970        /// ```ignore,no_run
1971        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
1972        /// use google_cloud_trace_v2::model::TruncatableString;
1973        /// let x = StackFrame::new().set_or_clear_function_name(Some(TruncatableString::default()/* use setters */));
1974        /// let x = StackFrame::new().set_or_clear_function_name(None::<TruncatableString>);
1975        /// ```
1976        pub fn set_or_clear_function_name<T>(mut self, v: std::option::Option<T>) -> Self
1977        where
1978            T: std::convert::Into<crate::model::TruncatableString>,
1979        {
1980            self.function_name = v.map(|x| x.into());
1981            self
1982        }
1983
1984        /// Sets the value of [original_function_name][crate::model::stack_trace::StackFrame::original_function_name].
1985        ///
1986        /// # Example
1987        /// ```ignore,no_run
1988        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
1989        /// use google_cloud_trace_v2::model::TruncatableString;
1990        /// let x = StackFrame::new().set_original_function_name(TruncatableString::default()/* use setters */);
1991        /// ```
1992        pub fn set_original_function_name<T>(mut self, v: T) -> Self
1993        where
1994            T: std::convert::Into<crate::model::TruncatableString>,
1995        {
1996            self.original_function_name = std::option::Option::Some(v.into());
1997            self
1998        }
1999
2000        /// Sets or clears the value of [original_function_name][crate::model::stack_trace::StackFrame::original_function_name].
2001        ///
2002        /// # Example
2003        /// ```ignore,no_run
2004        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2005        /// use google_cloud_trace_v2::model::TruncatableString;
2006        /// let x = StackFrame::new().set_or_clear_original_function_name(Some(TruncatableString::default()/* use setters */));
2007        /// let x = StackFrame::new().set_or_clear_original_function_name(None::<TruncatableString>);
2008        /// ```
2009        pub fn set_or_clear_original_function_name<T>(mut self, v: std::option::Option<T>) -> Self
2010        where
2011            T: std::convert::Into<crate::model::TruncatableString>,
2012        {
2013            self.original_function_name = v.map(|x| x.into());
2014            self
2015        }
2016
2017        /// Sets the value of [file_name][crate::model::stack_trace::StackFrame::file_name].
2018        ///
2019        /// # Example
2020        /// ```ignore,no_run
2021        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2022        /// use google_cloud_trace_v2::model::TruncatableString;
2023        /// let x = StackFrame::new().set_file_name(TruncatableString::default()/* use setters */);
2024        /// ```
2025        pub fn set_file_name<T>(mut self, v: T) -> Self
2026        where
2027            T: std::convert::Into<crate::model::TruncatableString>,
2028        {
2029            self.file_name = std::option::Option::Some(v.into());
2030            self
2031        }
2032
2033        /// Sets or clears the value of [file_name][crate::model::stack_trace::StackFrame::file_name].
2034        ///
2035        /// # Example
2036        /// ```ignore,no_run
2037        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2038        /// use google_cloud_trace_v2::model::TruncatableString;
2039        /// let x = StackFrame::new().set_or_clear_file_name(Some(TruncatableString::default()/* use setters */));
2040        /// let x = StackFrame::new().set_or_clear_file_name(None::<TruncatableString>);
2041        /// ```
2042        pub fn set_or_clear_file_name<T>(mut self, v: std::option::Option<T>) -> Self
2043        where
2044            T: std::convert::Into<crate::model::TruncatableString>,
2045        {
2046            self.file_name = v.map(|x| x.into());
2047            self
2048        }
2049
2050        /// Sets the value of [line_number][crate::model::stack_trace::StackFrame::line_number].
2051        ///
2052        /// # Example
2053        /// ```ignore,no_run
2054        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2055        /// let x = StackFrame::new().set_line_number(42);
2056        /// ```
2057        pub fn set_line_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2058            self.line_number = v.into();
2059            self
2060        }
2061
2062        /// Sets the value of [column_number][crate::model::stack_trace::StackFrame::column_number].
2063        ///
2064        /// # Example
2065        /// ```ignore,no_run
2066        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2067        /// let x = StackFrame::new().set_column_number(42);
2068        /// ```
2069        pub fn set_column_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2070            self.column_number = v.into();
2071            self
2072        }
2073
2074        /// Sets the value of [load_module][crate::model::stack_trace::StackFrame::load_module].
2075        ///
2076        /// # Example
2077        /// ```ignore,no_run
2078        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2079        /// use google_cloud_trace_v2::model::Module;
2080        /// let x = StackFrame::new().set_load_module(Module::default()/* use setters */);
2081        /// ```
2082        pub fn set_load_module<T>(mut self, v: T) -> Self
2083        where
2084            T: std::convert::Into<crate::model::Module>,
2085        {
2086            self.load_module = std::option::Option::Some(v.into());
2087            self
2088        }
2089
2090        /// Sets or clears the value of [load_module][crate::model::stack_trace::StackFrame::load_module].
2091        ///
2092        /// # Example
2093        /// ```ignore,no_run
2094        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2095        /// use google_cloud_trace_v2::model::Module;
2096        /// let x = StackFrame::new().set_or_clear_load_module(Some(Module::default()/* use setters */));
2097        /// let x = StackFrame::new().set_or_clear_load_module(None::<Module>);
2098        /// ```
2099        pub fn set_or_clear_load_module<T>(mut self, v: std::option::Option<T>) -> Self
2100        where
2101            T: std::convert::Into<crate::model::Module>,
2102        {
2103            self.load_module = v.map(|x| x.into());
2104            self
2105        }
2106
2107        /// Sets the value of [source_version][crate::model::stack_trace::StackFrame::source_version].
2108        ///
2109        /// # Example
2110        /// ```ignore,no_run
2111        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2112        /// use google_cloud_trace_v2::model::TruncatableString;
2113        /// let x = StackFrame::new().set_source_version(TruncatableString::default()/* use setters */);
2114        /// ```
2115        pub fn set_source_version<T>(mut self, v: T) -> Self
2116        where
2117            T: std::convert::Into<crate::model::TruncatableString>,
2118        {
2119            self.source_version = std::option::Option::Some(v.into());
2120            self
2121        }
2122
2123        /// Sets or clears the value of [source_version][crate::model::stack_trace::StackFrame::source_version].
2124        ///
2125        /// # Example
2126        /// ```ignore,no_run
2127        /// # use google_cloud_trace_v2::model::stack_trace::StackFrame;
2128        /// use google_cloud_trace_v2::model::TruncatableString;
2129        /// let x = StackFrame::new().set_or_clear_source_version(Some(TruncatableString::default()/* use setters */));
2130        /// let x = StackFrame::new().set_or_clear_source_version(None::<TruncatableString>);
2131        /// ```
2132        pub fn set_or_clear_source_version<T>(mut self, v: std::option::Option<T>) -> Self
2133        where
2134            T: std::convert::Into<crate::model::TruncatableString>,
2135        {
2136            self.source_version = v.map(|x| x.into());
2137            self
2138        }
2139    }
2140
2141    impl wkt::message::Message for StackFrame {
2142        fn typename() -> &'static str {
2143            "type.googleapis.com/google.devtools.cloudtrace.v2.StackTrace.StackFrame"
2144        }
2145    }
2146
2147    /// A collection of stack frames, which can be truncated.
2148    #[derive(Clone, Default, PartialEq)]
2149    #[non_exhaustive]
2150    pub struct StackFrames {
2151        /// Stack frames in this call stack.
2152        pub frame: std::vec::Vec<crate::model::stack_trace::StackFrame>,
2153
2154        /// The number of stack frames that were dropped because there
2155        /// were too many stack frames.
2156        /// If this value is 0, then no stack frames were dropped.
2157        pub dropped_frames_count: i32,
2158
2159        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2160    }
2161
2162    impl StackFrames {
2163        /// Creates a new default instance.
2164        pub fn new() -> Self {
2165            std::default::Default::default()
2166        }
2167
2168        /// Sets the value of [frame][crate::model::stack_trace::StackFrames::frame].
2169        ///
2170        /// # Example
2171        /// ```ignore,no_run
2172        /// # use google_cloud_trace_v2::model::stack_trace::StackFrames;
2173        /// use google_cloud_trace_v2::model::stack_trace::StackFrame;
2174        /// let x = StackFrames::new()
2175        ///     .set_frame([
2176        ///         StackFrame::default()/* use setters */,
2177        ///         StackFrame::default()/* use (different) setters */,
2178        ///     ]);
2179        /// ```
2180        pub fn set_frame<T, V>(mut self, v: T) -> Self
2181        where
2182            T: std::iter::IntoIterator<Item = V>,
2183            V: std::convert::Into<crate::model::stack_trace::StackFrame>,
2184        {
2185            use std::iter::Iterator;
2186            self.frame = v.into_iter().map(|i| i.into()).collect();
2187            self
2188        }
2189
2190        /// Sets the value of [dropped_frames_count][crate::model::stack_trace::StackFrames::dropped_frames_count].
2191        ///
2192        /// # Example
2193        /// ```ignore,no_run
2194        /// # use google_cloud_trace_v2::model::stack_trace::StackFrames;
2195        /// let x = StackFrames::new().set_dropped_frames_count(42);
2196        /// ```
2197        pub fn set_dropped_frames_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2198            self.dropped_frames_count = v.into();
2199            self
2200        }
2201    }
2202
2203    impl wkt::message::Message for StackFrames {
2204        fn typename() -> &'static str {
2205            "type.googleapis.com/google.devtools.cloudtrace.v2.StackTrace.StackFrames"
2206        }
2207    }
2208}
2209
2210/// Binary module.
2211#[derive(Clone, Default, PartialEq)]
2212#[non_exhaustive]
2213pub struct Module {
2214    /// For example: main binary, kernel modules, and dynamic libraries
2215    /// such as libc.so, sharedlib.so (up to 256 bytes).
2216    pub module: std::option::Option<crate::model::TruncatableString>,
2217
2218    /// A unique identifier for the module, usually a hash of its
2219    /// contents (up to 128 bytes).
2220    pub build_id: std::option::Option<crate::model::TruncatableString>,
2221
2222    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2223}
2224
2225impl Module {
2226    /// Creates a new default instance.
2227    pub fn new() -> Self {
2228        std::default::Default::default()
2229    }
2230
2231    /// Sets the value of [module][crate::model::Module::module].
2232    ///
2233    /// # Example
2234    /// ```ignore,no_run
2235    /// # use google_cloud_trace_v2::model::Module;
2236    /// use google_cloud_trace_v2::model::TruncatableString;
2237    /// let x = Module::new().set_module(TruncatableString::default()/* use setters */);
2238    /// ```
2239    pub fn set_module<T>(mut self, v: T) -> Self
2240    where
2241        T: std::convert::Into<crate::model::TruncatableString>,
2242    {
2243        self.module = std::option::Option::Some(v.into());
2244        self
2245    }
2246
2247    /// Sets or clears the value of [module][crate::model::Module::module].
2248    ///
2249    /// # Example
2250    /// ```ignore,no_run
2251    /// # use google_cloud_trace_v2::model::Module;
2252    /// use google_cloud_trace_v2::model::TruncatableString;
2253    /// let x = Module::new().set_or_clear_module(Some(TruncatableString::default()/* use setters */));
2254    /// let x = Module::new().set_or_clear_module(None::<TruncatableString>);
2255    /// ```
2256    pub fn set_or_clear_module<T>(mut self, v: std::option::Option<T>) -> Self
2257    where
2258        T: std::convert::Into<crate::model::TruncatableString>,
2259    {
2260        self.module = v.map(|x| x.into());
2261        self
2262    }
2263
2264    /// Sets the value of [build_id][crate::model::Module::build_id].
2265    ///
2266    /// # Example
2267    /// ```ignore,no_run
2268    /// # use google_cloud_trace_v2::model::Module;
2269    /// use google_cloud_trace_v2::model::TruncatableString;
2270    /// let x = Module::new().set_build_id(TruncatableString::default()/* use setters */);
2271    /// ```
2272    pub fn set_build_id<T>(mut self, v: T) -> Self
2273    where
2274        T: std::convert::Into<crate::model::TruncatableString>,
2275    {
2276        self.build_id = std::option::Option::Some(v.into());
2277        self
2278    }
2279
2280    /// Sets or clears the value of [build_id][crate::model::Module::build_id].
2281    ///
2282    /// # Example
2283    /// ```ignore,no_run
2284    /// # use google_cloud_trace_v2::model::Module;
2285    /// use google_cloud_trace_v2::model::TruncatableString;
2286    /// let x = Module::new().set_or_clear_build_id(Some(TruncatableString::default()/* use setters */));
2287    /// let x = Module::new().set_or_clear_build_id(None::<TruncatableString>);
2288    /// ```
2289    pub fn set_or_clear_build_id<T>(mut self, v: std::option::Option<T>) -> Self
2290    where
2291        T: std::convert::Into<crate::model::TruncatableString>,
2292    {
2293        self.build_id = v.map(|x| x.into());
2294        self
2295    }
2296}
2297
2298impl wkt::message::Message for Module {
2299    fn typename() -> &'static str {
2300        "type.googleapis.com/google.devtools.cloudtrace.v2.Module"
2301    }
2302}
2303
2304/// Represents a string that might be shortened to a specified length.
2305#[derive(Clone, Default, PartialEq)]
2306#[non_exhaustive]
2307pub struct TruncatableString {
2308    /// The shortened string. For example, if the original string is 500
2309    /// bytes long and the limit of the string is 128 bytes, then
2310    /// `value` contains the first 128 bytes of the 500-byte string.
2311    ///
2312    /// Truncation always happens on a UTF8 character boundary. If there
2313    /// are multi-byte characters in the string, then the length of the
2314    /// shortened string might be less than the size limit.
2315    pub value: std::string::String,
2316
2317    /// The number of bytes removed from the original string. If this
2318    /// value is 0, then the string was not shortened.
2319    pub truncated_byte_count: i32,
2320
2321    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2322}
2323
2324impl TruncatableString {
2325    /// Creates a new default instance.
2326    pub fn new() -> Self {
2327        std::default::Default::default()
2328    }
2329
2330    /// Sets the value of [value][crate::model::TruncatableString::value].
2331    ///
2332    /// # Example
2333    /// ```ignore,no_run
2334    /// # use google_cloud_trace_v2::model::TruncatableString;
2335    /// let x = TruncatableString::new().set_value("example");
2336    /// ```
2337    pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2338        self.value = v.into();
2339        self
2340    }
2341
2342    /// Sets the value of [truncated_byte_count][crate::model::TruncatableString::truncated_byte_count].
2343    ///
2344    /// # Example
2345    /// ```ignore,no_run
2346    /// # use google_cloud_trace_v2::model::TruncatableString;
2347    /// let x = TruncatableString::new().set_truncated_byte_count(42);
2348    /// ```
2349    pub fn set_truncated_byte_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2350        self.truncated_byte_count = v.into();
2351        self
2352    }
2353}
2354
2355impl wkt::message::Message for TruncatableString {
2356    fn typename() -> &'static str {
2357        "type.googleapis.com/google.devtools.cloudtrace.v2.TruncatableString"
2358    }
2359}
2360
2361/// The request message for the `BatchWriteSpans` method.
2362#[derive(Clone, Default, PartialEq)]
2363#[non_exhaustive]
2364pub struct BatchWriteSpansRequest {
2365    /// Required. The name of the project where the spans belong. The format is
2366    /// `projects/[PROJECT_ID]`.
2367    pub name: std::string::String,
2368
2369    /// Required. A list of new spans. The span names must not match existing
2370    /// spans, otherwise the results are undefined.
2371    pub spans: std::vec::Vec<crate::model::Span>,
2372
2373    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2374}
2375
2376impl BatchWriteSpansRequest {
2377    /// Creates a new default instance.
2378    pub fn new() -> Self {
2379        std::default::Default::default()
2380    }
2381
2382    /// Sets the value of [name][crate::model::BatchWriteSpansRequest::name].
2383    ///
2384    /// # Example
2385    /// ```ignore,no_run
2386    /// # use google_cloud_trace_v2::model::BatchWriteSpansRequest;
2387    /// let x = BatchWriteSpansRequest::new().set_name("example");
2388    /// ```
2389    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2390        self.name = v.into();
2391        self
2392    }
2393
2394    /// Sets the value of [spans][crate::model::BatchWriteSpansRequest::spans].
2395    ///
2396    /// # Example
2397    /// ```ignore,no_run
2398    /// # use google_cloud_trace_v2::model::BatchWriteSpansRequest;
2399    /// use google_cloud_trace_v2::model::Span;
2400    /// let x = BatchWriteSpansRequest::new()
2401    ///     .set_spans([
2402    ///         Span::default()/* use setters */,
2403    ///         Span::default()/* use (different) setters */,
2404    ///     ]);
2405    /// ```
2406    pub fn set_spans<T, V>(mut self, v: T) -> Self
2407    where
2408        T: std::iter::IntoIterator<Item = V>,
2409        V: std::convert::Into<crate::model::Span>,
2410    {
2411        use std::iter::Iterator;
2412        self.spans = v.into_iter().map(|i| i.into()).collect();
2413        self
2414    }
2415}
2416
2417impl wkt::message::Message for BatchWriteSpansRequest {
2418    fn typename() -> &'static str {
2419        "type.googleapis.com/google.devtools.cloudtrace.v2.BatchWriteSpansRequest"
2420    }
2421}