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