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 gax;
23extern crate gaxi;
24extern crate lazy_static;
25extern crate reqwest;
26extern crate rpc;
27extern crate serde;
28extern crate serde_json;
29extern crate serde_with;
30extern crate std;
31extern crate tracing;
32extern crate wkt;
33
34mod debug;
35mod deserialize;
36mod serialize;
37
38/// A span represents a single operation within a trace. Spans can be
39/// nested to form a trace tree. Often, a trace contains a root span
40/// that describes the end-to-end latency, and one or more subspans for
41/// its sub-operations.
42///
43/// A trace can also contain multiple root spans, or none at all.
44/// Spans do not need to be contiguous. There might be
45/// gaps or overlaps between spans in a trace.
46#[derive(Clone, Default, PartialEq)]
47#[non_exhaustive]
48pub struct Span {
49    /// Required. The resource name of the span in the following format:
50    ///
51    /// * `projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]`
52    ///
53    /// `[TRACE_ID]` is a unique identifier for a trace within a project;
54    /// it is a 32-character hexadecimal encoding of a 16-byte array. It should
55    /// not be zero.
56    ///
57    /// `[SPAN_ID]` is a unique identifier for a span within a trace; it
58    /// is a 16-character hexadecimal encoding of an 8-byte array. It should not
59    /// be zero.
60    /// .
61    pub name: std::string::String,
62
63    /// Required. The `[SPAN_ID]` portion of the span's resource name.
64    pub span_id: std::string::String,
65
66    /// The `[SPAN_ID]` of this span's parent span. If this is a root span,
67    /// then this field must be empty.
68    pub parent_span_id: std::string::String,
69
70    /// Required. A description of the span's operation (up to 128 bytes).
71    /// Cloud Trace displays the description in the
72    /// Cloud console.
73    /// For example, the display name can be a qualified method name or a file name
74    /// and a line number where the operation is called. A best practice is to use
75    /// the same display name within an application and at the same call point.
76    /// This makes it easier to correlate spans in different traces.
77    pub display_name: std::option::Option<crate::model::TruncatableString>,
78
79    /// Required. The start time of the span. On the client side, this is the time
80    /// kept by the local machine where the span execution starts. On the server
81    /// side, this is the time when the server's application handler starts
82    /// running.
83    pub start_time: std::option::Option<wkt::Timestamp>,
84
85    /// Required. The end time of the span. On the client side, this is the time
86    /// kept by the local machine where the span execution ends. On the server
87    /// side, this is the time when the server application handler stops running.
88    pub end_time: std::option::Option<wkt::Timestamp>,
89
90    /// A set of attributes on the span. You can have up to 32 attributes per
91    /// span.
92    pub attributes: std::option::Option<crate::model::span::Attributes>,
93
94    /// Stack trace captured at the start of the span.
95    pub stack_trace: std::option::Option<crate::model::StackTrace>,
96
97    /// A set of time events. You can have up to 32 annotations and 128 message
98    /// events per span.
99    pub time_events: std::option::Option<crate::model::span::TimeEvents>,
100
101    /// Links associated with the span. You can have up to 128 links per Span.
102    pub links: std::option::Option<crate::model::span::Links>,
103
104    /// Optional. The final status for this span.
105    pub status: std::option::Option<rpc::model::Status>,
106
107    /// Optional. Set this parameter to indicate whether this span is in
108    /// the same process as its parent. If you do not set this parameter,
109    /// Trace is unable to take advantage of this helpful information.
110    pub same_process_as_parent_span: std::option::Option<wkt::BoolValue>,
111
112    /// Optional. The number of child spans that were generated while this span
113    /// was active. If set, allows implementation to detect missing child spans.
114    pub child_span_count: std::option::Option<wkt::Int32Value>,
115
116    /// Optional. Distinguishes between spans generated in a particular context.
117    /// For example, two spans with the same name may be distinguished using
118    /// `CLIENT` (caller) and `SERVER` (callee) to identify an RPC call.
119    pub span_kind: crate::model::span::SpanKind,
120
121    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
122}
123
124impl Span {
125    pub fn new() -> Self {
126        std::default::Default::default()
127    }
128
129    /// Sets the value of [name][crate::model::Span::name].
130    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
131        self.name = v.into();
132        self
133    }
134
135    /// Sets the value of [span_id][crate::model::Span::span_id].
136    pub fn set_span_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
137        self.span_id = v.into();
138        self
139    }
140
141    /// Sets the value of [parent_span_id][crate::model::Span::parent_span_id].
142    pub fn set_parent_span_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
143        self.parent_span_id = v.into();
144        self
145    }
146
147    /// Sets the value of [display_name][crate::model::Span::display_name].
148    pub fn set_display_name<T>(mut self, v: T) -> Self
149    where
150        T: std::convert::Into<crate::model::TruncatableString>,
151    {
152        self.display_name = std::option::Option::Some(v.into());
153        self
154    }
155
156    /// Sets or clears the value of [display_name][crate::model::Span::display_name].
157    pub fn set_or_clear_display_name<T>(mut self, v: std::option::Option<T>) -> Self
158    where
159        T: std::convert::Into<crate::model::TruncatableString>,
160    {
161        self.display_name = v.map(|x| x.into());
162        self
163    }
164
165    /// Sets the value of [start_time][crate::model::Span::start_time].
166    pub fn set_start_time<T>(mut self, v: T) -> Self
167    where
168        T: std::convert::Into<wkt::Timestamp>,
169    {
170        self.start_time = std::option::Option::Some(v.into());
171        self
172    }
173
174    /// Sets or clears the value of [start_time][crate::model::Span::start_time].
175    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
176    where
177        T: std::convert::Into<wkt::Timestamp>,
178    {
179        self.start_time = v.map(|x| x.into());
180        self
181    }
182
183    /// Sets the value of [end_time][crate::model::Span::end_time].
184    pub fn set_end_time<T>(mut self, v: T) -> Self
185    where
186        T: std::convert::Into<wkt::Timestamp>,
187    {
188        self.end_time = std::option::Option::Some(v.into());
189        self
190    }
191
192    /// Sets or clears the value of [end_time][crate::model::Span::end_time].
193    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
194    where
195        T: std::convert::Into<wkt::Timestamp>,
196    {
197        self.end_time = v.map(|x| x.into());
198        self
199    }
200
201    /// Sets the value of [attributes][crate::model::Span::attributes].
202    pub fn set_attributes<T>(mut self, v: T) -> Self
203    where
204        T: std::convert::Into<crate::model::span::Attributes>,
205    {
206        self.attributes = std::option::Option::Some(v.into());
207        self
208    }
209
210    /// Sets or clears the value of [attributes][crate::model::Span::attributes].
211    pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
212    where
213        T: std::convert::Into<crate::model::span::Attributes>,
214    {
215        self.attributes = v.map(|x| x.into());
216        self
217    }
218
219    /// Sets the value of [stack_trace][crate::model::Span::stack_trace].
220    pub fn set_stack_trace<T>(mut self, v: T) -> Self
221    where
222        T: std::convert::Into<crate::model::StackTrace>,
223    {
224        self.stack_trace = std::option::Option::Some(v.into());
225        self
226    }
227
228    /// Sets or clears the value of [stack_trace][crate::model::Span::stack_trace].
229    pub fn set_or_clear_stack_trace<T>(mut self, v: std::option::Option<T>) -> Self
230    where
231        T: std::convert::Into<crate::model::StackTrace>,
232    {
233        self.stack_trace = v.map(|x| x.into());
234        self
235    }
236
237    /// Sets the value of [time_events][crate::model::Span::time_events].
238    pub fn set_time_events<T>(mut self, v: T) -> Self
239    where
240        T: std::convert::Into<crate::model::span::TimeEvents>,
241    {
242        self.time_events = std::option::Option::Some(v.into());
243        self
244    }
245
246    /// Sets or clears the value of [time_events][crate::model::Span::time_events].
247    pub fn set_or_clear_time_events<T>(mut self, v: std::option::Option<T>) -> Self
248    where
249        T: std::convert::Into<crate::model::span::TimeEvents>,
250    {
251        self.time_events = v.map(|x| x.into());
252        self
253    }
254
255    /// Sets the value of [links][crate::model::Span::links].
256    pub fn set_links<T>(mut self, v: T) -> Self
257    where
258        T: std::convert::Into<crate::model::span::Links>,
259    {
260        self.links = std::option::Option::Some(v.into());
261        self
262    }
263
264    /// Sets or clears the value of [links][crate::model::Span::links].
265    pub fn set_or_clear_links<T>(mut self, v: std::option::Option<T>) -> Self
266    where
267        T: std::convert::Into<crate::model::span::Links>,
268    {
269        self.links = v.map(|x| x.into());
270        self
271    }
272
273    /// Sets the value of [status][crate::model::Span::status].
274    pub fn set_status<T>(mut self, v: T) -> Self
275    where
276        T: std::convert::Into<rpc::model::Status>,
277    {
278        self.status = std::option::Option::Some(v.into());
279        self
280    }
281
282    /// Sets or clears the value of [status][crate::model::Span::status].
283    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
284    where
285        T: std::convert::Into<rpc::model::Status>,
286    {
287        self.status = v.map(|x| x.into());
288        self
289    }
290
291    /// Sets the value of [same_process_as_parent_span][crate::model::Span::same_process_as_parent_span].
292    pub fn set_same_process_as_parent_span<T>(mut self, v: T) -> Self
293    where
294        T: std::convert::Into<wkt::BoolValue>,
295    {
296        self.same_process_as_parent_span = std::option::Option::Some(v.into());
297        self
298    }
299
300    /// Sets or clears the value of [same_process_as_parent_span][crate::model::Span::same_process_as_parent_span].
301    pub fn set_or_clear_same_process_as_parent_span<T>(mut self, v: std::option::Option<T>) -> Self
302    where
303        T: std::convert::Into<wkt::BoolValue>,
304    {
305        self.same_process_as_parent_span = v.map(|x| x.into());
306        self
307    }
308
309    /// Sets the value of [child_span_count][crate::model::Span::child_span_count].
310    pub fn set_child_span_count<T>(mut self, v: T) -> Self
311    where
312        T: std::convert::Into<wkt::Int32Value>,
313    {
314        self.child_span_count = std::option::Option::Some(v.into());
315        self
316    }
317
318    /// Sets or clears the value of [child_span_count][crate::model::Span::child_span_count].
319    pub fn set_or_clear_child_span_count<T>(mut self, v: std::option::Option<T>) -> Self
320    where
321        T: std::convert::Into<wkt::Int32Value>,
322    {
323        self.child_span_count = v.map(|x| x.into());
324        self
325    }
326
327    /// Sets the value of [span_kind][crate::model::Span::span_kind].
328    pub fn set_span_kind<T: std::convert::Into<crate::model::span::SpanKind>>(
329        mut self,
330        v: T,
331    ) -> Self {
332        self.span_kind = v.into();
333        self
334    }
335}
336
337impl wkt::message::Message for Span {
338    fn typename() -> &'static str {
339        "type.googleapis.com/google.devtools.cloudtrace.v2.Span"
340    }
341}
342
343/// Defines additional types related to [Span].
344pub mod span {
345    #[allow(unused_imports)]
346    use super::*;
347
348    /// A set of attributes as key-value pairs.
349    #[derive(Clone, Default, PartialEq)]
350    #[non_exhaustive]
351    pub struct Attributes {
352        /// A set of attributes. Each attribute's key can be up to 128 bytes
353        /// long. The value can be a string up to 256 bytes, a signed 64-bit integer,
354        /// or the boolean values `true` or `false`. For example:
355        ///
356        /// ```norust
357        /// "/instance_id": { "string_value": { "value": "my-instance" } }
358        /// "/http/request_bytes": { "int_value": 300 }
359        /// "abc.com/myattribute": { "bool_value": false }
360        /// ```
361        pub attribute_map:
362            std::collections::HashMap<std::string::String, crate::model::AttributeValue>,
363
364        /// The number of attributes that were discarded. Attributes can be discarded
365        /// because their keys are too long or because there are too many attributes.
366        /// If this value is 0 then all attributes are valid.
367        pub dropped_attributes_count: i32,
368
369        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
370    }
371
372    impl Attributes {
373        pub fn new() -> Self {
374            std::default::Default::default()
375        }
376
377        /// Sets the value of [attribute_map][crate::model::span::Attributes::attribute_map].
378        pub fn set_attribute_map<T, K, V>(mut self, v: T) -> Self
379        where
380            T: std::iter::IntoIterator<Item = (K, V)>,
381            K: std::convert::Into<std::string::String>,
382            V: std::convert::Into<crate::model::AttributeValue>,
383        {
384            use std::iter::Iterator;
385            self.attribute_map = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
386            self
387        }
388
389        /// Sets the value of [dropped_attributes_count][crate::model::span::Attributes::dropped_attributes_count].
390        pub fn set_dropped_attributes_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
391            self.dropped_attributes_count = v.into();
392            self
393        }
394    }
395
396    impl wkt::message::Message for Attributes {
397        fn typename() -> &'static str {
398            "type.googleapis.com/google.devtools.cloudtrace.v2.Span.Attributes"
399        }
400    }
401
402    /// A time-stamped annotation or message event in the Span.
403    #[derive(Clone, Default, PartialEq)]
404    #[non_exhaustive]
405    pub struct TimeEvent {
406        /// The timestamp indicating the time the event occurred.
407        pub time: std::option::Option<wkt::Timestamp>,
408
409        /// A `TimeEvent` can contain either an `Annotation` object or a
410        /// `MessageEvent` object, but not both.
411        pub value: std::option::Option<crate::model::span::time_event::Value>,
412
413        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
414    }
415
416    impl TimeEvent {
417        pub fn new() -> Self {
418            std::default::Default::default()
419        }
420
421        /// Sets the value of [time][crate::model::span::TimeEvent::time].
422        pub fn set_time<T>(mut self, v: T) -> Self
423        where
424            T: std::convert::Into<wkt::Timestamp>,
425        {
426            self.time = std::option::Option::Some(v.into());
427            self
428        }
429
430        /// Sets or clears the value of [time][crate::model::span::TimeEvent::time].
431        pub fn set_or_clear_time<T>(mut self, v: std::option::Option<T>) -> Self
432        where
433            T: std::convert::Into<wkt::Timestamp>,
434        {
435            self.time = v.map(|x| x.into());
436            self
437        }
438
439        /// Sets the value of [value][crate::model::span::TimeEvent::value].
440        ///
441        /// Note that all the setters affecting `value` are mutually
442        /// exclusive.
443        pub fn set_value<
444            T: std::convert::Into<std::option::Option<crate::model::span::time_event::Value>>,
445        >(
446            mut self,
447            v: T,
448        ) -> Self {
449            self.value = v.into();
450            self
451        }
452
453        /// The value of [value][crate::model::span::TimeEvent::value]
454        /// if it holds a `Annotation`, `None` if the field is not set or
455        /// holds a different branch.
456        pub fn annotation(
457            &self,
458        ) -> std::option::Option<&std::boxed::Box<crate::model::span::time_event::Annotation>>
459        {
460            #[allow(unreachable_patterns)]
461            self.value.as_ref().and_then(|v| match v {
462                crate::model::span::time_event::Value::Annotation(v) => {
463                    std::option::Option::Some(v)
464                }
465                _ => std::option::Option::None,
466            })
467        }
468
469        /// Sets the value of [value][crate::model::span::TimeEvent::value]
470        /// to hold a `Annotation`.
471        ///
472        /// Note that all the setters affecting `value` are
473        /// mutually exclusive.
474        pub fn set_annotation<
475            T: std::convert::Into<std::boxed::Box<crate::model::span::time_event::Annotation>>,
476        >(
477            mut self,
478            v: T,
479        ) -> Self {
480            self.value = std::option::Option::Some(
481                crate::model::span::time_event::Value::Annotation(v.into()),
482            );
483            self
484        }
485
486        /// The value of [value][crate::model::span::TimeEvent::value]
487        /// if it holds a `MessageEvent`, `None` if the field is not set or
488        /// holds a different branch.
489        pub fn message_event(
490            &self,
491        ) -> std::option::Option<&std::boxed::Box<crate::model::span::time_event::MessageEvent>>
492        {
493            #[allow(unreachable_patterns)]
494            self.value.as_ref().and_then(|v| match v {
495                crate::model::span::time_event::Value::MessageEvent(v) => {
496                    std::option::Option::Some(v)
497                }
498                _ => std::option::Option::None,
499            })
500        }
501
502        /// Sets the value of [value][crate::model::span::TimeEvent::value]
503        /// to hold a `MessageEvent`.
504        ///
505        /// Note that all the setters affecting `value` are
506        /// mutually exclusive.
507        pub fn set_message_event<
508            T: std::convert::Into<std::boxed::Box<crate::model::span::time_event::MessageEvent>>,
509        >(
510            mut self,
511            v: T,
512        ) -> Self {
513            self.value = std::option::Option::Some(
514                crate::model::span::time_event::Value::MessageEvent(v.into()),
515            );
516            self
517        }
518    }
519
520    impl wkt::message::Message for TimeEvent {
521        fn typename() -> &'static str {
522            "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvent"
523        }
524    }
525
526    /// Defines additional types related to [TimeEvent].
527    pub mod time_event {
528        #[allow(unused_imports)]
529        use super::*;
530
531        /// Text annotation with a set of attributes.
532        #[derive(Clone, Default, PartialEq)]
533        #[non_exhaustive]
534        pub struct Annotation {
535            /// A user-supplied message describing the event. The maximum length for
536            /// the description is 256 bytes.
537            pub description: std::option::Option<crate::model::TruncatableString>,
538
539            /// A set of attributes on the annotation. You can have up to 4 attributes
540            /// per Annotation.
541            pub attributes: std::option::Option<crate::model::span::Attributes>,
542
543            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
544        }
545
546        impl Annotation {
547            pub fn new() -> Self {
548                std::default::Default::default()
549            }
550
551            /// Sets the value of [description][crate::model::span::time_event::Annotation::description].
552            pub fn set_description<T>(mut self, v: T) -> Self
553            where
554                T: std::convert::Into<crate::model::TruncatableString>,
555            {
556                self.description = std::option::Option::Some(v.into());
557                self
558            }
559
560            /// Sets or clears the value of [description][crate::model::span::time_event::Annotation::description].
561            pub fn set_or_clear_description<T>(mut self, v: std::option::Option<T>) -> Self
562            where
563                T: std::convert::Into<crate::model::TruncatableString>,
564            {
565                self.description = v.map(|x| x.into());
566                self
567            }
568
569            /// Sets the value of [attributes][crate::model::span::time_event::Annotation::attributes].
570            pub fn set_attributes<T>(mut self, v: T) -> Self
571            where
572                T: std::convert::Into<crate::model::span::Attributes>,
573            {
574                self.attributes = std::option::Option::Some(v.into());
575                self
576            }
577
578            /// Sets or clears the value of [attributes][crate::model::span::time_event::Annotation::attributes].
579            pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
580            where
581                T: std::convert::Into<crate::model::span::Attributes>,
582            {
583                self.attributes = v.map(|x| x.into());
584                self
585            }
586        }
587
588        impl wkt::message::Message for Annotation {
589            fn typename() -> &'static str {
590                "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvent.Annotation"
591            }
592        }
593
594        /// An event describing a message sent/received between Spans.
595        #[derive(Clone, Default, PartialEq)]
596        #[non_exhaustive]
597        pub struct MessageEvent {
598            /// Type of MessageEvent. Indicates whether the message was sent or
599            /// received.
600            pub r#type: crate::model::span::time_event::message_event::Type,
601
602            /// An identifier for the MessageEvent's message that can be used to match
603            /// `SENT` and `RECEIVED` MessageEvents.
604            pub id: i64,
605
606            /// The number of uncompressed bytes sent or received.
607            pub uncompressed_size_bytes: i64,
608
609            /// The number of compressed bytes sent or received. If missing, the
610            /// compressed size is assumed to be the same size as the uncompressed
611            /// size.
612            pub compressed_size_bytes: i64,
613
614            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
615        }
616
617        impl MessageEvent {
618            pub fn new() -> Self {
619                std::default::Default::default()
620            }
621
622            /// Sets the value of [r#type][crate::model::span::time_event::MessageEvent::type].
623            pub fn set_type<
624                T: std::convert::Into<crate::model::span::time_event::message_event::Type>,
625            >(
626                mut self,
627                v: T,
628            ) -> Self {
629                self.r#type = v.into();
630                self
631            }
632
633            /// Sets the value of [id][crate::model::span::time_event::MessageEvent::id].
634            pub fn set_id<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
635                self.id = v.into();
636                self
637            }
638
639            /// Sets the value of [uncompressed_size_bytes][crate::model::span::time_event::MessageEvent::uncompressed_size_bytes].
640            pub fn set_uncompressed_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
641                self.uncompressed_size_bytes = v.into();
642                self
643            }
644
645            /// Sets the value of [compressed_size_bytes][crate::model::span::time_event::MessageEvent::compressed_size_bytes].
646            pub fn set_compressed_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
647                self.compressed_size_bytes = v.into();
648                self
649            }
650        }
651
652        impl wkt::message::Message for MessageEvent {
653            fn typename() -> &'static str {
654                "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent"
655            }
656        }
657
658        /// Defines additional types related to [MessageEvent].
659        pub mod message_event {
660            #[allow(unused_imports)]
661            use super::*;
662
663            /// Indicates whether the message was sent or received.
664            ///
665            /// # Working with unknown values
666            ///
667            /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
668            /// additional enum variants at any time. Adding new variants is not considered
669            /// a breaking change. Applications should write their code in anticipation of:
670            ///
671            /// - New values appearing in future releases of the client library, **and**
672            /// - New values received dynamically, without application changes.
673            ///
674            /// Please consult the [Working with enums] section in the user guide for some
675            /// guidelines.
676            ///
677            /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
678            #[derive(Clone, Debug, PartialEq)]
679            #[non_exhaustive]
680            pub enum Type {
681                /// Unknown event type.
682                Unspecified,
683                /// Indicates a sent message.
684                Sent,
685                /// Indicates a received message.
686                Received,
687                /// If set, the enum was initialized with an unknown value.
688                ///
689                /// Applications can examine the value using [Type::value] or
690                /// [Type::name].
691                UnknownValue(r#type::UnknownValue),
692            }
693
694            #[doc(hidden)]
695            pub mod r#type {
696                #[allow(unused_imports)]
697                use super::*;
698                #[derive(Clone, Debug, PartialEq)]
699                pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
700            }
701
702            impl Type {
703                /// Gets the enum value.
704                ///
705                /// Returns `None` if the enum contains an unknown value deserialized from
706                /// the string representation of enums.
707                pub fn value(&self) -> std::option::Option<i32> {
708                    match self {
709                        Self::Unspecified => std::option::Option::Some(0),
710                        Self::Sent => std::option::Option::Some(1),
711                        Self::Received => std::option::Option::Some(2),
712                        Self::UnknownValue(u) => u.0.value(),
713                    }
714                }
715
716                /// Gets the enum value as a string.
717                ///
718                /// Returns `None` if the enum contains an unknown value deserialized from
719                /// the integer representation of enums.
720                pub fn name(&self) -> std::option::Option<&str> {
721                    match self {
722                        Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
723                        Self::Sent => std::option::Option::Some("SENT"),
724                        Self::Received => std::option::Option::Some("RECEIVED"),
725                        Self::UnknownValue(u) => u.0.name(),
726                    }
727                }
728            }
729
730            impl std::default::Default for Type {
731                fn default() -> Self {
732                    use std::convert::From;
733                    Self::from(0)
734                }
735            }
736
737            impl std::fmt::Display for Type {
738                fn fmt(
739                    &self,
740                    f: &mut std::fmt::Formatter<'_>,
741                ) -> std::result::Result<(), std::fmt::Error> {
742                    wkt::internal::display_enum(f, self.name(), self.value())
743                }
744            }
745
746            impl std::convert::From<i32> for Type {
747                fn from(value: i32) -> Self {
748                    match value {
749                        0 => Self::Unspecified,
750                        1 => Self::Sent,
751                        2 => Self::Received,
752                        _ => Self::UnknownValue(r#type::UnknownValue(
753                            wkt::internal::UnknownEnumValue::Integer(value),
754                        )),
755                    }
756                }
757            }
758
759            impl std::convert::From<&str> for Type {
760                fn from(value: &str) -> Self {
761                    use std::string::ToString;
762                    match value {
763                        "TYPE_UNSPECIFIED" => Self::Unspecified,
764                        "SENT" => Self::Sent,
765                        "RECEIVED" => Self::Received,
766                        _ => Self::UnknownValue(r#type::UnknownValue(
767                            wkt::internal::UnknownEnumValue::String(value.to_string()),
768                        )),
769                    }
770                }
771            }
772
773            impl serde::ser::Serialize for Type {
774                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
775                where
776                    S: serde::Serializer,
777                {
778                    match self {
779                        Self::Unspecified => serializer.serialize_i32(0),
780                        Self::Sent => serializer.serialize_i32(1),
781                        Self::Received => serializer.serialize_i32(2),
782                        Self::UnknownValue(u) => u.0.serialize(serializer),
783                    }
784                }
785            }
786
787            impl<'de> serde::de::Deserialize<'de> for Type {
788                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
789                where
790                    D: serde::Deserializer<'de>,
791                {
792                    deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
793                        ".google.devtools.cloudtrace.v2.Span.TimeEvent.MessageEvent.Type",
794                    ))
795                }
796            }
797        }
798
799        /// A `TimeEvent` can contain either an `Annotation` object or a
800        /// `MessageEvent` object, but not both.
801        #[derive(Clone, Debug, PartialEq)]
802        #[non_exhaustive]
803        pub enum Value {
804            /// Text annotation with a set of attributes.
805            Annotation(std::boxed::Box<crate::model::span::time_event::Annotation>),
806            /// An event describing a message sent/received between Spans.
807            MessageEvent(std::boxed::Box<crate::model::span::time_event::MessageEvent>),
808        }
809    }
810
811    /// A collection of `TimeEvent`s. A `TimeEvent` is a time-stamped annotation
812    /// on the span, consisting of either user-supplied key:value pairs, or
813    /// details of a message sent/received between Spans.
814    #[derive(Clone, Default, PartialEq)]
815    #[non_exhaustive]
816    pub struct TimeEvents {
817        /// A collection of `TimeEvent`s.
818        pub time_event: std::vec::Vec<crate::model::span::TimeEvent>,
819
820        /// The number of dropped annotations in all the included time events.
821        /// If the value is 0, then no annotations were dropped.
822        pub dropped_annotations_count: i32,
823
824        /// The number of dropped message events in all the included time events.
825        /// If the value is 0, then no message events were dropped.
826        pub dropped_message_events_count: i32,
827
828        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
829    }
830
831    impl TimeEvents {
832        pub fn new() -> Self {
833            std::default::Default::default()
834        }
835
836        /// Sets the value of [time_event][crate::model::span::TimeEvents::time_event].
837        pub fn set_time_event<T, V>(mut self, v: T) -> Self
838        where
839            T: std::iter::IntoIterator<Item = V>,
840            V: std::convert::Into<crate::model::span::TimeEvent>,
841        {
842            use std::iter::Iterator;
843            self.time_event = v.into_iter().map(|i| i.into()).collect();
844            self
845        }
846
847        /// Sets the value of [dropped_annotations_count][crate::model::span::TimeEvents::dropped_annotations_count].
848        pub fn set_dropped_annotations_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
849            self.dropped_annotations_count = v.into();
850            self
851        }
852
853        /// Sets the value of [dropped_message_events_count][crate::model::span::TimeEvents::dropped_message_events_count].
854        pub fn set_dropped_message_events_count<T: std::convert::Into<i32>>(
855            mut self,
856            v: T,
857        ) -> Self {
858            self.dropped_message_events_count = v.into();
859            self
860        }
861    }
862
863    impl wkt::message::Message for TimeEvents {
864        fn typename() -> &'static str {
865            "type.googleapis.com/google.devtools.cloudtrace.v2.Span.TimeEvents"
866        }
867    }
868
869    /// A pointer from the current span to another span in the same trace or in a
870    /// different trace. For example, this can be used in batching operations,
871    /// where a single batch handler processes multiple requests from different
872    /// traces or when the handler receives a request from a different project.
873    #[derive(Clone, Default, PartialEq)]
874    #[non_exhaustive]
875    pub struct Link {
876        /// The `[TRACE_ID]` for a trace within a project.
877        pub trace_id: std::string::String,
878
879        /// The `[SPAN_ID]` for a span within a trace.
880        pub span_id: std::string::String,
881
882        /// The relationship of the current span relative to the linked span.
883        pub r#type: crate::model::span::link::Type,
884
885        /// A set of attributes on the link. Up to 32 attributes can be
886        /// specified per link.
887        pub attributes: std::option::Option<crate::model::span::Attributes>,
888
889        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
890    }
891
892    impl Link {
893        pub fn new() -> Self {
894            std::default::Default::default()
895        }
896
897        /// Sets the value of [trace_id][crate::model::span::Link::trace_id].
898        pub fn set_trace_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
899            self.trace_id = v.into();
900            self
901        }
902
903        /// Sets the value of [span_id][crate::model::span::Link::span_id].
904        pub fn set_span_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
905            self.span_id = v.into();
906            self
907        }
908
909        /// Sets the value of [r#type][crate::model::span::Link::type].
910        pub fn set_type<T: std::convert::Into<crate::model::span::link::Type>>(
911            mut self,
912            v: T,
913        ) -> Self {
914            self.r#type = v.into();
915            self
916        }
917
918        /// Sets the value of [attributes][crate::model::span::Link::attributes].
919        pub fn set_attributes<T>(mut self, v: T) -> Self
920        where
921            T: std::convert::Into<crate::model::span::Attributes>,
922        {
923            self.attributes = std::option::Option::Some(v.into());
924            self
925        }
926
927        /// Sets or clears the value of [attributes][crate::model::span::Link::attributes].
928        pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
929        where
930            T: std::convert::Into<crate::model::span::Attributes>,
931        {
932            self.attributes = v.map(|x| x.into());
933            self
934        }
935    }
936
937    impl wkt::message::Message for Link {
938        fn typename() -> &'static str {
939            "type.googleapis.com/google.devtools.cloudtrace.v2.Span.Link"
940        }
941    }
942
943    /// Defines additional types related to [Link].
944    pub mod link {
945        #[allow(unused_imports)]
946        use super::*;
947
948        /// The relationship of the current span relative to the linked span: child,
949        /// parent, or unspecified.
950        ///
951        /// # Working with unknown values
952        ///
953        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
954        /// additional enum variants at any time. Adding new variants is not considered
955        /// a breaking change. Applications should write their code in anticipation of:
956        ///
957        /// - New values appearing in future releases of the client library, **and**
958        /// - New values received dynamically, without application changes.
959        ///
960        /// Please consult the [Working with enums] section in the user guide for some
961        /// guidelines.
962        ///
963        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
964        #[derive(Clone, Debug, PartialEq)]
965        #[non_exhaustive]
966        pub enum Type {
967            /// The relationship of the two spans is unknown.
968            Unspecified,
969            /// The linked span is a child of the current span.
970            ChildLinkedSpan,
971            /// The linked span is a parent of the current span.
972            ParentLinkedSpan,
973            /// If set, the enum was initialized with an unknown value.
974            ///
975            /// Applications can examine the value using [Type::value] or
976            /// [Type::name].
977            UnknownValue(r#type::UnknownValue),
978        }
979
980        #[doc(hidden)]
981        pub mod r#type {
982            #[allow(unused_imports)]
983            use super::*;
984            #[derive(Clone, Debug, PartialEq)]
985            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
986        }
987
988        impl Type {
989            /// Gets the enum value.
990            ///
991            /// Returns `None` if the enum contains an unknown value deserialized from
992            /// the string representation of enums.
993            pub fn value(&self) -> std::option::Option<i32> {
994                match self {
995                    Self::Unspecified => std::option::Option::Some(0),
996                    Self::ChildLinkedSpan => std::option::Option::Some(1),
997                    Self::ParentLinkedSpan => std::option::Option::Some(2),
998                    Self::UnknownValue(u) => u.0.value(),
999                }
1000            }
1001
1002            /// Gets the enum value as a string.
1003            ///
1004            /// Returns `None` if the enum contains an unknown value deserialized from
1005            /// the integer representation of enums.
1006            pub fn name(&self) -> std::option::Option<&str> {
1007                match self {
1008                    Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
1009                    Self::ChildLinkedSpan => std::option::Option::Some("CHILD_LINKED_SPAN"),
1010                    Self::ParentLinkedSpan => std::option::Option::Some("PARENT_LINKED_SPAN"),
1011                    Self::UnknownValue(u) => u.0.name(),
1012                }
1013            }
1014        }
1015
1016        impl std::default::Default for Type {
1017            fn default() -> Self {
1018                use std::convert::From;
1019                Self::from(0)
1020            }
1021        }
1022
1023        impl std::fmt::Display for Type {
1024            fn fmt(
1025                &self,
1026                f: &mut std::fmt::Formatter<'_>,
1027            ) -> std::result::Result<(), std::fmt::Error> {
1028                wkt::internal::display_enum(f, self.name(), self.value())
1029            }
1030        }
1031
1032        impl std::convert::From<i32> for Type {
1033            fn from(value: i32) -> Self {
1034                match value {
1035                    0 => Self::Unspecified,
1036                    1 => Self::ChildLinkedSpan,
1037                    2 => Self::ParentLinkedSpan,
1038                    _ => Self::UnknownValue(r#type::UnknownValue(
1039                        wkt::internal::UnknownEnumValue::Integer(value),
1040                    )),
1041                }
1042            }
1043        }
1044
1045        impl std::convert::From<&str> for Type {
1046            fn from(value: &str) -> Self {
1047                use std::string::ToString;
1048                match value {
1049                    "TYPE_UNSPECIFIED" => Self::Unspecified,
1050                    "CHILD_LINKED_SPAN" => Self::ChildLinkedSpan,
1051                    "PARENT_LINKED_SPAN" => Self::ParentLinkedSpan,
1052                    _ => Self::UnknownValue(r#type::UnknownValue(
1053                        wkt::internal::UnknownEnumValue::String(value.to_string()),
1054                    )),
1055                }
1056            }
1057        }
1058
1059        impl serde::ser::Serialize for Type {
1060            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1061            where
1062                S: serde::Serializer,
1063            {
1064                match self {
1065                    Self::Unspecified => serializer.serialize_i32(0),
1066                    Self::ChildLinkedSpan => serializer.serialize_i32(1),
1067                    Self::ParentLinkedSpan => serializer.serialize_i32(2),
1068                    Self::UnknownValue(u) => u.0.serialize(serializer),
1069                }
1070            }
1071        }
1072
1073        impl<'de> serde::de::Deserialize<'de> for Type {
1074            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1075            where
1076                D: serde::Deserializer<'de>,
1077            {
1078                deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
1079                    ".google.devtools.cloudtrace.v2.Span.Link.Type",
1080                ))
1081            }
1082        }
1083    }
1084
1085    /// A collection of links, which are references from this span to a span
1086    /// in the same or different trace.
1087    #[derive(Clone, Default, PartialEq)]
1088    #[non_exhaustive]
1089    pub struct Links {
1090        /// A collection of links.
1091        pub link: std::vec::Vec<crate::model::span::Link>,
1092
1093        /// The number of dropped links after the maximum size was enforced. If
1094        /// this value is 0, then no links were dropped.
1095        pub dropped_links_count: i32,
1096
1097        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1098    }
1099
1100    impl Links {
1101        pub fn new() -> Self {
1102            std::default::Default::default()
1103        }
1104
1105        /// Sets the value of [link][crate::model::span::Links::link].
1106        pub fn set_link<T, V>(mut self, v: T) -> Self
1107        where
1108            T: std::iter::IntoIterator<Item = V>,
1109            V: std::convert::Into<crate::model::span::Link>,
1110        {
1111            use std::iter::Iterator;
1112            self.link = v.into_iter().map(|i| i.into()).collect();
1113            self
1114        }
1115
1116        /// Sets the value of [dropped_links_count][crate::model::span::Links::dropped_links_count].
1117        pub fn set_dropped_links_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1118            self.dropped_links_count = v.into();
1119            self
1120        }
1121    }
1122
1123    impl wkt::message::Message for Links {
1124        fn typename() -> &'static str {
1125            "type.googleapis.com/google.devtools.cloudtrace.v2.Span.Links"
1126        }
1127    }
1128
1129    /// Type of span. Can be used to specify additional relationships between spans
1130    /// in addition to a parent/child relationship.
1131    ///
1132    /// # Working with unknown values
1133    ///
1134    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1135    /// additional enum variants at any time. Adding new variants is not considered
1136    /// a breaking change. Applications should write their code in anticipation of:
1137    ///
1138    /// - New values appearing in future releases of the client library, **and**
1139    /// - New values received dynamically, without application changes.
1140    ///
1141    /// Please consult the [Working with enums] section in the user guide for some
1142    /// guidelines.
1143    ///
1144    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1145    #[derive(Clone, Debug, PartialEq)]
1146    #[non_exhaustive]
1147    pub enum SpanKind {
1148        /// Unspecified. Do NOT use as default.
1149        /// Implementations MAY assume SpanKind.INTERNAL to be default.
1150        Unspecified,
1151        /// Indicates that the span is used internally. Default value.
1152        Internal,
1153        /// Indicates that the span covers server-side handling of an RPC or other
1154        /// remote network request.
1155        Server,
1156        /// Indicates that the span covers the client-side wrapper around an RPC or
1157        /// other remote request.
1158        Client,
1159        /// Indicates that the span describes producer sending a message to a broker.
1160        /// Unlike client and  server, there is no direct critical path latency
1161        /// relationship between producer and consumer spans (e.g. publishing a
1162        /// message to a pubsub service).
1163        Producer,
1164        /// Indicates that the span describes consumer receiving a message from a
1165        /// broker. Unlike client and  server, there is no direct critical path
1166        /// latency relationship between producer and consumer spans (e.g. receiving
1167        /// a message from a pubsub service subscription).
1168        Consumer,
1169        /// If set, the enum was initialized with an unknown value.
1170        ///
1171        /// Applications can examine the value using [SpanKind::value] or
1172        /// [SpanKind::name].
1173        UnknownValue(span_kind::UnknownValue),
1174    }
1175
1176    #[doc(hidden)]
1177    pub mod span_kind {
1178        #[allow(unused_imports)]
1179        use super::*;
1180        #[derive(Clone, Debug, PartialEq)]
1181        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1182    }
1183
1184    impl SpanKind {
1185        /// Gets the enum value.
1186        ///
1187        /// Returns `None` if the enum contains an unknown value deserialized from
1188        /// the string representation of enums.
1189        pub fn value(&self) -> std::option::Option<i32> {
1190            match self {
1191                Self::Unspecified => std::option::Option::Some(0),
1192                Self::Internal => std::option::Option::Some(1),
1193                Self::Server => std::option::Option::Some(2),
1194                Self::Client => std::option::Option::Some(3),
1195                Self::Producer => std::option::Option::Some(4),
1196                Self::Consumer => std::option::Option::Some(5),
1197                Self::UnknownValue(u) => u.0.value(),
1198            }
1199        }
1200
1201        /// Gets the enum value as a string.
1202        ///
1203        /// Returns `None` if the enum contains an unknown value deserialized from
1204        /// the integer representation of enums.
1205        pub fn name(&self) -> std::option::Option<&str> {
1206            match self {
1207                Self::Unspecified => std::option::Option::Some("SPAN_KIND_UNSPECIFIED"),
1208                Self::Internal => std::option::Option::Some("INTERNAL"),
1209                Self::Server => std::option::Option::Some("SERVER"),
1210                Self::Client => std::option::Option::Some("CLIENT"),
1211                Self::Producer => std::option::Option::Some("PRODUCER"),
1212                Self::Consumer => std::option::Option::Some("CONSUMER"),
1213                Self::UnknownValue(u) => u.0.name(),
1214            }
1215        }
1216    }
1217
1218    impl std::default::Default for SpanKind {
1219        fn default() -> Self {
1220            use std::convert::From;
1221            Self::from(0)
1222        }
1223    }
1224
1225    impl std::fmt::Display for SpanKind {
1226        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1227            wkt::internal::display_enum(f, self.name(), self.value())
1228        }
1229    }
1230
1231    impl std::convert::From<i32> for SpanKind {
1232        fn from(value: i32) -> Self {
1233            match value {
1234                0 => Self::Unspecified,
1235                1 => Self::Internal,
1236                2 => Self::Server,
1237                3 => Self::Client,
1238                4 => Self::Producer,
1239                5 => Self::Consumer,
1240                _ => Self::UnknownValue(span_kind::UnknownValue(
1241                    wkt::internal::UnknownEnumValue::Integer(value),
1242                )),
1243            }
1244        }
1245    }
1246
1247    impl std::convert::From<&str> for SpanKind {
1248        fn from(value: &str) -> Self {
1249            use std::string::ToString;
1250            match value {
1251                "SPAN_KIND_UNSPECIFIED" => Self::Unspecified,
1252                "INTERNAL" => Self::Internal,
1253                "SERVER" => Self::Server,
1254                "CLIENT" => Self::Client,
1255                "PRODUCER" => Self::Producer,
1256                "CONSUMER" => Self::Consumer,
1257                _ => Self::UnknownValue(span_kind::UnknownValue(
1258                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1259                )),
1260            }
1261        }
1262    }
1263
1264    impl serde::ser::Serialize for SpanKind {
1265        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1266        where
1267            S: serde::Serializer,
1268        {
1269            match self {
1270                Self::Unspecified => serializer.serialize_i32(0),
1271                Self::Internal => serializer.serialize_i32(1),
1272                Self::Server => serializer.serialize_i32(2),
1273                Self::Client => serializer.serialize_i32(3),
1274                Self::Producer => serializer.serialize_i32(4),
1275                Self::Consumer => serializer.serialize_i32(5),
1276                Self::UnknownValue(u) => u.0.serialize(serializer),
1277            }
1278        }
1279    }
1280
1281    impl<'de> serde::de::Deserialize<'de> for SpanKind {
1282        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1283        where
1284            D: serde::Deserializer<'de>,
1285        {
1286            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SpanKind>::new(
1287                ".google.devtools.cloudtrace.v2.Span.SpanKind",
1288            ))
1289        }
1290    }
1291}
1292
1293/// The allowed types for `[VALUE]` in a `[KEY]:[VALUE]` attribute.
1294#[derive(Clone, Default, PartialEq)]
1295#[non_exhaustive]
1296pub struct AttributeValue {
1297    /// The type of the value.
1298    pub value: std::option::Option<crate::model::attribute_value::Value>,
1299
1300    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1301}
1302
1303impl AttributeValue {
1304    pub fn new() -> Self {
1305        std::default::Default::default()
1306    }
1307
1308    /// Sets the value of [value][crate::model::AttributeValue::value].
1309    ///
1310    /// Note that all the setters affecting `value` are mutually
1311    /// exclusive.
1312    pub fn set_value<
1313        T: std::convert::Into<std::option::Option<crate::model::attribute_value::Value>>,
1314    >(
1315        mut self,
1316        v: T,
1317    ) -> Self {
1318        self.value = v.into();
1319        self
1320    }
1321
1322    /// The value of [value][crate::model::AttributeValue::value]
1323    /// if it holds a `StringValue`, `None` if the field is not set or
1324    /// holds a different branch.
1325    pub fn string_value(
1326        &self,
1327    ) -> std::option::Option<&std::boxed::Box<crate::model::TruncatableString>> {
1328        #[allow(unreachable_patterns)]
1329        self.value.as_ref().and_then(|v| match v {
1330            crate::model::attribute_value::Value::StringValue(v) => std::option::Option::Some(v),
1331            _ => std::option::Option::None,
1332        })
1333    }
1334
1335    /// Sets the value of [value][crate::model::AttributeValue::value]
1336    /// to hold a `StringValue`.
1337    ///
1338    /// Note that all the setters affecting `value` are
1339    /// mutually exclusive.
1340    pub fn set_string_value<
1341        T: std::convert::Into<std::boxed::Box<crate::model::TruncatableString>>,
1342    >(
1343        mut self,
1344        v: T,
1345    ) -> Self {
1346        self.value =
1347            std::option::Option::Some(crate::model::attribute_value::Value::StringValue(v.into()));
1348        self
1349    }
1350
1351    /// The value of [value][crate::model::AttributeValue::value]
1352    /// if it holds a `IntValue`, `None` if the field is not set or
1353    /// holds a different branch.
1354    pub fn int_value(&self) -> std::option::Option<&i64> {
1355        #[allow(unreachable_patterns)]
1356        self.value.as_ref().and_then(|v| match v {
1357            crate::model::attribute_value::Value::IntValue(v) => std::option::Option::Some(v),
1358            _ => std::option::Option::None,
1359        })
1360    }
1361
1362    /// Sets the value of [value][crate::model::AttributeValue::value]
1363    /// to hold a `IntValue`.
1364    ///
1365    /// Note that all the setters affecting `value` are
1366    /// mutually exclusive.
1367    pub fn set_int_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1368        self.value =
1369            std::option::Option::Some(crate::model::attribute_value::Value::IntValue(v.into()));
1370        self
1371    }
1372
1373    /// The value of [value][crate::model::AttributeValue::value]
1374    /// if it holds a `BoolValue`, `None` if the field is not set or
1375    /// holds a different branch.
1376    pub fn bool_value(&self) -> std::option::Option<&bool> {
1377        #[allow(unreachable_patterns)]
1378        self.value.as_ref().and_then(|v| match v {
1379            crate::model::attribute_value::Value::BoolValue(v) => std::option::Option::Some(v),
1380            _ => std::option::Option::None,
1381        })
1382    }
1383
1384    /// Sets the value of [value][crate::model::AttributeValue::value]
1385    /// to hold a `BoolValue`.
1386    ///
1387    /// Note that all the setters affecting `value` are
1388    /// mutually exclusive.
1389    pub fn set_bool_value<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1390        self.value =
1391            std::option::Option::Some(crate::model::attribute_value::Value::BoolValue(v.into()));
1392        self
1393    }
1394}
1395
1396impl wkt::message::Message for AttributeValue {
1397    fn typename() -> &'static str {
1398        "type.googleapis.com/google.devtools.cloudtrace.v2.AttributeValue"
1399    }
1400}
1401
1402/// Defines additional types related to [AttributeValue].
1403pub mod attribute_value {
1404    #[allow(unused_imports)]
1405    use super::*;
1406
1407    /// The type of the value.
1408    #[derive(Clone, Debug, PartialEq)]
1409    #[non_exhaustive]
1410    pub enum Value {
1411        /// A string up to 256 bytes long.
1412        StringValue(std::boxed::Box<crate::model::TruncatableString>),
1413        /// A 64-bit signed integer.
1414        IntValue(i64),
1415        /// A Boolean value represented by `true` or `false`.
1416        BoolValue(bool),
1417    }
1418}
1419
1420/// A call stack appearing in a trace.
1421#[derive(Clone, Default, PartialEq)]
1422#[non_exhaustive]
1423pub struct StackTrace {
1424    /// Stack frames in this stack trace. A maximum of 128 frames are allowed.
1425    pub stack_frames: std::option::Option<crate::model::stack_trace::StackFrames>,
1426
1427    /// The hash ID is used to conserve network bandwidth for duplicate
1428    /// stack traces within a single trace.
1429    ///
1430    /// Often multiple spans will have identical stack traces.
1431    /// The first occurrence of a stack trace should contain both the
1432    /// `stackFrame` content and a value in `stackTraceHashId`.
1433    ///
1434    /// Subsequent spans within the same request can refer
1435    /// to that stack trace by only setting `stackTraceHashId`.
1436    pub stack_trace_hash_id: i64,
1437
1438    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1439}
1440
1441impl StackTrace {
1442    pub fn new() -> Self {
1443        std::default::Default::default()
1444    }
1445
1446    /// Sets the value of [stack_frames][crate::model::StackTrace::stack_frames].
1447    pub fn set_stack_frames<T>(mut self, v: T) -> Self
1448    where
1449        T: std::convert::Into<crate::model::stack_trace::StackFrames>,
1450    {
1451        self.stack_frames = std::option::Option::Some(v.into());
1452        self
1453    }
1454
1455    /// Sets or clears the value of [stack_frames][crate::model::StackTrace::stack_frames].
1456    pub fn set_or_clear_stack_frames<T>(mut self, v: std::option::Option<T>) -> Self
1457    where
1458        T: std::convert::Into<crate::model::stack_trace::StackFrames>,
1459    {
1460        self.stack_frames = v.map(|x| x.into());
1461        self
1462    }
1463
1464    /// Sets the value of [stack_trace_hash_id][crate::model::StackTrace::stack_trace_hash_id].
1465    pub fn set_stack_trace_hash_id<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1466        self.stack_trace_hash_id = v.into();
1467        self
1468    }
1469}
1470
1471impl wkt::message::Message for StackTrace {
1472    fn typename() -> &'static str {
1473        "type.googleapis.com/google.devtools.cloudtrace.v2.StackTrace"
1474    }
1475}
1476
1477/// Defines additional types related to [StackTrace].
1478pub mod stack_trace {
1479    #[allow(unused_imports)]
1480    use super::*;
1481
1482    /// Represents a single stack frame in a stack trace.
1483    #[derive(Clone, Default, PartialEq)]
1484    #[non_exhaustive]
1485    pub struct StackFrame {
1486        /// The fully-qualified name that uniquely identifies the function or
1487        /// method that is active in this frame (up to 1024 bytes).
1488        pub function_name: std::option::Option<crate::model::TruncatableString>,
1489
1490        /// An un-mangled function name, if `function_name` is mangled.
1491        /// To get information about name mangling, run
1492        /// [this search](https://www.google.com/search?q=cxx+name+mangling).
1493        /// The name can be fully-qualified (up to 1024 bytes).
1494        pub original_function_name: std::option::Option<crate::model::TruncatableString>,
1495
1496        /// The name of the source file where the function call appears (up to 256
1497        /// bytes).
1498        pub file_name: std::option::Option<crate::model::TruncatableString>,
1499
1500        /// The line number in `file_name` where the function call appears.
1501        pub line_number: i64,
1502
1503        /// The column number where the function call appears, if available.
1504        /// This is important in JavaScript because of its anonymous functions.
1505        pub column_number: i64,
1506
1507        /// The binary module from where the code was loaded.
1508        pub load_module: std::option::Option<crate::model::Module>,
1509
1510        /// The version of the deployed source code (up to 128 bytes).
1511        pub source_version: std::option::Option<crate::model::TruncatableString>,
1512
1513        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1514    }
1515
1516    impl StackFrame {
1517        pub fn new() -> Self {
1518            std::default::Default::default()
1519        }
1520
1521        /// Sets the value of [function_name][crate::model::stack_trace::StackFrame::function_name].
1522        pub fn set_function_name<T>(mut self, v: T) -> Self
1523        where
1524            T: std::convert::Into<crate::model::TruncatableString>,
1525        {
1526            self.function_name = std::option::Option::Some(v.into());
1527            self
1528        }
1529
1530        /// Sets or clears the value of [function_name][crate::model::stack_trace::StackFrame::function_name].
1531        pub fn set_or_clear_function_name<T>(mut self, v: std::option::Option<T>) -> Self
1532        where
1533            T: std::convert::Into<crate::model::TruncatableString>,
1534        {
1535            self.function_name = v.map(|x| x.into());
1536            self
1537        }
1538
1539        /// Sets the value of [original_function_name][crate::model::stack_trace::StackFrame::original_function_name].
1540        pub fn set_original_function_name<T>(mut self, v: T) -> Self
1541        where
1542            T: std::convert::Into<crate::model::TruncatableString>,
1543        {
1544            self.original_function_name = std::option::Option::Some(v.into());
1545            self
1546        }
1547
1548        /// Sets or clears the value of [original_function_name][crate::model::stack_trace::StackFrame::original_function_name].
1549        pub fn set_or_clear_original_function_name<T>(mut self, v: std::option::Option<T>) -> Self
1550        where
1551            T: std::convert::Into<crate::model::TruncatableString>,
1552        {
1553            self.original_function_name = v.map(|x| x.into());
1554            self
1555        }
1556
1557        /// Sets the value of [file_name][crate::model::stack_trace::StackFrame::file_name].
1558        pub fn set_file_name<T>(mut self, v: T) -> Self
1559        where
1560            T: std::convert::Into<crate::model::TruncatableString>,
1561        {
1562            self.file_name = std::option::Option::Some(v.into());
1563            self
1564        }
1565
1566        /// Sets or clears the value of [file_name][crate::model::stack_trace::StackFrame::file_name].
1567        pub fn set_or_clear_file_name<T>(mut self, v: std::option::Option<T>) -> Self
1568        where
1569            T: std::convert::Into<crate::model::TruncatableString>,
1570        {
1571            self.file_name = v.map(|x| x.into());
1572            self
1573        }
1574
1575        /// Sets the value of [line_number][crate::model::stack_trace::StackFrame::line_number].
1576        pub fn set_line_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1577            self.line_number = v.into();
1578            self
1579        }
1580
1581        /// Sets the value of [column_number][crate::model::stack_trace::StackFrame::column_number].
1582        pub fn set_column_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1583            self.column_number = v.into();
1584            self
1585        }
1586
1587        /// Sets the value of [load_module][crate::model::stack_trace::StackFrame::load_module].
1588        pub fn set_load_module<T>(mut self, v: T) -> Self
1589        where
1590            T: std::convert::Into<crate::model::Module>,
1591        {
1592            self.load_module = std::option::Option::Some(v.into());
1593            self
1594        }
1595
1596        /// Sets or clears the value of [load_module][crate::model::stack_trace::StackFrame::load_module].
1597        pub fn set_or_clear_load_module<T>(mut self, v: std::option::Option<T>) -> Self
1598        where
1599            T: std::convert::Into<crate::model::Module>,
1600        {
1601            self.load_module = v.map(|x| x.into());
1602            self
1603        }
1604
1605        /// Sets the value of [source_version][crate::model::stack_trace::StackFrame::source_version].
1606        pub fn set_source_version<T>(mut self, v: T) -> Self
1607        where
1608            T: std::convert::Into<crate::model::TruncatableString>,
1609        {
1610            self.source_version = std::option::Option::Some(v.into());
1611            self
1612        }
1613
1614        /// Sets or clears the value of [source_version][crate::model::stack_trace::StackFrame::source_version].
1615        pub fn set_or_clear_source_version<T>(mut self, v: std::option::Option<T>) -> Self
1616        where
1617            T: std::convert::Into<crate::model::TruncatableString>,
1618        {
1619            self.source_version = v.map(|x| x.into());
1620            self
1621        }
1622    }
1623
1624    impl wkt::message::Message for StackFrame {
1625        fn typename() -> &'static str {
1626            "type.googleapis.com/google.devtools.cloudtrace.v2.StackTrace.StackFrame"
1627        }
1628    }
1629
1630    /// A collection of stack frames, which can be truncated.
1631    #[derive(Clone, Default, PartialEq)]
1632    #[non_exhaustive]
1633    pub struct StackFrames {
1634        /// Stack frames in this call stack.
1635        pub frame: std::vec::Vec<crate::model::stack_trace::StackFrame>,
1636
1637        /// The number of stack frames that were dropped because there
1638        /// were too many stack frames.
1639        /// If this value is 0, then no stack frames were dropped.
1640        pub dropped_frames_count: i32,
1641
1642        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1643    }
1644
1645    impl StackFrames {
1646        pub fn new() -> Self {
1647            std::default::Default::default()
1648        }
1649
1650        /// Sets the value of [frame][crate::model::stack_trace::StackFrames::frame].
1651        pub fn set_frame<T, V>(mut self, v: T) -> Self
1652        where
1653            T: std::iter::IntoIterator<Item = V>,
1654            V: std::convert::Into<crate::model::stack_trace::StackFrame>,
1655        {
1656            use std::iter::Iterator;
1657            self.frame = v.into_iter().map(|i| i.into()).collect();
1658            self
1659        }
1660
1661        /// Sets the value of [dropped_frames_count][crate::model::stack_trace::StackFrames::dropped_frames_count].
1662        pub fn set_dropped_frames_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1663            self.dropped_frames_count = v.into();
1664            self
1665        }
1666    }
1667
1668    impl wkt::message::Message for StackFrames {
1669        fn typename() -> &'static str {
1670            "type.googleapis.com/google.devtools.cloudtrace.v2.StackTrace.StackFrames"
1671        }
1672    }
1673}
1674
1675/// Binary module.
1676#[derive(Clone, Default, PartialEq)]
1677#[non_exhaustive]
1678pub struct Module {
1679    /// For example: main binary, kernel modules, and dynamic libraries
1680    /// such as libc.so, sharedlib.so (up to 256 bytes).
1681    pub module: std::option::Option<crate::model::TruncatableString>,
1682
1683    /// A unique identifier for the module, usually a hash of its
1684    /// contents (up to 128 bytes).
1685    pub build_id: std::option::Option<crate::model::TruncatableString>,
1686
1687    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1688}
1689
1690impl Module {
1691    pub fn new() -> Self {
1692        std::default::Default::default()
1693    }
1694
1695    /// Sets the value of [module][crate::model::Module::module].
1696    pub fn set_module<T>(mut self, v: T) -> Self
1697    where
1698        T: std::convert::Into<crate::model::TruncatableString>,
1699    {
1700        self.module = std::option::Option::Some(v.into());
1701        self
1702    }
1703
1704    /// Sets or clears the value of [module][crate::model::Module::module].
1705    pub fn set_or_clear_module<T>(mut self, v: std::option::Option<T>) -> Self
1706    where
1707        T: std::convert::Into<crate::model::TruncatableString>,
1708    {
1709        self.module = v.map(|x| x.into());
1710        self
1711    }
1712
1713    /// Sets the value of [build_id][crate::model::Module::build_id].
1714    pub fn set_build_id<T>(mut self, v: T) -> Self
1715    where
1716        T: std::convert::Into<crate::model::TruncatableString>,
1717    {
1718        self.build_id = std::option::Option::Some(v.into());
1719        self
1720    }
1721
1722    /// Sets or clears the value of [build_id][crate::model::Module::build_id].
1723    pub fn set_or_clear_build_id<T>(mut self, v: std::option::Option<T>) -> Self
1724    where
1725        T: std::convert::Into<crate::model::TruncatableString>,
1726    {
1727        self.build_id = v.map(|x| x.into());
1728        self
1729    }
1730}
1731
1732impl wkt::message::Message for Module {
1733    fn typename() -> &'static str {
1734        "type.googleapis.com/google.devtools.cloudtrace.v2.Module"
1735    }
1736}
1737
1738/// Represents a string that might be shortened to a specified length.
1739#[derive(Clone, Default, PartialEq)]
1740#[non_exhaustive]
1741pub struct TruncatableString {
1742    /// The shortened string. For example, if the original string is 500
1743    /// bytes long and the limit of the string is 128 bytes, then
1744    /// `value` contains the first 128 bytes of the 500-byte string.
1745    ///
1746    /// Truncation always happens on a UTF8 character boundary. If there
1747    /// are multi-byte characters in the string, then the length of the
1748    /// shortened string might be less than the size limit.
1749    pub value: std::string::String,
1750
1751    /// The number of bytes removed from the original string. If this
1752    /// value is 0, then the string was not shortened.
1753    pub truncated_byte_count: i32,
1754
1755    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1756}
1757
1758impl TruncatableString {
1759    pub fn new() -> Self {
1760        std::default::Default::default()
1761    }
1762
1763    /// Sets the value of [value][crate::model::TruncatableString::value].
1764    pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1765        self.value = v.into();
1766        self
1767    }
1768
1769    /// Sets the value of [truncated_byte_count][crate::model::TruncatableString::truncated_byte_count].
1770    pub fn set_truncated_byte_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1771        self.truncated_byte_count = v.into();
1772        self
1773    }
1774}
1775
1776impl wkt::message::Message for TruncatableString {
1777    fn typename() -> &'static str {
1778        "type.googleapis.com/google.devtools.cloudtrace.v2.TruncatableString"
1779    }
1780}
1781
1782/// The request message for the `BatchWriteSpans` method.
1783#[derive(Clone, Default, PartialEq)]
1784#[non_exhaustive]
1785pub struct BatchWriteSpansRequest {
1786    /// Required. The name of the project where the spans belong. The format is
1787    /// `projects/[PROJECT_ID]`.
1788    pub name: std::string::String,
1789
1790    /// Required. A list of new spans. The span names must not match existing
1791    /// spans, otherwise the results are undefined.
1792    pub spans: std::vec::Vec<crate::model::Span>,
1793
1794    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1795}
1796
1797impl BatchWriteSpansRequest {
1798    pub fn new() -> Self {
1799        std::default::Default::default()
1800    }
1801
1802    /// Sets the value of [name][crate::model::BatchWriteSpansRequest::name].
1803    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1804        self.name = v.into();
1805        self
1806    }
1807
1808    /// Sets the value of [spans][crate::model::BatchWriteSpansRequest::spans].
1809    pub fn set_spans<T, V>(mut self, v: T) -> Self
1810    where
1811        T: std::iter::IntoIterator<Item = V>,
1812        V: std::convert::Into<crate::model::Span>,
1813    {
1814        use std::iter::Iterator;
1815        self.spans = v.into_iter().map(|i| i.into()).collect();
1816        self
1817    }
1818}
1819
1820impl wkt::message::Message for BatchWriteSpansRequest {
1821    fn typename() -> &'static str {
1822        "type.googleapis.com/google.devtools.cloudtrace.v2.BatchWriteSpansRequest"
1823    }
1824}