google_cloud_spanner/generated/gapic_dataplane/model.rs
1// Copyright 2026 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
22mod debug;
23mod deserialize;
24mod serialize;
25
26/// Spanner Change Streams enable customers to capture and stream out changes to
27/// their Spanner databases in real-time. A change stream
28/// can be created with option partition_mode='IMMUTABLE_KEY_RANGE' or
29/// partition_mode='MUTABLE_KEY_RANGE'.
30///
31/// This message is only used in Change Streams created with the option
32/// partition_mode='MUTABLE_KEY_RANGE'. Spanner automatically creates a special
33/// Table-Valued Function (TVF) along with each Change Streams. The function
34/// provides access to the change stream's records. The function is named
35/// READ_<change_stream_name> (where <change_stream_name> is the
36/// name of the change stream), and it returns a table with only one column
37/// called ChangeRecord.
38#[derive(Clone, Default, PartialEq)]
39#[non_exhaustive]
40pub struct ChangeStreamRecord {
41 /// One of the change stream subrecords.
42 pub record: std::option::Option<crate::model::change_stream_record::Record>,
43
44 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
45}
46
47impl ChangeStreamRecord {
48 /// Creates a new default instance.
49 pub fn new() -> Self {
50 std::default::Default::default()
51 }
52
53 /// Sets the value of [record][crate::model::ChangeStreamRecord::record].
54 ///
55 /// Note that all the setters affecting `record` are mutually
56 /// exclusive.
57 pub fn set_record<
58 T: std::convert::Into<std::option::Option<crate::model::change_stream_record::Record>>,
59 >(
60 mut self,
61 v: T,
62 ) -> Self {
63 self.record = v.into();
64 self
65 }
66
67 /// The value of [record][crate::model::ChangeStreamRecord::record]
68 /// if it holds a `DataChangeRecord`, `None` if the field is not set or
69 /// holds a different branch.
70 pub fn data_change_record(
71 &self,
72 ) -> std::option::Option<&std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>>
73 {
74 #[allow(unreachable_patterns)]
75 self.record.as_ref().and_then(|v| match v {
76 crate::model::change_stream_record::Record::DataChangeRecord(v) => {
77 std::option::Option::Some(v)
78 }
79 _ => std::option::Option::None,
80 })
81 }
82
83 /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
84 /// to hold a `DataChangeRecord`.
85 ///
86 /// Note that all the setters affecting `record` are
87 /// mutually exclusive.
88 pub fn set_data_change_record<
89 T: std::convert::Into<std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>>,
90 >(
91 mut self,
92 v: T,
93 ) -> Self {
94 self.record = std::option::Option::Some(
95 crate::model::change_stream_record::Record::DataChangeRecord(v.into()),
96 );
97 self
98 }
99
100 /// The value of [record][crate::model::ChangeStreamRecord::record]
101 /// if it holds a `HeartbeatRecord`, `None` if the field is not set or
102 /// holds a different branch.
103 pub fn heartbeat_record(
104 &self,
105 ) -> std::option::Option<&std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>>
106 {
107 #[allow(unreachable_patterns)]
108 self.record.as_ref().and_then(|v| match v {
109 crate::model::change_stream_record::Record::HeartbeatRecord(v) => {
110 std::option::Option::Some(v)
111 }
112 _ => std::option::Option::None,
113 })
114 }
115
116 /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
117 /// to hold a `HeartbeatRecord`.
118 ///
119 /// Note that all the setters affecting `record` are
120 /// mutually exclusive.
121 pub fn set_heartbeat_record<
122 T: std::convert::Into<std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>>,
123 >(
124 mut self,
125 v: T,
126 ) -> Self {
127 self.record = std::option::Option::Some(
128 crate::model::change_stream_record::Record::HeartbeatRecord(v.into()),
129 );
130 self
131 }
132
133 /// The value of [record][crate::model::ChangeStreamRecord::record]
134 /// if it holds a `PartitionStartRecord`, `None` if the field is not set or
135 /// holds a different branch.
136 pub fn partition_start_record(
137 &self,
138 ) -> std::option::Option<
139 &std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
140 > {
141 #[allow(unreachable_patterns)]
142 self.record.as_ref().and_then(|v| match v {
143 crate::model::change_stream_record::Record::PartitionStartRecord(v) => {
144 std::option::Option::Some(v)
145 }
146 _ => std::option::Option::None,
147 })
148 }
149
150 /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
151 /// to hold a `PartitionStartRecord`.
152 ///
153 /// Note that all the setters affecting `record` are
154 /// mutually exclusive.
155 pub fn set_partition_start_record<
156 T: std::convert::Into<
157 std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
158 >,
159 >(
160 mut self,
161 v: T,
162 ) -> Self {
163 self.record = std::option::Option::Some(
164 crate::model::change_stream_record::Record::PartitionStartRecord(v.into()),
165 );
166 self
167 }
168
169 /// The value of [record][crate::model::ChangeStreamRecord::record]
170 /// if it holds a `PartitionEndRecord`, `None` if the field is not set or
171 /// holds a different branch.
172 pub fn partition_end_record(
173 &self,
174 ) -> std::option::Option<&std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>>
175 {
176 #[allow(unreachable_patterns)]
177 self.record.as_ref().and_then(|v| match v {
178 crate::model::change_stream_record::Record::PartitionEndRecord(v) => {
179 std::option::Option::Some(v)
180 }
181 _ => std::option::Option::None,
182 })
183 }
184
185 /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
186 /// to hold a `PartitionEndRecord`.
187 ///
188 /// Note that all the setters affecting `record` are
189 /// mutually exclusive.
190 pub fn set_partition_end_record<
191 T: std::convert::Into<std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>>,
192 >(
193 mut self,
194 v: T,
195 ) -> Self {
196 self.record = std::option::Option::Some(
197 crate::model::change_stream_record::Record::PartitionEndRecord(v.into()),
198 );
199 self
200 }
201
202 /// The value of [record][crate::model::ChangeStreamRecord::record]
203 /// if it holds a `PartitionEventRecord`, `None` if the field is not set or
204 /// holds a different branch.
205 pub fn partition_event_record(
206 &self,
207 ) -> std::option::Option<
208 &std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
209 > {
210 #[allow(unreachable_patterns)]
211 self.record.as_ref().and_then(|v| match v {
212 crate::model::change_stream_record::Record::PartitionEventRecord(v) => {
213 std::option::Option::Some(v)
214 }
215 _ => std::option::Option::None,
216 })
217 }
218
219 /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
220 /// to hold a `PartitionEventRecord`.
221 ///
222 /// Note that all the setters affecting `record` are
223 /// mutually exclusive.
224 pub fn set_partition_event_record<
225 T: std::convert::Into<
226 std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
227 >,
228 >(
229 mut self,
230 v: T,
231 ) -> Self {
232 self.record = std::option::Option::Some(
233 crate::model::change_stream_record::Record::PartitionEventRecord(v.into()),
234 );
235 self
236 }
237}
238
239impl wkt::message::Message for ChangeStreamRecord {
240 fn typename() -> &'static str {
241 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord"
242 }
243}
244
245/// Defines additional types related to [ChangeStreamRecord].
246pub mod change_stream_record {
247 #[allow(unused_imports)]
248 use super::*;
249
250 /// A data change record contains a set of changes to a table with the same
251 /// modification type (insert, update, or delete) committed at the same commit
252 /// timestamp in one change stream partition for the same transaction. Multiple
253 /// data change records can be returned for the same transaction across
254 /// multiple change stream partitions.
255 #[derive(Clone, Default, PartialEq)]
256 #[non_exhaustive]
257 pub struct DataChangeRecord {
258 /// Indicates the timestamp in which the change was committed.
259 /// DataChangeRecord.commit_timestamps,
260 /// PartitionStartRecord.start_timestamps,
261 /// PartitionEventRecord.commit_timestamps, and
262 /// PartitionEndRecord.end_timestamps can have the same value in the same
263 /// partition.
264 pub commit_timestamp: std::option::Option<wkt::Timestamp>,
265
266 /// Record sequence numbers are unique and monotonically increasing (but not
267 /// necessarily contiguous) for a specific timestamp across record
268 /// types in the same partition. To guarantee ordered processing, the reader
269 /// should process records (of potentially different types) in
270 /// record_sequence order for a specific timestamp in the same partition.
271 ///
272 /// The record sequence number ordering across partitions is only meaningful
273 /// in the context of a specific transaction. Record sequence numbers are
274 /// unique across partitions for a specific transaction. Sort the
275 /// DataChangeRecords for the same
276 /// [server_transaction_id][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.server_transaction_id]
277 /// by
278 /// [record_sequence][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.record_sequence]
279 /// to reconstruct the ordering of the changes within the transaction.
280 ///
281 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.record_sequence]: crate::model::change_stream_record::DataChangeRecord::record_sequence
282 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.server_transaction_id]: crate::model::change_stream_record::DataChangeRecord::server_transaction_id
283 pub record_sequence: std::string::String,
284
285 /// Provides a globally unique string that represents the transaction in
286 /// which the change was committed. Multiple transactions can have the same
287 /// commit timestamp, but each transaction has a unique
288 /// server_transaction_id.
289 pub server_transaction_id: std::string::String,
290
291 /// Indicates whether this is the last record for a transaction in the
292 /// current partition. Clients can use this field to determine when all
293 /// records for a transaction in the current partition have been received.
294 pub is_last_record_in_transaction_in_partition: bool,
295
296 /// Name of the table affected by the change.
297 pub table: std::string::String,
298
299 /// Provides metadata describing the columns associated with the
300 /// [mods][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.mods] listed
301 /// below.
302 ///
303 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.mods]: crate::model::change_stream_record::DataChangeRecord::mods
304 pub column_metadata:
305 std::vec::Vec<crate::model::change_stream_record::data_change_record::ColumnMetadata>,
306
307 /// Describes the changes that were made.
308 pub mods: std::vec::Vec<crate::model::change_stream_record::data_change_record::Mod>,
309
310 /// Describes the type of change.
311 pub mod_type: crate::model::change_stream_record::data_change_record::ModType,
312
313 /// Describes the value capture type that was specified in the change stream
314 /// configuration when this change was captured.
315 pub value_capture_type:
316 crate::model::change_stream_record::data_change_record::ValueCaptureType,
317
318 /// Indicates the number of data change records that are part of this
319 /// transaction across all change stream partitions. This value can be used
320 /// to assemble all the records associated with a particular transaction.
321 pub number_of_records_in_transaction: i32,
322
323 /// Indicates the number of partitions that return data change records for
324 /// this transaction. This value can be helpful in assembling all records
325 /// associated with a particular transaction.
326 pub number_of_partitions_in_transaction: i32,
327
328 /// Indicates the transaction tag associated with this transaction.
329 pub transaction_tag: std::string::String,
330
331 /// Indicates whether the transaction is a system transaction. System
332 /// transactions include those issued by time-to-live (TTL), column backfill,
333 /// etc.
334 pub is_system_transaction: bool,
335
336 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
337 }
338
339 impl DataChangeRecord {
340 /// Creates a new default instance.
341 pub fn new() -> Self {
342 std::default::Default::default()
343 }
344
345 /// Sets the value of [commit_timestamp][crate::model::change_stream_record::DataChangeRecord::commit_timestamp].
346 pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
347 where
348 T: std::convert::Into<wkt::Timestamp>,
349 {
350 self.commit_timestamp = std::option::Option::Some(v.into());
351 self
352 }
353
354 /// Sets or clears the value of [commit_timestamp][crate::model::change_stream_record::DataChangeRecord::commit_timestamp].
355 pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
356 where
357 T: std::convert::Into<wkt::Timestamp>,
358 {
359 self.commit_timestamp = v.map(|x| x.into());
360 self
361 }
362
363 /// Sets the value of [record_sequence][crate::model::change_stream_record::DataChangeRecord::record_sequence].
364 pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
365 mut self,
366 v: T,
367 ) -> Self {
368 self.record_sequence = v.into();
369 self
370 }
371
372 /// Sets the value of [server_transaction_id][crate::model::change_stream_record::DataChangeRecord::server_transaction_id].
373 pub fn set_server_transaction_id<T: std::convert::Into<std::string::String>>(
374 mut self,
375 v: T,
376 ) -> Self {
377 self.server_transaction_id = v.into();
378 self
379 }
380
381 /// Sets the value of [is_last_record_in_transaction_in_partition][crate::model::change_stream_record::DataChangeRecord::is_last_record_in_transaction_in_partition].
382 pub fn set_is_last_record_in_transaction_in_partition<T: std::convert::Into<bool>>(
383 mut self,
384 v: T,
385 ) -> Self {
386 self.is_last_record_in_transaction_in_partition = v.into();
387 self
388 }
389
390 /// Sets the value of [table][crate::model::change_stream_record::DataChangeRecord::table].
391 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
392 self.table = v.into();
393 self
394 }
395
396 /// Sets the value of [column_metadata][crate::model::change_stream_record::DataChangeRecord::column_metadata].
397 pub fn set_column_metadata<T, V>(mut self, v: T) -> Self
398 where
399 T: std::iter::IntoIterator<Item = V>,
400 V: std::convert::Into<
401 crate::model::change_stream_record::data_change_record::ColumnMetadata,
402 >,
403 {
404 use std::iter::Iterator;
405 self.column_metadata = v.into_iter().map(|i| i.into()).collect();
406 self
407 }
408
409 /// Sets the value of [mods][crate::model::change_stream_record::DataChangeRecord::mods].
410 pub fn set_mods<T, V>(mut self, v: T) -> Self
411 where
412 T: std::iter::IntoIterator<Item = V>,
413 V: std::convert::Into<crate::model::change_stream_record::data_change_record::Mod>,
414 {
415 use std::iter::Iterator;
416 self.mods = v.into_iter().map(|i| i.into()).collect();
417 self
418 }
419
420 /// Sets the value of [mod_type][crate::model::change_stream_record::DataChangeRecord::mod_type].
421 pub fn set_mod_type<
422 T: std::convert::Into<crate::model::change_stream_record::data_change_record::ModType>,
423 >(
424 mut self,
425 v: T,
426 ) -> Self {
427 self.mod_type = v.into();
428 self
429 }
430
431 /// Sets the value of [value_capture_type][crate::model::change_stream_record::DataChangeRecord::value_capture_type].
432 pub fn set_value_capture_type<
433 T: std::convert::Into<
434 crate::model::change_stream_record::data_change_record::ValueCaptureType,
435 >,
436 >(
437 mut self,
438 v: T,
439 ) -> Self {
440 self.value_capture_type = v.into();
441 self
442 }
443
444 /// Sets the value of [number_of_records_in_transaction][crate::model::change_stream_record::DataChangeRecord::number_of_records_in_transaction].
445 pub fn set_number_of_records_in_transaction<T: std::convert::Into<i32>>(
446 mut self,
447 v: T,
448 ) -> Self {
449 self.number_of_records_in_transaction = v.into();
450 self
451 }
452
453 /// Sets the value of [number_of_partitions_in_transaction][crate::model::change_stream_record::DataChangeRecord::number_of_partitions_in_transaction].
454 pub fn set_number_of_partitions_in_transaction<T: std::convert::Into<i32>>(
455 mut self,
456 v: T,
457 ) -> Self {
458 self.number_of_partitions_in_transaction = v.into();
459 self
460 }
461
462 /// Sets the value of [transaction_tag][crate::model::change_stream_record::DataChangeRecord::transaction_tag].
463 pub fn set_transaction_tag<T: std::convert::Into<std::string::String>>(
464 mut self,
465 v: T,
466 ) -> Self {
467 self.transaction_tag = v.into();
468 self
469 }
470
471 /// Sets the value of [is_system_transaction][crate::model::change_stream_record::DataChangeRecord::is_system_transaction].
472 pub fn set_is_system_transaction<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
473 self.is_system_transaction = v.into();
474 self
475 }
476 }
477
478 impl wkt::message::Message for DataChangeRecord {
479 fn typename() -> &'static str {
480 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord"
481 }
482 }
483
484 /// Defines additional types related to [DataChangeRecord].
485 pub mod data_change_record {
486 #[allow(unused_imports)]
487 use super::*;
488
489 /// Metadata for a column.
490 #[derive(Clone, Default, PartialEq)]
491 #[non_exhaustive]
492 pub struct ColumnMetadata {
493 /// Name of the column.
494 pub name: std::string::String,
495
496 /// Type of the column.
497 pub r#type: std::option::Option<crate::model::Type>,
498
499 /// Indicates whether the column is a primary key column.
500 pub is_primary_key: bool,
501
502 /// Ordinal position of the column based on the original table definition
503 /// in the schema starting with a value of 1.
504 pub ordinal_position: i64,
505
506 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
507 }
508
509 impl ColumnMetadata {
510 /// Creates a new default instance.
511 pub fn new() -> Self {
512 std::default::Default::default()
513 }
514
515 /// Sets the value of [name][crate::model::change_stream_record::data_change_record::ColumnMetadata::name].
516 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
517 self.name = v.into();
518 self
519 }
520
521 /// Sets the value of [r#type][crate::model::change_stream_record::data_change_record::ColumnMetadata::type].
522 pub fn set_type<T>(mut self, v: T) -> Self
523 where
524 T: std::convert::Into<crate::model::Type>,
525 {
526 self.r#type = std::option::Option::Some(v.into());
527 self
528 }
529
530 /// Sets or clears the value of [r#type][crate::model::change_stream_record::data_change_record::ColumnMetadata::type].
531 pub fn set_or_clear_type<T>(mut self, v: std::option::Option<T>) -> Self
532 where
533 T: std::convert::Into<crate::model::Type>,
534 {
535 self.r#type = v.map(|x| x.into());
536 self
537 }
538
539 /// Sets the value of [is_primary_key][crate::model::change_stream_record::data_change_record::ColumnMetadata::is_primary_key].
540 pub fn set_is_primary_key<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
541 self.is_primary_key = v.into();
542 self
543 }
544
545 /// Sets the value of [ordinal_position][crate::model::change_stream_record::data_change_record::ColumnMetadata::ordinal_position].
546 pub fn set_ordinal_position<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
547 self.ordinal_position = v.into();
548 self
549 }
550 }
551
552 impl wkt::message::Message for ColumnMetadata {
553 fn typename() -> &'static str {
554 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ColumnMetadata"
555 }
556 }
557
558 /// Returns the value and associated metadata for a particular field of the
559 /// [Mod][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.Mod].
560 ///
561 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.Mod]: crate::model::change_stream_record::data_change_record::Mod
562 #[derive(Clone, Default, PartialEq)]
563 #[non_exhaustive]
564 pub struct ModValue {
565 /// Index within the repeated
566 /// [column_metadata][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.column_metadata]
567 /// field, to obtain the column metadata for the column that was modified.
568 ///
569 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.column_metadata]: crate::model::change_stream_record::DataChangeRecord::column_metadata
570 pub column_metadata_index: i32,
571
572 /// The value of the column.
573 pub value: std::option::Option<wkt::Value>,
574
575 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
576 }
577
578 impl ModValue {
579 /// Creates a new default instance.
580 pub fn new() -> Self {
581 std::default::Default::default()
582 }
583
584 /// Sets the value of [column_metadata_index][crate::model::change_stream_record::data_change_record::ModValue::column_metadata_index].
585 pub fn set_column_metadata_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
586 self.column_metadata_index = v.into();
587 self
588 }
589
590 /// Sets the value of [value][crate::model::change_stream_record::data_change_record::ModValue::value].
591 pub fn set_value<T>(mut self, v: T) -> Self
592 where
593 T: std::convert::Into<wkt::Value>,
594 {
595 self.value = std::option::Option::Some(v.into());
596 self
597 }
598
599 /// Sets or clears the value of [value][crate::model::change_stream_record::data_change_record::ModValue::value].
600 pub fn set_or_clear_value<T>(mut self, v: std::option::Option<T>) -> Self
601 where
602 T: std::convert::Into<wkt::Value>,
603 {
604 self.value = v.map(|x| x.into());
605 self
606 }
607 }
608
609 impl wkt::message::Message for ModValue {
610 fn typename() -> &'static str {
611 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModValue"
612 }
613 }
614
615 /// A mod describes all data changes in a watched table row.
616 #[derive(Clone, Default, PartialEq)]
617 #[non_exhaustive]
618 pub struct Mod {
619 /// Returns the value of the primary key of the modified row.
620 pub keys:
621 std::vec::Vec<crate::model::change_stream_record::data_change_record::ModValue>,
622
623 /// Returns the old values before the change for the modified columns.
624 /// Always empty for
625 /// [INSERT][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.INSERT],
626 /// or if old values are not being captured specified by
627 /// [value_capture_type][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ValueCaptureType].
628 ///
629 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.INSERT]: crate::model::change_stream_record::data_change_record::ModType::Insert
630 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ValueCaptureType]: crate::model::change_stream_record::data_change_record::ValueCaptureType
631 pub old_values:
632 std::vec::Vec<crate::model::change_stream_record::data_change_record::ModValue>,
633
634 /// Returns the new values after the change for the modified columns.
635 /// Always empty for
636 /// [DELETE][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.DELETE].
637 ///
638 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.DELETE]: crate::model::change_stream_record::data_change_record::ModType::Delete
639 pub new_values:
640 std::vec::Vec<crate::model::change_stream_record::data_change_record::ModValue>,
641
642 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
643 }
644
645 impl Mod {
646 /// Creates a new default instance.
647 pub fn new() -> Self {
648 std::default::Default::default()
649 }
650
651 /// Sets the value of [keys][crate::model::change_stream_record::data_change_record::Mod::keys].
652 pub fn set_keys<T, V>(mut self, v: T) -> Self
653 where
654 T: std::iter::IntoIterator<Item = V>,
655 V: std::convert::Into<
656 crate::model::change_stream_record::data_change_record::ModValue,
657 >,
658 {
659 use std::iter::Iterator;
660 self.keys = v.into_iter().map(|i| i.into()).collect();
661 self
662 }
663
664 /// Sets the value of [old_values][crate::model::change_stream_record::data_change_record::Mod::old_values].
665 pub fn set_old_values<T, V>(mut self, v: T) -> Self
666 where
667 T: std::iter::IntoIterator<Item = V>,
668 V: std::convert::Into<
669 crate::model::change_stream_record::data_change_record::ModValue,
670 >,
671 {
672 use std::iter::Iterator;
673 self.old_values = v.into_iter().map(|i| i.into()).collect();
674 self
675 }
676
677 /// Sets the value of [new_values][crate::model::change_stream_record::data_change_record::Mod::new_values].
678 pub fn set_new_values<T, V>(mut self, v: T) -> Self
679 where
680 T: std::iter::IntoIterator<Item = V>,
681 V: std::convert::Into<
682 crate::model::change_stream_record::data_change_record::ModValue,
683 >,
684 {
685 use std::iter::Iterator;
686 self.new_values = v.into_iter().map(|i| i.into()).collect();
687 self
688 }
689 }
690
691 impl wkt::message::Message for Mod {
692 fn typename() -> &'static str {
693 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord.Mod"
694 }
695 }
696
697 /// Mod type describes the type of change Spanner applied to the data. For
698 /// example, if the client submits an INSERT_OR_UPDATE request, Spanner will
699 /// perform an insert if there is no existing row and return ModType INSERT.
700 /// Alternatively, if there is an existing row, Spanner will perform an
701 /// update and return ModType UPDATE.
702 ///
703 /// # Working with unknown values
704 ///
705 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
706 /// additional enum variants at any time. Adding new variants is not considered
707 /// a breaking change. Applications should write their code in anticipation of:
708 ///
709 /// - New values appearing in future releases of the client library, **and**
710 /// - New values received dynamically, without application changes.
711 ///
712 /// Please consult the [Working with enums] section in the user guide for some
713 /// guidelines.
714 ///
715 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
716 #[derive(Clone, Debug, PartialEq)]
717 #[non_exhaustive]
718 pub enum ModType {
719 /// Not specified.
720 Unspecified,
721 /// Indicates data was inserted.
722 Insert,
723 /// Indicates existing data was updated.
724 Update,
725 /// Indicates existing data was deleted.
726 Delete,
727 /// If set, the enum was initialized with an unknown value.
728 ///
729 /// Applications can examine the value using [ModType::value] or
730 /// [ModType::name].
731 UnknownValue(mod_type::UnknownValue),
732 }
733
734 #[doc(hidden)]
735 pub mod mod_type {
736 #[allow(unused_imports)]
737 use super::*;
738 #[derive(Clone, Debug, PartialEq)]
739 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
740 }
741
742 impl ModType {
743 /// Gets the enum value.
744 ///
745 /// Returns `None` if the enum contains an unknown value deserialized from
746 /// the string representation of enums.
747 pub fn value(&self) -> std::option::Option<i32> {
748 match self {
749 Self::Unspecified => std::option::Option::Some(0),
750 Self::Insert => std::option::Option::Some(10),
751 Self::Update => std::option::Option::Some(20),
752 Self::Delete => std::option::Option::Some(30),
753 Self::UnknownValue(u) => u.0.value(),
754 }
755 }
756
757 /// Gets the enum value as a string.
758 ///
759 /// Returns `None` if the enum contains an unknown value deserialized from
760 /// the integer representation of enums.
761 pub fn name(&self) -> std::option::Option<&str> {
762 match self {
763 Self::Unspecified => std::option::Option::Some("MOD_TYPE_UNSPECIFIED"),
764 Self::Insert => std::option::Option::Some("INSERT"),
765 Self::Update => std::option::Option::Some("UPDATE"),
766 Self::Delete => std::option::Option::Some("DELETE"),
767 Self::UnknownValue(u) => u.0.name(),
768 }
769 }
770 }
771
772 impl std::default::Default for ModType {
773 fn default() -> Self {
774 use std::convert::From;
775 Self::from(0)
776 }
777 }
778
779 impl std::fmt::Display for ModType {
780 fn fmt(
781 &self,
782 f: &mut std::fmt::Formatter<'_>,
783 ) -> std::result::Result<(), std::fmt::Error> {
784 wkt::internal::display_enum(f, self.name(), self.value())
785 }
786 }
787
788 impl std::convert::From<i32> for ModType {
789 fn from(value: i32) -> Self {
790 match value {
791 0 => Self::Unspecified,
792 10 => Self::Insert,
793 20 => Self::Update,
794 30 => Self::Delete,
795 _ => Self::UnknownValue(mod_type::UnknownValue(
796 wkt::internal::UnknownEnumValue::Integer(value),
797 )),
798 }
799 }
800 }
801
802 impl std::convert::From<&str> for ModType {
803 fn from(value: &str) -> Self {
804 use std::string::ToString;
805 match value {
806 "MOD_TYPE_UNSPECIFIED" => Self::Unspecified,
807 "INSERT" => Self::Insert,
808 "UPDATE" => Self::Update,
809 "DELETE" => Self::Delete,
810 _ => Self::UnknownValue(mod_type::UnknownValue(
811 wkt::internal::UnknownEnumValue::String(value.to_string()),
812 )),
813 }
814 }
815 }
816
817 impl serde::ser::Serialize for ModType {
818 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
819 where
820 S: serde::Serializer,
821 {
822 match self {
823 Self::Unspecified => serializer.serialize_i32(0),
824 Self::Insert => serializer.serialize_i32(10),
825 Self::Update => serializer.serialize_i32(20),
826 Self::Delete => serializer.serialize_i32(30),
827 Self::UnknownValue(u) => u.0.serialize(serializer),
828 }
829 }
830 }
831
832 impl<'de> serde::de::Deserialize<'de> for ModType {
833 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
834 where
835 D: serde::Deserializer<'de>,
836 {
837 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ModType>::new(
838 ".google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType",
839 ))
840 }
841 }
842
843 /// Value capture type describes which values are recorded in the data
844 /// change record.
845 ///
846 /// # Working with unknown values
847 ///
848 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
849 /// additional enum variants at any time. Adding new variants is not considered
850 /// a breaking change. Applications should write their code in anticipation of:
851 ///
852 /// - New values appearing in future releases of the client library, **and**
853 /// - New values received dynamically, without application changes.
854 ///
855 /// Please consult the [Working with enums] section in the user guide for some
856 /// guidelines.
857 ///
858 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
859 #[derive(Clone, Debug, PartialEq)]
860 #[non_exhaustive]
861 pub enum ValueCaptureType {
862 /// Not specified.
863 Unspecified,
864 /// Records both old and new values of the modified watched columns.
865 OldAndNewValues,
866 /// Records only new values of the modified watched columns.
867 NewValues,
868 /// Records new values of all watched columns, including modified and
869 /// unmodified columns.
870 NewRow,
871 /// Records the new values of all watched columns, including modified and
872 /// unmodified columns. Also records the old values of the modified
873 /// columns.
874 NewRowAndOldValues,
875 /// If set, the enum was initialized with an unknown value.
876 ///
877 /// Applications can examine the value using [ValueCaptureType::value] or
878 /// [ValueCaptureType::name].
879 UnknownValue(value_capture_type::UnknownValue),
880 }
881
882 #[doc(hidden)]
883 pub mod value_capture_type {
884 #[allow(unused_imports)]
885 use super::*;
886 #[derive(Clone, Debug, PartialEq)]
887 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
888 }
889
890 impl ValueCaptureType {
891 /// Gets the enum value.
892 ///
893 /// Returns `None` if the enum contains an unknown value deserialized from
894 /// the string representation of enums.
895 pub fn value(&self) -> std::option::Option<i32> {
896 match self {
897 Self::Unspecified => std::option::Option::Some(0),
898 Self::OldAndNewValues => std::option::Option::Some(10),
899 Self::NewValues => std::option::Option::Some(20),
900 Self::NewRow => std::option::Option::Some(30),
901 Self::NewRowAndOldValues => std::option::Option::Some(40),
902 Self::UnknownValue(u) => u.0.value(),
903 }
904 }
905
906 /// Gets the enum value as a string.
907 ///
908 /// Returns `None` if the enum contains an unknown value deserialized from
909 /// the integer representation of enums.
910 pub fn name(&self) -> std::option::Option<&str> {
911 match self {
912 Self::Unspecified => {
913 std::option::Option::Some("VALUE_CAPTURE_TYPE_UNSPECIFIED")
914 }
915 Self::OldAndNewValues => std::option::Option::Some("OLD_AND_NEW_VALUES"),
916 Self::NewValues => std::option::Option::Some("NEW_VALUES"),
917 Self::NewRow => std::option::Option::Some("NEW_ROW"),
918 Self::NewRowAndOldValues => std::option::Option::Some("NEW_ROW_AND_OLD_VALUES"),
919 Self::UnknownValue(u) => u.0.name(),
920 }
921 }
922 }
923
924 impl std::default::Default for ValueCaptureType {
925 fn default() -> Self {
926 use std::convert::From;
927 Self::from(0)
928 }
929 }
930
931 impl std::fmt::Display for ValueCaptureType {
932 fn fmt(
933 &self,
934 f: &mut std::fmt::Formatter<'_>,
935 ) -> std::result::Result<(), std::fmt::Error> {
936 wkt::internal::display_enum(f, self.name(), self.value())
937 }
938 }
939
940 impl std::convert::From<i32> for ValueCaptureType {
941 fn from(value: i32) -> Self {
942 match value {
943 0 => Self::Unspecified,
944 10 => Self::OldAndNewValues,
945 20 => Self::NewValues,
946 30 => Self::NewRow,
947 40 => Self::NewRowAndOldValues,
948 _ => Self::UnknownValue(value_capture_type::UnknownValue(
949 wkt::internal::UnknownEnumValue::Integer(value),
950 )),
951 }
952 }
953 }
954
955 impl std::convert::From<&str> for ValueCaptureType {
956 fn from(value: &str) -> Self {
957 use std::string::ToString;
958 match value {
959 "VALUE_CAPTURE_TYPE_UNSPECIFIED" => Self::Unspecified,
960 "OLD_AND_NEW_VALUES" => Self::OldAndNewValues,
961 "NEW_VALUES" => Self::NewValues,
962 "NEW_ROW" => Self::NewRow,
963 "NEW_ROW_AND_OLD_VALUES" => Self::NewRowAndOldValues,
964 _ => Self::UnknownValue(value_capture_type::UnknownValue(
965 wkt::internal::UnknownEnumValue::String(value.to_string()),
966 )),
967 }
968 }
969 }
970
971 impl serde::ser::Serialize for ValueCaptureType {
972 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
973 where
974 S: serde::Serializer,
975 {
976 match self {
977 Self::Unspecified => serializer.serialize_i32(0),
978 Self::OldAndNewValues => serializer.serialize_i32(10),
979 Self::NewValues => serializer.serialize_i32(20),
980 Self::NewRow => serializer.serialize_i32(30),
981 Self::NewRowAndOldValues => serializer.serialize_i32(40),
982 Self::UnknownValue(u) => u.0.serialize(serializer),
983 }
984 }
985 }
986
987 impl<'de> serde::de::Deserialize<'de> for ValueCaptureType {
988 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
989 where
990 D: serde::Deserializer<'de>,
991 {
992 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ValueCaptureType>::new(
993 ".google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ValueCaptureType",
994 ))
995 }
996 }
997 }
998
999 /// A heartbeat record is returned as a progress indicator, when there are no
1000 /// data changes or any other partition record types in the change stream
1001 /// partition.
1002 #[derive(Clone, Default, PartialEq)]
1003 #[non_exhaustive]
1004 pub struct HeartbeatRecord {
1005 /// Indicates the timestamp at which the query has returned all the records
1006 /// in the change stream partition with timestamp <= heartbeat timestamp.
1007 /// The heartbeat timestamp will not be the same as the timestamps of other
1008 /// record types in the same partition.
1009 pub timestamp: std::option::Option<wkt::Timestamp>,
1010
1011 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1012 }
1013
1014 impl HeartbeatRecord {
1015 /// Creates a new default instance.
1016 pub fn new() -> Self {
1017 std::default::Default::default()
1018 }
1019
1020 /// Sets the value of [timestamp][crate::model::change_stream_record::HeartbeatRecord::timestamp].
1021 pub fn set_timestamp<T>(mut self, v: T) -> Self
1022 where
1023 T: std::convert::Into<wkt::Timestamp>,
1024 {
1025 self.timestamp = std::option::Option::Some(v.into());
1026 self
1027 }
1028
1029 /// Sets or clears the value of [timestamp][crate::model::change_stream_record::HeartbeatRecord::timestamp].
1030 pub fn set_or_clear_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1031 where
1032 T: std::convert::Into<wkt::Timestamp>,
1033 {
1034 self.timestamp = v.map(|x| x.into());
1035 self
1036 }
1037 }
1038
1039 impl wkt::message::Message for HeartbeatRecord {
1040 fn typename() -> &'static str {
1041 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.HeartbeatRecord"
1042 }
1043 }
1044
1045 /// A partition start record serves as a notification that the client should
1046 /// schedule the partitions to be queried. PartitionStartRecord returns
1047 /// information about one or more partitions.
1048 #[derive(Clone, Default, PartialEq)]
1049 #[non_exhaustive]
1050 pub struct PartitionStartRecord {
1051 /// Start timestamp at which the partitions should be queried to return
1052 /// change stream records with timestamps >= start_timestamp.
1053 /// DataChangeRecord.commit_timestamps,
1054 /// PartitionStartRecord.start_timestamps,
1055 /// PartitionEventRecord.commit_timestamps, and
1056 /// PartitionEndRecord.end_timestamps can have the same value in the same
1057 /// partition.
1058 pub start_timestamp: std::option::Option<wkt::Timestamp>,
1059
1060 /// Record sequence numbers are unique and monotonically increasing (but not
1061 /// necessarily contiguous) for a specific timestamp across record
1062 /// types in the same partition. To guarantee ordered processing, the reader
1063 /// should process records (of potentially different types) in
1064 /// record_sequence order for a specific timestamp in the same partition.
1065 pub record_sequence: std::string::String,
1066
1067 /// Unique partition identifiers to be used in queries.
1068 pub partition_tokens: std::vec::Vec<std::string::String>,
1069
1070 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1071 }
1072
1073 impl PartitionStartRecord {
1074 /// Creates a new default instance.
1075 pub fn new() -> Self {
1076 std::default::Default::default()
1077 }
1078
1079 /// Sets the value of [start_timestamp][crate::model::change_stream_record::PartitionStartRecord::start_timestamp].
1080 pub fn set_start_timestamp<T>(mut self, v: T) -> Self
1081 where
1082 T: std::convert::Into<wkt::Timestamp>,
1083 {
1084 self.start_timestamp = std::option::Option::Some(v.into());
1085 self
1086 }
1087
1088 /// Sets or clears the value of [start_timestamp][crate::model::change_stream_record::PartitionStartRecord::start_timestamp].
1089 pub fn set_or_clear_start_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1090 where
1091 T: std::convert::Into<wkt::Timestamp>,
1092 {
1093 self.start_timestamp = v.map(|x| x.into());
1094 self
1095 }
1096
1097 /// Sets the value of [record_sequence][crate::model::change_stream_record::PartitionStartRecord::record_sequence].
1098 pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
1099 mut self,
1100 v: T,
1101 ) -> Self {
1102 self.record_sequence = v.into();
1103 self
1104 }
1105
1106 /// Sets the value of [partition_tokens][crate::model::change_stream_record::PartitionStartRecord::partition_tokens].
1107 pub fn set_partition_tokens<T, V>(mut self, v: T) -> Self
1108 where
1109 T: std::iter::IntoIterator<Item = V>,
1110 V: std::convert::Into<std::string::String>,
1111 {
1112 use std::iter::Iterator;
1113 self.partition_tokens = v.into_iter().map(|i| i.into()).collect();
1114 self
1115 }
1116 }
1117
1118 impl wkt::message::Message for PartitionStartRecord {
1119 fn typename() -> &'static str {
1120 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionStartRecord"
1121 }
1122 }
1123
1124 /// A partition end record serves as a notification that the client should stop
1125 /// reading the partition. No further records are expected to be retrieved on
1126 /// it.
1127 #[derive(Clone, Default, PartialEq)]
1128 #[non_exhaustive]
1129 pub struct PartitionEndRecord {
1130 /// End timestamp at which the change stream partition is terminated. All
1131 /// changes generated by this partition will have timestamps <=
1132 /// end_timestamp. DataChangeRecord.commit_timestamps,
1133 /// PartitionStartRecord.start_timestamps,
1134 /// PartitionEventRecord.commit_timestamps, and
1135 /// PartitionEndRecord.end_timestamps can have the same value in the same
1136 /// partition. PartitionEndRecord is the last record returned for a
1137 /// partition.
1138 pub end_timestamp: std::option::Option<wkt::Timestamp>,
1139
1140 /// Record sequence numbers are unique and monotonically increasing (but not
1141 /// necessarily contiguous) for a specific timestamp across record
1142 /// types in the same partition. To guarantee ordered processing, the reader
1143 /// should process records (of potentially different types) in
1144 /// record_sequence order for a specific timestamp in the same partition.
1145 pub record_sequence: std::string::String,
1146
1147 /// Unique partition identifier describing the terminated change stream
1148 /// partition.
1149 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEndRecord.partition_token]
1150 /// is equal to the partition token of the change stream partition currently
1151 /// queried to return this PartitionEndRecord.
1152 ///
1153 /// [google.spanner.v1.ChangeStreamRecord.PartitionEndRecord.partition_token]: crate::model::change_stream_record::PartitionEndRecord::partition_token
1154 pub partition_token: std::string::String,
1155
1156 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1157 }
1158
1159 impl PartitionEndRecord {
1160 /// Creates a new default instance.
1161 pub fn new() -> Self {
1162 std::default::Default::default()
1163 }
1164
1165 /// Sets the value of [end_timestamp][crate::model::change_stream_record::PartitionEndRecord::end_timestamp].
1166 pub fn set_end_timestamp<T>(mut self, v: T) -> Self
1167 where
1168 T: std::convert::Into<wkt::Timestamp>,
1169 {
1170 self.end_timestamp = std::option::Option::Some(v.into());
1171 self
1172 }
1173
1174 /// Sets or clears the value of [end_timestamp][crate::model::change_stream_record::PartitionEndRecord::end_timestamp].
1175 pub fn set_or_clear_end_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1176 where
1177 T: std::convert::Into<wkt::Timestamp>,
1178 {
1179 self.end_timestamp = v.map(|x| x.into());
1180 self
1181 }
1182
1183 /// Sets the value of [record_sequence][crate::model::change_stream_record::PartitionEndRecord::record_sequence].
1184 pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
1185 mut self,
1186 v: T,
1187 ) -> Self {
1188 self.record_sequence = v.into();
1189 self
1190 }
1191
1192 /// Sets the value of [partition_token][crate::model::change_stream_record::PartitionEndRecord::partition_token].
1193 pub fn set_partition_token<T: std::convert::Into<std::string::String>>(
1194 mut self,
1195 v: T,
1196 ) -> Self {
1197 self.partition_token = v.into();
1198 self
1199 }
1200 }
1201
1202 impl wkt::message::Message for PartitionEndRecord {
1203 fn typename() -> &'static str {
1204 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEndRecord"
1205 }
1206 }
1207
1208 /// A partition event record describes key range changes for a change stream
1209 /// partition. The changes to a row defined by its primary key can be captured
1210 /// in one change stream partition for a specific time range, and then be
1211 /// captured in a different change stream partition for a different time range.
1212 /// This movement of key ranges across change stream partitions is a reflection
1213 /// of activities, such as Spanner's dynamic splitting and load balancing, etc.
1214 /// Processing this event is needed if users want to guarantee processing of
1215 /// the changes for any key in timestamp order. If time ordered processing of
1216 /// changes for a primary key is not needed, this event can be ignored.
1217 /// To guarantee time ordered processing for each primary key, if the event
1218 /// describes move-ins, the reader of this partition needs to wait until the
1219 /// readers of the source partitions have processed all records with timestamps
1220 /// <= this PartitionEventRecord.commit_timestamp, before advancing beyond this
1221 /// PartitionEventRecord. If the event describes move-outs, the reader can
1222 /// notify the readers of the destination partitions that they can continue
1223 /// processing.
1224 #[derive(Clone, Default, PartialEq)]
1225 #[non_exhaustive]
1226 pub struct PartitionEventRecord {
1227 /// Indicates the commit timestamp at which the key range change occurred.
1228 /// DataChangeRecord.commit_timestamps,
1229 /// PartitionStartRecord.start_timestamps,
1230 /// PartitionEventRecord.commit_timestamps, and
1231 /// PartitionEndRecord.end_timestamps can have the same value in the same
1232 /// partition.
1233 pub commit_timestamp: std::option::Option<wkt::Timestamp>,
1234
1235 /// Record sequence numbers are unique and monotonically increasing (but not
1236 /// necessarily contiguous) for a specific timestamp across record
1237 /// types in the same partition. To guarantee ordered processing, the reader
1238 /// should process records (of potentially different types) in
1239 /// record_sequence order for a specific timestamp in the same partition.
1240 pub record_sequence: std::string::String,
1241
1242 /// Unique partition identifier describing the partition this event
1243 /// occurred on.
1244 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]
1245 /// is equal to the partition token of the change stream partition currently
1246 /// queried to return this PartitionEventRecord.
1247 ///
1248 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1249 pub partition_token: std::string::String,
1250
1251 /// Set when one or more key ranges are moved into the change stream
1252 /// partition identified by
1253 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1254 ///
1255 /// Example: Two key ranges are moved into partition (P1) from partition (P2)
1256 /// and partition (P3) in a single transaction at timestamp T.
1257 ///
1258 /// The PartitionEventRecord returned in P1 will reflect the move as:
1259 ///
1260 /// PartitionEventRecord {
1261 /// commit_timestamp: T
1262 /// partition_token: "P1"
1263 /// move_in_events {
1264 /// source_partition_token: "P2"
1265 /// }
1266 /// move_in_events {
1267 /// source_partition_token: "P3"
1268 /// }
1269 /// }
1270 ///
1271 /// The PartitionEventRecord returned in P2 will reflect the move as:
1272 ///
1273 /// PartitionEventRecord {
1274 /// commit_timestamp: T
1275 /// partition_token: "P2"
1276 /// move_out_events {
1277 /// destination_partition_token: "P1"
1278 /// }
1279 /// }
1280 ///
1281 /// The PartitionEventRecord returned in P3 will reflect the move as:
1282 ///
1283 /// PartitionEventRecord {
1284 /// commit_timestamp: T
1285 /// partition_token: "P3"
1286 /// move_out_events {
1287 /// destination_partition_token: "P1"
1288 /// }
1289 /// }
1290 ///
1291 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1292 pub move_in_events:
1293 std::vec::Vec<crate::model::change_stream_record::partition_event_record::MoveInEvent>,
1294
1295 /// Set when one or more key ranges are moved out of the change stream
1296 /// partition identified by
1297 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1298 ///
1299 /// Example: Two key ranges are moved out of partition (P1) to partition (P2)
1300 /// and partition (P3) in a single transaction at timestamp T.
1301 ///
1302 /// The PartitionEventRecord returned in P1 will reflect the move as:
1303 ///
1304 /// PartitionEventRecord {
1305 /// commit_timestamp: T
1306 /// partition_token: "P1"
1307 /// move_out_events {
1308 /// destination_partition_token: "P2"
1309 /// }
1310 /// move_out_events {
1311 /// destination_partition_token: "P3"
1312 /// }
1313 /// }
1314 ///
1315 /// The PartitionEventRecord returned in P2 will reflect the move as:
1316 ///
1317 /// PartitionEventRecord {
1318 /// commit_timestamp: T
1319 /// partition_token: "P2"
1320 /// move_in_events {
1321 /// source_partition_token: "P1"
1322 /// }
1323 /// }
1324 ///
1325 /// The PartitionEventRecord returned in P3 will reflect the move as:
1326 ///
1327 /// PartitionEventRecord {
1328 /// commit_timestamp: T
1329 /// partition_token: "P3"
1330 /// move_in_events {
1331 /// source_partition_token: "P1"
1332 /// }
1333 /// }
1334 ///
1335 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1336 pub move_out_events:
1337 std::vec::Vec<crate::model::change_stream_record::partition_event_record::MoveOutEvent>,
1338
1339 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1340 }
1341
1342 impl PartitionEventRecord {
1343 /// Creates a new default instance.
1344 pub fn new() -> Self {
1345 std::default::Default::default()
1346 }
1347
1348 /// Sets the value of [commit_timestamp][crate::model::change_stream_record::PartitionEventRecord::commit_timestamp].
1349 pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
1350 where
1351 T: std::convert::Into<wkt::Timestamp>,
1352 {
1353 self.commit_timestamp = std::option::Option::Some(v.into());
1354 self
1355 }
1356
1357 /// Sets or clears the value of [commit_timestamp][crate::model::change_stream_record::PartitionEventRecord::commit_timestamp].
1358 pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1359 where
1360 T: std::convert::Into<wkt::Timestamp>,
1361 {
1362 self.commit_timestamp = v.map(|x| x.into());
1363 self
1364 }
1365
1366 /// Sets the value of [record_sequence][crate::model::change_stream_record::PartitionEventRecord::record_sequence].
1367 pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
1368 mut self,
1369 v: T,
1370 ) -> Self {
1371 self.record_sequence = v.into();
1372 self
1373 }
1374
1375 /// Sets the value of [partition_token][crate::model::change_stream_record::PartitionEventRecord::partition_token].
1376 pub fn set_partition_token<T: std::convert::Into<std::string::String>>(
1377 mut self,
1378 v: T,
1379 ) -> Self {
1380 self.partition_token = v.into();
1381 self
1382 }
1383
1384 /// Sets the value of [move_in_events][crate::model::change_stream_record::PartitionEventRecord::move_in_events].
1385 pub fn set_move_in_events<T, V>(mut self, v: T) -> Self
1386 where
1387 T: std::iter::IntoIterator<Item = V>,
1388 V: std::convert::Into<
1389 crate::model::change_stream_record::partition_event_record::MoveInEvent,
1390 >,
1391 {
1392 use std::iter::Iterator;
1393 self.move_in_events = v.into_iter().map(|i| i.into()).collect();
1394 self
1395 }
1396
1397 /// Sets the value of [move_out_events][crate::model::change_stream_record::PartitionEventRecord::move_out_events].
1398 pub fn set_move_out_events<T, V>(mut self, v: T) -> Self
1399 where
1400 T: std::iter::IntoIterator<Item = V>,
1401 V: std::convert::Into<
1402 crate::model::change_stream_record::partition_event_record::MoveOutEvent,
1403 >,
1404 {
1405 use std::iter::Iterator;
1406 self.move_out_events = v.into_iter().map(|i| i.into()).collect();
1407 self
1408 }
1409 }
1410
1411 impl wkt::message::Message for PartitionEventRecord {
1412 fn typename() -> &'static str {
1413 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEventRecord"
1414 }
1415 }
1416
1417 /// Defines additional types related to [PartitionEventRecord].
1418 pub mod partition_event_record {
1419 #[allow(unused_imports)]
1420 use super::*;
1421
1422 /// Describes move-in of the key ranges into the change stream partition
1423 /// identified by
1424 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1425 ///
1426 /// To maintain processing the changes for a particular key in timestamp
1427 /// order, the query processing the change stream partition identified by
1428 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]
1429 /// should not advance beyond the partition event record commit timestamp
1430 /// until the queries processing the source change stream partitions have
1431 /// processed all change stream records with timestamps <= the partition
1432 /// event record commit timestamp.
1433 ///
1434 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1435 #[derive(Clone, Default, PartialEq)]
1436 #[non_exhaustive]
1437 pub struct MoveInEvent {
1438 /// An unique partition identifier describing the source change stream
1439 /// partition that recorded changes for the key range that is moving
1440 /// into this partition.
1441 pub source_partition_token: std::string::String,
1442
1443 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1444 }
1445
1446 impl MoveInEvent {
1447 /// Creates a new default instance.
1448 pub fn new() -> Self {
1449 std::default::Default::default()
1450 }
1451
1452 /// Sets the value of [source_partition_token][crate::model::change_stream_record::partition_event_record::MoveInEvent::source_partition_token].
1453 pub fn set_source_partition_token<T: std::convert::Into<std::string::String>>(
1454 mut self,
1455 v: T,
1456 ) -> Self {
1457 self.source_partition_token = v.into();
1458 self
1459 }
1460 }
1461
1462 impl wkt::message::Message for MoveInEvent {
1463 fn typename() -> &'static str {
1464 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveInEvent"
1465 }
1466 }
1467
1468 /// Describes move-out of the key ranges out of the change stream partition
1469 /// identified by
1470 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1471 ///
1472 /// To maintain processing the changes for a particular key in timestamp
1473 /// order, the query processing the
1474 /// [MoveOutEvent][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveOutEvent]
1475 /// in the partition identified by
1476 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]
1477 /// should inform the queries processing the destination partitions that
1478 /// they can unblock and proceed processing records past the
1479 /// [commit_timestamp][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.commit_timestamp].
1480 ///
1481 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveOutEvent]: crate::model::change_stream_record::partition_event_record::MoveOutEvent
1482 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.commit_timestamp]: crate::model::change_stream_record::PartitionEventRecord::commit_timestamp
1483 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1484 #[derive(Clone, Default, PartialEq)]
1485 #[non_exhaustive]
1486 pub struct MoveOutEvent {
1487 /// An unique partition identifier describing the destination change
1488 /// stream partition that will record changes for the key range that is
1489 /// moving out of this partition.
1490 pub destination_partition_token: std::string::String,
1491
1492 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1493 }
1494
1495 impl MoveOutEvent {
1496 /// Creates a new default instance.
1497 pub fn new() -> Self {
1498 std::default::Default::default()
1499 }
1500
1501 /// Sets the value of [destination_partition_token][crate::model::change_stream_record::partition_event_record::MoveOutEvent::destination_partition_token].
1502 pub fn set_destination_partition_token<T: std::convert::Into<std::string::String>>(
1503 mut self,
1504 v: T,
1505 ) -> Self {
1506 self.destination_partition_token = v.into();
1507 self
1508 }
1509 }
1510
1511 impl wkt::message::Message for MoveOutEvent {
1512 fn typename() -> &'static str {
1513 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveOutEvent"
1514 }
1515 }
1516 }
1517
1518 /// One of the change stream subrecords.
1519 #[derive(Clone, Debug, PartialEq)]
1520 #[non_exhaustive]
1521 pub enum Record {
1522 /// Data change record describing a data change for a change stream
1523 /// partition.
1524 DataChangeRecord(std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>),
1525 /// Heartbeat record describing a heartbeat for a change stream partition.
1526 HeartbeatRecord(std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>),
1527 /// Partition start record describing a new change stream partition.
1528 PartitionStartRecord(
1529 std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
1530 ),
1531 /// Partition end record describing a terminated change stream partition.
1532 PartitionEndRecord(std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>),
1533 /// Partition event record describing key range changes for a change stream
1534 /// partition.
1535 PartitionEventRecord(
1536 std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
1537 ),
1538 }
1539
1540 impl Record {
1541 /// Initializes the enum to the [DataChangeRecord](Self::DataChangeRecord) branch.
1542 pub fn from_data_change_record(
1543 value: impl std::convert::Into<
1544 std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>,
1545 >,
1546 ) -> Self {
1547 Self::DataChangeRecord(value.into())
1548 }
1549 /// Initializes the enum to the [HeartbeatRecord](Self::HeartbeatRecord) branch.
1550 pub fn from_heartbeat_record(
1551 value: impl std::convert::Into<
1552 std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>,
1553 >,
1554 ) -> Self {
1555 Self::HeartbeatRecord(value.into())
1556 }
1557 /// Initializes the enum to the [PartitionStartRecord](Self::PartitionStartRecord) branch.
1558 pub fn from_partition_start_record(
1559 value: impl std::convert::Into<
1560 std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
1561 >,
1562 ) -> Self {
1563 Self::PartitionStartRecord(value.into())
1564 }
1565 /// Initializes the enum to the [PartitionEndRecord](Self::PartitionEndRecord) branch.
1566 pub fn from_partition_end_record(
1567 value: impl std::convert::Into<
1568 std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>,
1569 >,
1570 ) -> Self {
1571 Self::PartitionEndRecord(value.into())
1572 }
1573 /// Initializes the enum to the [PartitionEventRecord](Self::PartitionEventRecord) branch.
1574 pub fn from_partition_event_record(
1575 value: impl std::convert::Into<
1576 std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
1577 >,
1578 ) -> Self {
1579 Self::PartitionEventRecord(value.into())
1580 }
1581 }
1582}
1583
1584/// The response for [Commit][google.spanner.v1.Spanner.Commit].
1585///
1586/// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
1587#[derive(Clone, Default, PartialEq)]
1588#[non_exhaustive]
1589pub struct CommitResponse {
1590 /// The Cloud Spanner timestamp at which the transaction committed.
1591 pub commit_timestamp: std::option::Option<wkt::Timestamp>,
1592
1593 /// The statistics about this `Commit`. Not returned by default.
1594 /// For more information, see
1595 /// [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats].
1596 ///
1597 /// [google.spanner.v1.CommitRequest.return_commit_stats]: crate::model::CommitRequest::return_commit_stats
1598 pub commit_stats: std::option::Option<crate::model::commit_response::CommitStats>,
1599
1600 /// If `TransactionOptions.isolation_level` is set to
1601 /// `IsolationLevel.REPEATABLE_READ`, then the snapshot timestamp is the
1602 /// timestamp at which all reads in the transaction ran. This timestamp is
1603 /// never returned.
1604 pub snapshot_timestamp: std::option::Option<wkt::Timestamp>,
1605
1606 /// Optional. A cache update expresses a set of changes the client should
1607 /// incorporate into its location cache. The client should discard the changes
1608 /// if they are older than the data it already has. This data can be obtained
1609 /// in response to requests that included a `RoutingHint` field, but may also
1610 /// be obtained by explicit location-fetching RPCs which may be added in the
1611 /// future.
1612 pub cache_update: std::option::Option<crate::model::CacheUpdate>,
1613
1614 /// The isolation level used for the read-write transaction.
1615 pub isolation_level: crate::model::transaction_options::IsolationLevel,
1616
1617 /// The read lock mode used for the read-write transaction.
1618 pub read_lock_mode: crate::model::transaction_options::read_write::ReadLockMode,
1619
1620 /// You must examine and retry the commit if the following is populated.
1621 pub multiplexed_session_retry:
1622 std::option::Option<crate::model::commit_response::MultiplexedSessionRetry>,
1623
1624 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1625}
1626
1627impl CommitResponse {
1628 /// Creates a new default instance.
1629 pub fn new() -> Self {
1630 std::default::Default::default()
1631 }
1632
1633 /// Sets the value of [commit_timestamp][crate::model::CommitResponse::commit_timestamp].
1634 pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
1635 where
1636 T: std::convert::Into<wkt::Timestamp>,
1637 {
1638 self.commit_timestamp = std::option::Option::Some(v.into());
1639 self
1640 }
1641
1642 /// Sets or clears the value of [commit_timestamp][crate::model::CommitResponse::commit_timestamp].
1643 pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1644 where
1645 T: std::convert::Into<wkt::Timestamp>,
1646 {
1647 self.commit_timestamp = v.map(|x| x.into());
1648 self
1649 }
1650
1651 /// Sets the value of [commit_stats][crate::model::CommitResponse::commit_stats].
1652 pub fn set_commit_stats<T>(mut self, v: T) -> Self
1653 where
1654 T: std::convert::Into<crate::model::commit_response::CommitStats>,
1655 {
1656 self.commit_stats = std::option::Option::Some(v.into());
1657 self
1658 }
1659
1660 /// Sets or clears the value of [commit_stats][crate::model::CommitResponse::commit_stats].
1661 pub fn set_or_clear_commit_stats<T>(mut self, v: std::option::Option<T>) -> Self
1662 where
1663 T: std::convert::Into<crate::model::commit_response::CommitStats>,
1664 {
1665 self.commit_stats = v.map(|x| x.into());
1666 self
1667 }
1668
1669 /// Sets the value of [snapshot_timestamp][crate::model::CommitResponse::snapshot_timestamp].
1670 pub fn set_snapshot_timestamp<T>(mut self, v: T) -> Self
1671 where
1672 T: std::convert::Into<wkt::Timestamp>,
1673 {
1674 self.snapshot_timestamp = std::option::Option::Some(v.into());
1675 self
1676 }
1677
1678 /// Sets or clears the value of [snapshot_timestamp][crate::model::CommitResponse::snapshot_timestamp].
1679 pub fn set_or_clear_snapshot_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1680 where
1681 T: std::convert::Into<wkt::Timestamp>,
1682 {
1683 self.snapshot_timestamp = v.map(|x| x.into());
1684 self
1685 }
1686
1687 /// Sets the value of [cache_update][crate::model::CommitResponse::cache_update].
1688 pub fn set_cache_update<T>(mut self, v: T) -> Self
1689 where
1690 T: std::convert::Into<crate::model::CacheUpdate>,
1691 {
1692 self.cache_update = std::option::Option::Some(v.into());
1693 self
1694 }
1695
1696 /// Sets or clears the value of [cache_update][crate::model::CommitResponse::cache_update].
1697 pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
1698 where
1699 T: std::convert::Into<crate::model::CacheUpdate>,
1700 {
1701 self.cache_update = v.map(|x| x.into());
1702 self
1703 }
1704
1705 /// Sets the value of [isolation_level][crate::model::CommitResponse::isolation_level].
1706 pub fn set_isolation_level<
1707 T: std::convert::Into<crate::model::transaction_options::IsolationLevel>,
1708 >(
1709 mut self,
1710 v: T,
1711 ) -> Self {
1712 self.isolation_level = v.into();
1713 self
1714 }
1715
1716 /// Sets the value of [read_lock_mode][crate::model::CommitResponse::read_lock_mode].
1717 pub fn set_read_lock_mode<
1718 T: std::convert::Into<crate::model::transaction_options::read_write::ReadLockMode>,
1719 >(
1720 mut self,
1721 v: T,
1722 ) -> Self {
1723 self.read_lock_mode = v.into();
1724 self
1725 }
1726
1727 /// Sets the value of [multiplexed_session_retry][crate::model::CommitResponse::multiplexed_session_retry].
1728 ///
1729 /// Note that all the setters affecting `multiplexed_session_retry` are mutually
1730 /// exclusive.
1731 pub fn set_multiplexed_session_retry<
1732 T: std::convert::Into<
1733 std::option::Option<crate::model::commit_response::MultiplexedSessionRetry>,
1734 >,
1735 >(
1736 mut self,
1737 v: T,
1738 ) -> Self {
1739 self.multiplexed_session_retry = v.into();
1740 self
1741 }
1742
1743 /// The value of [multiplexed_session_retry][crate::model::CommitResponse::multiplexed_session_retry]
1744 /// if it holds a `PrecommitToken`, `None` if the field is not set or
1745 /// holds a different branch.
1746 pub fn precommit_token(
1747 &self,
1748 ) -> std::option::Option<&std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>> {
1749 #[allow(unreachable_patterns)]
1750 self.multiplexed_session_retry
1751 .as_ref()
1752 .and_then(|v| match v {
1753 crate::model::commit_response::MultiplexedSessionRetry::PrecommitToken(v) => {
1754 std::option::Option::Some(v)
1755 }
1756 _ => std::option::Option::None,
1757 })
1758 }
1759
1760 /// Sets the value of [multiplexed_session_retry][crate::model::CommitResponse::multiplexed_session_retry]
1761 /// to hold a `PrecommitToken`.
1762 ///
1763 /// Note that all the setters affecting `multiplexed_session_retry` are
1764 /// mutually exclusive.
1765 pub fn set_precommit_token<
1766 T: std::convert::Into<std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>>,
1767 >(
1768 mut self,
1769 v: T,
1770 ) -> Self {
1771 self.multiplexed_session_retry = std::option::Option::Some(
1772 crate::model::commit_response::MultiplexedSessionRetry::PrecommitToken(v.into()),
1773 );
1774 self
1775 }
1776}
1777
1778impl wkt::message::Message for CommitResponse {
1779 fn typename() -> &'static str {
1780 "type.googleapis.com/google.spanner.v1.CommitResponse"
1781 }
1782}
1783
1784/// Defines additional types related to [CommitResponse].
1785pub mod commit_response {
1786 #[allow(unused_imports)]
1787 use super::*;
1788
1789 /// Additional statistics about a commit.
1790 #[derive(Clone, Default, PartialEq)]
1791 #[non_exhaustive]
1792 pub struct CommitStats {
1793 /// The total number of mutations for the transaction. Knowing the
1794 /// `mutation_count` value can help you maximize the number of mutations
1795 /// in a transaction and minimize the number of API round trips. You can
1796 /// also monitor this value to prevent transactions from exceeding the system
1797 /// [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data).
1798 /// If the number of mutations exceeds the limit, the server returns
1799 /// [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT).
1800 pub mutation_count: i64,
1801
1802 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1803 }
1804
1805 impl CommitStats {
1806 /// Creates a new default instance.
1807 pub fn new() -> Self {
1808 std::default::Default::default()
1809 }
1810
1811 /// Sets the value of [mutation_count][crate::model::commit_response::CommitStats::mutation_count].
1812 pub fn set_mutation_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1813 self.mutation_count = v.into();
1814 self
1815 }
1816 }
1817
1818 impl wkt::message::Message for CommitStats {
1819 fn typename() -> &'static str {
1820 "type.googleapis.com/google.spanner.v1.CommitResponse.CommitStats"
1821 }
1822 }
1823
1824 /// You must examine and retry the commit if the following is populated.
1825 #[derive(Clone, Debug, PartialEq)]
1826 #[non_exhaustive]
1827 pub enum MultiplexedSessionRetry {
1828 /// If specified, transaction has not committed yet.
1829 /// You must retry the commit with the new precommit token.
1830 PrecommitToken(std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>),
1831 }
1832
1833 impl MultiplexedSessionRetry {
1834 /// Initializes the enum to the [PrecommitToken](Self::PrecommitToken) branch.
1835 pub fn from_precommit_token(
1836 value: impl std::convert::Into<
1837 std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>,
1838 >,
1839 ) -> Self {
1840 Self::PrecommitToken(value.into())
1841 }
1842 }
1843}
1844
1845/// KeyRange represents a range of rows in a table or index.
1846///
1847/// A range has a start key and an end key. These keys can be open or
1848/// closed, indicating if the range includes rows with that key.
1849///
1850/// Keys are represented by lists, where the ith value in the list
1851/// corresponds to the ith component of the table or index primary key.
1852/// Individual values are encoded as described
1853/// [here][google.spanner.v1.TypeCode].
1854///
1855/// For example, consider the following table definition:
1856///
1857/// ```norust
1858/// CREATE TABLE UserEvents (
1859/// UserName STRING(MAX),
1860/// EventDate STRING(10)
1861/// ) PRIMARY KEY(UserName, EventDate);
1862/// ```
1863///
1864/// The following keys name rows in this table:
1865///
1866/// ```norust
1867/// ["Bob", "2014-09-23"]
1868/// ["Alfred", "2015-06-12"]
1869/// ```
1870///
1871/// Since the `UserEvents` table's `PRIMARY KEY` clause names two
1872/// columns, each `UserEvents` key has two elements; the first is the
1873/// `UserName`, and the second is the `EventDate`.
1874///
1875/// Key ranges with multiple components are interpreted
1876/// lexicographically by component using the table or index key's declared
1877/// sort order. For example, the following range returns all events for
1878/// user `"Bob"` that occurred in the year 2015:
1879///
1880/// ```norust
1881/// "start_closed": ["Bob", "2015-01-01"]
1882/// "end_closed": ["Bob", "2015-12-31"]
1883/// ```
1884///
1885/// Start and end keys can omit trailing key components. This affects the
1886/// inclusion and exclusion of rows that exactly match the provided key
1887/// components: if the key is closed, then rows that exactly match the
1888/// provided components are included; if the key is open, then rows
1889/// that exactly match are not included.
1890///
1891/// For example, the following range includes all events for `"Bob"` that
1892/// occurred during and after the year 2000:
1893///
1894/// ```norust
1895/// "start_closed": ["Bob", "2000-01-01"]
1896/// "end_closed": ["Bob"]
1897/// ```
1898///
1899/// The next example retrieves all events for `"Bob"`:
1900///
1901/// ```norust
1902/// "start_closed": ["Bob"]
1903/// "end_closed": ["Bob"]
1904/// ```
1905///
1906/// To retrieve events before the year 2000:
1907///
1908/// ```norust
1909/// "start_closed": ["Bob"]
1910/// "end_open": ["Bob", "2000-01-01"]
1911/// ```
1912///
1913/// The following range includes all rows in the table:
1914///
1915/// ```norust
1916/// "start_closed": []
1917/// "end_closed": []
1918/// ```
1919///
1920/// This range returns all users whose `UserName` begins with any
1921/// character from A to C:
1922///
1923/// ```norust
1924/// "start_closed": ["A"]
1925/// "end_open": ["D"]
1926/// ```
1927///
1928/// This range returns all users whose `UserName` begins with B:
1929///
1930/// ```norust
1931/// "start_closed": ["B"]
1932/// "end_open": ["C"]
1933/// ```
1934///
1935/// Key ranges honor column sort order. For example, suppose a table is
1936/// defined as follows:
1937///
1938/// ```norust
1939/// CREATE TABLE DescendingSortedTable {
1940/// Key INT64,
1941/// ...
1942/// ) PRIMARY KEY(Key DESC);
1943/// ```
1944///
1945/// The following range retrieves all rows with key values between 1
1946/// and 100 inclusive:
1947///
1948/// ```norust
1949/// "start_closed": ["100"]
1950/// "end_closed": ["1"]
1951/// ```
1952///
1953/// Note that 100 is passed as the start, and 1 is passed as the end,
1954/// because `Key` is a descending column in the schema.
1955///
1956/// [google.spanner.v1.TypeCode]: crate::model::TypeCode
1957#[derive(Clone, Default, PartialEq)]
1958#[non_exhaustive]
1959pub struct KeyRange {
1960 /// The start key must be provided. It can be either closed or open.
1961 pub start_key_type: std::option::Option<crate::model::key_range::StartKeyType>,
1962
1963 /// The end key must be provided. It can be either closed or open.
1964 pub end_key_type: std::option::Option<crate::model::key_range::EndKeyType>,
1965
1966 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1967}
1968
1969impl KeyRange {
1970 /// Creates a new default instance.
1971 pub fn new() -> Self {
1972 std::default::Default::default()
1973 }
1974
1975 /// Sets the value of [start_key_type][crate::model::KeyRange::start_key_type].
1976 ///
1977 /// Note that all the setters affecting `start_key_type` are mutually
1978 /// exclusive.
1979 pub fn set_start_key_type<
1980 T: std::convert::Into<std::option::Option<crate::model::key_range::StartKeyType>>,
1981 >(
1982 mut self,
1983 v: T,
1984 ) -> Self {
1985 self.start_key_type = v.into();
1986 self
1987 }
1988
1989 /// The value of [start_key_type][crate::model::KeyRange::start_key_type]
1990 /// if it holds a `StartClosed`, `None` if the field is not set or
1991 /// holds a different branch.
1992 pub fn start_closed(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
1993 #[allow(unreachable_patterns)]
1994 self.start_key_type.as_ref().and_then(|v| match v {
1995 crate::model::key_range::StartKeyType::StartClosed(v) => std::option::Option::Some(v),
1996 _ => std::option::Option::None,
1997 })
1998 }
1999
2000 /// Sets the value of [start_key_type][crate::model::KeyRange::start_key_type]
2001 /// to hold a `StartClosed`.
2002 ///
2003 /// Note that all the setters affecting `start_key_type` are
2004 /// mutually exclusive.
2005 pub fn set_start_closed<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2006 mut self,
2007 v: T,
2008 ) -> Self {
2009 self.start_key_type =
2010 std::option::Option::Some(crate::model::key_range::StartKeyType::StartClosed(v.into()));
2011 self
2012 }
2013
2014 /// The value of [start_key_type][crate::model::KeyRange::start_key_type]
2015 /// if it holds a `StartOpen`, `None` if the field is not set or
2016 /// holds a different branch.
2017 pub fn start_open(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
2018 #[allow(unreachable_patterns)]
2019 self.start_key_type.as_ref().and_then(|v| match v {
2020 crate::model::key_range::StartKeyType::StartOpen(v) => std::option::Option::Some(v),
2021 _ => std::option::Option::None,
2022 })
2023 }
2024
2025 /// Sets the value of [start_key_type][crate::model::KeyRange::start_key_type]
2026 /// to hold a `StartOpen`.
2027 ///
2028 /// Note that all the setters affecting `start_key_type` are
2029 /// mutually exclusive.
2030 pub fn set_start_open<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2031 mut self,
2032 v: T,
2033 ) -> Self {
2034 self.start_key_type =
2035 std::option::Option::Some(crate::model::key_range::StartKeyType::StartOpen(v.into()));
2036 self
2037 }
2038
2039 /// Sets the value of [end_key_type][crate::model::KeyRange::end_key_type].
2040 ///
2041 /// Note that all the setters affecting `end_key_type` are mutually
2042 /// exclusive.
2043 pub fn set_end_key_type<
2044 T: std::convert::Into<std::option::Option<crate::model::key_range::EndKeyType>>,
2045 >(
2046 mut self,
2047 v: T,
2048 ) -> Self {
2049 self.end_key_type = v.into();
2050 self
2051 }
2052
2053 /// The value of [end_key_type][crate::model::KeyRange::end_key_type]
2054 /// if it holds a `EndClosed`, `None` if the field is not set or
2055 /// holds a different branch.
2056 pub fn end_closed(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
2057 #[allow(unreachable_patterns)]
2058 self.end_key_type.as_ref().and_then(|v| match v {
2059 crate::model::key_range::EndKeyType::EndClosed(v) => std::option::Option::Some(v),
2060 _ => std::option::Option::None,
2061 })
2062 }
2063
2064 /// Sets the value of [end_key_type][crate::model::KeyRange::end_key_type]
2065 /// to hold a `EndClosed`.
2066 ///
2067 /// Note that all the setters affecting `end_key_type` are
2068 /// mutually exclusive.
2069 pub fn set_end_closed<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2070 mut self,
2071 v: T,
2072 ) -> Self {
2073 self.end_key_type =
2074 std::option::Option::Some(crate::model::key_range::EndKeyType::EndClosed(v.into()));
2075 self
2076 }
2077
2078 /// The value of [end_key_type][crate::model::KeyRange::end_key_type]
2079 /// if it holds a `EndOpen`, `None` if the field is not set or
2080 /// holds a different branch.
2081 pub fn end_open(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
2082 #[allow(unreachable_patterns)]
2083 self.end_key_type.as_ref().and_then(|v| match v {
2084 crate::model::key_range::EndKeyType::EndOpen(v) => std::option::Option::Some(v),
2085 _ => std::option::Option::None,
2086 })
2087 }
2088
2089 /// Sets the value of [end_key_type][crate::model::KeyRange::end_key_type]
2090 /// to hold a `EndOpen`.
2091 ///
2092 /// Note that all the setters affecting `end_key_type` are
2093 /// mutually exclusive.
2094 pub fn set_end_open<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2095 mut self,
2096 v: T,
2097 ) -> Self {
2098 self.end_key_type =
2099 std::option::Option::Some(crate::model::key_range::EndKeyType::EndOpen(v.into()));
2100 self
2101 }
2102}
2103
2104impl wkt::message::Message for KeyRange {
2105 fn typename() -> &'static str {
2106 "type.googleapis.com/google.spanner.v1.KeyRange"
2107 }
2108}
2109
2110/// Defines additional types related to [KeyRange].
2111pub mod key_range {
2112 #[allow(unused_imports)]
2113 use super::*;
2114
2115 /// The start key must be provided. It can be either closed or open.
2116 #[derive(Clone, Debug, PartialEq)]
2117 #[non_exhaustive]
2118 pub enum StartKeyType {
2119 /// If the start is closed, then the range includes all rows whose
2120 /// first `len(start_closed)` key columns exactly match `start_closed`.
2121 StartClosed(std::boxed::Box<wkt::ListValue>),
2122 /// If the start is open, then the range excludes rows whose first
2123 /// `len(start_open)` key columns exactly match `start_open`.
2124 StartOpen(std::boxed::Box<wkt::ListValue>),
2125 }
2126
2127 impl StartKeyType {
2128 /// Initializes the enum to the [StartClosed](Self::StartClosed) branch.
2129 pub fn from_start_closed(
2130 value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2131 ) -> Self {
2132 Self::StartClosed(value.into())
2133 }
2134 /// Initializes the enum to the [StartOpen](Self::StartOpen) branch.
2135 pub fn from_start_open(
2136 value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2137 ) -> Self {
2138 Self::StartOpen(value.into())
2139 }
2140 }
2141
2142 /// The end key must be provided. It can be either closed or open.
2143 #[derive(Clone, Debug, PartialEq)]
2144 #[non_exhaustive]
2145 pub enum EndKeyType {
2146 /// If the end is closed, then the range includes all rows whose
2147 /// first `len(end_closed)` key columns exactly match `end_closed`.
2148 EndClosed(std::boxed::Box<wkt::ListValue>),
2149 /// If the end is open, then the range excludes rows whose first
2150 /// `len(end_open)` key columns exactly match `end_open`.
2151 EndOpen(std::boxed::Box<wkt::ListValue>),
2152 }
2153
2154 impl EndKeyType {
2155 /// Initializes the enum to the [EndClosed](Self::EndClosed) branch.
2156 pub fn from_end_closed(
2157 value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2158 ) -> Self {
2159 Self::EndClosed(value.into())
2160 }
2161 /// Initializes the enum to the [EndOpen](Self::EndOpen) branch.
2162 pub fn from_end_open(
2163 value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2164 ) -> Self {
2165 Self::EndOpen(value.into())
2166 }
2167 }
2168}
2169
2170/// `KeySet` defines a collection of Cloud Spanner keys and/or key ranges. All
2171/// the keys are expected to be in the same table or index. The keys need
2172/// not be sorted in any particular way.
2173///
2174/// If the same key is specified multiple times in the set (for example
2175/// if two ranges, two keys, or a key and a range overlap), Cloud Spanner
2176/// behaves as if the key were only specified once.
2177#[derive(Clone, Default, PartialEq)]
2178#[non_exhaustive]
2179pub struct KeySet {
2180 /// A list of specific keys. Entries in `keys` should have exactly as
2181 /// many elements as there are columns in the primary or index key
2182 /// with which this `KeySet` is used. Individual key values are
2183 /// encoded as described [here][google.spanner.v1.TypeCode].
2184 ///
2185 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
2186 pub keys: std::vec::Vec<wkt::ListValue>,
2187
2188 /// A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more
2189 /// information about key range specifications.
2190 ///
2191 /// [google.spanner.v1.KeyRange]: crate::model::KeyRange
2192 pub ranges: std::vec::Vec<crate::model::KeyRange>,
2193
2194 /// For convenience `all` can be set to `true` to indicate that this
2195 /// `KeySet` matches all keys in the table or index. Note that any keys
2196 /// specified in `keys` or `ranges` are only yielded once.
2197 pub all: bool,
2198
2199 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2200}
2201
2202impl KeySet {
2203 /// Creates a new default instance.
2204 pub fn new() -> Self {
2205 std::default::Default::default()
2206 }
2207
2208 /// Sets the value of [keys][crate::model::KeySet::keys].
2209 pub fn set_keys<T, V>(mut self, v: T) -> Self
2210 where
2211 T: std::iter::IntoIterator<Item = V>,
2212 V: std::convert::Into<wkt::ListValue>,
2213 {
2214 use std::iter::Iterator;
2215 self.keys = v.into_iter().map(|i| i.into()).collect();
2216 self
2217 }
2218
2219 /// Sets the value of [ranges][crate::model::KeySet::ranges].
2220 pub fn set_ranges<T, V>(mut self, v: T) -> Self
2221 where
2222 T: std::iter::IntoIterator<Item = V>,
2223 V: std::convert::Into<crate::model::KeyRange>,
2224 {
2225 use std::iter::Iterator;
2226 self.ranges = v.into_iter().map(|i| i.into()).collect();
2227 self
2228 }
2229
2230 /// Sets the value of [all][crate::model::KeySet::all].
2231 pub fn set_all<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2232 self.all = v.into();
2233 self
2234 }
2235}
2236
2237impl wkt::message::Message for KeySet {
2238 fn typename() -> &'static str {
2239 "type.googleapis.com/google.spanner.v1.KeySet"
2240 }
2241}
2242
2243/// A `Range` represents a range of keys in a database. The keys themselves
2244/// are encoded in "sortable string format", also known as ssformat. Consult
2245/// Spanner's open source client libraries for details on the encoding.
2246///
2247/// Each range represents a contiguous range of rows, possibly from multiple
2248/// tables/indexes. Each range is associated with a single paxos group (known as
2249/// a "group" throughout this API), a split (which names the exact range within
2250/// the group), and a generation that can be used to determine whether a given
2251/// `Range` represents a newer or older location for the key range.
2252#[derive(Clone, Default, PartialEq)]
2253#[non_exhaustive]
2254pub struct Range {
2255 /// The start key of the range, inclusive. Encoded in "sortable string format"
2256 /// (ssformat).
2257 pub start_key: ::bytes::Bytes,
2258
2259 /// The limit key of the range, exclusive. Encoded in "sortable string format"
2260 /// (ssformat).
2261 pub limit_key: ::bytes::Bytes,
2262
2263 /// The UID of the paxos group where this range is stored. UIDs are unique
2264 /// within the database. References `Group.group_uid`.
2265 pub group_uid: u64,
2266
2267 /// A group can store multiple ranges of keys. Each key range is named by an
2268 /// ID (the split ID). Within a group, split IDs are unique. The `split_id`
2269 /// names the exact split in `group_uid` where this range is stored.
2270 pub split_id: u64,
2271
2272 /// `generation` indicates the freshness of the range information contained
2273 /// in this proto. Generations can be compared lexicographically; if generation
2274 /// A is greater than generation B, then the `Range` corresponding to A is
2275 /// newer than the `Range` corresponding to B, and should be used
2276 /// preferentially.
2277 pub generation: ::bytes::Bytes,
2278
2279 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2280}
2281
2282impl Range {
2283 /// Creates a new default instance.
2284 pub fn new() -> Self {
2285 std::default::Default::default()
2286 }
2287
2288 /// Sets the value of [start_key][crate::model::Range::start_key].
2289 pub fn set_start_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2290 self.start_key = v.into();
2291 self
2292 }
2293
2294 /// Sets the value of [limit_key][crate::model::Range::limit_key].
2295 pub fn set_limit_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2296 self.limit_key = v.into();
2297 self
2298 }
2299
2300 /// Sets the value of [group_uid][crate::model::Range::group_uid].
2301 pub fn set_group_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2302 self.group_uid = v.into();
2303 self
2304 }
2305
2306 /// Sets the value of [split_id][crate::model::Range::split_id].
2307 pub fn set_split_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2308 self.split_id = v.into();
2309 self
2310 }
2311
2312 /// Sets the value of [generation][crate::model::Range::generation].
2313 pub fn set_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2314 self.generation = v.into();
2315 self
2316 }
2317}
2318
2319impl wkt::message::Message for Range {
2320 fn typename() -> &'static str {
2321 "type.googleapis.com/google.spanner.v1.Range"
2322 }
2323}
2324
2325/// A `Tablet` represents a single replica of a `Group`. A tablet is served by a
2326/// single server at a time, and can move between servers due to server death or
2327/// simply load balancing.
2328#[derive(Clone, Default, PartialEq)]
2329#[non_exhaustive]
2330pub struct Tablet {
2331 /// The UID of the tablet, unique within the database. Matches the
2332 /// `tablet_uids` and `leader_tablet_uid` fields in `Group`.
2333 pub tablet_uid: u64,
2334
2335 /// The address of the server that is serving this tablet -- either an IP
2336 /// address or DNS hostname and a port number.
2337 pub server_address: std::string::String,
2338
2339 /// Where this tablet is located. This is the name of a Google Cloud region,
2340 /// such as "us-central1".
2341 pub location: std::string::String,
2342
2343 /// The role of the tablet.
2344 pub role: crate::model::tablet::Role,
2345
2346 /// `incarnation` indicates the freshness of the tablet information contained
2347 /// in this proto. Incarnations can be compared lexicographically; if
2348 /// incarnation A is greater than incarnation B, then the `Tablet`
2349 /// corresponding to A is newer than the `Tablet` corresponding to B, and
2350 /// should be used preferentially.
2351 pub incarnation: ::bytes::Bytes,
2352
2353 /// Distances help the client pick the closest tablet out of the list of
2354 /// tablets for a given request. Tablets with lower distances should generally
2355 /// be preferred. Tablets with the same distance are approximately equally
2356 /// close; the client can choose arbitrarily.
2357 ///
2358 /// Distances do not correspond precisely to expected latency, geographical
2359 /// distance, or anything else. Distances should be compared only between
2360 /// tablets of the same group; they are not meaningful between different
2361 /// groups.
2362 ///
2363 /// A value of zero indicates that the tablet may be in the same zone as
2364 /// the client, and have minimum network latency. A value less than or equal to
2365 /// five indicates that the tablet is thought to be in the same region as the
2366 /// client, and may have a few milliseconds of network latency. Values greater
2367 /// than five are most likely in a different region, with non-trivial network
2368 /// latency.
2369 ///
2370 /// Clients should use the following algorithm:
2371 ///
2372 /// * If the request is using a directed read, eliminate any tablets that
2373 /// do not match the directed read's target zone and/or replica type.
2374 /// * (Read-write transactions only) Choose leader tablet if it has an
2375 /// distance <=5.
2376 /// * Group and sort tablets by distance. Choose a random
2377 /// tablet with the lowest distance. If the request
2378 /// is not a directed read, only consider replicas with distances <=5.
2379 /// * Send the request to the fallback endpoint.
2380 ///
2381 /// The tablet picked by this algorithm may be skipped, either because it is
2382 /// marked as `skip` by the server or because the corresponding server is
2383 /// unreachable, flow controlled, etc. Skipped tablets should be added to the
2384 /// `skipped_tablet_uid` field in `RoutingHint`; the algorithm above should
2385 /// then be re-run without including the skipped tablet(s) to pick the next
2386 /// best tablet.
2387 pub distance: u32,
2388
2389 /// If true, the tablet should not be chosen by the client. Typically, this
2390 /// signals that the tablet is unhealthy in some way. Tablets with `skip`
2391 /// set to true should be reported back to the server in
2392 /// `RoutingHint.skipped_tablet_uid`; this cues the server to send updated
2393 /// information for this tablet should it become usable again.
2394 pub skip: bool,
2395
2396 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2397}
2398
2399impl Tablet {
2400 /// Creates a new default instance.
2401 pub fn new() -> Self {
2402 std::default::Default::default()
2403 }
2404
2405 /// Sets the value of [tablet_uid][crate::model::Tablet::tablet_uid].
2406 pub fn set_tablet_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2407 self.tablet_uid = v.into();
2408 self
2409 }
2410
2411 /// Sets the value of [server_address][crate::model::Tablet::server_address].
2412 pub fn set_server_address<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2413 self.server_address = v.into();
2414 self
2415 }
2416
2417 /// Sets the value of [location][crate::model::Tablet::location].
2418 pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2419 self.location = v.into();
2420 self
2421 }
2422
2423 /// Sets the value of [role][crate::model::Tablet::role].
2424 pub fn set_role<T: std::convert::Into<crate::model::tablet::Role>>(mut self, v: T) -> Self {
2425 self.role = v.into();
2426 self
2427 }
2428
2429 /// Sets the value of [incarnation][crate::model::Tablet::incarnation].
2430 pub fn set_incarnation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2431 self.incarnation = v.into();
2432 self
2433 }
2434
2435 /// Sets the value of [distance][crate::model::Tablet::distance].
2436 pub fn set_distance<T: std::convert::Into<u32>>(mut self, v: T) -> Self {
2437 self.distance = v.into();
2438 self
2439 }
2440
2441 /// Sets the value of [skip][crate::model::Tablet::skip].
2442 pub fn set_skip<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2443 self.skip = v.into();
2444 self
2445 }
2446}
2447
2448impl wkt::message::Message for Tablet {
2449 fn typename() -> &'static str {
2450 "type.googleapis.com/google.spanner.v1.Tablet"
2451 }
2452}
2453
2454/// Defines additional types related to [Tablet].
2455pub mod tablet {
2456 #[allow(unused_imports)]
2457 use super::*;
2458
2459 /// Indicates the role of the tablet.
2460 ///
2461 /// # Working with unknown values
2462 ///
2463 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2464 /// additional enum variants at any time. Adding new variants is not considered
2465 /// a breaking change. Applications should write their code in anticipation of:
2466 ///
2467 /// - New values appearing in future releases of the client library, **and**
2468 /// - New values received dynamically, without application changes.
2469 ///
2470 /// Please consult the [Working with enums] section in the user guide for some
2471 /// guidelines.
2472 ///
2473 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2474 #[derive(Clone, Debug, PartialEq)]
2475 #[non_exhaustive]
2476 pub enum Role {
2477 /// Not specified.
2478 Unspecified,
2479 /// The tablet can perform reads and (if elected leader) writes.
2480 ReadWrite,
2481 /// The tablet can only perform reads.
2482 ReadOnly,
2483 /// If set, the enum was initialized with an unknown value.
2484 ///
2485 /// Applications can examine the value using [Role::value] or
2486 /// [Role::name].
2487 UnknownValue(role::UnknownValue),
2488 }
2489
2490 #[doc(hidden)]
2491 pub mod role {
2492 #[allow(unused_imports)]
2493 use super::*;
2494 #[derive(Clone, Debug, PartialEq)]
2495 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2496 }
2497
2498 impl Role {
2499 /// Gets the enum value.
2500 ///
2501 /// Returns `None` if the enum contains an unknown value deserialized from
2502 /// the string representation of enums.
2503 pub fn value(&self) -> std::option::Option<i32> {
2504 match self {
2505 Self::Unspecified => std::option::Option::Some(0),
2506 Self::ReadWrite => std::option::Option::Some(1),
2507 Self::ReadOnly => std::option::Option::Some(2),
2508 Self::UnknownValue(u) => u.0.value(),
2509 }
2510 }
2511
2512 /// Gets the enum value as a string.
2513 ///
2514 /// Returns `None` if the enum contains an unknown value deserialized from
2515 /// the integer representation of enums.
2516 pub fn name(&self) -> std::option::Option<&str> {
2517 match self {
2518 Self::Unspecified => std::option::Option::Some("ROLE_UNSPECIFIED"),
2519 Self::ReadWrite => std::option::Option::Some("READ_WRITE"),
2520 Self::ReadOnly => std::option::Option::Some("READ_ONLY"),
2521 Self::UnknownValue(u) => u.0.name(),
2522 }
2523 }
2524 }
2525
2526 impl std::default::Default for Role {
2527 fn default() -> Self {
2528 use std::convert::From;
2529 Self::from(0)
2530 }
2531 }
2532
2533 impl std::fmt::Display for Role {
2534 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2535 wkt::internal::display_enum(f, self.name(), self.value())
2536 }
2537 }
2538
2539 impl std::convert::From<i32> for Role {
2540 fn from(value: i32) -> Self {
2541 match value {
2542 0 => Self::Unspecified,
2543 1 => Self::ReadWrite,
2544 2 => Self::ReadOnly,
2545 _ => Self::UnknownValue(role::UnknownValue(
2546 wkt::internal::UnknownEnumValue::Integer(value),
2547 )),
2548 }
2549 }
2550 }
2551
2552 impl std::convert::From<&str> for Role {
2553 fn from(value: &str) -> Self {
2554 use std::string::ToString;
2555 match value {
2556 "ROLE_UNSPECIFIED" => Self::Unspecified,
2557 "READ_WRITE" => Self::ReadWrite,
2558 "READ_ONLY" => Self::ReadOnly,
2559 _ => Self::UnknownValue(role::UnknownValue(
2560 wkt::internal::UnknownEnumValue::String(value.to_string()),
2561 )),
2562 }
2563 }
2564 }
2565
2566 impl serde::ser::Serialize for Role {
2567 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2568 where
2569 S: serde::Serializer,
2570 {
2571 match self {
2572 Self::Unspecified => serializer.serialize_i32(0),
2573 Self::ReadWrite => serializer.serialize_i32(1),
2574 Self::ReadOnly => serializer.serialize_i32(2),
2575 Self::UnknownValue(u) => u.0.serialize(serializer),
2576 }
2577 }
2578 }
2579
2580 impl<'de> serde::de::Deserialize<'de> for Role {
2581 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2582 where
2583 D: serde::Deserializer<'de>,
2584 {
2585 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Role>::new(
2586 ".google.spanner.v1.Tablet.Role",
2587 ))
2588 }
2589 }
2590}
2591
2592/// A `Group` represents a paxos group in a database. A group is a set of
2593/// tablets that are replicated across multiple servers. Groups may have a leader
2594/// tablet. Groups store one (or sometimes more) ranges of keys.
2595#[derive(Clone, Default, PartialEq)]
2596#[non_exhaustive]
2597pub struct Group {
2598 /// The UID of the paxos group, unique within the database. Matches the
2599 /// `group_uid` field in `Range`.
2600 pub group_uid: u64,
2601
2602 /// A list of tablets that are part of the group. Note that this list may not
2603 /// be exhaustive; it will only include tablets the server considers useful
2604 /// to the client. The returned list is ordered ascending by distance.
2605 ///
2606 /// Tablet UIDs reference `Tablet.tablet_uid`.
2607 pub tablets: std::vec::Vec<crate::model::Tablet>,
2608
2609 /// The last known leader tablet of the group as an index into `tablets`. May
2610 /// be negative if the group has no known leader.
2611 pub leader_index: i32,
2612
2613 /// `generation` indicates the freshness of the group information (including
2614 /// leader information) contained in this proto. Generations can be compared
2615 /// lexicographically; if generation A is greater than generation B, then the
2616 /// `Group` corresponding to A is newer than the `Group` corresponding to B,
2617 /// and should be used preferentially.
2618 pub generation: ::bytes::Bytes,
2619
2620 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2621}
2622
2623impl Group {
2624 /// Creates a new default instance.
2625 pub fn new() -> Self {
2626 std::default::Default::default()
2627 }
2628
2629 /// Sets the value of [group_uid][crate::model::Group::group_uid].
2630 pub fn set_group_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2631 self.group_uid = v.into();
2632 self
2633 }
2634
2635 /// Sets the value of [tablets][crate::model::Group::tablets].
2636 pub fn set_tablets<T, V>(mut self, v: T) -> Self
2637 where
2638 T: std::iter::IntoIterator<Item = V>,
2639 V: std::convert::Into<crate::model::Tablet>,
2640 {
2641 use std::iter::Iterator;
2642 self.tablets = v.into_iter().map(|i| i.into()).collect();
2643 self
2644 }
2645
2646 /// Sets the value of [leader_index][crate::model::Group::leader_index].
2647 pub fn set_leader_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2648 self.leader_index = v.into();
2649 self
2650 }
2651
2652 /// Sets the value of [generation][crate::model::Group::generation].
2653 pub fn set_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2654 self.generation = v.into();
2655 self
2656 }
2657}
2658
2659impl wkt::message::Message for Group {
2660 fn typename() -> &'static str {
2661 "type.googleapis.com/google.spanner.v1.Group"
2662 }
2663}
2664
2665/// A `KeyRecipe` provides the metadata required to translate reads, mutations,
2666/// and queries into a byte array in "sortable string format" (ssformat)that can
2667/// be used with `Range`s to route requests. Note that the client *must* tolerate
2668/// `KeyRecipe`s that appear to be invalid, since the `KeyRecipe` format may
2669/// change over time. Requests with invalid `KeyRecipe`s should be routed to a
2670/// default server.
2671#[derive(Clone, Default, PartialEq)]
2672#[non_exhaustive]
2673pub struct KeyRecipe {
2674 /// Parts are in the order they should appear in the encoded key.
2675 pub part: std::vec::Vec<crate::model::key_recipe::Part>,
2676
2677 /// A recipe can be associated with a table, index, or query. Tables recipes
2678 /// are used to encode read and write keys; index recipes are used for index
2679 /// reads, and query recipes are used only for SQL queries.
2680 pub target: std::option::Option<crate::model::key_recipe::Target>,
2681
2682 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2683}
2684
2685impl KeyRecipe {
2686 /// Creates a new default instance.
2687 pub fn new() -> Self {
2688 std::default::Default::default()
2689 }
2690
2691 /// Sets the value of [part][crate::model::KeyRecipe::part].
2692 pub fn set_part<T, V>(mut self, v: T) -> Self
2693 where
2694 T: std::iter::IntoIterator<Item = V>,
2695 V: std::convert::Into<crate::model::key_recipe::Part>,
2696 {
2697 use std::iter::Iterator;
2698 self.part = v.into_iter().map(|i| i.into()).collect();
2699 self
2700 }
2701
2702 /// Sets the value of [target][crate::model::KeyRecipe::target].
2703 ///
2704 /// Note that all the setters affecting `target` are mutually
2705 /// exclusive.
2706 pub fn set_target<
2707 T: std::convert::Into<std::option::Option<crate::model::key_recipe::Target>>,
2708 >(
2709 mut self,
2710 v: T,
2711 ) -> Self {
2712 self.target = v.into();
2713 self
2714 }
2715
2716 /// The value of [target][crate::model::KeyRecipe::target]
2717 /// if it holds a `TableName`, `None` if the field is not set or
2718 /// holds a different branch.
2719 pub fn table_name(&self) -> std::option::Option<&std::string::String> {
2720 #[allow(unreachable_patterns)]
2721 self.target.as_ref().and_then(|v| match v {
2722 crate::model::key_recipe::Target::TableName(v) => std::option::Option::Some(v),
2723 _ => std::option::Option::None,
2724 })
2725 }
2726
2727 /// Sets the value of [target][crate::model::KeyRecipe::target]
2728 /// to hold a `TableName`.
2729 ///
2730 /// Note that all the setters affecting `target` are
2731 /// mutually exclusive.
2732 pub fn set_table_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2733 self.target =
2734 std::option::Option::Some(crate::model::key_recipe::Target::TableName(v.into()));
2735 self
2736 }
2737
2738 /// The value of [target][crate::model::KeyRecipe::target]
2739 /// if it holds a `IndexName`, `None` if the field is not set or
2740 /// holds a different branch.
2741 pub fn index_name(&self) -> std::option::Option<&std::string::String> {
2742 #[allow(unreachable_patterns)]
2743 self.target.as_ref().and_then(|v| match v {
2744 crate::model::key_recipe::Target::IndexName(v) => std::option::Option::Some(v),
2745 _ => std::option::Option::None,
2746 })
2747 }
2748
2749 /// Sets the value of [target][crate::model::KeyRecipe::target]
2750 /// to hold a `IndexName`.
2751 ///
2752 /// Note that all the setters affecting `target` are
2753 /// mutually exclusive.
2754 pub fn set_index_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2755 self.target =
2756 std::option::Option::Some(crate::model::key_recipe::Target::IndexName(v.into()));
2757 self
2758 }
2759
2760 /// The value of [target][crate::model::KeyRecipe::target]
2761 /// if it holds a `OperationUid`, `None` if the field is not set or
2762 /// holds a different branch.
2763 pub fn operation_uid(&self) -> std::option::Option<&u64> {
2764 #[allow(unreachable_patterns)]
2765 self.target.as_ref().and_then(|v| match v {
2766 crate::model::key_recipe::Target::OperationUid(v) => std::option::Option::Some(v),
2767 _ => std::option::Option::None,
2768 })
2769 }
2770
2771 /// Sets the value of [target][crate::model::KeyRecipe::target]
2772 /// to hold a `OperationUid`.
2773 ///
2774 /// Note that all the setters affecting `target` are
2775 /// mutually exclusive.
2776 pub fn set_operation_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2777 self.target =
2778 std::option::Option::Some(crate::model::key_recipe::Target::OperationUid(v.into()));
2779 self
2780 }
2781}
2782
2783impl wkt::message::Message for KeyRecipe {
2784 fn typename() -> &'static str {
2785 "type.googleapis.com/google.spanner.v1.KeyRecipe"
2786 }
2787}
2788
2789/// Defines additional types related to [KeyRecipe].
2790pub mod key_recipe {
2791 #[allow(unused_imports)]
2792 use super::*;
2793
2794 /// An ssformat key is composed of a sequence of tag numbers and key column
2795 /// values. `Part` represents a single tag or key column value.
2796 #[derive(Clone, Default, PartialEq)]
2797 #[non_exhaustive]
2798 pub struct Part {
2799 /// If non-zero, `tag` is the only field present in this `Part`. The part
2800 /// is encoded by appending `tag` to the ssformat key.
2801 pub tag: u32,
2802
2803 /// Whether the key column is sorted ascending or descending. Only present
2804 /// if `tag` is zero.
2805 pub order: crate::model::key_recipe::part::Order,
2806
2807 /// How NULLs are represented in the encoded key part. Only present if `tag`
2808 /// is zero.
2809 pub null_order: crate::model::key_recipe::part::NullOrder,
2810
2811 /// The type of the key part. Only present if `tag` is zero.
2812 pub r#type: std::option::Option<crate::model::Type>,
2813
2814 /// It is a repeated field to support fetching key columns from nested
2815 /// structs, such as `STRUCT` query parameters.
2816 pub struct_identifiers: std::vec::Vec<i32>,
2817
2818 /// Only present if `tag` is zero.
2819 pub value_type: std::option::Option<crate::model::key_recipe::part::ValueType>,
2820
2821 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2822 }
2823
2824 impl Part {
2825 /// Creates a new default instance.
2826 pub fn new() -> Self {
2827 std::default::Default::default()
2828 }
2829
2830 /// Sets the value of [tag][crate::model::key_recipe::Part::tag].
2831 pub fn set_tag<T: std::convert::Into<u32>>(mut self, v: T) -> Self {
2832 self.tag = v.into();
2833 self
2834 }
2835
2836 /// Sets the value of [order][crate::model::key_recipe::Part::order].
2837 pub fn set_order<T: std::convert::Into<crate::model::key_recipe::part::Order>>(
2838 mut self,
2839 v: T,
2840 ) -> Self {
2841 self.order = v.into();
2842 self
2843 }
2844
2845 /// Sets the value of [null_order][crate::model::key_recipe::Part::null_order].
2846 pub fn set_null_order<T: std::convert::Into<crate::model::key_recipe::part::NullOrder>>(
2847 mut self,
2848 v: T,
2849 ) -> Self {
2850 self.null_order = v.into();
2851 self
2852 }
2853
2854 /// Sets the value of [r#type][crate::model::key_recipe::Part::type].
2855 pub fn set_type<T>(mut self, v: T) -> Self
2856 where
2857 T: std::convert::Into<crate::model::Type>,
2858 {
2859 self.r#type = std::option::Option::Some(v.into());
2860 self
2861 }
2862
2863 /// Sets or clears the value of [r#type][crate::model::key_recipe::Part::type].
2864 pub fn set_or_clear_type<T>(mut self, v: std::option::Option<T>) -> Self
2865 where
2866 T: std::convert::Into<crate::model::Type>,
2867 {
2868 self.r#type = v.map(|x| x.into());
2869 self
2870 }
2871
2872 /// Sets the value of [struct_identifiers][crate::model::key_recipe::Part::struct_identifiers].
2873 pub fn set_struct_identifiers<T, V>(mut self, v: T) -> Self
2874 where
2875 T: std::iter::IntoIterator<Item = V>,
2876 V: std::convert::Into<i32>,
2877 {
2878 use std::iter::Iterator;
2879 self.struct_identifiers = v.into_iter().map(|i| i.into()).collect();
2880 self
2881 }
2882
2883 /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type].
2884 ///
2885 /// Note that all the setters affecting `value_type` are mutually
2886 /// exclusive.
2887 pub fn set_value_type<
2888 T: std::convert::Into<std::option::Option<crate::model::key_recipe::part::ValueType>>,
2889 >(
2890 mut self,
2891 v: T,
2892 ) -> Self {
2893 self.value_type = v.into();
2894 self
2895 }
2896
2897 /// The value of [value_type][crate::model::key_recipe::Part::value_type]
2898 /// if it holds a `Identifier`, `None` if the field is not set or
2899 /// holds a different branch.
2900 pub fn identifier(&self) -> std::option::Option<&std::string::String> {
2901 #[allow(unreachable_patterns)]
2902 self.value_type.as_ref().and_then(|v| match v {
2903 crate::model::key_recipe::part::ValueType::Identifier(v) => {
2904 std::option::Option::Some(v)
2905 }
2906 _ => std::option::Option::None,
2907 })
2908 }
2909
2910 /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type]
2911 /// to hold a `Identifier`.
2912 ///
2913 /// Note that all the setters affecting `value_type` are
2914 /// mutually exclusive.
2915 pub fn set_identifier<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2916 self.value_type = std::option::Option::Some(
2917 crate::model::key_recipe::part::ValueType::Identifier(v.into()),
2918 );
2919 self
2920 }
2921
2922 /// The value of [value_type][crate::model::key_recipe::Part::value_type]
2923 /// if it holds a `Value`, `None` if the field is not set or
2924 /// holds a different branch.
2925 pub fn value(&self) -> std::option::Option<&std::boxed::Box<wkt::Value>> {
2926 #[allow(unreachable_patterns)]
2927 self.value_type.as_ref().and_then(|v| match v {
2928 crate::model::key_recipe::part::ValueType::Value(v) => std::option::Option::Some(v),
2929 _ => std::option::Option::None,
2930 })
2931 }
2932
2933 /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type]
2934 /// to hold a `Value`.
2935 ///
2936 /// Note that all the setters affecting `value_type` are
2937 /// mutually exclusive.
2938 pub fn set_value<T: std::convert::Into<std::boxed::Box<wkt::Value>>>(
2939 mut self,
2940 v: T,
2941 ) -> Self {
2942 self.value_type = std::option::Option::Some(
2943 crate::model::key_recipe::part::ValueType::Value(v.into()),
2944 );
2945 self
2946 }
2947
2948 /// The value of [value_type][crate::model::key_recipe::Part::value_type]
2949 /// if it holds a `Random`, `None` if the field is not set or
2950 /// holds a different branch.
2951 pub fn random(&self) -> std::option::Option<&bool> {
2952 #[allow(unreachable_patterns)]
2953 self.value_type.as_ref().and_then(|v| match v {
2954 crate::model::key_recipe::part::ValueType::Random(v) => {
2955 std::option::Option::Some(v)
2956 }
2957 _ => std::option::Option::None,
2958 })
2959 }
2960
2961 /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type]
2962 /// to hold a `Random`.
2963 ///
2964 /// Note that all the setters affecting `value_type` are
2965 /// mutually exclusive.
2966 pub fn set_random<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2967 self.value_type = std::option::Option::Some(
2968 crate::model::key_recipe::part::ValueType::Random(v.into()),
2969 );
2970 self
2971 }
2972 }
2973
2974 impl wkt::message::Message for Part {
2975 fn typename() -> &'static str {
2976 "type.googleapis.com/google.spanner.v1.KeyRecipe.Part"
2977 }
2978 }
2979
2980 /// Defines additional types related to [Part].
2981 pub mod part {
2982 #[allow(unused_imports)]
2983 use super::*;
2984
2985 /// The remaining fields encode column values.
2986 ///
2987 /// # Working with unknown values
2988 ///
2989 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2990 /// additional enum variants at any time. Adding new variants is not considered
2991 /// a breaking change. Applications should write their code in anticipation of:
2992 ///
2993 /// - New values appearing in future releases of the client library, **and**
2994 /// - New values received dynamically, without application changes.
2995 ///
2996 /// Please consult the [Working with enums] section in the user guide for some
2997 /// guidelines.
2998 ///
2999 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3000 #[derive(Clone, Debug, PartialEq)]
3001 #[non_exhaustive]
3002 pub enum Order {
3003 /// Default value, equivalent to `ASCENDING`.
3004 Unspecified,
3005 /// The key is ascending - corresponds to `ASC` in the schema definition.
3006 Ascending,
3007 /// The key is descending - corresponds to `DESC` in the schema definition.
3008 Descending,
3009 /// If set, the enum was initialized with an unknown value.
3010 ///
3011 /// Applications can examine the value using [Order::value] or
3012 /// [Order::name].
3013 UnknownValue(order::UnknownValue),
3014 }
3015
3016 #[doc(hidden)]
3017 pub mod order {
3018 #[allow(unused_imports)]
3019 use super::*;
3020 #[derive(Clone, Debug, PartialEq)]
3021 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3022 }
3023
3024 impl Order {
3025 /// Gets the enum value.
3026 ///
3027 /// Returns `None` if the enum contains an unknown value deserialized from
3028 /// the string representation of enums.
3029 pub fn value(&self) -> std::option::Option<i32> {
3030 match self {
3031 Self::Unspecified => std::option::Option::Some(0),
3032 Self::Ascending => std::option::Option::Some(1),
3033 Self::Descending => std::option::Option::Some(2),
3034 Self::UnknownValue(u) => u.0.value(),
3035 }
3036 }
3037
3038 /// Gets the enum value as a string.
3039 ///
3040 /// Returns `None` if the enum contains an unknown value deserialized from
3041 /// the integer representation of enums.
3042 pub fn name(&self) -> std::option::Option<&str> {
3043 match self {
3044 Self::Unspecified => std::option::Option::Some("ORDER_UNSPECIFIED"),
3045 Self::Ascending => std::option::Option::Some("ASCENDING"),
3046 Self::Descending => std::option::Option::Some("DESCENDING"),
3047 Self::UnknownValue(u) => u.0.name(),
3048 }
3049 }
3050 }
3051
3052 impl std::default::Default for Order {
3053 fn default() -> Self {
3054 use std::convert::From;
3055 Self::from(0)
3056 }
3057 }
3058
3059 impl std::fmt::Display for Order {
3060 fn fmt(
3061 &self,
3062 f: &mut std::fmt::Formatter<'_>,
3063 ) -> std::result::Result<(), std::fmt::Error> {
3064 wkt::internal::display_enum(f, self.name(), self.value())
3065 }
3066 }
3067
3068 impl std::convert::From<i32> for Order {
3069 fn from(value: i32) -> Self {
3070 match value {
3071 0 => Self::Unspecified,
3072 1 => Self::Ascending,
3073 2 => Self::Descending,
3074 _ => Self::UnknownValue(order::UnknownValue(
3075 wkt::internal::UnknownEnumValue::Integer(value),
3076 )),
3077 }
3078 }
3079 }
3080
3081 impl std::convert::From<&str> for Order {
3082 fn from(value: &str) -> Self {
3083 use std::string::ToString;
3084 match value {
3085 "ORDER_UNSPECIFIED" => Self::Unspecified,
3086 "ASCENDING" => Self::Ascending,
3087 "DESCENDING" => Self::Descending,
3088 _ => Self::UnknownValue(order::UnknownValue(
3089 wkt::internal::UnknownEnumValue::String(value.to_string()),
3090 )),
3091 }
3092 }
3093 }
3094
3095 impl serde::ser::Serialize for Order {
3096 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3097 where
3098 S: serde::Serializer,
3099 {
3100 match self {
3101 Self::Unspecified => serializer.serialize_i32(0),
3102 Self::Ascending => serializer.serialize_i32(1),
3103 Self::Descending => serializer.serialize_i32(2),
3104 Self::UnknownValue(u) => u.0.serialize(serializer),
3105 }
3106 }
3107 }
3108
3109 impl<'de> serde::de::Deserialize<'de> for Order {
3110 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3111 where
3112 D: serde::Deserializer<'de>,
3113 {
3114 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Order>::new(
3115 ".google.spanner.v1.KeyRecipe.Part.Order",
3116 ))
3117 }
3118 }
3119
3120 /// The null order of the key column. This dictates where NULL values sort
3121 /// in the sorted order. Note that columns which are `NOT NULL` can have a
3122 /// special encoding.
3123 ///
3124 /// # Working with unknown values
3125 ///
3126 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3127 /// additional enum variants at any time. Adding new variants is not considered
3128 /// a breaking change. Applications should write their code in anticipation of:
3129 ///
3130 /// - New values appearing in future releases of the client library, **and**
3131 /// - New values received dynamically, without application changes.
3132 ///
3133 /// Please consult the [Working with enums] section in the user guide for some
3134 /// guidelines.
3135 ///
3136 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3137 #[derive(Clone, Debug, PartialEq)]
3138 #[non_exhaustive]
3139 pub enum NullOrder {
3140 /// Default value. This value is unused.
3141 Unspecified,
3142 /// NULL values sort before any non-NULL values.
3143 NullsFirst,
3144 /// NULL values sort after any non-NULL values.
3145 NullsLast,
3146 /// The column does not support NULL values.
3147 NotNull,
3148 /// If set, the enum was initialized with an unknown value.
3149 ///
3150 /// Applications can examine the value using [NullOrder::value] or
3151 /// [NullOrder::name].
3152 UnknownValue(null_order::UnknownValue),
3153 }
3154
3155 #[doc(hidden)]
3156 pub mod null_order {
3157 #[allow(unused_imports)]
3158 use super::*;
3159 #[derive(Clone, Debug, PartialEq)]
3160 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3161 }
3162
3163 impl NullOrder {
3164 /// Gets the enum value.
3165 ///
3166 /// Returns `None` if the enum contains an unknown value deserialized from
3167 /// the string representation of enums.
3168 pub fn value(&self) -> std::option::Option<i32> {
3169 match self {
3170 Self::Unspecified => std::option::Option::Some(0),
3171 Self::NullsFirst => std::option::Option::Some(1),
3172 Self::NullsLast => std::option::Option::Some(2),
3173 Self::NotNull => std::option::Option::Some(3),
3174 Self::UnknownValue(u) => u.0.value(),
3175 }
3176 }
3177
3178 /// Gets the enum value as a string.
3179 ///
3180 /// Returns `None` if the enum contains an unknown value deserialized from
3181 /// the integer representation of enums.
3182 pub fn name(&self) -> std::option::Option<&str> {
3183 match self {
3184 Self::Unspecified => std::option::Option::Some("NULL_ORDER_UNSPECIFIED"),
3185 Self::NullsFirst => std::option::Option::Some("NULLS_FIRST"),
3186 Self::NullsLast => std::option::Option::Some("NULLS_LAST"),
3187 Self::NotNull => std::option::Option::Some("NOT_NULL"),
3188 Self::UnknownValue(u) => u.0.name(),
3189 }
3190 }
3191 }
3192
3193 impl std::default::Default for NullOrder {
3194 fn default() -> Self {
3195 use std::convert::From;
3196 Self::from(0)
3197 }
3198 }
3199
3200 impl std::fmt::Display for NullOrder {
3201 fn fmt(
3202 &self,
3203 f: &mut std::fmt::Formatter<'_>,
3204 ) -> std::result::Result<(), std::fmt::Error> {
3205 wkt::internal::display_enum(f, self.name(), self.value())
3206 }
3207 }
3208
3209 impl std::convert::From<i32> for NullOrder {
3210 fn from(value: i32) -> Self {
3211 match value {
3212 0 => Self::Unspecified,
3213 1 => Self::NullsFirst,
3214 2 => Self::NullsLast,
3215 3 => Self::NotNull,
3216 _ => Self::UnknownValue(null_order::UnknownValue(
3217 wkt::internal::UnknownEnumValue::Integer(value),
3218 )),
3219 }
3220 }
3221 }
3222
3223 impl std::convert::From<&str> for NullOrder {
3224 fn from(value: &str) -> Self {
3225 use std::string::ToString;
3226 match value {
3227 "NULL_ORDER_UNSPECIFIED" => Self::Unspecified,
3228 "NULLS_FIRST" => Self::NullsFirst,
3229 "NULLS_LAST" => Self::NullsLast,
3230 "NOT_NULL" => Self::NotNull,
3231 _ => Self::UnknownValue(null_order::UnknownValue(
3232 wkt::internal::UnknownEnumValue::String(value.to_string()),
3233 )),
3234 }
3235 }
3236 }
3237
3238 impl serde::ser::Serialize for NullOrder {
3239 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3240 where
3241 S: serde::Serializer,
3242 {
3243 match self {
3244 Self::Unspecified => serializer.serialize_i32(0),
3245 Self::NullsFirst => serializer.serialize_i32(1),
3246 Self::NullsLast => serializer.serialize_i32(2),
3247 Self::NotNull => serializer.serialize_i32(3),
3248 Self::UnknownValue(u) => u.0.serialize(serializer),
3249 }
3250 }
3251 }
3252
3253 impl<'de> serde::de::Deserialize<'de> for NullOrder {
3254 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3255 where
3256 D: serde::Deserializer<'de>,
3257 {
3258 deserializer.deserialize_any(wkt::internal::EnumVisitor::<NullOrder>::new(
3259 ".google.spanner.v1.KeyRecipe.Part.NullOrder",
3260 ))
3261 }
3262 }
3263
3264 /// Only present if `tag` is zero.
3265 #[derive(Clone, Debug, PartialEq)]
3266 #[non_exhaustive]
3267 pub enum ValueType {
3268 /// `identifier` is the name of the column or query parameter.
3269 Identifier(std::string::String),
3270 /// The constant value of the key part.
3271 /// It is present when query uses a constant as a part of the key.
3272 Value(std::boxed::Box<wkt::Value>),
3273 /// If true, the client is responsible to fill in the value randomly.
3274 /// It's relevant only for the INT64 type.
3275 Random(bool),
3276 }
3277
3278 impl ValueType {
3279 /// Initializes the enum to the [Identifier](Self::Identifier) branch.
3280 pub fn from_identifier(value: impl std::convert::Into<std::string::String>) -> Self {
3281 Self::Identifier(value.into())
3282 }
3283 /// Initializes the enum to the [Value](Self::Value) branch.
3284 pub fn from_value(value: impl std::convert::Into<std::boxed::Box<wkt::Value>>) -> Self {
3285 Self::Value(value.into())
3286 }
3287 /// Initializes the enum to the [Random](Self::Random) branch.
3288 pub fn from_random(value: impl std::convert::Into<bool>) -> Self {
3289 Self::Random(value.into())
3290 }
3291 }
3292 }
3293
3294 /// A recipe can be associated with a table, index, or query. Tables recipes
3295 /// are used to encode read and write keys; index recipes are used for index
3296 /// reads, and query recipes are used only for SQL queries.
3297 #[derive(Clone, Debug, PartialEq)]
3298 #[non_exhaustive]
3299 pub enum Target {
3300 /// A table name, matching the name from the database schema.
3301 TableName(std::string::String),
3302 /// An index name, matching the name from the database schema.
3303 IndexName(std::string::String),
3304 /// The UID of a query, matching the UID from `RoutingHint`.
3305 OperationUid(u64),
3306 }
3307
3308 impl Target {
3309 /// Initializes the enum to the [TableName](Self::TableName) branch.
3310 pub fn from_table_name(value: impl std::convert::Into<std::string::String>) -> Self {
3311 Self::TableName(value.into())
3312 }
3313 /// Initializes the enum to the [IndexName](Self::IndexName) branch.
3314 pub fn from_index_name(value: impl std::convert::Into<std::string::String>) -> Self {
3315 Self::IndexName(value.into())
3316 }
3317 /// Initializes the enum to the [OperationUid](Self::OperationUid) branch.
3318 pub fn from_operation_uid(value: impl std::convert::Into<u64>) -> Self {
3319 Self::OperationUid(value.into())
3320 }
3321 }
3322}
3323
3324/// A `RecipeList` contains a list of `KeyRecipe`s, which share the same
3325/// schema generation.
3326#[derive(Clone, Default, PartialEq)]
3327#[non_exhaustive]
3328pub struct RecipeList {
3329 /// The schema generation of the recipes. To be sent to the server in
3330 /// `RoutingHint.schema_generation` whenever one of the recipes is used.
3331 /// `schema_generation` values are comparable with each other; if generation A
3332 /// compares greater than generation B, then A is a more recent schema than B.
3333 /// Clients should in general aim to cache only the latest schema generation,
3334 /// and discard more stale recipes.
3335 pub schema_generation: ::bytes::Bytes,
3336
3337 /// A list of recipes to be cached.
3338 pub recipe: std::vec::Vec<crate::model::KeyRecipe>,
3339
3340 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3341}
3342
3343impl RecipeList {
3344 /// Creates a new default instance.
3345 pub fn new() -> Self {
3346 std::default::Default::default()
3347 }
3348
3349 /// Sets the value of [schema_generation][crate::model::RecipeList::schema_generation].
3350 pub fn set_schema_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3351 self.schema_generation = v.into();
3352 self
3353 }
3354
3355 /// Sets the value of [recipe][crate::model::RecipeList::recipe].
3356 pub fn set_recipe<T, V>(mut self, v: T) -> Self
3357 where
3358 T: std::iter::IntoIterator<Item = V>,
3359 V: std::convert::Into<crate::model::KeyRecipe>,
3360 {
3361 use std::iter::Iterator;
3362 self.recipe = v.into_iter().map(|i| i.into()).collect();
3363 self
3364 }
3365}
3366
3367impl wkt::message::Message for RecipeList {
3368 fn typename() -> &'static str {
3369 "type.googleapis.com/google.spanner.v1.RecipeList"
3370 }
3371}
3372
3373/// A `CacheUpdate` expresses a set of changes the client should incorporate into
3374/// its location cache. These changes may or may not be newer than what the
3375/// client has in its cache, and should be discarded if necessary. `CacheUpdate`s
3376/// can be obtained in response to requests that included a `RoutingHint`
3377/// field, but may also be obtained by explicit location-fetching RPCs which may
3378/// be added in the future.
3379#[derive(Clone, Default, PartialEq)]
3380#[non_exhaustive]
3381pub struct CacheUpdate {
3382 /// An internal ID for the database. Database names can be reused if a database
3383 /// is deleted and re-created. Each time the database is re-created, it will
3384 /// get a new database ID, which will never be re-used for any other database.
3385 pub database_id: u64,
3386
3387 /// A list of ranges to be cached.
3388 pub range: std::vec::Vec<crate::model::Range>,
3389
3390 /// A list of groups to be cached.
3391 pub group: std::vec::Vec<crate::model::Group>,
3392
3393 /// A list of recipes to be cached.
3394 pub key_recipes: std::option::Option<crate::model::RecipeList>,
3395
3396 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3397}
3398
3399impl CacheUpdate {
3400 /// Creates a new default instance.
3401 pub fn new() -> Self {
3402 std::default::Default::default()
3403 }
3404
3405 /// Sets the value of [database_id][crate::model::CacheUpdate::database_id].
3406 pub fn set_database_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3407 self.database_id = v.into();
3408 self
3409 }
3410
3411 /// Sets the value of [range][crate::model::CacheUpdate::range].
3412 pub fn set_range<T, V>(mut self, v: T) -> Self
3413 where
3414 T: std::iter::IntoIterator<Item = V>,
3415 V: std::convert::Into<crate::model::Range>,
3416 {
3417 use std::iter::Iterator;
3418 self.range = v.into_iter().map(|i| i.into()).collect();
3419 self
3420 }
3421
3422 /// Sets the value of [group][crate::model::CacheUpdate::group].
3423 pub fn set_group<T, V>(mut self, v: T) -> Self
3424 where
3425 T: std::iter::IntoIterator<Item = V>,
3426 V: std::convert::Into<crate::model::Group>,
3427 {
3428 use std::iter::Iterator;
3429 self.group = v.into_iter().map(|i| i.into()).collect();
3430 self
3431 }
3432
3433 /// Sets the value of [key_recipes][crate::model::CacheUpdate::key_recipes].
3434 pub fn set_key_recipes<T>(mut self, v: T) -> Self
3435 where
3436 T: std::convert::Into<crate::model::RecipeList>,
3437 {
3438 self.key_recipes = std::option::Option::Some(v.into());
3439 self
3440 }
3441
3442 /// Sets or clears the value of [key_recipes][crate::model::CacheUpdate::key_recipes].
3443 pub fn set_or_clear_key_recipes<T>(mut self, v: std::option::Option<T>) -> Self
3444 where
3445 T: std::convert::Into<crate::model::RecipeList>,
3446 {
3447 self.key_recipes = v.map(|x| x.into());
3448 self
3449 }
3450}
3451
3452impl wkt::message::Message for CacheUpdate {
3453 fn typename() -> &'static str {
3454 "type.googleapis.com/google.spanner.v1.CacheUpdate"
3455 }
3456}
3457
3458/// `RoutingHint` can be optionally added to location-aware Spanner
3459/// requests. It gives the server hints that can be used to route the request to
3460/// an appropriate server, potentially significantly decreasing latency and
3461/// improving throughput. To achieve improved performance, most fields must be
3462/// filled in with accurate values.
3463///
3464/// The presence of a valid `RoutingHint` tells the server that the client
3465/// is location-aware.
3466///
3467/// `RoutingHint` does not change the semantics of the request; it is
3468/// purely a performance hint; the request will perform the same actions on the
3469/// database's data as if `RoutingHint` were not present. However, if
3470/// the `RoutingHint` is incomplete or incorrect, the response may include
3471/// a `CacheUpdate` the client can use to correct its location cache.
3472#[derive(Clone, Default, PartialEq)]
3473#[non_exhaustive]
3474pub struct RoutingHint {
3475 /// A session-scoped unique ID for the operation, computed client-side.
3476 /// Requests with the same `operation_uid` should have a shared 'shape',
3477 /// meaning that some fields are expected to be the same, such as the SQL
3478 /// query, the target table/columns (for reads) etc. Requests with the same
3479 /// `operation_uid` are meant to differ only in fields like keys/key
3480 /// ranges/query parameters, transaction IDs, etc.
3481 ///
3482 /// `operation_uid` must be non-zero for `RoutingHint` to be valid.
3483 pub operation_uid: u64,
3484
3485 /// The database ID of the database being accessed, see
3486 /// `CacheUpdate.database_id`. Should match the cache entries that were used
3487 /// to generate the rest of the fields in this `RoutingHint`.
3488 pub database_id: u64,
3489
3490 /// The schema generation of the recipe that was used to generate `key` and
3491 /// `limit_key`. See also `RecipeList.schema_generation`.
3492 pub schema_generation: ::bytes::Bytes,
3493
3494 /// The key / key range that this request accesses. For operations that
3495 /// access a single key, `key` should be set and `limit_key` should be empty.
3496 /// For operations that access a key range, `key` and `limit_key` should both
3497 /// be set, to the inclusive start and exclusive end of the range respectively.
3498 ///
3499 /// The keys are encoded in "sortable string format" (ssformat), using a
3500 /// `KeyRecipe` that is appropriate for the request. See `KeyRecipe` for more
3501 /// details.
3502 pub key: ::bytes::Bytes,
3503
3504 /// If this request targets a key range, this is the exclusive end of the
3505 /// range. See `key` for more details.
3506 pub limit_key: ::bytes::Bytes,
3507
3508 /// The group UID of the group that the client believes serves the range
3509 /// defined by `key` and `limit_key`. See `Range.group_uid` for more details.
3510 pub group_uid: u64,
3511
3512 /// The split ID of the split that the client believes contains the range
3513 /// defined by `key` and `limit_key`. See `Range.split_id` for more details.
3514 pub split_id: u64,
3515
3516 /// The tablet UID of the tablet from group `group_uid` that the client
3517 /// believes is best to serve this request. See `Group.local_tablet_uids` and
3518 /// `Group.leader_tablet_uid`.
3519 pub tablet_uid: u64,
3520
3521 /// If the client had multiple options for tablet selection, and some of its
3522 /// first choices were unhealthy (e.g., the server is unreachable, or
3523 /// `Tablet.skip` is true), this field will contain the tablet UIDs of those
3524 /// tablets, with their incarnations. The server may include a `CacheUpdate`
3525 /// with new locations for those tablets.
3526 pub skipped_tablet_uid: std::vec::Vec<crate::model::routing_hint::SkippedTablet>,
3527
3528 /// If present, the client's current location. This should be the name of a
3529 /// Google Cloud zone or region, such as "us-central1".
3530 ///
3531 /// If absent, the client's location will be assumed to be the same as the
3532 /// location of the server the client ends up connected to.
3533 ///
3534 /// Locations are primarily valuable for clients that connect from regions
3535 /// other than the ones that contain the Spanner database.
3536 pub client_location: std::string::String,
3537
3538 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3539}
3540
3541impl RoutingHint {
3542 /// Creates a new default instance.
3543 pub fn new() -> Self {
3544 std::default::Default::default()
3545 }
3546
3547 /// Sets the value of [operation_uid][crate::model::RoutingHint::operation_uid].
3548 pub fn set_operation_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3549 self.operation_uid = v.into();
3550 self
3551 }
3552
3553 /// Sets the value of [database_id][crate::model::RoutingHint::database_id].
3554 pub fn set_database_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3555 self.database_id = v.into();
3556 self
3557 }
3558
3559 /// Sets the value of [schema_generation][crate::model::RoutingHint::schema_generation].
3560 pub fn set_schema_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3561 self.schema_generation = v.into();
3562 self
3563 }
3564
3565 /// Sets the value of [key][crate::model::RoutingHint::key].
3566 pub fn set_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3567 self.key = v.into();
3568 self
3569 }
3570
3571 /// Sets the value of [limit_key][crate::model::RoutingHint::limit_key].
3572 pub fn set_limit_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3573 self.limit_key = v.into();
3574 self
3575 }
3576
3577 /// Sets the value of [group_uid][crate::model::RoutingHint::group_uid].
3578 pub fn set_group_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3579 self.group_uid = v.into();
3580 self
3581 }
3582
3583 /// Sets the value of [split_id][crate::model::RoutingHint::split_id].
3584 pub fn set_split_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3585 self.split_id = v.into();
3586 self
3587 }
3588
3589 /// Sets the value of [tablet_uid][crate::model::RoutingHint::tablet_uid].
3590 pub fn set_tablet_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3591 self.tablet_uid = v.into();
3592 self
3593 }
3594
3595 /// Sets the value of [skipped_tablet_uid][crate::model::RoutingHint::skipped_tablet_uid].
3596 pub fn set_skipped_tablet_uid<T, V>(mut self, v: T) -> Self
3597 where
3598 T: std::iter::IntoIterator<Item = V>,
3599 V: std::convert::Into<crate::model::routing_hint::SkippedTablet>,
3600 {
3601 use std::iter::Iterator;
3602 self.skipped_tablet_uid = v.into_iter().map(|i| i.into()).collect();
3603 self
3604 }
3605
3606 /// Sets the value of [client_location][crate::model::RoutingHint::client_location].
3607 pub fn set_client_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3608 self.client_location = v.into();
3609 self
3610 }
3611}
3612
3613impl wkt::message::Message for RoutingHint {
3614 fn typename() -> &'static str {
3615 "type.googleapis.com/google.spanner.v1.RoutingHint"
3616 }
3617}
3618
3619/// Defines additional types related to [RoutingHint].
3620pub mod routing_hint {
3621 #[allow(unused_imports)]
3622 use super::*;
3623
3624 /// A tablet that was skipped by the client. See `Tablet.tablet_uid` and
3625 /// `Tablet.incarnation`.
3626 #[derive(Clone, Default, PartialEq)]
3627 #[non_exhaustive]
3628 pub struct SkippedTablet {
3629 /// The tablet UID of the tablet that was skipped. See `Tablet.tablet_uid`.
3630 pub tablet_uid: u64,
3631
3632 /// The incarnation of the tablet that was skipped. See `Tablet.incarnation`.
3633 pub incarnation: ::bytes::Bytes,
3634
3635 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3636 }
3637
3638 impl SkippedTablet {
3639 /// Creates a new default instance.
3640 pub fn new() -> Self {
3641 std::default::Default::default()
3642 }
3643
3644 /// Sets the value of [tablet_uid][crate::model::routing_hint::SkippedTablet::tablet_uid].
3645 pub fn set_tablet_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3646 self.tablet_uid = v.into();
3647 self
3648 }
3649
3650 /// Sets the value of [incarnation][crate::model::routing_hint::SkippedTablet::incarnation].
3651 pub fn set_incarnation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3652 self.incarnation = v.into();
3653 self
3654 }
3655 }
3656
3657 impl wkt::message::Message for SkippedTablet {
3658 fn typename() -> &'static str {
3659 "type.googleapis.com/google.spanner.v1.RoutingHint.SkippedTablet"
3660 }
3661 }
3662}
3663
3664/// A modification to one or more Cloud Spanner rows. Mutations can be
3665/// applied to a Cloud Spanner database by sending them in a
3666/// [Commit][google.spanner.v1.Spanner.Commit] call.
3667///
3668/// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
3669#[derive(Clone, Default, PartialEq)]
3670#[non_exhaustive]
3671pub struct Mutation {
3672 /// Required. The operation to perform.
3673 pub operation: std::option::Option<crate::model::mutation::Operation>,
3674
3675 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3676}
3677
3678impl Mutation {
3679 /// Creates a new default instance.
3680 pub fn new() -> Self {
3681 std::default::Default::default()
3682 }
3683
3684 /// Sets the value of [operation][crate::model::Mutation::operation].
3685 ///
3686 /// Note that all the setters affecting `operation` are mutually
3687 /// exclusive.
3688 pub fn set_operation<
3689 T: std::convert::Into<std::option::Option<crate::model::mutation::Operation>>,
3690 >(
3691 mut self,
3692 v: T,
3693 ) -> Self {
3694 self.operation = v.into();
3695 self
3696 }
3697
3698 /// The value of [operation][crate::model::Mutation::operation]
3699 /// if it holds a `Insert`, `None` if the field is not set or
3700 /// holds a different branch.
3701 pub fn insert(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3702 #[allow(unreachable_patterns)]
3703 self.operation.as_ref().and_then(|v| match v {
3704 crate::model::mutation::Operation::Insert(v) => std::option::Option::Some(v),
3705 _ => std::option::Option::None,
3706 })
3707 }
3708
3709 /// Sets the value of [operation][crate::model::Mutation::operation]
3710 /// to hold a `Insert`.
3711 ///
3712 /// Note that all the setters affecting `operation` are
3713 /// mutually exclusive.
3714 pub fn set_insert<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>>(
3715 mut self,
3716 v: T,
3717 ) -> Self {
3718 self.operation =
3719 std::option::Option::Some(crate::model::mutation::Operation::Insert(v.into()));
3720 self
3721 }
3722
3723 /// The value of [operation][crate::model::Mutation::operation]
3724 /// if it holds a `Update`, `None` if the field is not set or
3725 /// holds a different branch.
3726 pub fn update(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3727 #[allow(unreachable_patterns)]
3728 self.operation.as_ref().and_then(|v| match v {
3729 crate::model::mutation::Operation::Update(v) => std::option::Option::Some(v),
3730 _ => std::option::Option::None,
3731 })
3732 }
3733
3734 /// Sets the value of [operation][crate::model::Mutation::operation]
3735 /// to hold a `Update`.
3736 ///
3737 /// Note that all the setters affecting `operation` are
3738 /// mutually exclusive.
3739 pub fn set_update<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>>(
3740 mut self,
3741 v: T,
3742 ) -> Self {
3743 self.operation =
3744 std::option::Option::Some(crate::model::mutation::Operation::Update(v.into()));
3745 self
3746 }
3747
3748 /// The value of [operation][crate::model::Mutation::operation]
3749 /// if it holds a `InsertOrUpdate`, `None` if the field is not set or
3750 /// holds a different branch.
3751 pub fn insert_or_update(
3752 &self,
3753 ) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3754 #[allow(unreachable_patterns)]
3755 self.operation.as_ref().and_then(|v| match v {
3756 crate::model::mutation::Operation::InsertOrUpdate(v) => std::option::Option::Some(v),
3757 _ => std::option::Option::None,
3758 })
3759 }
3760
3761 /// Sets the value of [operation][crate::model::Mutation::operation]
3762 /// to hold a `InsertOrUpdate`.
3763 ///
3764 /// Note that all the setters affecting `operation` are
3765 /// mutually exclusive.
3766 pub fn set_insert_or_update<
3767 T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
3768 >(
3769 mut self,
3770 v: T,
3771 ) -> Self {
3772 self.operation =
3773 std::option::Option::Some(crate::model::mutation::Operation::InsertOrUpdate(v.into()));
3774 self
3775 }
3776
3777 /// The value of [operation][crate::model::Mutation::operation]
3778 /// if it holds a `Replace`, `None` if the field is not set or
3779 /// holds a different branch.
3780 pub fn replace(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3781 #[allow(unreachable_patterns)]
3782 self.operation.as_ref().and_then(|v| match v {
3783 crate::model::mutation::Operation::Replace(v) => std::option::Option::Some(v),
3784 _ => std::option::Option::None,
3785 })
3786 }
3787
3788 /// Sets the value of [operation][crate::model::Mutation::operation]
3789 /// to hold a `Replace`.
3790 ///
3791 /// Note that all the setters affecting `operation` are
3792 /// mutually exclusive.
3793 pub fn set_replace<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>>(
3794 mut self,
3795 v: T,
3796 ) -> Self {
3797 self.operation =
3798 std::option::Option::Some(crate::model::mutation::Operation::Replace(v.into()));
3799 self
3800 }
3801
3802 /// The value of [operation][crate::model::Mutation::operation]
3803 /// if it holds a `Delete`, `None` if the field is not set or
3804 /// holds a different branch.
3805 pub fn delete(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Delete>> {
3806 #[allow(unreachable_patterns)]
3807 self.operation.as_ref().and_then(|v| match v {
3808 crate::model::mutation::Operation::Delete(v) => std::option::Option::Some(v),
3809 _ => std::option::Option::None,
3810 })
3811 }
3812
3813 /// Sets the value of [operation][crate::model::Mutation::operation]
3814 /// to hold a `Delete`.
3815 ///
3816 /// Note that all the setters affecting `operation` are
3817 /// mutually exclusive.
3818 pub fn set_delete<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Delete>>>(
3819 mut self,
3820 v: T,
3821 ) -> Self {
3822 self.operation =
3823 std::option::Option::Some(crate::model::mutation::Operation::Delete(v.into()));
3824 self
3825 }
3826
3827 /// The value of [operation][crate::model::Mutation::operation]
3828 /// if it holds a `Send`, `None` if the field is not set or
3829 /// holds a different branch.
3830 pub fn send(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Send>> {
3831 #[allow(unreachable_patterns)]
3832 self.operation.as_ref().and_then(|v| match v {
3833 crate::model::mutation::Operation::Send(v) => std::option::Option::Some(v),
3834 _ => std::option::Option::None,
3835 })
3836 }
3837
3838 /// Sets the value of [operation][crate::model::Mutation::operation]
3839 /// to hold a `Send`.
3840 ///
3841 /// Note that all the setters affecting `operation` are
3842 /// mutually exclusive.
3843 pub fn set_send<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Send>>>(
3844 mut self,
3845 v: T,
3846 ) -> Self {
3847 self.operation =
3848 std::option::Option::Some(crate::model::mutation::Operation::Send(v.into()));
3849 self
3850 }
3851
3852 /// The value of [operation][crate::model::Mutation::operation]
3853 /// if it holds a `Ack`, `None` if the field is not set or
3854 /// holds a different branch.
3855 pub fn ack(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Ack>> {
3856 #[allow(unreachable_patterns)]
3857 self.operation.as_ref().and_then(|v| match v {
3858 crate::model::mutation::Operation::Ack(v) => std::option::Option::Some(v),
3859 _ => std::option::Option::None,
3860 })
3861 }
3862
3863 /// Sets the value of [operation][crate::model::Mutation::operation]
3864 /// to hold a `Ack`.
3865 ///
3866 /// Note that all the setters affecting `operation` are
3867 /// mutually exclusive.
3868 pub fn set_ack<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Ack>>>(
3869 mut self,
3870 v: T,
3871 ) -> Self {
3872 self.operation =
3873 std::option::Option::Some(crate::model::mutation::Operation::Ack(v.into()));
3874 self
3875 }
3876}
3877
3878impl wkt::message::Message for Mutation {
3879 fn typename() -> &'static str {
3880 "type.googleapis.com/google.spanner.v1.Mutation"
3881 }
3882}
3883
3884/// Defines additional types related to [Mutation].
3885pub mod mutation {
3886 #[allow(unused_imports)]
3887 use super::*;
3888
3889 /// Arguments to [insert][google.spanner.v1.Mutation.insert],
3890 /// [update][google.spanner.v1.Mutation.update],
3891 /// [insert_or_update][google.spanner.v1.Mutation.insert_or_update], and
3892 /// [replace][google.spanner.v1.Mutation.replace] operations.
3893 ///
3894 /// [google.spanner.v1.Mutation.insert]: crate::model::Mutation::operation
3895 /// [google.spanner.v1.Mutation.insert_or_update]: crate::model::Mutation::operation
3896 /// [google.spanner.v1.Mutation.replace]: crate::model::Mutation::operation
3897 /// [google.spanner.v1.Mutation.update]: crate::model::Mutation::operation
3898 #[derive(Clone, Default, PartialEq)]
3899 #[non_exhaustive]
3900 pub struct Write {
3901 /// Required. The table whose rows will be written.
3902 pub table: std::string::String,
3903
3904 /// The names of the columns in
3905 /// [table][google.spanner.v1.Mutation.Write.table] to be written.
3906 ///
3907 /// The list of columns must contain enough columns to allow
3908 /// Cloud Spanner to derive values for all primary key columns in the
3909 /// row(s) to be modified.
3910 ///
3911 /// [google.spanner.v1.Mutation.Write.table]: crate::model::mutation::Write::table
3912 pub columns: std::vec::Vec<std::string::String>,
3913
3914 /// The values to be written. `values` can contain more than one
3915 /// list of values. If it does, then multiple rows are written, one
3916 /// for each entry in `values`. Each list in `values` must have
3917 /// exactly as many entries as there are entries in
3918 /// [columns][google.spanner.v1.Mutation.Write.columns] above. Sending
3919 /// multiple lists is equivalent to sending multiple `Mutation`s, each
3920 /// containing one `values` entry and repeating
3921 /// [table][google.spanner.v1.Mutation.Write.table] and
3922 /// [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in
3923 /// each list are encoded as described [here][google.spanner.v1.TypeCode].
3924 ///
3925 /// [google.spanner.v1.Mutation.Write.columns]: crate::model::mutation::Write::columns
3926 /// [google.spanner.v1.Mutation.Write.table]: crate::model::mutation::Write::table
3927 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
3928 pub values: std::vec::Vec<wkt::ListValue>,
3929
3930 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3931 }
3932
3933 impl Write {
3934 /// Creates a new default instance.
3935 pub fn new() -> Self {
3936 std::default::Default::default()
3937 }
3938
3939 /// Sets the value of [table][crate::model::mutation::Write::table].
3940 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3941 self.table = v.into();
3942 self
3943 }
3944
3945 /// Sets the value of [columns][crate::model::mutation::Write::columns].
3946 pub fn set_columns<T, V>(mut self, v: T) -> Self
3947 where
3948 T: std::iter::IntoIterator<Item = V>,
3949 V: std::convert::Into<std::string::String>,
3950 {
3951 use std::iter::Iterator;
3952 self.columns = v.into_iter().map(|i| i.into()).collect();
3953 self
3954 }
3955
3956 /// Sets the value of [values][crate::model::mutation::Write::values].
3957 pub fn set_values<T, V>(mut self, v: T) -> Self
3958 where
3959 T: std::iter::IntoIterator<Item = V>,
3960 V: std::convert::Into<wkt::ListValue>,
3961 {
3962 use std::iter::Iterator;
3963 self.values = v.into_iter().map(|i| i.into()).collect();
3964 self
3965 }
3966 }
3967
3968 impl wkt::message::Message for Write {
3969 fn typename() -> &'static str {
3970 "type.googleapis.com/google.spanner.v1.Mutation.Write"
3971 }
3972 }
3973
3974 /// Arguments to [delete][google.spanner.v1.Mutation.delete] operations.
3975 ///
3976 /// [google.spanner.v1.Mutation.delete]: crate::model::Mutation::operation
3977 #[derive(Clone, Default, PartialEq)]
3978 #[non_exhaustive]
3979 pub struct Delete {
3980 /// Required. The table whose rows will be deleted.
3981 pub table: std::string::String,
3982
3983 /// Required. The primary keys of the rows within
3984 /// [table][google.spanner.v1.Mutation.Delete.table] to delete. The primary
3985 /// keys must be specified in the order in which they appear in the `PRIMARY
3986 /// KEY()` clause of the table's equivalent DDL statement (the DDL statement
3987 /// used to create the table). Delete is idempotent. The transaction will
3988 /// succeed even if some or all rows do not exist.
3989 ///
3990 /// [google.spanner.v1.Mutation.Delete.table]: crate::model::mutation::Delete::table
3991 pub key_set: std::option::Option<crate::model::KeySet>,
3992
3993 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3994 }
3995
3996 impl Delete {
3997 /// Creates a new default instance.
3998 pub fn new() -> Self {
3999 std::default::Default::default()
4000 }
4001
4002 /// Sets the value of [table][crate::model::mutation::Delete::table].
4003 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4004 self.table = v.into();
4005 self
4006 }
4007
4008 /// Sets the value of [key_set][crate::model::mutation::Delete::key_set].
4009 pub fn set_key_set<T>(mut self, v: T) -> Self
4010 where
4011 T: std::convert::Into<crate::model::KeySet>,
4012 {
4013 self.key_set = std::option::Option::Some(v.into());
4014 self
4015 }
4016
4017 /// Sets or clears the value of [key_set][crate::model::mutation::Delete::key_set].
4018 pub fn set_or_clear_key_set<T>(mut self, v: std::option::Option<T>) -> Self
4019 where
4020 T: std::convert::Into<crate::model::KeySet>,
4021 {
4022 self.key_set = v.map(|x| x.into());
4023 self
4024 }
4025 }
4026
4027 impl wkt::message::Message for Delete {
4028 fn typename() -> &'static str {
4029 "type.googleapis.com/google.spanner.v1.Mutation.Delete"
4030 }
4031 }
4032
4033 /// Arguments to [send][google.spanner.v1.Mutation.send] operations.
4034 ///
4035 /// [google.spanner.v1.Mutation.send]: crate::model::Mutation::operation
4036 #[derive(Clone, Default, PartialEq)]
4037 #[non_exhaustive]
4038 pub struct Send {
4039 /// Required. The queue to which the message will be sent.
4040 pub queue: std::string::String,
4041
4042 /// Required. The primary key of the message to be sent.
4043 pub key: std::option::Option<wkt::ListValue>,
4044
4045 /// The time at which Spanner will begin attempting to deliver the message.
4046 /// If `deliver_time` is not set, Spanner will deliver the message
4047 /// immediately. If `deliver_time` is in the past, Spanner will replace it
4048 /// with a value closer to the current time.
4049 pub deliver_time: std::option::Option<wkt::Timestamp>,
4050
4051 /// The payload of the message.
4052 pub payload: std::option::Option<wkt::Value>,
4053
4054 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4055 }
4056
4057 impl Send {
4058 /// Creates a new default instance.
4059 pub fn new() -> Self {
4060 std::default::Default::default()
4061 }
4062
4063 /// Sets the value of [queue][crate::model::mutation::Send::queue].
4064 pub fn set_queue<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4065 self.queue = v.into();
4066 self
4067 }
4068
4069 /// Sets the value of [key][crate::model::mutation::Send::key].
4070 pub fn set_key<T>(mut self, v: T) -> Self
4071 where
4072 T: std::convert::Into<wkt::ListValue>,
4073 {
4074 self.key = std::option::Option::Some(v.into());
4075 self
4076 }
4077
4078 /// Sets or clears the value of [key][crate::model::mutation::Send::key].
4079 pub fn set_or_clear_key<T>(mut self, v: std::option::Option<T>) -> Self
4080 where
4081 T: std::convert::Into<wkt::ListValue>,
4082 {
4083 self.key = v.map(|x| x.into());
4084 self
4085 }
4086
4087 /// Sets the value of [deliver_time][crate::model::mutation::Send::deliver_time].
4088 pub fn set_deliver_time<T>(mut self, v: T) -> Self
4089 where
4090 T: std::convert::Into<wkt::Timestamp>,
4091 {
4092 self.deliver_time = std::option::Option::Some(v.into());
4093 self
4094 }
4095
4096 /// Sets or clears the value of [deliver_time][crate::model::mutation::Send::deliver_time].
4097 pub fn set_or_clear_deliver_time<T>(mut self, v: std::option::Option<T>) -> Self
4098 where
4099 T: std::convert::Into<wkt::Timestamp>,
4100 {
4101 self.deliver_time = v.map(|x| x.into());
4102 self
4103 }
4104
4105 /// Sets the value of [payload][crate::model::mutation::Send::payload].
4106 pub fn set_payload<T>(mut self, v: T) -> Self
4107 where
4108 T: std::convert::Into<wkt::Value>,
4109 {
4110 self.payload = std::option::Option::Some(v.into());
4111 self
4112 }
4113
4114 /// Sets or clears the value of [payload][crate::model::mutation::Send::payload].
4115 pub fn set_or_clear_payload<T>(mut self, v: std::option::Option<T>) -> Self
4116 where
4117 T: std::convert::Into<wkt::Value>,
4118 {
4119 self.payload = v.map(|x| x.into());
4120 self
4121 }
4122 }
4123
4124 impl wkt::message::Message for Send {
4125 fn typename() -> &'static str {
4126 "type.googleapis.com/google.spanner.v1.Mutation.Send"
4127 }
4128 }
4129
4130 /// Arguments to [ack][google.spanner.v1.Mutation.ack] operations.
4131 ///
4132 /// [google.spanner.v1.Mutation.ack]: crate::model::Mutation::operation
4133 #[derive(Clone, Default, PartialEq)]
4134 #[non_exhaustive]
4135 pub struct Ack {
4136 /// Required. The queue where the message to be acked is stored.
4137 pub queue: std::string::String,
4138
4139 /// Required. The primary key of the message to be acked.
4140 pub key: std::option::Option<wkt::ListValue>,
4141
4142 /// By default, an attempt to ack a message that does not exist will fail
4143 /// with a `NOT_FOUND` error. With `ignore_not_found` set to true, the ack
4144 /// will succeed even if the message does not exist. This is useful for
4145 /// unconditionally acking a message, even if it is missing or has already
4146 /// been acked.
4147 pub ignore_not_found: bool,
4148
4149 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4150 }
4151
4152 impl Ack {
4153 /// Creates a new default instance.
4154 pub fn new() -> Self {
4155 std::default::Default::default()
4156 }
4157
4158 /// Sets the value of [queue][crate::model::mutation::Ack::queue].
4159 pub fn set_queue<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4160 self.queue = v.into();
4161 self
4162 }
4163
4164 /// Sets the value of [key][crate::model::mutation::Ack::key].
4165 pub fn set_key<T>(mut self, v: T) -> Self
4166 where
4167 T: std::convert::Into<wkt::ListValue>,
4168 {
4169 self.key = std::option::Option::Some(v.into());
4170 self
4171 }
4172
4173 /// Sets or clears the value of [key][crate::model::mutation::Ack::key].
4174 pub fn set_or_clear_key<T>(mut self, v: std::option::Option<T>) -> Self
4175 where
4176 T: std::convert::Into<wkt::ListValue>,
4177 {
4178 self.key = v.map(|x| x.into());
4179 self
4180 }
4181
4182 /// Sets the value of [ignore_not_found][crate::model::mutation::Ack::ignore_not_found].
4183 pub fn set_ignore_not_found<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4184 self.ignore_not_found = v.into();
4185 self
4186 }
4187 }
4188
4189 impl wkt::message::Message for Ack {
4190 fn typename() -> &'static str {
4191 "type.googleapis.com/google.spanner.v1.Mutation.Ack"
4192 }
4193 }
4194
4195 /// Required. The operation to perform.
4196 #[derive(Clone, Debug, PartialEq)]
4197 #[non_exhaustive]
4198 pub enum Operation {
4199 /// Insert new rows in a table. If any of the rows already exist,
4200 /// the write or transaction fails with error `ALREADY_EXISTS`.
4201 Insert(std::boxed::Box<crate::model::mutation::Write>),
4202 /// Update existing rows in a table. If any of the rows does not
4203 /// already exist, the transaction fails with error `NOT_FOUND`.
4204 Update(std::boxed::Box<crate::model::mutation::Write>),
4205 /// Like [insert][google.spanner.v1.Mutation.insert], except that if the row
4206 /// already exists, then its column values are overwritten with the ones
4207 /// provided. Any column values not explicitly written are preserved.
4208 ///
4209 /// When using
4210 /// [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as
4211 /// when using [insert][google.spanner.v1.Mutation.insert], all `NOT NULL`
4212 /// columns in the table must be given a value. This holds true even when the
4213 /// row already exists and will therefore actually be updated.
4214 ///
4215 /// [google.spanner.v1.Mutation.insert]: crate::model::Mutation::operation
4216 /// [google.spanner.v1.Mutation.insert_or_update]: crate::model::Mutation::operation
4217 InsertOrUpdate(std::boxed::Box<crate::model::mutation::Write>),
4218 /// Like [insert][google.spanner.v1.Mutation.insert], except that if the row
4219 /// already exists, it is deleted, and the column values provided are
4220 /// inserted instead. Unlike
4221 /// [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this
4222 /// means any values not explicitly written become `NULL`.
4223 ///
4224 /// In an interleaved table, if you create the child table with the
4225 /// `ON DELETE CASCADE` annotation, then replacing a parent row
4226 /// also deletes the child rows. Otherwise, you must delete the
4227 /// child rows before you replace the parent row.
4228 ///
4229 /// [google.spanner.v1.Mutation.insert]: crate::model::Mutation::operation
4230 /// [google.spanner.v1.Mutation.insert_or_update]: crate::model::Mutation::operation
4231 Replace(std::boxed::Box<crate::model::mutation::Write>),
4232 /// Delete rows from a table. Succeeds whether or not the named
4233 /// rows were present.
4234 Delete(std::boxed::Box<crate::model::mutation::Delete>),
4235 /// Send a message to a queue.
4236 Send(std::boxed::Box<crate::model::mutation::Send>),
4237 /// Ack a message from a queue.
4238 Ack(std::boxed::Box<crate::model::mutation::Ack>),
4239 }
4240
4241 impl Operation {
4242 /// Initializes the enum to the [Insert](Self::Insert) branch.
4243 pub fn from_insert(
4244 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4245 ) -> Self {
4246 Self::Insert(value.into())
4247 }
4248 /// Initializes the enum to the [Update](Self::Update) branch.
4249 pub fn from_update(
4250 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4251 ) -> Self {
4252 Self::Update(value.into())
4253 }
4254 /// Initializes the enum to the [InsertOrUpdate](Self::InsertOrUpdate) branch.
4255 pub fn from_insert_or_update(
4256 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4257 ) -> Self {
4258 Self::InsertOrUpdate(value.into())
4259 }
4260 /// Initializes the enum to the [Replace](Self::Replace) branch.
4261 pub fn from_replace(
4262 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4263 ) -> Self {
4264 Self::Replace(value.into())
4265 }
4266 /// Initializes the enum to the [Delete](Self::Delete) branch.
4267 pub fn from_delete(
4268 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Delete>>,
4269 ) -> Self {
4270 Self::Delete(value.into())
4271 }
4272 /// Initializes the enum to the [Send](Self::Send) branch.
4273 pub fn from_send(
4274 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Send>>,
4275 ) -> Self {
4276 Self::Send(value.into())
4277 }
4278 /// Initializes the enum to the [Ack](Self::Ack) branch.
4279 pub fn from_ack(
4280 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Ack>>,
4281 ) -> Self {
4282 Self::Ack(value.into())
4283 }
4284 }
4285}
4286
4287/// Node information for nodes appearing in a
4288/// [QueryPlan.plan_nodes][google.spanner.v1.QueryPlan.plan_nodes].
4289///
4290/// [google.spanner.v1.QueryPlan.plan_nodes]: crate::model::QueryPlan::plan_nodes
4291#[derive(Clone, Default, PartialEq)]
4292#[non_exhaustive]
4293pub struct PlanNode {
4294 /// The `PlanNode`'s index in [node
4295 /// list][google.spanner.v1.QueryPlan.plan_nodes].
4296 ///
4297 /// [google.spanner.v1.QueryPlan.plan_nodes]: crate::model::QueryPlan::plan_nodes
4298 pub index: i32,
4299
4300 /// Used to determine the type of node. May be needed for visualizing
4301 /// different kinds of nodes differently. For example, If the node is a
4302 /// [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a
4303 /// condensed representation which can be used to directly embed a description
4304 /// of the node in its parent.
4305 ///
4306 /// [google.spanner.v1.PlanNode.Kind.SCALAR]: crate::model::plan_node::Kind::Scalar
4307 pub kind: crate::model::plan_node::Kind,
4308
4309 /// The display name for the node.
4310 pub display_name: std::string::String,
4311
4312 /// List of child node `index`es and their relationship to this parent.
4313 pub child_links: std::vec::Vec<crate::model::plan_node::ChildLink>,
4314
4315 /// Condensed representation for
4316 /// [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes.
4317 ///
4318 /// [google.spanner.v1.PlanNode.Kind.SCALAR]: crate::model::plan_node::Kind::Scalar
4319 pub short_representation: std::option::Option<crate::model::plan_node::ShortRepresentation>,
4320
4321 /// Attributes relevant to the node contained in a group of key-value pairs.
4322 /// For example, a Parameter Reference node could have the following
4323 /// information in its metadata:
4324 ///
4325 /// ```norust
4326 /// {
4327 /// "parameter_reference": "param1",
4328 /// "parameter_type": "array"
4329 /// }
4330 /// ```
4331 pub metadata: std::option::Option<wkt::Struct>,
4332
4333 /// The execution statistics associated with the node, contained in a group of
4334 /// key-value pairs. Only present if the plan was returned as a result of a
4335 /// profile query. For example, number of executions, number of rows/time per
4336 /// execution etc.
4337 pub execution_stats: std::option::Option<wkt::Struct>,
4338
4339 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4340}
4341
4342impl PlanNode {
4343 /// Creates a new default instance.
4344 pub fn new() -> Self {
4345 std::default::Default::default()
4346 }
4347
4348 /// Sets the value of [index][crate::model::PlanNode::index].
4349 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4350 self.index = v.into();
4351 self
4352 }
4353
4354 /// Sets the value of [kind][crate::model::PlanNode::kind].
4355 pub fn set_kind<T: std::convert::Into<crate::model::plan_node::Kind>>(mut self, v: T) -> Self {
4356 self.kind = v.into();
4357 self
4358 }
4359
4360 /// Sets the value of [display_name][crate::model::PlanNode::display_name].
4361 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4362 self.display_name = v.into();
4363 self
4364 }
4365
4366 /// Sets the value of [child_links][crate::model::PlanNode::child_links].
4367 pub fn set_child_links<T, V>(mut self, v: T) -> Self
4368 where
4369 T: std::iter::IntoIterator<Item = V>,
4370 V: std::convert::Into<crate::model::plan_node::ChildLink>,
4371 {
4372 use std::iter::Iterator;
4373 self.child_links = v.into_iter().map(|i| i.into()).collect();
4374 self
4375 }
4376
4377 /// Sets the value of [short_representation][crate::model::PlanNode::short_representation].
4378 pub fn set_short_representation<T>(mut self, v: T) -> Self
4379 where
4380 T: std::convert::Into<crate::model::plan_node::ShortRepresentation>,
4381 {
4382 self.short_representation = std::option::Option::Some(v.into());
4383 self
4384 }
4385
4386 /// Sets or clears the value of [short_representation][crate::model::PlanNode::short_representation].
4387 pub fn set_or_clear_short_representation<T>(mut self, v: std::option::Option<T>) -> Self
4388 where
4389 T: std::convert::Into<crate::model::plan_node::ShortRepresentation>,
4390 {
4391 self.short_representation = v.map(|x| x.into());
4392 self
4393 }
4394
4395 /// Sets the value of [metadata][crate::model::PlanNode::metadata].
4396 pub fn set_metadata<T>(mut self, v: T) -> Self
4397 where
4398 T: std::convert::Into<wkt::Struct>,
4399 {
4400 self.metadata = std::option::Option::Some(v.into());
4401 self
4402 }
4403
4404 /// Sets or clears the value of [metadata][crate::model::PlanNode::metadata].
4405 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
4406 where
4407 T: std::convert::Into<wkt::Struct>,
4408 {
4409 self.metadata = v.map(|x| x.into());
4410 self
4411 }
4412
4413 /// Sets the value of [execution_stats][crate::model::PlanNode::execution_stats].
4414 pub fn set_execution_stats<T>(mut self, v: T) -> Self
4415 where
4416 T: std::convert::Into<wkt::Struct>,
4417 {
4418 self.execution_stats = std::option::Option::Some(v.into());
4419 self
4420 }
4421
4422 /// Sets or clears the value of [execution_stats][crate::model::PlanNode::execution_stats].
4423 pub fn set_or_clear_execution_stats<T>(mut self, v: std::option::Option<T>) -> Self
4424 where
4425 T: std::convert::Into<wkt::Struct>,
4426 {
4427 self.execution_stats = v.map(|x| x.into());
4428 self
4429 }
4430}
4431
4432impl wkt::message::Message for PlanNode {
4433 fn typename() -> &'static str {
4434 "type.googleapis.com/google.spanner.v1.PlanNode"
4435 }
4436}
4437
4438/// Defines additional types related to [PlanNode].
4439pub mod plan_node {
4440 #[allow(unused_imports)]
4441 use super::*;
4442
4443 /// Metadata associated with a parent-child relationship appearing in a
4444 /// [PlanNode][google.spanner.v1.PlanNode].
4445 ///
4446 /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4447 #[derive(Clone, Default, PartialEq)]
4448 #[non_exhaustive]
4449 pub struct ChildLink {
4450 /// The node to which the link points.
4451 pub child_index: i32,
4452
4453 /// The type of the link. For example, in Hash Joins this could be used to
4454 /// distinguish between the build child and the probe child, or in the case
4455 /// of the child being an output variable, to represent the tag associated
4456 /// with the output variable.
4457 pub r#type: std::string::String,
4458
4459 /// Only present if the child node is
4460 /// [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds to an
4461 /// output variable of the parent node. The field carries the name of the
4462 /// output variable. For example, a `TableScan` operator that reads rows from
4463 /// a table will have child links to the `SCALAR` nodes representing the
4464 /// output variables created for each column that is read by the operator.
4465 /// The corresponding `variable` fields will be set to the variable names
4466 /// assigned to the columns.
4467 ///
4468 /// [google.spanner.v1.PlanNode.Kind.SCALAR]: crate::model::plan_node::Kind::Scalar
4469 pub variable: std::string::String,
4470
4471 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4472 }
4473
4474 impl ChildLink {
4475 /// Creates a new default instance.
4476 pub fn new() -> Self {
4477 std::default::Default::default()
4478 }
4479
4480 /// Sets the value of [child_index][crate::model::plan_node::ChildLink::child_index].
4481 pub fn set_child_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4482 self.child_index = v.into();
4483 self
4484 }
4485
4486 /// Sets the value of [r#type][crate::model::plan_node::ChildLink::type].
4487 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4488 self.r#type = v.into();
4489 self
4490 }
4491
4492 /// Sets the value of [variable][crate::model::plan_node::ChildLink::variable].
4493 pub fn set_variable<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4494 self.variable = v.into();
4495 self
4496 }
4497 }
4498
4499 impl wkt::message::Message for ChildLink {
4500 fn typename() -> &'static str {
4501 "type.googleapis.com/google.spanner.v1.PlanNode.ChildLink"
4502 }
4503 }
4504
4505 /// Condensed representation of a node and its subtree. Only present for
4506 /// `SCALAR` [PlanNode(s)][google.spanner.v1.PlanNode].
4507 ///
4508 /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4509 #[derive(Clone, Default, PartialEq)]
4510 #[non_exhaustive]
4511 pub struct ShortRepresentation {
4512 /// A string representation of the expression subtree rooted at this node.
4513 pub description: std::string::String,
4514
4515 /// A mapping of (subquery variable name) -> (subquery node id) for cases
4516 /// where the `description` string of this node references a `SCALAR`
4517 /// subquery contained in the expression subtree rooted at this node. The
4518 /// referenced `SCALAR` subquery may not necessarily be a direct child of
4519 /// this node.
4520 pub subqueries: std::collections::HashMap<std::string::String, i32>,
4521
4522 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4523 }
4524
4525 impl ShortRepresentation {
4526 /// Creates a new default instance.
4527 pub fn new() -> Self {
4528 std::default::Default::default()
4529 }
4530
4531 /// Sets the value of [description][crate::model::plan_node::ShortRepresentation::description].
4532 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4533 self.description = v.into();
4534 self
4535 }
4536
4537 /// Sets the value of [subqueries][crate::model::plan_node::ShortRepresentation::subqueries].
4538 pub fn set_subqueries<T, K, V>(mut self, v: T) -> Self
4539 where
4540 T: std::iter::IntoIterator<Item = (K, V)>,
4541 K: std::convert::Into<std::string::String>,
4542 V: std::convert::Into<i32>,
4543 {
4544 use std::iter::Iterator;
4545 self.subqueries = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4546 self
4547 }
4548 }
4549
4550 impl wkt::message::Message for ShortRepresentation {
4551 fn typename() -> &'static str {
4552 "type.googleapis.com/google.spanner.v1.PlanNode.ShortRepresentation"
4553 }
4554 }
4555
4556 /// The kind of [PlanNode][google.spanner.v1.PlanNode]. Distinguishes between
4557 /// the two different kinds of nodes that can appear in a query plan.
4558 ///
4559 /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4560 ///
4561 /// # Working with unknown values
4562 ///
4563 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4564 /// additional enum variants at any time. Adding new variants is not considered
4565 /// a breaking change. Applications should write their code in anticipation of:
4566 ///
4567 /// - New values appearing in future releases of the client library, **and**
4568 /// - New values received dynamically, without application changes.
4569 ///
4570 /// Please consult the [Working with enums] section in the user guide for some
4571 /// guidelines.
4572 ///
4573 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4574 #[derive(Clone, Debug, PartialEq)]
4575 #[non_exhaustive]
4576 pub enum Kind {
4577 /// Not specified.
4578 Unspecified,
4579 /// Denotes a Relational operator node in the expression tree. Relational
4580 /// operators represent iterative processing of rows during query execution.
4581 /// For example, a `TableScan` operation that reads rows from a table.
4582 Relational,
4583 /// Denotes a Scalar node in the expression tree. Scalar nodes represent
4584 /// non-iterable entities in the query plan. For example, constants or
4585 /// arithmetic operators appearing inside predicate expressions or references
4586 /// to column names.
4587 Scalar,
4588 /// If set, the enum was initialized with an unknown value.
4589 ///
4590 /// Applications can examine the value using [Kind::value] or
4591 /// [Kind::name].
4592 UnknownValue(kind::UnknownValue),
4593 }
4594
4595 #[doc(hidden)]
4596 pub mod kind {
4597 #[allow(unused_imports)]
4598 use super::*;
4599 #[derive(Clone, Debug, PartialEq)]
4600 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4601 }
4602
4603 impl Kind {
4604 /// Gets the enum value.
4605 ///
4606 /// Returns `None` if the enum contains an unknown value deserialized from
4607 /// the string representation of enums.
4608 pub fn value(&self) -> std::option::Option<i32> {
4609 match self {
4610 Self::Unspecified => std::option::Option::Some(0),
4611 Self::Relational => std::option::Option::Some(1),
4612 Self::Scalar => std::option::Option::Some(2),
4613 Self::UnknownValue(u) => u.0.value(),
4614 }
4615 }
4616
4617 /// Gets the enum value as a string.
4618 ///
4619 /// Returns `None` if the enum contains an unknown value deserialized from
4620 /// the integer representation of enums.
4621 pub fn name(&self) -> std::option::Option<&str> {
4622 match self {
4623 Self::Unspecified => std::option::Option::Some("KIND_UNSPECIFIED"),
4624 Self::Relational => std::option::Option::Some("RELATIONAL"),
4625 Self::Scalar => std::option::Option::Some("SCALAR"),
4626 Self::UnknownValue(u) => u.0.name(),
4627 }
4628 }
4629 }
4630
4631 impl std::default::Default for Kind {
4632 fn default() -> Self {
4633 use std::convert::From;
4634 Self::from(0)
4635 }
4636 }
4637
4638 impl std::fmt::Display for Kind {
4639 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4640 wkt::internal::display_enum(f, self.name(), self.value())
4641 }
4642 }
4643
4644 impl std::convert::From<i32> for Kind {
4645 fn from(value: i32) -> Self {
4646 match value {
4647 0 => Self::Unspecified,
4648 1 => Self::Relational,
4649 2 => Self::Scalar,
4650 _ => Self::UnknownValue(kind::UnknownValue(
4651 wkt::internal::UnknownEnumValue::Integer(value),
4652 )),
4653 }
4654 }
4655 }
4656
4657 impl std::convert::From<&str> for Kind {
4658 fn from(value: &str) -> Self {
4659 use std::string::ToString;
4660 match value {
4661 "KIND_UNSPECIFIED" => Self::Unspecified,
4662 "RELATIONAL" => Self::Relational,
4663 "SCALAR" => Self::Scalar,
4664 _ => Self::UnknownValue(kind::UnknownValue(
4665 wkt::internal::UnknownEnumValue::String(value.to_string()),
4666 )),
4667 }
4668 }
4669 }
4670
4671 impl serde::ser::Serialize for Kind {
4672 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4673 where
4674 S: serde::Serializer,
4675 {
4676 match self {
4677 Self::Unspecified => serializer.serialize_i32(0),
4678 Self::Relational => serializer.serialize_i32(1),
4679 Self::Scalar => serializer.serialize_i32(2),
4680 Self::UnknownValue(u) => u.0.serialize(serializer),
4681 }
4682 }
4683 }
4684
4685 impl<'de> serde::de::Deserialize<'de> for Kind {
4686 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4687 where
4688 D: serde::Deserializer<'de>,
4689 {
4690 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Kind>::new(
4691 ".google.spanner.v1.PlanNode.Kind",
4692 ))
4693 }
4694 }
4695}
4696
4697/// Output of query advisor analysis.
4698#[derive(Clone, Default, PartialEq)]
4699#[non_exhaustive]
4700pub struct QueryAdvisorResult {
4701 /// Optional. Index Recommendation for a query. This is an optional field and
4702 /// the recommendation will only be available when the recommendation
4703 /// guarantees significant improvement in query performance.
4704 pub index_advice: std::vec::Vec<crate::model::query_advisor_result::IndexAdvice>,
4705
4706 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4707}
4708
4709impl QueryAdvisorResult {
4710 /// Creates a new default instance.
4711 pub fn new() -> Self {
4712 std::default::Default::default()
4713 }
4714
4715 /// Sets the value of [index_advice][crate::model::QueryAdvisorResult::index_advice].
4716 pub fn set_index_advice<T, V>(mut self, v: T) -> Self
4717 where
4718 T: std::iter::IntoIterator<Item = V>,
4719 V: std::convert::Into<crate::model::query_advisor_result::IndexAdvice>,
4720 {
4721 use std::iter::Iterator;
4722 self.index_advice = v.into_iter().map(|i| i.into()).collect();
4723 self
4724 }
4725}
4726
4727impl wkt::message::Message for QueryAdvisorResult {
4728 fn typename() -> &'static str {
4729 "type.googleapis.com/google.spanner.v1.QueryAdvisorResult"
4730 }
4731}
4732
4733/// Defines additional types related to [QueryAdvisorResult].
4734pub mod query_advisor_result {
4735 #[allow(unused_imports)]
4736 use super::*;
4737
4738 /// Recommendation to add new indexes to run queries more efficiently.
4739 #[derive(Clone, Default, PartialEq)]
4740 #[non_exhaustive]
4741 pub struct IndexAdvice {
4742 /// Optional. DDL statements to add new indexes that will improve the query.
4743 pub ddl: std::vec::Vec<std::string::String>,
4744
4745 /// Optional. Estimated latency improvement factor. For example if the query
4746 /// currently takes 500 ms to run and the estimated latency with new indexes
4747 /// is 100 ms this field will be 5.
4748 pub improvement_factor: f64,
4749
4750 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4751 }
4752
4753 impl IndexAdvice {
4754 /// Creates a new default instance.
4755 pub fn new() -> Self {
4756 std::default::Default::default()
4757 }
4758
4759 /// Sets the value of [ddl][crate::model::query_advisor_result::IndexAdvice::ddl].
4760 pub fn set_ddl<T, V>(mut self, v: T) -> Self
4761 where
4762 T: std::iter::IntoIterator<Item = V>,
4763 V: std::convert::Into<std::string::String>,
4764 {
4765 use std::iter::Iterator;
4766 self.ddl = v.into_iter().map(|i| i.into()).collect();
4767 self
4768 }
4769
4770 /// Sets the value of [improvement_factor][crate::model::query_advisor_result::IndexAdvice::improvement_factor].
4771 pub fn set_improvement_factor<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4772 self.improvement_factor = v.into();
4773 self
4774 }
4775 }
4776
4777 impl wkt::message::Message for IndexAdvice {
4778 fn typename() -> &'static str {
4779 "type.googleapis.com/google.spanner.v1.QueryAdvisorResult.IndexAdvice"
4780 }
4781 }
4782}
4783
4784/// Contains an ordered list of nodes appearing in the query plan.
4785#[derive(Clone, Default, PartialEq)]
4786#[non_exhaustive]
4787pub struct QueryPlan {
4788 /// The nodes in the query plan. Plan nodes are returned in pre-order starting
4789 /// with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id`
4790 /// corresponds to its index in `plan_nodes`.
4791 ///
4792 /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4793 pub plan_nodes: std::vec::Vec<crate::model::PlanNode>,
4794
4795 /// Optional. The advise/recommendations for a query. Currently this field will
4796 /// be serving index recommendations for a query.
4797 pub query_advice: std::option::Option<crate::model::QueryAdvisorResult>,
4798
4799 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4800}
4801
4802impl QueryPlan {
4803 /// Creates a new default instance.
4804 pub fn new() -> Self {
4805 std::default::Default::default()
4806 }
4807
4808 /// Sets the value of [plan_nodes][crate::model::QueryPlan::plan_nodes].
4809 pub fn set_plan_nodes<T, V>(mut self, v: T) -> Self
4810 where
4811 T: std::iter::IntoIterator<Item = V>,
4812 V: std::convert::Into<crate::model::PlanNode>,
4813 {
4814 use std::iter::Iterator;
4815 self.plan_nodes = v.into_iter().map(|i| i.into()).collect();
4816 self
4817 }
4818
4819 /// Sets the value of [query_advice][crate::model::QueryPlan::query_advice].
4820 pub fn set_query_advice<T>(mut self, v: T) -> Self
4821 where
4822 T: std::convert::Into<crate::model::QueryAdvisorResult>,
4823 {
4824 self.query_advice = std::option::Option::Some(v.into());
4825 self
4826 }
4827
4828 /// Sets or clears the value of [query_advice][crate::model::QueryPlan::query_advice].
4829 pub fn set_or_clear_query_advice<T>(mut self, v: std::option::Option<T>) -> Self
4830 where
4831 T: std::convert::Into<crate::model::QueryAdvisorResult>,
4832 {
4833 self.query_advice = v.map(|x| x.into());
4834 self
4835 }
4836}
4837
4838impl wkt::message::Message for QueryPlan {
4839 fn typename() -> &'static str {
4840 "type.googleapis.com/google.spanner.v1.QueryPlan"
4841 }
4842}
4843
4844/// Results from [Read][google.spanner.v1.Spanner.Read] or
4845/// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
4846///
4847/// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
4848/// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
4849#[derive(Clone, Default, PartialEq)]
4850#[non_exhaustive]
4851pub struct ResultSet {
4852 /// Metadata about the result set, such as row type information.
4853 pub metadata: std::option::Option<crate::model::ResultSetMetadata>,
4854
4855 /// Each element in `rows` is a row whose format is defined by
4856 /// [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
4857 /// element in each row matches the ith field in
4858 /// [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
4859 /// are encoded based on type as described [here][google.spanner.v1.TypeCode].
4860 ///
4861 /// [google.spanner.v1.ResultSetMetadata.row_type]: crate::model::ResultSetMetadata::row_type
4862 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
4863 pub rows: std::vec::Vec<wkt::ListValue>,
4864
4865 /// Query plan and execution statistics for the SQL statement that
4866 /// produced this result set. These can be requested by setting
4867 /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
4868 /// DML statements always produce stats containing the number of rows
4869 /// modified, unless executed using the
4870 /// [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
4871 /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
4872 /// Other fields might or might not be populated, based on the
4873 /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
4874 ///
4875 /// [google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]: crate::model::execute_sql_request::QueryMode::Plan
4876 /// [google.spanner.v1.ExecuteSqlRequest.query_mode]: crate::model::ExecuteSqlRequest::query_mode
4877 pub stats: std::option::Option<crate::model::ResultSetStats>,
4878
4879 /// Optional. A precommit token is included if the read-write transaction is on
4880 /// a multiplexed session. Pass the precommit token with the highest sequence
4881 /// number from this transaction attempt to the
4882 /// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
4883 ///
4884 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
4885 pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
4886
4887 /// Optional. A cache update expresses a set of changes the client should
4888 /// incorporate into its location cache. The client should discard the changes
4889 /// if they are older than the data it already has. This data can be obtained
4890 /// in response to requests that included a `RoutingHint` field, but may also
4891 /// be obtained by explicit location-fetching RPCs which may be added in the
4892 /// future.
4893 pub cache_update: std::option::Option<crate::model::CacheUpdate>,
4894
4895 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4896}
4897
4898impl ResultSet {
4899 /// Creates a new default instance.
4900 pub fn new() -> Self {
4901 std::default::Default::default()
4902 }
4903
4904 /// Sets the value of [metadata][crate::model::ResultSet::metadata].
4905 pub fn set_metadata<T>(mut self, v: T) -> Self
4906 where
4907 T: std::convert::Into<crate::model::ResultSetMetadata>,
4908 {
4909 self.metadata = std::option::Option::Some(v.into());
4910 self
4911 }
4912
4913 /// Sets or clears the value of [metadata][crate::model::ResultSet::metadata].
4914 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
4915 where
4916 T: std::convert::Into<crate::model::ResultSetMetadata>,
4917 {
4918 self.metadata = v.map(|x| x.into());
4919 self
4920 }
4921
4922 /// Sets the value of [rows][crate::model::ResultSet::rows].
4923 pub fn set_rows<T, V>(mut self, v: T) -> Self
4924 where
4925 T: std::iter::IntoIterator<Item = V>,
4926 V: std::convert::Into<wkt::ListValue>,
4927 {
4928 use std::iter::Iterator;
4929 self.rows = v.into_iter().map(|i| i.into()).collect();
4930 self
4931 }
4932
4933 /// Sets the value of [stats][crate::model::ResultSet::stats].
4934 pub fn set_stats<T>(mut self, v: T) -> Self
4935 where
4936 T: std::convert::Into<crate::model::ResultSetStats>,
4937 {
4938 self.stats = std::option::Option::Some(v.into());
4939 self
4940 }
4941
4942 /// Sets or clears the value of [stats][crate::model::ResultSet::stats].
4943 pub fn set_or_clear_stats<T>(mut self, v: std::option::Option<T>) -> Self
4944 where
4945 T: std::convert::Into<crate::model::ResultSetStats>,
4946 {
4947 self.stats = v.map(|x| x.into());
4948 self
4949 }
4950
4951 /// Sets the value of [precommit_token][crate::model::ResultSet::precommit_token].
4952 pub fn set_precommit_token<T>(mut self, v: T) -> Self
4953 where
4954 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
4955 {
4956 self.precommit_token = std::option::Option::Some(v.into());
4957 self
4958 }
4959
4960 /// Sets or clears the value of [precommit_token][crate::model::ResultSet::precommit_token].
4961 pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
4962 where
4963 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
4964 {
4965 self.precommit_token = v.map(|x| x.into());
4966 self
4967 }
4968
4969 /// Sets the value of [cache_update][crate::model::ResultSet::cache_update].
4970 pub fn set_cache_update<T>(mut self, v: T) -> Self
4971 where
4972 T: std::convert::Into<crate::model::CacheUpdate>,
4973 {
4974 self.cache_update = std::option::Option::Some(v.into());
4975 self
4976 }
4977
4978 /// Sets or clears the value of [cache_update][crate::model::ResultSet::cache_update].
4979 pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
4980 where
4981 T: std::convert::Into<crate::model::CacheUpdate>,
4982 {
4983 self.cache_update = v.map(|x| x.into());
4984 self
4985 }
4986}
4987
4988impl wkt::message::Message for ResultSet {
4989 fn typename() -> &'static str {
4990 "type.googleapis.com/google.spanner.v1.ResultSet"
4991 }
4992}
4993
4994/// Partial results from a streaming read or SQL query. Streaming reads and
4995/// SQL queries better tolerate large result sets, large rows, and large
4996/// values, but are a little trickier to consume.
4997#[derive(Clone, Default, PartialEq)]
4998#[non_exhaustive]
4999pub struct PartialResultSet {
5000 /// Metadata about the result set, such as row type information.
5001 /// Only present in the first response.
5002 pub metadata: std::option::Option<crate::model::ResultSetMetadata>,
5003
5004 /// A streamed result set consists of a stream of values, which might
5005 /// be split into many `PartialResultSet` messages to accommodate
5006 /// large rows and/or large values. Every N complete values defines a
5007 /// row, where N is equal to the number of entries in
5008 /// [metadata.row_type.fields][google.spanner.v1.StructType.fields].
5009 ///
5010 /// Most values are encoded based on type as described
5011 /// [here][google.spanner.v1.TypeCode].
5012 ///
5013 /// It's possible that the last value in values is "chunked",
5014 /// meaning that the rest of the value is sent in subsequent
5015 /// `PartialResultSet`(s). This is denoted by the
5016 /// [chunked_value][google.spanner.v1.PartialResultSet.chunked_value] field.
5017 /// Two or more chunked values can be merged to form a complete value as
5018 /// follows:
5019 ///
5020 /// * `bool/number/null`: can't be chunked
5021 /// * `string`: concatenate the strings
5022 /// * `list`: concatenate the lists. If the last element in a list is a
5023 /// `string`, `list`, or `object`, merge it with the first element in
5024 /// the next list by applying these rules recursively.
5025 /// * `object`: concatenate the (field name, field value) pairs. If a
5026 /// field name is duplicated, then apply these rules recursively
5027 /// to merge the field values.
5028 ///
5029 /// Some examples of merging:
5030 ///
5031 /// ```norust
5032 /// Strings are concatenated.
5033 /// "foo", "bar" => "foobar"
5034 ///
5035 /// Lists of non-strings are concatenated.
5036 /// [2, 3], [4] => [2, 3, 4]
5037 ///
5038 /// Lists are concatenated, but the last and first elements are merged
5039 /// because they are strings.
5040 /// ["a", "b"], ["c", "d"] => ["a", "bc", "d"]
5041 ///
5042 /// Lists are concatenated, but the last and first elements are merged
5043 /// because they are lists. Recursively, the last and first elements
5044 /// of the inner lists are merged because they are strings.
5045 /// ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"]
5046 ///
5047 /// Non-overlapping object fields are combined.
5048 /// {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"}
5049 ///
5050 /// Overlapping object fields are merged.
5051 /// {"a": "1"}, {"a": "2"} => {"a": "12"}
5052 ///
5053 /// Examples of merging objects containing lists of strings.
5054 /// {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]}
5055 /// ```
5056 ///
5057 /// For a more complete example, suppose a streaming SQL query is
5058 /// yielding a result set whose rows contain a single string
5059 /// field. The following `PartialResultSet`s might be yielded:
5060 ///
5061 /// ```norust
5062 /// {
5063 /// "metadata": { ... }
5064 /// "values": ["Hello", "W"]
5065 /// "chunked_value": true
5066 /// "resume_token": "Af65..."
5067 /// }
5068 /// {
5069 /// "values": ["orl"]
5070 /// "chunked_value": true
5071 /// }
5072 /// {
5073 /// "values": ["d"]
5074 /// "resume_token": "Zx1B..."
5075 /// }
5076 /// ```
5077 ///
5078 /// This sequence of `PartialResultSet`s encodes two rows, one
5079 /// containing the field value `"Hello"`, and a second containing the
5080 /// field value `"World" = "W" + "orl" + "d"`.
5081 ///
5082 /// Not all `PartialResultSet`s contain a `resume_token`. Execution can only be
5083 /// resumed from a previously yielded `resume_token`. For the above sequence of
5084 /// `PartialResultSet`s, resuming the query with `"resume_token": "Af65..."`
5085 /// yields results from the `PartialResultSet` with value "orl".
5086 ///
5087 /// [google.spanner.v1.PartialResultSet.chunked_value]: crate::model::PartialResultSet::chunked_value
5088 /// [google.spanner.v1.StructType.fields]: crate::model::StructType::fields
5089 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
5090 pub values: std::vec::Vec<wkt::Value>,
5091
5092 /// If true, then the final value in
5093 /// [values][google.spanner.v1.PartialResultSet.values] is chunked, and must be
5094 /// combined with more values from subsequent `PartialResultSet`s to obtain a
5095 /// complete field value.
5096 ///
5097 /// [google.spanner.v1.PartialResultSet.values]: crate::model::PartialResultSet::values
5098 pub chunked_value: bool,
5099
5100 /// Streaming calls might be interrupted for a variety of reasons, such
5101 /// as TCP connection loss. If this occurs, the stream of results can
5102 /// be resumed by re-sending the original request and including
5103 /// `resume_token`. Note that executing any other transaction in the
5104 /// same session invalidates the token.
5105 pub resume_token: ::bytes::Bytes,
5106
5107 /// Query plan and execution statistics for the statement that produced this
5108 /// streaming result set. These can be requested by setting
5109 /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]
5110 /// and are sent only once with the last response in the stream. This field is
5111 /// also present in the last response for DML statements.
5112 ///
5113 /// [google.spanner.v1.ExecuteSqlRequest.query_mode]: crate::model::ExecuteSqlRequest::query_mode
5114 pub stats: std::option::Option<crate::model::ResultSetStats>,
5115
5116 /// Optional. A precommit token is included if the read-write transaction
5117 /// has multiplexed sessions enabled. Pass the precommit token with the highest
5118 /// sequence number from this transaction attempt to the
5119 /// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
5120 ///
5121 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
5122 pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
5123
5124 /// Optional. Indicates whether this is the last `PartialResultSet` in the
5125 /// stream. The server might optionally set this field. Clients shouldn't rely
5126 /// on this field being set in all cases.
5127 pub last: bool,
5128
5129 /// Optional. A cache update expresses a set of changes the client should
5130 /// incorporate into its location cache. The client should discard the changes
5131 /// if they are older than the data it already has. This data can be obtained
5132 /// in response to requests that included a `RoutingHint` field, but may also
5133 /// be obtained by explicit location-fetching RPCs which may be added in the
5134 /// future.
5135 pub cache_update: std::option::Option<crate::model::CacheUpdate>,
5136
5137 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5138}
5139
5140impl PartialResultSet {
5141 /// Creates a new default instance.
5142 pub fn new() -> Self {
5143 std::default::Default::default()
5144 }
5145
5146 /// Sets the value of [metadata][crate::model::PartialResultSet::metadata].
5147 pub fn set_metadata<T>(mut self, v: T) -> Self
5148 where
5149 T: std::convert::Into<crate::model::ResultSetMetadata>,
5150 {
5151 self.metadata = std::option::Option::Some(v.into());
5152 self
5153 }
5154
5155 /// Sets or clears the value of [metadata][crate::model::PartialResultSet::metadata].
5156 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
5157 where
5158 T: std::convert::Into<crate::model::ResultSetMetadata>,
5159 {
5160 self.metadata = v.map(|x| x.into());
5161 self
5162 }
5163
5164 /// Sets the value of [values][crate::model::PartialResultSet::values].
5165 pub fn set_values<T, V>(mut self, v: T) -> Self
5166 where
5167 T: std::iter::IntoIterator<Item = V>,
5168 V: std::convert::Into<wkt::Value>,
5169 {
5170 use std::iter::Iterator;
5171 self.values = v.into_iter().map(|i| i.into()).collect();
5172 self
5173 }
5174
5175 /// Sets the value of [chunked_value][crate::model::PartialResultSet::chunked_value].
5176 pub fn set_chunked_value<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5177 self.chunked_value = v.into();
5178 self
5179 }
5180
5181 /// Sets the value of [resume_token][crate::model::PartialResultSet::resume_token].
5182 pub fn set_resume_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
5183 self.resume_token = v.into();
5184 self
5185 }
5186
5187 /// Sets the value of [stats][crate::model::PartialResultSet::stats].
5188 pub fn set_stats<T>(mut self, v: T) -> Self
5189 where
5190 T: std::convert::Into<crate::model::ResultSetStats>,
5191 {
5192 self.stats = std::option::Option::Some(v.into());
5193 self
5194 }
5195
5196 /// Sets or clears the value of [stats][crate::model::PartialResultSet::stats].
5197 pub fn set_or_clear_stats<T>(mut self, v: std::option::Option<T>) -> Self
5198 where
5199 T: std::convert::Into<crate::model::ResultSetStats>,
5200 {
5201 self.stats = v.map(|x| x.into());
5202 self
5203 }
5204
5205 /// Sets the value of [precommit_token][crate::model::PartialResultSet::precommit_token].
5206 pub fn set_precommit_token<T>(mut self, v: T) -> Self
5207 where
5208 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
5209 {
5210 self.precommit_token = std::option::Option::Some(v.into());
5211 self
5212 }
5213
5214 /// Sets or clears the value of [precommit_token][crate::model::PartialResultSet::precommit_token].
5215 pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
5216 where
5217 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
5218 {
5219 self.precommit_token = v.map(|x| x.into());
5220 self
5221 }
5222
5223 /// Sets the value of [last][crate::model::PartialResultSet::last].
5224 pub fn set_last<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5225 self.last = v.into();
5226 self
5227 }
5228
5229 /// Sets the value of [cache_update][crate::model::PartialResultSet::cache_update].
5230 pub fn set_cache_update<T>(mut self, v: T) -> Self
5231 where
5232 T: std::convert::Into<crate::model::CacheUpdate>,
5233 {
5234 self.cache_update = std::option::Option::Some(v.into());
5235 self
5236 }
5237
5238 /// Sets or clears the value of [cache_update][crate::model::PartialResultSet::cache_update].
5239 pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
5240 where
5241 T: std::convert::Into<crate::model::CacheUpdate>,
5242 {
5243 self.cache_update = v.map(|x| x.into());
5244 self
5245 }
5246}
5247
5248impl wkt::message::Message for PartialResultSet {
5249 fn typename() -> &'static str {
5250 "type.googleapis.com/google.spanner.v1.PartialResultSet"
5251 }
5252}
5253
5254/// Metadata about a [ResultSet][google.spanner.v1.ResultSet] or
5255/// [PartialResultSet][google.spanner.v1.PartialResultSet].
5256///
5257/// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
5258/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
5259#[derive(Clone, Default, PartialEq)]
5260#[non_exhaustive]
5261pub struct ResultSetMetadata {
5262 /// Indicates the field names and types for the rows in the result
5263 /// set. For example, a SQL query like `"SELECT UserId, UserName FROM
5264 /// Users"` could return a `row_type` value like:
5265 ///
5266 /// ```norust
5267 /// "fields": [
5268 /// { "name": "UserId", "type": { "code": "INT64" } },
5269 /// { "name": "UserName", "type": { "code": "STRING" } },
5270 /// ]
5271 /// ```
5272 pub row_type: std::option::Option<crate::model::StructType>,
5273
5274 /// If the read or SQL query began a transaction as a side-effect, the
5275 /// information about the new transaction is yielded here.
5276 pub transaction: std::option::Option<crate::model::Transaction>,
5277
5278 /// A SQL query can be parameterized. In PLAN mode, these parameters can be
5279 /// undeclared. This indicates the field names and types for those undeclared
5280 /// parameters in the SQL query. For example, a SQL query like `"SELECT * FROM
5281 /// Users where UserId = @userId and UserName = @userName "` could return a
5282 /// `undeclared_parameters` value like:
5283 ///
5284 /// ```norust
5285 /// "fields": [
5286 /// { "name": "UserId", "type": { "code": "INT64" } },
5287 /// { "name": "UserName", "type": { "code": "STRING" } },
5288 /// ]
5289 /// ```
5290 pub undeclared_parameters: std::option::Option<crate::model::StructType>,
5291
5292 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5293}
5294
5295impl ResultSetMetadata {
5296 /// Creates a new default instance.
5297 pub fn new() -> Self {
5298 std::default::Default::default()
5299 }
5300
5301 /// Sets the value of [row_type][crate::model::ResultSetMetadata::row_type].
5302 pub fn set_row_type<T>(mut self, v: T) -> Self
5303 where
5304 T: std::convert::Into<crate::model::StructType>,
5305 {
5306 self.row_type = std::option::Option::Some(v.into());
5307 self
5308 }
5309
5310 /// Sets or clears the value of [row_type][crate::model::ResultSetMetadata::row_type].
5311 pub fn set_or_clear_row_type<T>(mut self, v: std::option::Option<T>) -> Self
5312 where
5313 T: std::convert::Into<crate::model::StructType>,
5314 {
5315 self.row_type = v.map(|x| x.into());
5316 self
5317 }
5318
5319 /// Sets the value of [transaction][crate::model::ResultSetMetadata::transaction].
5320 pub fn set_transaction<T>(mut self, v: T) -> Self
5321 where
5322 T: std::convert::Into<crate::model::Transaction>,
5323 {
5324 self.transaction = std::option::Option::Some(v.into());
5325 self
5326 }
5327
5328 /// Sets or clears the value of [transaction][crate::model::ResultSetMetadata::transaction].
5329 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
5330 where
5331 T: std::convert::Into<crate::model::Transaction>,
5332 {
5333 self.transaction = v.map(|x| x.into());
5334 self
5335 }
5336
5337 /// Sets the value of [undeclared_parameters][crate::model::ResultSetMetadata::undeclared_parameters].
5338 pub fn set_undeclared_parameters<T>(mut self, v: T) -> Self
5339 where
5340 T: std::convert::Into<crate::model::StructType>,
5341 {
5342 self.undeclared_parameters = std::option::Option::Some(v.into());
5343 self
5344 }
5345
5346 /// Sets or clears the value of [undeclared_parameters][crate::model::ResultSetMetadata::undeclared_parameters].
5347 pub fn set_or_clear_undeclared_parameters<T>(mut self, v: std::option::Option<T>) -> Self
5348 where
5349 T: std::convert::Into<crate::model::StructType>,
5350 {
5351 self.undeclared_parameters = v.map(|x| x.into());
5352 self
5353 }
5354}
5355
5356impl wkt::message::Message for ResultSetMetadata {
5357 fn typename() -> &'static str {
5358 "type.googleapis.com/google.spanner.v1.ResultSetMetadata"
5359 }
5360}
5361
5362/// Additional statistics about a [ResultSet][google.spanner.v1.ResultSet] or
5363/// [PartialResultSet][google.spanner.v1.PartialResultSet].
5364///
5365/// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
5366/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
5367#[derive(Clone, Default, PartialEq)]
5368#[non_exhaustive]
5369pub struct ResultSetStats {
5370 /// [QueryPlan][google.spanner.v1.QueryPlan] for the query associated with this
5371 /// result.
5372 ///
5373 /// [google.spanner.v1.QueryPlan]: crate::model::QueryPlan
5374 pub query_plan: std::option::Option<crate::model::QueryPlan>,
5375
5376 /// Aggregated statistics from the execution of the query. Only present when
5377 /// the query is profiled. For example, a query could return the statistics as
5378 /// follows:
5379 ///
5380 /// ```norust
5381 /// {
5382 /// "rows_returned": "3",
5383 /// "elapsed_time": "1.22 secs",
5384 /// "cpu_time": "1.19 secs"
5385 /// }
5386 /// ```
5387 pub query_stats: std::option::Option<wkt::Struct>,
5388
5389 /// The number of rows modified by the DML statement.
5390 pub row_count: std::option::Option<crate::model::result_set_stats::RowCount>,
5391
5392 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5393}
5394
5395impl ResultSetStats {
5396 /// Creates a new default instance.
5397 pub fn new() -> Self {
5398 std::default::Default::default()
5399 }
5400
5401 /// Sets the value of [query_plan][crate::model::ResultSetStats::query_plan].
5402 pub fn set_query_plan<T>(mut self, v: T) -> Self
5403 where
5404 T: std::convert::Into<crate::model::QueryPlan>,
5405 {
5406 self.query_plan = std::option::Option::Some(v.into());
5407 self
5408 }
5409
5410 /// Sets or clears the value of [query_plan][crate::model::ResultSetStats::query_plan].
5411 pub fn set_or_clear_query_plan<T>(mut self, v: std::option::Option<T>) -> Self
5412 where
5413 T: std::convert::Into<crate::model::QueryPlan>,
5414 {
5415 self.query_plan = v.map(|x| x.into());
5416 self
5417 }
5418
5419 /// Sets the value of [query_stats][crate::model::ResultSetStats::query_stats].
5420 pub fn set_query_stats<T>(mut self, v: T) -> Self
5421 where
5422 T: std::convert::Into<wkt::Struct>,
5423 {
5424 self.query_stats = std::option::Option::Some(v.into());
5425 self
5426 }
5427
5428 /// Sets or clears the value of [query_stats][crate::model::ResultSetStats::query_stats].
5429 pub fn set_or_clear_query_stats<T>(mut self, v: std::option::Option<T>) -> Self
5430 where
5431 T: std::convert::Into<wkt::Struct>,
5432 {
5433 self.query_stats = v.map(|x| x.into());
5434 self
5435 }
5436
5437 /// Sets the value of [row_count][crate::model::ResultSetStats::row_count].
5438 ///
5439 /// Note that all the setters affecting `row_count` are mutually
5440 /// exclusive.
5441 pub fn set_row_count<
5442 T: std::convert::Into<std::option::Option<crate::model::result_set_stats::RowCount>>,
5443 >(
5444 mut self,
5445 v: T,
5446 ) -> Self {
5447 self.row_count = v.into();
5448 self
5449 }
5450
5451 /// The value of [row_count][crate::model::ResultSetStats::row_count]
5452 /// if it holds a `RowCountExact`, `None` if the field is not set or
5453 /// holds a different branch.
5454 pub fn row_count_exact(&self) -> std::option::Option<&i64> {
5455 #[allow(unreachable_patterns)]
5456 self.row_count.as_ref().and_then(|v| match v {
5457 crate::model::result_set_stats::RowCount::RowCountExact(v) => {
5458 std::option::Option::Some(v)
5459 }
5460 _ => std::option::Option::None,
5461 })
5462 }
5463
5464 /// Sets the value of [row_count][crate::model::ResultSetStats::row_count]
5465 /// to hold a `RowCountExact`.
5466 ///
5467 /// Note that all the setters affecting `row_count` are
5468 /// mutually exclusive.
5469 pub fn set_row_count_exact<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5470 self.row_count = std::option::Option::Some(
5471 crate::model::result_set_stats::RowCount::RowCountExact(v.into()),
5472 );
5473 self
5474 }
5475
5476 /// The value of [row_count][crate::model::ResultSetStats::row_count]
5477 /// if it holds a `RowCountLowerBound`, `None` if the field is not set or
5478 /// holds a different branch.
5479 pub fn row_count_lower_bound(&self) -> std::option::Option<&i64> {
5480 #[allow(unreachable_patterns)]
5481 self.row_count.as_ref().and_then(|v| match v {
5482 crate::model::result_set_stats::RowCount::RowCountLowerBound(v) => {
5483 std::option::Option::Some(v)
5484 }
5485 _ => std::option::Option::None,
5486 })
5487 }
5488
5489 /// Sets the value of [row_count][crate::model::ResultSetStats::row_count]
5490 /// to hold a `RowCountLowerBound`.
5491 ///
5492 /// Note that all the setters affecting `row_count` are
5493 /// mutually exclusive.
5494 pub fn set_row_count_lower_bound<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5495 self.row_count = std::option::Option::Some(
5496 crate::model::result_set_stats::RowCount::RowCountLowerBound(v.into()),
5497 );
5498 self
5499 }
5500}
5501
5502impl wkt::message::Message for ResultSetStats {
5503 fn typename() -> &'static str {
5504 "type.googleapis.com/google.spanner.v1.ResultSetStats"
5505 }
5506}
5507
5508/// Defines additional types related to [ResultSetStats].
5509pub mod result_set_stats {
5510 #[allow(unused_imports)]
5511 use super::*;
5512
5513 /// The number of rows modified by the DML statement.
5514 #[derive(Clone, Debug, PartialEq)]
5515 #[non_exhaustive]
5516 pub enum RowCount {
5517 /// Standard DML returns an exact count of rows that were modified.
5518 RowCountExact(i64),
5519 /// Partitioned DML doesn't offer exactly-once semantics, so it
5520 /// returns a lower bound of the rows modified.
5521 RowCountLowerBound(i64),
5522 }
5523
5524 impl RowCount {
5525 /// Initializes the enum to the [RowCountExact](Self::RowCountExact) branch.
5526 pub fn from_row_count_exact(value: impl std::convert::Into<i64>) -> Self {
5527 Self::RowCountExact(value.into())
5528 }
5529 /// Initializes the enum to the [RowCountLowerBound](Self::RowCountLowerBound) branch.
5530 pub fn from_row_count_lower_bound(value: impl std::convert::Into<i64>) -> Self {
5531 Self::RowCountLowerBound(value.into())
5532 }
5533 }
5534}
5535
5536/// The request for [CreateSession][google.spanner.v1.Spanner.CreateSession].
5537///
5538/// [google.spanner.v1.Spanner.CreateSession]: crate::client::Spanner::create_session
5539#[derive(Clone, Default, PartialEq)]
5540#[non_exhaustive]
5541pub struct CreateSessionRequest {
5542 /// Required. The database in which the new session is created.
5543 pub database: std::string::String,
5544
5545 /// Required. The session to create.
5546 pub session: std::option::Option<crate::model::Session>,
5547
5548 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5549}
5550
5551impl CreateSessionRequest {
5552 /// Creates a new default instance.
5553 pub fn new() -> Self {
5554 std::default::Default::default()
5555 }
5556
5557 /// Sets the value of [database][crate::model::CreateSessionRequest::database].
5558 pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5559 self.database = v.into();
5560 self
5561 }
5562
5563 /// Sets the value of [session][crate::model::CreateSessionRequest::session].
5564 pub fn set_session<T>(mut self, v: T) -> Self
5565 where
5566 T: std::convert::Into<crate::model::Session>,
5567 {
5568 self.session = std::option::Option::Some(v.into());
5569 self
5570 }
5571
5572 /// Sets or clears the value of [session][crate::model::CreateSessionRequest::session].
5573 pub fn set_or_clear_session<T>(mut self, v: std::option::Option<T>) -> Self
5574 where
5575 T: std::convert::Into<crate::model::Session>,
5576 {
5577 self.session = v.map(|x| x.into());
5578 self
5579 }
5580}
5581
5582impl wkt::message::Message for CreateSessionRequest {
5583 fn typename() -> &'static str {
5584 "type.googleapis.com/google.spanner.v1.CreateSessionRequest"
5585 }
5586}
5587
5588/// The request for
5589/// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
5590///
5591/// [google.spanner.v1.Spanner.BatchCreateSessions]: crate::client::Spanner::batch_create_sessions
5592#[derive(Clone, Default, PartialEq)]
5593#[non_exhaustive]
5594pub struct BatchCreateSessionsRequest {
5595 /// Required. The database in which the new sessions are created.
5596 pub database: std::string::String,
5597
5598 /// Parameters to apply to each created session.
5599 pub session_template: std::option::Option<crate::model::Session>,
5600
5601 /// Required. The number of sessions to be created in this batch call. At least
5602 /// one session is created. The API can return fewer than the requested number
5603 /// of sessions. If a specific number of sessions are desired, the client can
5604 /// make additional calls to `BatchCreateSessions` (adjusting
5605 /// [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count]
5606 /// as necessary).
5607 ///
5608 /// [google.spanner.v1.BatchCreateSessionsRequest.session_count]: crate::model::BatchCreateSessionsRequest::session_count
5609 pub session_count: i32,
5610
5611 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5612}
5613
5614impl BatchCreateSessionsRequest {
5615 /// Creates a new default instance.
5616 pub fn new() -> Self {
5617 std::default::Default::default()
5618 }
5619
5620 /// Sets the value of [database][crate::model::BatchCreateSessionsRequest::database].
5621 pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5622 self.database = v.into();
5623 self
5624 }
5625
5626 /// Sets the value of [session_template][crate::model::BatchCreateSessionsRequest::session_template].
5627 pub fn set_session_template<T>(mut self, v: T) -> Self
5628 where
5629 T: std::convert::Into<crate::model::Session>,
5630 {
5631 self.session_template = std::option::Option::Some(v.into());
5632 self
5633 }
5634
5635 /// Sets or clears the value of [session_template][crate::model::BatchCreateSessionsRequest::session_template].
5636 pub fn set_or_clear_session_template<T>(mut self, v: std::option::Option<T>) -> Self
5637 where
5638 T: std::convert::Into<crate::model::Session>,
5639 {
5640 self.session_template = v.map(|x| x.into());
5641 self
5642 }
5643
5644 /// Sets the value of [session_count][crate::model::BatchCreateSessionsRequest::session_count].
5645 pub fn set_session_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5646 self.session_count = v.into();
5647 self
5648 }
5649}
5650
5651impl wkt::message::Message for BatchCreateSessionsRequest {
5652 fn typename() -> &'static str {
5653 "type.googleapis.com/google.spanner.v1.BatchCreateSessionsRequest"
5654 }
5655}
5656
5657/// The response for
5658/// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
5659///
5660/// [google.spanner.v1.Spanner.BatchCreateSessions]: crate::client::Spanner::batch_create_sessions
5661#[derive(Clone, Default, PartialEq)]
5662#[non_exhaustive]
5663pub struct BatchCreateSessionsResponse {
5664 /// The freshly created sessions.
5665 pub session: std::vec::Vec<crate::model::Session>,
5666
5667 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5668}
5669
5670impl BatchCreateSessionsResponse {
5671 /// Creates a new default instance.
5672 pub fn new() -> Self {
5673 std::default::Default::default()
5674 }
5675
5676 /// Sets the value of [session][crate::model::BatchCreateSessionsResponse::session].
5677 pub fn set_session<T, V>(mut self, v: T) -> Self
5678 where
5679 T: std::iter::IntoIterator<Item = V>,
5680 V: std::convert::Into<crate::model::Session>,
5681 {
5682 use std::iter::Iterator;
5683 self.session = v.into_iter().map(|i| i.into()).collect();
5684 self
5685 }
5686}
5687
5688impl wkt::message::Message for BatchCreateSessionsResponse {
5689 fn typename() -> &'static str {
5690 "type.googleapis.com/google.spanner.v1.BatchCreateSessionsResponse"
5691 }
5692}
5693
5694/// A session in the Cloud Spanner API.
5695#[derive(Clone, Default, PartialEq)]
5696#[non_exhaustive]
5697pub struct Session {
5698 /// Output only. The name of the session. This is always system-assigned.
5699 pub name: std::string::String,
5700
5701 /// The labels for the session.
5702 ///
5703 /// * Label keys must be between 1 and 63 characters long and must conform to
5704 /// the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.
5705 /// * Label values must be between 0 and 63 characters long and must conform
5706 /// to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
5707 /// * No more than 64 labels can be associated with a given session.
5708 ///
5709 /// See <https://goo.gl/xmQnxf> for more information on and examples of labels.
5710 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
5711
5712 /// Output only. The timestamp when the session is created.
5713 pub create_time: std::option::Option<wkt::Timestamp>,
5714
5715 /// Output only. The approximate timestamp when the session is last used. It's
5716 /// typically earlier than the actual last use time.
5717 pub approximate_last_use_time: std::option::Option<wkt::Timestamp>,
5718
5719 /// The database role which created this session.
5720 pub creator_role: std::string::String,
5721
5722 /// Optional. If `true`, specifies a multiplexed session. Use a multiplexed
5723 /// session for multiple, concurrent operations including any combination of
5724 /// read-only and read-write transactions. Use
5725 /// [`sessions.create`][google.spanner.v1.Spanner.CreateSession] to create
5726 /// multiplexed sessions. Don't use
5727 /// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions] to
5728 /// create a multiplexed session. You can't delete or list multiplexed
5729 /// sessions.
5730 ///
5731 /// [google.spanner.v1.Spanner.BatchCreateSessions]: crate::client::Spanner::batch_create_sessions
5732 /// [google.spanner.v1.Spanner.CreateSession]: crate::client::Spanner::create_session
5733 pub multiplexed: bool,
5734
5735 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5736}
5737
5738impl Session {
5739 /// Creates a new default instance.
5740 pub fn new() -> Self {
5741 std::default::Default::default()
5742 }
5743
5744 /// Sets the value of [name][crate::model::Session::name].
5745 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5746 self.name = v.into();
5747 self
5748 }
5749
5750 /// Sets the value of [labels][crate::model::Session::labels].
5751 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
5752 where
5753 T: std::iter::IntoIterator<Item = (K, V)>,
5754 K: std::convert::Into<std::string::String>,
5755 V: std::convert::Into<std::string::String>,
5756 {
5757 use std::iter::Iterator;
5758 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5759 self
5760 }
5761
5762 /// Sets the value of [create_time][crate::model::Session::create_time].
5763 pub fn set_create_time<T>(mut self, v: T) -> Self
5764 where
5765 T: std::convert::Into<wkt::Timestamp>,
5766 {
5767 self.create_time = std::option::Option::Some(v.into());
5768 self
5769 }
5770
5771 /// Sets or clears the value of [create_time][crate::model::Session::create_time].
5772 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
5773 where
5774 T: std::convert::Into<wkt::Timestamp>,
5775 {
5776 self.create_time = v.map(|x| x.into());
5777 self
5778 }
5779
5780 /// Sets the value of [approximate_last_use_time][crate::model::Session::approximate_last_use_time].
5781 pub fn set_approximate_last_use_time<T>(mut self, v: T) -> Self
5782 where
5783 T: std::convert::Into<wkt::Timestamp>,
5784 {
5785 self.approximate_last_use_time = std::option::Option::Some(v.into());
5786 self
5787 }
5788
5789 /// Sets or clears the value of [approximate_last_use_time][crate::model::Session::approximate_last_use_time].
5790 pub fn set_or_clear_approximate_last_use_time<T>(mut self, v: std::option::Option<T>) -> Self
5791 where
5792 T: std::convert::Into<wkt::Timestamp>,
5793 {
5794 self.approximate_last_use_time = v.map(|x| x.into());
5795 self
5796 }
5797
5798 /// Sets the value of [creator_role][crate::model::Session::creator_role].
5799 pub fn set_creator_role<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5800 self.creator_role = v.into();
5801 self
5802 }
5803
5804 /// Sets the value of [multiplexed][crate::model::Session::multiplexed].
5805 pub fn set_multiplexed<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5806 self.multiplexed = v.into();
5807 self
5808 }
5809}
5810
5811impl wkt::message::Message for Session {
5812 fn typename() -> &'static str {
5813 "type.googleapis.com/google.spanner.v1.Session"
5814 }
5815}
5816
5817/// The request for [GetSession][google.spanner.v1.Spanner.GetSession].
5818///
5819/// [google.spanner.v1.Spanner.GetSession]: crate::client::Spanner::get_session
5820#[derive(Clone, Default, PartialEq)]
5821#[non_exhaustive]
5822pub struct GetSessionRequest {
5823 /// Required. The name of the session to retrieve.
5824 pub name: std::string::String,
5825
5826 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5827}
5828
5829impl GetSessionRequest {
5830 /// Creates a new default instance.
5831 pub fn new() -> Self {
5832 std::default::Default::default()
5833 }
5834
5835 /// Sets the value of [name][crate::model::GetSessionRequest::name].
5836 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5837 self.name = v.into();
5838 self
5839 }
5840}
5841
5842impl wkt::message::Message for GetSessionRequest {
5843 fn typename() -> &'static str {
5844 "type.googleapis.com/google.spanner.v1.GetSessionRequest"
5845 }
5846}
5847
5848/// The request for [ListSessions][google.spanner.v1.Spanner.ListSessions].
5849///
5850/// [google.spanner.v1.Spanner.ListSessions]: crate::client::Spanner::list_sessions
5851#[derive(Clone, Default, PartialEq)]
5852#[non_exhaustive]
5853pub struct ListSessionsRequest {
5854 /// Required. The database in which to list sessions.
5855 pub database: std::string::String,
5856
5857 /// Number of sessions to be returned in the response. If 0 or less, defaults
5858 /// to the server's maximum allowed page size.
5859 pub page_size: i32,
5860
5861 /// If non-empty, `page_token` should contain a
5862 /// [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token]
5863 /// from a previous
5864 /// [ListSessionsResponse][google.spanner.v1.ListSessionsResponse].
5865 ///
5866 /// [google.spanner.v1.ListSessionsResponse]: crate::model::ListSessionsResponse
5867 /// [google.spanner.v1.ListSessionsResponse.next_page_token]: crate::model::ListSessionsResponse::next_page_token
5868 pub page_token: std::string::String,
5869
5870 /// An expression for filtering the results of the request. Filter rules are
5871 /// case insensitive. The fields eligible for filtering are:
5872 ///
5873 /// * `labels.key` where key is the name of a label
5874 ///
5875 /// Some examples of using filters are:
5876 ///
5877 /// * `labels.env:*` --> The session has the label "env".
5878 /// * `labels.env:dev` --> The session has the label "env" and the value of
5879 /// the label contains the string "dev".
5880 pub filter: std::string::String,
5881
5882 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5883}
5884
5885impl ListSessionsRequest {
5886 /// Creates a new default instance.
5887 pub fn new() -> Self {
5888 std::default::Default::default()
5889 }
5890
5891 /// Sets the value of [database][crate::model::ListSessionsRequest::database].
5892 pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5893 self.database = v.into();
5894 self
5895 }
5896
5897 /// Sets the value of [page_size][crate::model::ListSessionsRequest::page_size].
5898 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5899 self.page_size = v.into();
5900 self
5901 }
5902
5903 /// Sets the value of [page_token][crate::model::ListSessionsRequest::page_token].
5904 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5905 self.page_token = v.into();
5906 self
5907 }
5908
5909 /// Sets the value of [filter][crate::model::ListSessionsRequest::filter].
5910 pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5911 self.filter = v.into();
5912 self
5913 }
5914}
5915
5916impl wkt::message::Message for ListSessionsRequest {
5917 fn typename() -> &'static str {
5918 "type.googleapis.com/google.spanner.v1.ListSessionsRequest"
5919 }
5920}
5921
5922/// The response for [ListSessions][google.spanner.v1.Spanner.ListSessions].
5923///
5924/// [google.spanner.v1.Spanner.ListSessions]: crate::client::Spanner::list_sessions
5925#[derive(Clone, Default, PartialEq)]
5926#[non_exhaustive]
5927pub struct ListSessionsResponse {
5928 /// The list of requested sessions.
5929 pub sessions: std::vec::Vec<crate::model::Session>,
5930
5931 /// `next_page_token` can be sent in a subsequent
5932 /// [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more
5933 /// of the matching sessions.
5934 ///
5935 /// [google.spanner.v1.Spanner.ListSessions]: crate::client::Spanner::list_sessions
5936 pub next_page_token: std::string::String,
5937
5938 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5939}
5940
5941impl ListSessionsResponse {
5942 /// Creates a new default instance.
5943 pub fn new() -> Self {
5944 std::default::Default::default()
5945 }
5946
5947 /// Sets the value of [sessions][crate::model::ListSessionsResponse::sessions].
5948 pub fn set_sessions<T, V>(mut self, v: T) -> Self
5949 where
5950 T: std::iter::IntoIterator<Item = V>,
5951 V: std::convert::Into<crate::model::Session>,
5952 {
5953 use std::iter::Iterator;
5954 self.sessions = v.into_iter().map(|i| i.into()).collect();
5955 self
5956 }
5957
5958 /// Sets the value of [next_page_token][crate::model::ListSessionsResponse::next_page_token].
5959 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5960 self.next_page_token = v.into();
5961 self
5962 }
5963}
5964
5965impl wkt::message::Message for ListSessionsResponse {
5966 fn typename() -> &'static str {
5967 "type.googleapis.com/google.spanner.v1.ListSessionsResponse"
5968 }
5969}
5970
5971#[doc(hidden)]
5972impl google_cloud_gax::paginator::internal::PageableResponse for ListSessionsResponse {
5973 type PageItem = crate::model::Session;
5974
5975 fn items(self) -> std::vec::Vec<Self::PageItem> {
5976 self.sessions
5977 }
5978
5979 fn next_page_token(&self) -> std::string::String {
5980 use std::clone::Clone;
5981 self.next_page_token.clone()
5982 }
5983}
5984
5985/// The request for [DeleteSession][google.spanner.v1.Spanner.DeleteSession].
5986///
5987/// [google.spanner.v1.Spanner.DeleteSession]: crate::client::Spanner::delete_session
5988#[derive(Clone, Default, PartialEq)]
5989#[non_exhaustive]
5990pub struct DeleteSessionRequest {
5991 /// Required. The name of the session to delete.
5992 pub name: std::string::String,
5993
5994 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5995}
5996
5997impl DeleteSessionRequest {
5998 /// Creates a new default instance.
5999 pub fn new() -> Self {
6000 std::default::Default::default()
6001 }
6002
6003 /// Sets the value of [name][crate::model::DeleteSessionRequest::name].
6004 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6005 self.name = v.into();
6006 self
6007 }
6008}
6009
6010impl wkt::message::Message for DeleteSessionRequest {
6011 fn typename() -> &'static str {
6012 "type.googleapis.com/google.spanner.v1.DeleteSessionRequest"
6013 }
6014}
6015
6016/// Common request options for various APIs.
6017#[derive(Clone, Default, PartialEq)]
6018#[non_exhaustive]
6019pub struct RequestOptions {
6020 /// Priority for the request.
6021 pub priority: crate::model::request_options::Priority,
6022
6023 /// A per-request tag which can be applied to queries or reads, used for
6024 /// statistics collection.
6025 /// Both `request_tag` and `transaction_tag` can be specified for a read or
6026 /// query that belongs to a transaction.
6027 /// This field is ignored for requests where it's not applicable (for example,
6028 /// `CommitRequest`).
6029 /// Legal characters for `request_tag` values are all printable characters
6030 /// (ASCII 32 - 126) and the length of a request_tag is limited to 50
6031 /// characters. Values that exceed this limit are truncated.
6032 /// Any leading underscore (_) characters are removed from the string.
6033 pub request_tag: std::string::String,
6034
6035 /// A tag used for statistics collection about this transaction.
6036 /// Both `request_tag` and `transaction_tag` can be specified for a read or
6037 /// query that belongs to a transaction.
6038 /// To enable tagging on a transaction, `transaction_tag` must be set to the
6039 /// same value for all requests belonging to the same transaction, including
6040 /// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
6041 /// If this request doesn't belong to any transaction, `transaction_tag` is
6042 /// ignored.
6043 /// Legal characters for `transaction_tag` values are all printable characters
6044 /// (ASCII 32 - 126) and the length of a `transaction_tag` is limited to 50
6045 /// characters. Values that exceed this limit are truncated.
6046 /// Any leading underscore (_) characters are removed from the string.
6047 ///
6048 /// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
6049 pub transaction_tag: std::string::String,
6050
6051 /// Optional. Optional context that may be needed for some requests.
6052 pub client_context: std::option::Option<crate::model::request_options::ClientContext>,
6053
6054 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6055}
6056
6057impl RequestOptions {
6058 /// Creates a new default instance.
6059 pub fn new() -> Self {
6060 std::default::Default::default()
6061 }
6062
6063 /// Sets the value of [priority][crate::model::RequestOptions::priority].
6064 pub fn set_priority<T: std::convert::Into<crate::model::request_options::Priority>>(
6065 mut self,
6066 v: T,
6067 ) -> Self {
6068 self.priority = v.into();
6069 self
6070 }
6071
6072 /// Sets the value of [request_tag][crate::model::RequestOptions::request_tag].
6073 pub fn set_request_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6074 self.request_tag = v.into();
6075 self
6076 }
6077
6078 /// Sets the value of [transaction_tag][crate::model::RequestOptions::transaction_tag].
6079 pub fn set_transaction_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6080 self.transaction_tag = v.into();
6081 self
6082 }
6083
6084 /// Sets the value of [client_context][crate::model::RequestOptions::client_context].
6085 pub fn set_client_context<T>(mut self, v: T) -> Self
6086 where
6087 T: std::convert::Into<crate::model::request_options::ClientContext>,
6088 {
6089 self.client_context = std::option::Option::Some(v.into());
6090 self
6091 }
6092
6093 /// Sets or clears the value of [client_context][crate::model::RequestOptions::client_context].
6094 pub fn set_or_clear_client_context<T>(mut self, v: std::option::Option<T>) -> Self
6095 where
6096 T: std::convert::Into<crate::model::request_options::ClientContext>,
6097 {
6098 self.client_context = v.map(|x| x.into());
6099 self
6100 }
6101}
6102
6103impl wkt::message::Message for RequestOptions {
6104 fn typename() -> &'static str {
6105 "type.googleapis.com/google.spanner.v1.RequestOptions"
6106 }
6107}
6108
6109/// Defines additional types related to [RequestOptions].
6110pub mod request_options {
6111 #[allow(unused_imports)]
6112 use super::*;
6113
6114 /// Container for various pieces of client-owned context attached to a request.
6115 #[derive(Clone, Default, PartialEq)]
6116 #[non_exhaustive]
6117 pub struct ClientContext {
6118 /// Optional. Map of parameter name to value for this request. These values
6119 /// will be returned by any SECURE_CONTEXT() calls invoked by this request
6120 /// (e.g., by queries against Parameterized Secure Views).
6121 pub secure_context: std::collections::HashMap<std::string::String, wkt::Value>,
6122
6123 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6124 }
6125
6126 impl ClientContext {
6127 /// Creates a new default instance.
6128 pub fn new() -> Self {
6129 std::default::Default::default()
6130 }
6131
6132 /// Sets the value of [secure_context][crate::model::request_options::ClientContext::secure_context].
6133 pub fn set_secure_context<T, K, V>(mut self, v: T) -> Self
6134 where
6135 T: std::iter::IntoIterator<Item = (K, V)>,
6136 K: std::convert::Into<std::string::String>,
6137 V: std::convert::Into<wkt::Value>,
6138 {
6139 use std::iter::Iterator;
6140 self.secure_context = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6141 self
6142 }
6143 }
6144
6145 impl wkt::message::Message for ClientContext {
6146 fn typename() -> &'static str {
6147 "type.googleapis.com/google.spanner.v1.RequestOptions.ClientContext"
6148 }
6149 }
6150
6151 /// The relative priority for requests. Note that priority isn't applicable
6152 /// for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
6153 ///
6154 /// The priority acts as a hint to the Cloud Spanner scheduler and doesn't
6155 /// guarantee priority or order of execution. For example:
6156 ///
6157 /// * Some parts of a write operation always execute at `PRIORITY_HIGH`,
6158 /// regardless of the specified priority. This can cause you to see an
6159 /// increase in high priority workload even when executing a low priority
6160 /// request. This can also potentially cause a priority inversion where a
6161 /// lower priority request is fulfilled ahead of a higher priority
6162 /// request.
6163 /// * If a transaction contains multiple operations with different priorities,
6164 /// Cloud Spanner doesn't guarantee to process the higher priority
6165 /// operations first. There might be other constraints to satisfy, such as
6166 /// the order of operations.
6167 ///
6168 /// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
6169 ///
6170 /// # Working with unknown values
6171 ///
6172 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6173 /// additional enum variants at any time. Adding new variants is not considered
6174 /// a breaking change. Applications should write their code in anticipation of:
6175 ///
6176 /// - New values appearing in future releases of the client library, **and**
6177 /// - New values received dynamically, without application changes.
6178 ///
6179 /// Please consult the [Working with enums] section in the user guide for some
6180 /// guidelines.
6181 ///
6182 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6183 #[derive(Clone, Debug, PartialEq)]
6184 #[non_exhaustive]
6185 pub enum Priority {
6186 /// `PRIORITY_UNSPECIFIED` is equivalent to `PRIORITY_HIGH`.
6187 Unspecified,
6188 /// This specifies that the request is low priority.
6189 Low,
6190 /// This specifies that the request is medium priority.
6191 Medium,
6192 /// This specifies that the request is high priority.
6193 High,
6194 /// If set, the enum was initialized with an unknown value.
6195 ///
6196 /// Applications can examine the value using [Priority::value] or
6197 /// [Priority::name].
6198 UnknownValue(priority::UnknownValue),
6199 }
6200
6201 #[doc(hidden)]
6202 pub mod priority {
6203 #[allow(unused_imports)]
6204 use super::*;
6205 #[derive(Clone, Debug, PartialEq)]
6206 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6207 }
6208
6209 impl Priority {
6210 /// Gets the enum value.
6211 ///
6212 /// Returns `None` if the enum contains an unknown value deserialized from
6213 /// the string representation of enums.
6214 pub fn value(&self) -> std::option::Option<i32> {
6215 match self {
6216 Self::Unspecified => std::option::Option::Some(0),
6217 Self::Low => std::option::Option::Some(1),
6218 Self::Medium => std::option::Option::Some(2),
6219 Self::High => std::option::Option::Some(3),
6220 Self::UnknownValue(u) => u.0.value(),
6221 }
6222 }
6223
6224 /// Gets the enum value as a string.
6225 ///
6226 /// Returns `None` if the enum contains an unknown value deserialized from
6227 /// the integer representation of enums.
6228 pub fn name(&self) -> std::option::Option<&str> {
6229 match self {
6230 Self::Unspecified => std::option::Option::Some("PRIORITY_UNSPECIFIED"),
6231 Self::Low => std::option::Option::Some("PRIORITY_LOW"),
6232 Self::Medium => std::option::Option::Some("PRIORITY_MEDIUM"),
6233 Self::High => std::option::Option::Some("PRIORITY_HIGH"),
6234 Self::UnknownValue(u) => u.0.name(),
6235 }
6236 }
6237 }
6238
6239 impl std::default::Default for Priority {
6240 fn default() -> Self {
6241 use std::convert::From;
6242 Self::from(0)
6243 }
6244 }
6245
6246 impl std::fmt::Display for Priority {
6247 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6248 wkt::internal::display_enum(f, self.name(), self.value())
6249 }
6250 }
6251
6252 impl std::convert::From<i32> for Priority {
6253 fn from(value: i32) -> Self {
6254 match value {
6255 0 => Self::Unspecified,
6256 1 => Self::Low,
6257 2 => Self::Medium,
6258 3 => Self::High,
6259 _ => Self::UnknownValue(priority::UnknownValue(
6260 wkt::internal::UnknownEnumValue::Integer(value),
6261 )),
6262 }
6263 }
6264 }
6265
6266 impl std::convert::From<&str> for Priority {
6267 fn from(value: &str) -> Self {
6268 use std::string::ToString;
6269 match value {
6270 "PRIORITY_UNSPECIFIED" => Self::Unspecified,
6271 "PRIORITY_LOW" => Self::Low,
6272 "PRIORITY_MEDIUM" => Self::Medium,
6273 "PRIORITY_HIGH" => Self::High,
6274 _ => Self::UnknownValue(priority::UnknownValue(
6275 wkt::internal::UnknownEnumValue::String(value.to_string()),
6276 )),
6277 }
6278 }
6279 }
6280
6281 impl serde::ser::Serialize for Priority {
6282 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6283 where
6284 S: serde::Serializer,
6285 {
6286 match self {
6287 Self::Unspecified => serializer.serialize_i32(0),
6288 Self::Low => serializer.serialize_i32(1),
6289 Self::Medium => serializer.serialize_i32(2),
6290 Self::High => serializer.serialize_i32(3),
6291 Self::UnknownValue(u) => u.0.serialize(serializer),
6292 }
6293 }
6294 }
6295
6296 impl<'de> serde::de::Deserialize<'de> for Priority {
6297 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6298 where
6299 D: serde::Deserializer<'de>,
6300 {
6301 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Priority>::new(
6302 ".google.spanner.v1.RequestOptions.Priority",
6303 ))
6304 }
6305 }
6306}
6307
6308/// The `DirectedReadOptions` can be used to indicate which replicas or regions
6309/// should be used for non-transactional reads or queries.
6310///
6311/// `DirectedReadOptions` can only be specified for a read-only transaction,
6312/// otherwise the API returns an `INVALID_ARGUMENT` error.
6313#[derive(Clone, Default, PartialEq)]
6314#[non_exhaustive]
6315pub struct DirectedReadOptions {
6316 /// Required. At most one of either `include_replicas` or `exclude_replicas`
6317 /// should be present in the message.
6318 pub replicas: std::option::Option<crate::model::directed_read_options::Replicas>,
6319
6320 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6321}
6322
6323impl DirectedReadOptions {
6324 /// Creates a new default instance.
6325 pub fn new() -> Self {
6326 std::default::Default::default()
6327 }
6328
6329 /// Sets the value of [replicas][crate::model::DirectedReadOptions::replicas].
6330 ///
6331 /// Note that all the setters affecting `replicas` are mutually
6332 /// exclusive.
6333 pub fn set_replicas<
6334 T: std::convert::Into<std::option::Option<crate::model::directed_read_options::Replicas>>,
6335 >(
6336 mut self,
6337 v: T,
6338 ) -> Self {
6339 self.replicas = v.into();
6340 self
6341 }
6342
6343 /// The value of [replicas][crate::model::DirectedReadOptions::replicas]
6344 /// if it holds a `IncludeReplicas`, `None` if the field is not set or
6345 /// holds a different branch.
6346 pub fn include_replicas(
6347 &self,
6348 ) -> std::option::Option<&std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>>
6349 {
6350 #[allow(unreachable_patterns)]
6351 self.replicas.as_ref().and_then(|v| match v {
6352 crate::model::directed_read_options::Replicas::IncludeReplicas(v) => {
6353 std::option::Option::Some(v)
6354 }
6355 _ => std::option::Option::None,
6356 })
6357 }
6358
6359 /// Sets the value of [replicas][crate::model::DirectedReadOptions::replicas]
6360 /// to hold a `IncludeReplicas`.
6361 ///
6362 /// Note that all the setters affecting `replicas` are
6363 /// mutually exclusive.
6364 pub fn set_include_replicas<
6365 T: std::convert::Into<std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>>,
6366 >(
6367 mut self,
6368 v: T,
6369 ) -> Self {
6370 self.replicas = std::option::Option::Some(
6371 crate::model::directed_read_options::Replicas::IncludeReplicas(v.into()),
6372 );
6373 self
6374 }
6375
6376 /// The value of [replicas][crate::model::DirectedReadOptions::replicas]
6377 /// if it holds a `ExcludeReplicas`, `None` if the field is not set or
6378 /// holds a different branch.
6379 pub fn exclude_replicas(
6380 &self,
6381 ) -> std::option::Option<&std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>>
6382 {
6383 #[allow(unreachable_patterns)]
6384 self.replicas.as_ref().and_then(|v| match v {
6385 crate::model::directed_read_options::Replicas::ExcludeReplicas(v) => {
6386 std::option::Option::Some(v)
6387 }
6388 _ => std::option::Option::None,
6389 })
6390 }
6391
6392 /// Sets the value of [replicas][crate::model::DirectedReadOptions::replicas]
6393 /// to hold a `ExcludeReplicas`.
6394 ///
6395 /// Note that all the setters affecting `replicas` are
6396 /// mutually exclusive.
6397 pub fn set_exclude_replicas<
6398 T: std::convert::Into<std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>>,
6399 >(
6400 mut self,
6401 v: T,
6402 ) -> Self {
6403 self.replicas = std::option::Option::Some(
6404 crate::model::directed_read_options::Replicas::ExcludeReplicas(v.into()),
6405 );
6406 self
6407 }
6408}
6409
6410impl wkt::message::Message for DirectedReadOptions {
6411 fn typename() -> &'static str {
6412 "type.googleapis.com/google.spanner.v1.DirectedReadOptions"
6413 }
6414}
6415
6416/// Defines additional types related to [DirectedReadOptions].
6417pub mod directed_read_options {
6418 #[allow(unused_imports)]
6419 use super::*;
6420
6421 /// The directed read replica selector.
6422 /// Callers must provide one or more of the following fields for replica
6423 /// selection:
6424 ///
6425 /// * `location` - The location must be one of the regions within the
6426 /// multi-region configuration of your database.
6427 /// * `type` - The type of the replica.
6428 ///
6429 /// Some examples of using replica_selectors are:
6430 ///
6431 /// * `location:us-east1` --> The "us-east1" replica(s) of any available type
6432 /// is used to process the request.
6433 /// * `type:READ_ONLY` --> The "READ_ONLY" type replica(s) in the nearest
6434 /// available location are used to process the
6435 /// request.
6436 /// * `location:us-east1 type:READ_ONLY` --> The "READ_ONLY" type replica(s)
6437 /// in location "us-east1" is used to process
6438 /// the request.
6439 #[derive(Clone, Default, PartialEq)]
6440 #[non_exhaustive]
6441 pub struct ReplicaSelection {
6442 /// The location or region of the serving requests, for example, "us-east1".
6443 pub location: std::string::String,
6444
6445 /// The type of replica.
6446 pub r#type: crate::model::directed_read_options::replica_selection::Type,
6447
6448 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6449 }
6450
6451 impl ReplicaSelection {
6452 /// Creates a new default instance.
6453 pub fn new() -> Self {
6454 std::default::Default::default()
6455 }
6456
6457 /// Sets the value of [location][crate::model::directed_read_options::ReplicaSelection::location].
6458 pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6459 self.location = v.into();
6460 self
6461 }
6462
6463 /// Sets the value of [r#type][crate::model::directed_read_options::ReplicaSelection::type].
6464 pub fn set_type<
6465 T: std::convert::Into<crate::model::directed_read_options::replica_selection::Type>,
6466 >(
6467 mut self,
6468 v: T,
6469 ) -> Self {
6470 self.r#type = v.into();
6471 self
6472 }
6473 }
6474
6475 impl wkt::message::Message for ReplicaSelection {
6476 fn typename() -> &'static str {
6477 "type.googleapis.com/google.spanner.v1.DirectedReadOptions.ReplicaSelection"
6478 }
6479 }
6480
6481 /// Defines additional types related to [ReplicaSelection].
6482 pub mod replica_selection {
6483 #[allow(unused_imports)]
6484 use super::*;
6485
6486 /// Indicates the type of replica.
6487 ///
6488 /// # Working with unknown values
6489 ///
6490 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6491 /// additional enum variants at any time. Adding new variants is not considered
6492 /// a breaking change. Applications should write their code in anticipation of:
6493 ///
6494 /// - New values appearing in future releases of the client library, **and**
6495 /// - New values received dynamically, without application changes.
6496 ///
6497 /// Please consult the [Working with enums] section in the user guide for some
6498 /// guidelines.
6499 ///
6500 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6501 #[derive(Clone, Debug, PartialEq)]
6502 #[non_exhaustive]
6503 pub enum Type {
6504 /// Not specified.
6505 Unspecified,
6506 /// Read-write replicas support both reads and writes.
6507 ReadWrite,
6508 /// Read-only replicas only support reads (not writes).
6509 ReadOnly,
6510 /// If set, the enum was initialized with an unknown value.
6511 ///
6512 /// Applications can examine the value using [Type::value] or
6513 /// [Type::name].
6514 UnknownValue(r#type::UnknownValue),
6515 }
6516
6517 #[doc(hidden)]
6518 pub mod r#type {
6519 #[allow(unused_imports)]
6520 use super::*;
6521 #[derive(Clone, Debug, PartialEq)]
6522 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6523 }
6524
6525 impl Type {
6526 /// Gets the enum value.
6527 ///
6528 /// Returns `None` if the enum contains an unknown value deserialized from
6529 /// the string representation of enums.
6530 pub fn value(&self) -> std::option::Option<i32> {
6531 match self {
6532 Self::Unspecified => std::option::Option::Some(0),
6533 Self::ReadWrite => std::option::Option::Some(1),
6534 Self::ReadOnly => std::option::Option::Some(2),
6535 Self::UnknownValue(u) => u.0.value(),
6536 }
6537 }
6538
6539 /// Gets the enum value as a string.
6540 ///
6541 /// Returns `None` if the enum contains an unknown value deserialized from
6542 /// the integer representation of enums.
6543 pub fn name(&self) -> std::option::Option<&str> {
6544 match self {
6545 Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
6546 Self::ReadWrite => std::option::Option::Some("READ_WRITE"),
6547 Self::ReadOnly => std::option::Option::Some("READ_ONLY"),
6548 Self::UnknownValue(u) => u.0.name(),
6549 }
6550 }
6551 }
6552
6553 impl std::default::Default for Type {
6554 fn default() -> Self {
6555 use std::convert::From;
6556 Self::from(0)
6557 }
6558 }
6559
6560 impl std::fmt::Display for Type {
6561 fn fmt(
6562 &self,
6563 f: &mut std::fmt::Formatter<'_>,
6564 ) -> std::result::Result<(), std::fmt::Error> {
6565 wkt::internal::display_enum(f, self.name(), self.value())
6566 }
6567 }
6568
6569 impl std::convert::From<i32> for Type {
6570 fn from(value: i32) -> Self {
6571 match value {
6572 0 => Self::Unspecified,
6573 1 => Self::ReadWrite,
6574 2 => Self::ReadOnly,
6575 _ => Self::UnknownValue(r#type::UnknownValue(
6576 wkt::internal::UnknownEnumValue::Integer(value),
6577 )),
6578 }
6579 }
6580 }
6581
6582 impl std::convert::From<&str> for Type {
6583 fn from(value: &str) -> Self {
6584 use std::string::ToString;
6585 match value {
6586 "TYPE_UNSPECIFIED" => Self::Unspecified,
6587 "READ_WRITE" => Self::ReadWrite,
6588 "READ_ONLY" => Self::ReadOnly,
6589 _ => Self::UnknownValue(r#type::UnknownValue(
6590 wkt::internal::UnknownEnumValue::String(value.to_string()),
6591 )),
6592 }
6593 }
6594 }
6595
6596 impl serde::ser::Serialize for Type {
6597 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6598 where
6599 S: serde::Serializer,
6600 {
6601 match self {
6602 Self::Unspecified => serializer.serialize_i32(0),
6603 Self::ReadWrite => serializer.serialize_i32(1),
6604 Self::ReadOnly => serializer.serialize_i32(2),
6605 Self::UnknownValue(u) => u.0.serialize(serializer),
6606 }
6607 }
6608 }
6609
6610 impl<'de> serde::de::Deserialize<'de> for Type {
6611 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6612 where
6613 D: serde::Deserializer<'de>,
6614 {
6615 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
6616 ".google.spanner.v1.DirectedReadOptions.ReplicaSelection.Type",
6617 ))
6618 }
6619 }
6620 }
6621
6622 /// An `IncludeReplicas` contains a repeated set of `ReplicaSelection` which
6623 /// indicates the order in which replicas should be considered.
6624 #[derive(Clone, Default, PartialEq)]
6625 #[non_exhaustive]
6626 pub struct IncludeReplicas {
6627 /// The directed read replica selector.
6628 pub replica_selections:
6629 std::vec::Vec<crate::model::directed_read_options::ReplicaSelection>,
6630
6631 /// If `true`, Spanner doesn't route requests to a replica outside the
6632 /// <`include_replicas` list when all of the specified replicas are
6633 /// unavailable or unhealthy. Default value is `false`.
6634 pub auto_failover_disabled: bool,
6635
6636 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6637 }
6638
6639 impl IncludeReplicas {
6640 /// Creates a new default instance.
6641 pub fn new() -> Self {
6642 std::default::Default::default()
6643 }
6644
6645 /// Sets the value of [replica_selections][crate::model::directed_read_options::IncludeReplicas::replica_selections].
6646 pub fn set_replica_selections<T, V>(mut self, v: T) -> Self
6647 where
6648 T: std::iter::IntoIterator<Item = V>,
6649 V: std::convert::Into<crate::model::directed_read_options::ReplicaSelection>,
6650 {
6651 use std::iter::Iterator;
6652 self.replica_selections = v.into_iter().map(|i| i.into()).collect();
6653 self
6654 }
6655
6656 /// Sets the value of [auto_failover_disabled][crate::model::directed_read_options::IncludeReplicas::auto_failover_disabled].
6657 pub fn set_auto_failover_disabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6658 self.auto_failover_disabled = v.into();
6659 self
6660 }
6661 }
6662
6663 impl wkt::message::Message for IncludeReplicas {
6664 fn typename() -> &'static str {
6665 "type.googleapis.com/google.spanner.v1.DirectedReadOptions.IncludeReplicas"
6666 }
6667 }
6668
6669 /// An ExcludeReplicas contains a repeated set of ReplicaSelection that should
6670 /// be excluded from serving requests.
6671 #[derive(Clone, Default, PartialEq)]
6672 #[non_exhaustive]
6673 pub struct ExcludeReplicas {
6674 /// The directed read replica selector.
6675 pub replica_selections:
6676 std::vec::Vec<crate::model::directed_read_options::ReplicaSelection>,
6677
6678 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6679 }
6680
6681 impl ExcludeReplicas {
6682 /// Creates a new default instance.
6683 pub fn new() -> Self {
6684 std::default::Default::default()
6685 }
6686
6687 /// Sets the value of [replica_selections][crate::model::directed_read_options::ExcludeReplicas::replica_selections].
6688 pub fn set_replica_selections<T, V>(mut self, v: T) -> Self
6689 where
6690 T: std::iter::IntoIterator<Item = V>,
6691 V: std::convert::Into<crate::model::directed_read_options::ReplicaSelection>,
6692 {
6693 use std::iter::Iterator;
6694 self.replica_selections = v.into_iter().map(|i| i.into()).collect();
6695 self
6696 }
6697 }
6698
6699 impl wkt::message::Message for ExcludeReplicas {
6700 fn typename() -> &'static str {
6701 "type.googleapis.com/google.spanner.v1.DirectedReadOptions.ExcludeReplicas"
6702 }
6703 }
6704
6705 /// Required. At most one of either `include_replicas` or `exclude_replicas`
6706 /// should be present in the message.
6707 #[derive(Clone, Debug, PartialEq)]
6708 #[non_exhaustive]
6709 pub enum Replicas {
6710 /// `Include_replicas` indicates the order of replicas (as they appear in
6711 /// this list) to process the request. If `auto_failover_disabled` is set to
6712 /// `true` and all replicas are exhausted without finding a healthy replica,
6713 /// Spanner waits for a replica in the list to become available, requests
6714 /// might fail due to `DEADLINE_EXCEEDED` errors.
6715 IncludeReplicas(std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>),
6716 /// `Exclude_replicas` indicates that specified replicas should be excluded
6717 /// from serving requests. Spanner doesn't route requests to the replicas
6718 /// in this list.
6719 ExcludeReplicas(std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>),
6720 }
6721
6722 impl Replicas {
6723 /// Initializes the enum to the [IncludeReplicas](Self::IncludeReplicas) branch.
6724 pub fn from_include_replicas(
6725 value: impl std::convert::Into<
6726 std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>,
6727 >,
6728 ) -> Self {
6729 Self::IncludeReplicas(value.into())
6730 }
6731 /// Initializes the enum to the [ExcludeReplicas](Self::ExcludeReplicas) branch.
6732 pub fn from_exclude_replicas(
6733 value: impl std::convert::Into<
6734 std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>,
6735 >,
6736 ) -> Self {
6737 Self::ExcludeReplicas(value.into())
6738 }
6739 }
6740}
6741
6742/// The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
6743/// [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
6744///
6745/// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
6746#[derive(Clone, Default, PartialEq)]
6747#[non_exhaustive]
6748pub struct ExecuteSqlRequest {
6749 /// Required. The session in which the SQL query should be performed.
6750 pub session: std::string::String,
6751
6752 /// The transaction to use.
6753 ///
6754 /// For queries, if none is provided, the default is a temporary read-only
6755 /// transaction with strong concurrency.
6756 ///
6757 /// Standard DML statements require a read-write transaction. To protect
6758 /// against replays, single-use transactions are not supported. The caller
6759 /// must either supply an existing transaction ID or begin a new transaction.
6760 ///
6761 /// Partitioned DML requires an existing Partitioned DML transaction ID.
6762 pub transaction: std::option::Option<crate::model::TransactionSelector>,
6763
6764 /// Required. The SQL string.
6765 pub sql: std::string::String,
6766
6767 /// Parameter names and values that bind to placeholders in the SQL string.
6768 ///
6769 /// A parameter placeholder consists of the `@` character followed by the
6770 /// parameter name (for example, `@firstName`). Parameter names must conform
6771 /// to the naming requirements of identifiers as specified at
6772 /// <https://cloud.google.com/spanner/docs/lexical#identifiers>.
6773 ///
6774 /// Parameters can appear anywhere that a literal value is expected. The same
6775 /// parameter name can be used more than once, for example:
6776 ///
6777 /// `"WHERE id > @msg_id AND id < @msg_id + 100"`
6778 ///
6779 /// It's an error to execute a SQL statement with unbound parameters.
6780 pub params: std::option::Option<wkt::Struct>,
6781
6782 /// It isn't always possible for Cloud Spanner to infer the right SQL type
6783 /// from a JSON value. For example, values of type `BYTES` and values
6784 /// of type `STRING` both appear in
6785 /// [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings.
6786 ///
6787 /// In these cases, you can use `param_types` to specify the exact
6788 /// SQL type for some or all of the SQL statement parameters. See the
6789 /// definition of [Type][google.spanner.v1.Type] for more information
6790 /// about SQL types.
6791 ///
6792 /// [google.spanner.v1.ExecuteSqlRequest.params]: crate::model::ExecuteSqlRequest::params
6793 /// [google.spanner.v1.Type]: crate::model::Type
6794 pub param_types: std::collections::HashMap<std::string::String, crate::model::Type>,
6795
6796 /// If this request is resuming a previously interrupted SQL statement
6797 /// execution, `resume_token` should be copied from the last
6798 /// [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
6799 /// interruption. Doing this enables the new SQL statement execution to resume
6800 /// where the last one left off. The rest of the request parameters must
6801 /// exactly match the request that yielded this token.
6802 ///
6803 /// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
6804 pub resume_token: ::bytes::Bytes,
6805
6806 /// Used to control the amount of debugging information returned in
6807 /// [ResultSetStats][google.spanner.v1.ResultSetStats]. If
6808 /// [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is
6809 /// set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only
6810 /// be set to
6811 /// [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL].
6812 ///
6813 /// [google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]: crate::model::execute_sql_request::QueryMode::Normal
6814 /// [google.spanner.v1.ExecuteSqlRequest.partition_token]: crate::model::ExecuteSqlRequest::partition_token
6815 /// [google.spanner.v1.ExecuteSqlRequest.query_mode]: crate::model::ExecuteSqlRequest::query_mode
6816 /// [google.spanner.v1.ResultSetStats]: crate::model::ResultSetStats
6817 pub query_mode: crate::model::execute_sql_request::QueryMode,
6818
6819 /// If present, results are restricted to the specified partition
6820 /// previously created using `PartitionQuery`. There must be an exact
6821 /// match for the values of fields common to this message and the
6822 /// `PartitionQueryRequest` message used to create this `partition_token`.
6823 pub partition_token: ::bytes::Bytes,
6824
6825 /// A per-transaction sequence number used to identify this request. This field
6826 /// makes each request idempotent such that if the request is received multiple
6827 /// times, at most one succeeds.
6828 ///
6829 /// The sequence number must be monotonically increasing within the
6830 /// transaction. If a request arrives for the first time with an out-of-order
6831 /// sequence number, the transaction can be aborted. Replays of previously
6832 /// handled requests yield the same response as the first execution.
6833 ///
6834 /// Required for DML statements. Ignored for queries.
6835 pub seqno: i64,
6836
6837 /// Query optimizer configuration to use for the given query.
6838 pub query_options: std::option::Option<crate::model::execute_sql_request::QueryOptions>,
6839
6840 /// Common options for this request.
6841 pub request_options: std::option::Option<crate::model::RequestOptions>,
6842
6843 /// Directed read options for this request.
6844 pub directed_read_options: std::option::Option<crate::model::DirectedReadOptions>,
6845
6846 /// If this is for a partitioned query and this field is set to `true`, the
6847 /// request is executed with Spanner Data Boost independent compute resources.
6848 ///
6849 /// If the field is set to `true` but the request doesn't set
6850 /// `partition_token`, the API returns an `INVALID_ARGUMENT` error.
6851 pub data_boost_enabled: bool,
6852
6853 /// Optional. If set to `true`, this statement marks the end of the
6854 /// transaction. After this statement executes, you must commit or abort the
6855 /// transaction. Attempts to execute any other requests against this
6856 /// transaction (including reads and queries) are rejected.
6857 ///
6858 /// For DML statements, setting this option might cause some error reporting to
6859 /// be deferred until commit time (for example, validation of unique
6860 /// constraints). Given this, successful execution of a DML statement shouldn't
6861 /// be assumed until a subsequent `Commit` call completes successfully.
6862 pub last_statement: bool,
6863
6864 /// Optional. Makes the Spanner requests location-aware if present.
6865 ///
6866 /// It gives the server hints that can be used to route the request
6867 /// to an appropriate server, potentially significantly decreasing latency and
6868 /// improving throughput. To achieve improved performance, most fields must be
6869 /// filled in with accurate values.
6870 pub routing_hint: std::option::Option<crate::model::RoutingHint>,
6871
6872 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6873}
6874
6875impl ExecuteSqlRequest {
6876 /// Creates a new default instance.
6877 pub fn new() -> Self {
6878 std::default::Default::default()
6879 }
6880
6881 /// Sets the value of [session][crate::model::ExecuteSqlRequest::session].
6882 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6883 self.session = v.into();
6884 self
6885 }
6886
6887 /// Sets the value of [transaction][crate::model::ExecuteSqlRequest::transaction].
6888 pub fn set_transaction<T>(mut self, v: T) -> Self
6889 where
6890 T: std::convert::Into<crate::model::TransactionSelector>,
6891 {
6892 self.transaction = std::option::Option::Some(v.into());
6893 self
6894 }
6895
6896 /// Sets or clears the value of [transaction][crate::model::ExecuteSqlRequest::transaction].
6897 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
6898 where
6899 T: std::convert::Into<crate::model::TransactionSelector>,
6900 {
6901 self.transaction = v.map(|x| x.into());
6902 self
6903 }
6904
6905 /// Sets the value of [sql][crate::model::ExecuteSqlRequest::sql].
6906 pub fn set_sql<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6907 self.sql = v.into();
6908 self
6909 }
6910
6911 /// Sets the value of [params][crate::model::ExecuteSqlRequest::params].
6912 pub fn set_params<T>(mut self, v: T) -> Self
6913 where
6914 T: std::convert::Into<wkt::Struct>,
6915 {
6916 self.params = std::option::Option::Some(v.into());
6917 self
6918 }
6919
6920 /// Sets or clears the value of [params][crate::model::ExecuteSqlRequest::params].
6921 pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
6922 where
6923 T: std::convert::Into<wkt::Struct>,
6924 {
6925 self.params = v.map(|x| x.into());
6926 self
6927 }
6928
6929 /// Sets the value of [param_types][crate::model::ExecuteSqlRequest::param_types].
6930 pub fn set_param_types<T, K, V>(mut self, v: T) -> Self
6931 where
6932 T: std::iter::IntoIterator<Item = (K, V)>,
6933 K: std::convert::Into<std::string::String>,
6934 V: std::convert::Into<crate::model::Type>,
6935 {
6936 use std::iter::Iterator;
6937 self.param_types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6938 self
6939 }
6940
6941 /// Sets the value of [resume_token][crate::model::ExecuteSqlRequest::resume_token].
6942 pub fn set_resume_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
6943 self.resume_token = v.into();
6944 self
6945 }
6946
6947 /// Sets the value of [query_mode][crate::model::ExecuteSqlRequest::query_mode].
6948 pub fn set_query_mode<T: std::convert::Into<crate::model::execute_sql_request::QueryMode>>(
6949 mut self,
6950 v: T,
6951 ) -> Self {
6952 self.query_mode = v.into();
6953 self
6954 }
6955
6956 /// Sets the value of [partition_token][crate::model::ExecuteSqlRequest::partition_token].
6957 pub fn set_partition_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
6958 self.partition_token = v.into();
6959 self
6960 }
6961
6962 /// Sets the value of [seqno][crate::model::ExecuteSqlRequest::seqno].
6963 pub fn set_seqno<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6964 self.seqno = v.into();
6965 self
6966 }
6967
6968 /// Sets the value of [query_options][crate::model::ExecuteSqlRequest::query_options].
6969 pub fn set_query_options<T>(mut self, v: T) -> Self
6970 where
6971 T: std::convert::Into<crate::model::execute_sql_request::QueryOptions>,
6972 {
6973 self.query_options = std::option::Option::Some(v.into());
6974 self
6975 }
6976
6977 /// Sets or clears the value of [query_options][crate::model::ExecuteSqlRequest::query_options].
6978 pub fn set_or_clear_query_options<T>(mut self, v: std::option::Option<T>) -> Self
6979 where
6980 T: std::convert::Into<crate::model::execute_sql_request::QueryOptions>,
6981 {
6982 self.query_options = v.map(|x| x.into());
6983 self
6984 }
6985
6986 /// Sets the value of [request_options][crate::model::ExecuteSqlRequest::request_options].
6987 pub fn set_request_options<T>(mut self, v: T) -> Self
6988 where
6989 T: std::convert::Into<crate::model::RequestOptions>,
6990 {
6991 self.request_options = std::option::Option::Some(v.into());
6992 self
6993 }
6994
6995 /// Sets or clears the value of [request_options][crate::model::ExecuteSqlRequest::request_options].
6996 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
6997 where
6998 T: std::convert::Into<crate::model::RequestOptions>,
6999 {
7000 self.request_options = v.map(|x| x.into());
7001 self
7002 }
7003
7004 /// Sets the value of [directed_read_options][crate::model::ExecuteSqlRequest::directed_read_options].
7005 pub fn set_directed_read_options<T>(mut self, v: T) -> Self
7006 where
7007 T: std::convert::Into<crate::model::DirectedReadOptions>,
7008 {
7009 self.directed_read_options = std::option::Option::Some(v.into());
7010 self
7011 }
7012
7013 /// Sets or clears the value of [directed_read_options][crate::model::ExecuteSqlRequest::directed_read_options].
7014 pub fn set_or_clear_directed_read_options<T>(mut self, v: std::option::Option<T>) -> Self
7015 where
7016 T: std::convert::Into<crate::model::DirectedReadOptions>,
7017 {
7018 self.directed_read_options = v.map(|x| x.into());
7019 self
7020 }
7021
7022 /// Sets the value of [data_boost_enabled][crate::model::ExecuteSqlRequest::data_boost_enabled].
7023 pub fn set_data_boost_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7024 self.data_boost_enabled = v.into();
7025 self
7026 }
7027
7028 /// Sets the value of [last_statement][crate::model::ExecuteSqlRequest::last_statement].
7029 pub fn set_last_statement<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7030 self.last_statement = v.into();
7031 self
7032 }
7033
7034 /// Sets the value of [routing_hint][crate::model::ExecuteSqlRequest::routing_hint].
7035 pub fn set_routing_hint<T>(mut self, v: T) -> Self
7036 where
7037 T: std::convert::Into<crate::model::RoutingHint>,
7038 {
7039 self.routing_hint = std::option::Option::Some(v.into());
7040 self
7041 }
7042
7043 /// Sets or clears the value of [routing_hint][crate::model::ExecuteSqlRequest::routing_hint].
7044 pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
7045 where
7046 T: std::convert::Into<crate::model::RoutingHint>,
7047 {
7048 self.routing_hint = v.map(|x| x.into());
7049 self
7050 }
7051}
7052
7053impl wkt::message::Message for ExecuteSqlRequest {
7054 fn typename() -> &'static str {
7055 "type.googleapis.com/google.spanner.v1.ExecuteSqlRequest"
7056 }
7057}
7058
7059/// Defines additional types related to [ExecuteSqlRequest].
7060pub mod execute_sql_request {
7061 #[allow(unused_imports)]
7062 use super::*;
7063
7064 /// Query optimizer configuration.
7065 #[derive(Clone, Default, PartialEq)]
7066 #[non_exhaustive]
7067 pub struct QueryOptions {
7068 /// An option to control the selection of optimizer version.
7069 ///
7070 /// This parameter allows individual queries to pick different query
7071 /// optimizer versions.
7072 ///
7073 /// Specifying `latest` as a value instructs Cloud Spanner to use the
7074 /// latest supported query optimizer version. If not specified, Cloud Spanner
7075 /// uses the optimizer version set at the database level options. Any other
7076 /// positive integer (from the list of supported optimizer versions)
7077 /// overrides the default optimizer version for query execution.
7078 ///
7079 /// The list of supported optimizer versions can be queried from
7080 /// `SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS`.
7081 ///
7082 /// Executing a SQL statement with an invalid optimizer version fails with
7083 /// an `INVALID_ARGUMENT` error.
7084 ///
7085 /// See
7086 /// <https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer>
7087 /// for more information on managing the query optimizer.
7088 ///
7089 /// The `optimizer_version` statement hint has precedence over this setting.
7090 pub optimizer_version: std::string::String,
7091
7092 /// An option to control the selection of optimizer statistics package.
7093 ///
7094 /// This parameter allows individual queries to use a different query
7095 /// optimizer statistics package.
7096 ///
7097 /// Specifying `latest` as a value instructs Cloud Spanner to use the latest
7098 /// generated statistics package. If not specified, Cloud Spanner uses
7099 /// the statistics package set at the database level options, or the latest
7100 /// package if the database option isn't set.
7101 ///
7102 /// The statistics package requested by the query has to be exempt from
7103 /// garbage collection. This can be achieved with the following DDL
7104 /// statement:
7105 ///
7106 /// ```norust
7107 /// ALTER STATISTICS <package_name> SET OPTIONS (allow_gc=false)
7108 /// ```
7109 ///
7110 /// The list of available statistics packages can be queried from
7111 /// `INFORMATION_SCHEMA.SPANNER_STATISTICS`.
7112 ///
7113 /// Executing a SQL statement with an invalid optimizer statistics package
7114 /// or with a statistics package that allows garbage collection fails with
7115 /// an `INVALID_ARGUMENT` error.
7116 pub optimizer_statistics_package: std::string::String,
7117
7118 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7119 }
7120
7121 impl QueryOptions {
7122 /// Creates a new default instance.
7123 pub fn new() -> Self {
7124 std::default::Default::default()
7125 }
7126
7127 /// Sets the value of [optimizer_version][crate::model::execute_sql_request::QueryOptions::optimizer_version].
7128 pub fn set_optimizer_version<T: std::convert::Into<std::string::String>>(
7129 mut self,
7130 v: T,
7131 ) -> Self {
7132 self.optimizer_version = v.into();
7133 self
7134 }
7135
7136 /// Sets the value of [optimizer_statistics_package][crate::model::execute_sql_request::QueryOptions::optimizer_statistics_package].
7137 pub fn set_optimizer_statistics_package<T: std::convert::Into<std::string::String>>(
7138 mut self,
7139 v: T,
7140 ) -> Self {
7141 self.optimizer_statistics_package = v.into();
7142 self
7143 }
7144 }
7145
7146 impl wkt::message::Message for QueryOptions {
7147 fn typename() -> &'static str {
7148 "type.googleapis.com/google.spanner.v1.ExecuteSqlRequest.QueryOptions"
7149 }
7150 }
7151
7152 /// Mode in which the statement must be processed.
7153 ///
7154 /// # Working with unknown values
7155 ///
7156 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7157 /// additional enum variants at any time. Adding new variants is not considered
7158 /// a breaking change. Applications should write their code in anticipation of:
7159 ///
7160 /// - New values appearing in future releases of the client library, **and**
7161 /// - New values received dynamically, without application changes.
7162 ///
7163 /// Please consult the [Working with enums] section in the user guide for some
7164 /// guidelines.
7165 ///
7166 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
7167 #[derive(Clone, Debug, PartialEq)]
7168 #[non_exhaustive]
7169 pub enum QueryMode {
7170 /// The default mode. Only the statement results are returned.
7171 Normal,
7172 /// This mode returns only the query plan, without any results or
7173 /// execution statistics information.
7174 Plan,
7175 /// This mode returns the query plan, overall execution statistics,
7176 /// operator level execution statistics along with the results. This has a
7177 /// performance overhead compared to the other modes. It isn't recommended
7178 /// to use this mode for production traffic.
7179 Profile,
7180 /// This mode returns the overall (but not operator-level) execution
7181 /// statistics along with the results.
7182 WithStats,
7183 /// This mode returns the query plan, overall (but not operator-level)
7184 /// execution statistics along with the results.
7185 WithPlanAndStats,
7186 /// If set, the enum was initialized with an unknown value.
7187 ///
7188 /// Applications can examine the value using [QueryMode::value] or
7189 /// [QueryMode::name].
7190 UnknownValue(query_mode::UnknownValue),
7191 }
7192
7193 #[doc(hidden)]
7194 pub mod query_mode {
7195 #[allow(unused_imports)]
7196 use super::*;
7197 #[derive(Clone, Debug, PartialEq)]
7198 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7199 }
7200
7201 impl QueryMode {
7202 /// Gets the enum value.
7203 ///
7204 /// Returns `None` if the enum contains an unknown value deserialized from
7205 /// the string representation of enums.
7206 pub fn value(&self) -> std::option::Option<i32> {
7207 match self {
7208 Self::Normal => std::option::Option::Some(0),
7209 Self::Plan => std::option::Option::Some(1),
7210 Self::Profile => std::option::Option::Some(2),
7211 Self::WithStats => std::option::Option::Some(3),
7212 Self::WithPlanAndStats => std::option::Option::Some(4),
7213 Self::UnknownValue(u) => u.0.value(),
7214 }
7215 }
7216
7217 /// Gets the enum value as a string.
7218 ///
7219 /// Returns `None` if the enum contains an unknown value deserialized from
7220 /// the integer representation of enums.
7221 pub fn name(&self) -> std::option::Option<&str> {
7222 match self {
7223 Self::Normal => std::option::Option::Some("NORMAL"),
7224 Self::Plan => std::option::Option::Some("PLAN"),
7225 Self::Profile => std::option::Option::Some("PROFILE"),
7226 Self::WithStats => std::option::Option::Some("WITH_STATS"),
7227 Self::WithPlanAndStats => std::option::Option::Some("WITH_PLAN_AND_STATS"),
7228 Self::UnknownValue(u) => u.0.name(),
7229 }
7230 }
7231 }
7232
7233 impl std::default::Default for QueryMode {
7234 fn default() -> Self {
7235 use std::convert::From;
7236 Self::from(0)
7237 }
7238 }
7239
7240 impl std::fmt::Display for QueryMode {
7241 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7242 wkt::internal::display_enum(f, self.name(), self.value())
7243 }
7244 }
7245
7246 impl std::convert::From<i32> for QueryMode {
7247 fn from(value: i32) -> Self {
7248 match value {
7249 0 => Self::Normal,
7250 1 => Self::Plan,
7251 2 => Self::Profile,
7252 3 => Self::WithStats,
7253 4 => Self::WithPlanAndStats,
7254 _ => Self::UnknownValue(query_mode::UnknownValue(
7255 wkt::internal::UnknownEnumValue::Integer(value),
7256 )),
7257 }
7258 }
7259 }
7260
7261 impl std::convert::From<&str> for QueryMode {
7262 fn from(value: &str) -> Self {
7263 use std::string::ToString;
7264 match value {
7265 "NORMAL" => Self::Normal,
7266 "PLAN" => Self::Plan,
7267 "PROFILE" => Self::Profile,
7268 "WITH_STATS" => Self::WithStats,
7269 "WITH_PLAN_AND_STATS" => Self::WithPlanAndStats,
7270 _ => Self::UnknownValue(query_mode::UnknownValue(
7271 wkt::internal::UnknownEnumValue::String(value.to_string()),
7272 )),
7273 }
7274 }
7275 }
7276
7277 impl serde::ser::Serialize for QueryMode {
7278 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7279 where
7280 S: serde::Serializer,
7281 {
7282 match self {
7283 Self::Normal => serializer.serialize_i32(0),
7284 Self::Plan => serializer.serialize_i32(1),
7285 Self::Profile => serializer.serialize_i32(2),
7286 Self::WithStats => serializer.serialize_i32(3),
7287 Self::WithPlanAndStats => serializer.serialize_i32(4),
7288 Self::UnknownValue(u) => u.0.serialize(serializer),
7289 }
7290 }
7291 }
7292
7293 impl<'de> serde::de::Deserialize<'de> for QueryMode {
7294 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7295 where
7296 D: serde::Deserializer<'de>,
7297 {
7298 deserializer.deserialize_any(wkt::internal::EnumVisitor::<QueryMode>::new(
7299 ".google.spanner.v1.ExecuteSqlRequest.QueryMode",
7300 ))
7301 }
7302 }
7303}
7304
7305/// The request for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
7306///
7307/// [google.spanner.v1.Spanner.ExecuteBatchDml]: crate::client::Spanner::execute_batch_dml
7308#[derive(Clone, Default, PartialEq)]
7309#[non_exhaustive]
7310pub struct ExecuteBatchDmlRequest {
7311 /// Required. The session in which the DML statements should be performed.
7312 pub session: std::string::String,
7313
7314 /// Required. The transaction to use. Must be a read-write transaction.
7315 ///
7316 /// To protect against replays, single-use transactions are not supported. The
7317 /// caller must either supply an existing transaction ID or begin a new
7318 /// transaction.
7319 pub transaction: std::option::Option<crate::model::TransactionSelector>,
7320
7321 /// Required. The list of statements to execute in this batch. Statements are
7322 /// executed serially, such that the effects of statement `i` are visible to
7323 /// statement `i+1`. Each statement must be a DML statement. Execution stops at
7324 /// the first failed statement; the remaining statements are not executed.
7325 ///
7326 /// Callers must provide at least one statement.
7327 pub statements: std::vec::Vec<crate::model::execute_batch_dml_request::Statement>,
7328
7329 /// Required. A per-transaction sequence number used to identify this request.
7330 /// This field makes each request idempotent such that if the request is
7331 /// received multiple times, at most one succeeds.
7332 ///
7333 /// The sequence number must be monotonically increasing within the
7334 /// transaction. If a request arrives for the first time with an out-of-order
7335 /// sequence number, the transaction might be aborted. Replays of previously
7336 /// handled requests yield the same response as the first execution.
7337 pub seqno: i64,
7338
7339 /// Common options for this request.
7340 pub request_options: std::option::Option<crate::model::RequestOptions>,
7341
7342 /// Optional. If set to `true`, this request marks the end of the transaction.
7343 /// After these statements execute, you must commit or abort the transaction.
7344 /// Attempts to execute any other requests against this transaction
7345 /// (including reads and queries) are rejected.
7346 ///
7347 /// Setting this option might cause some error reporting to be deferred until
7348 /// commit time (for example, validation of unique constraints). Given this,
7349 /// successful execution of statements shouldn't be assumed until a subsequent
7350 /// `Commit` call completes successfully.
7351 pub last_statements: bool,
7352
7353 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7354}
7355
7356impl ExecuteBatchDmlRequest {
7357 /// Creates a new default instance.
7358 pub fn new() -> Self {
7359 std::default::Default::default()
7360 }
7361
7362 /// Sets the value of [session][crate::model::ExecuteBatchDmlRequest::session].
7363 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7364 self.session = v.into();
7365 self
7366 }
7367
7368 /// Sets the value of [transaction][crate::model::ExecuteBatchDmlRequest::transaction].
7369 pub fn set_transaction<T>(mut self, v: T) -> Self
7370 where
7371 T: std::convert::Into<crate::model::TransactionSelector>,
7372 {
7373 self.transaction = std::option::Option::Some(v.into());
7374 self
7375 }
7376
7377 /// Sets or clears the value of [transaction][crate::model::ExecuteBatchDmlRequest::transaction].
7378 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
7379 where
7380 T: std::convert::Into<crate::model::TransactionSelector>,
7381 {
7382 self.transaction = v.map(|x| x.into());
7383 self
7384 }
7385
7386 /// Sets the value of [statements][crate::model::ExecuteBatchDmlRequest::statements].
7387 pub fn set_statements<T, V>(mut self, v: T) -> Self
7388 where
7389 T: std::iter::IntoIterator<Item = V>,
7390 V: std::convert::Into<crate::model::execute_batch_dml_request::Statement>,
7391 {
7392 use std::iter::Iterator;
7393 self.statements = v.into_iter().map(|i| i.into()).collect();
7394 self
7395 }
7396
7397 /// Sets the value of [seqno][crate::model::ExecuteBatchDmlRequest::seqno].
7398 pub fn set_seqno<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7399 self.seqno = v.into();
7400 self
7401 }
7402
7403 /// Sets the value of [request_options][crate::model::ExecuteBatchDmlRequest::request_options].
7404 pub fn set_request_options<T>(mut self, v: T) -> Self
7405 where
7406 T: std::convert::Into<crate::model::RequestOptions>,
7407 {
7408 self.request_options = std::option::Option::Some(v.into());
7409 self
7410 }
7411
7412 /// Sets or clears the value of [request_options][crate::model::ExecuteBatchDmlRequest::request_options].
7413 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
7414 where
7415 T: std::convert::Into<crate::model::RequestOptions>,
7416 {
7417 self.request_options = v.map(|x| x.into());
7418 self
7419 }
7420
7421 /// Sets the value of [last_statements][crate::model::ExecuteBatchDmlRequest::last_statements].
7422 pub fn set_last_statements<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7423 self.last_statements = v.into();
7424 self
7425 }
7426}
7427
7428impl wkt::message::Message for ExecuteBatchDmlRequest {
7429 fn typename() -> &'static str {
7430 "type.googleapis.com/google.spanner.v1.ExecuteBatchDmlRequest"
7431 }
7432}
7433
7434/// Defines additional types related to [ExecuteBatchDmlRequest].
7435pub mod execute_batch_dml_request {
7436 #[allow(unused_imports)]
7437 use super::*;
7438
7439 /// A single DML statement.
7440 #[derive(Clone, Default, PartialEq)]
7441 #[non_exhaustive]
7442 pub struct Statement {
7443 /// Required. The DML string.
7444 pub sql: std::string::String,
7445
7446 /// Parameter names and values that bind to placeholders in the DML string.
7447 ///
7448 /// A parameter placeholder consists of the `@` character followed by the
7449 /// parameter name (for example, `@firstName`). Parameter names can contain
7450 /// letters, numbers, and underscores.
7451 ///
7452 /// Parameters can appear anywhere that a literal value is expected. The
7453 /// same parameter name can be used more than once, for example:
7454 ///
7455 /// `"WHERE id > @msg_id AND id < @msg_id + 100"`
7456 ///
7457 /// It's an error to execute a SQL statement with unbound parameters.
7458 pub params: std::option::Option<wkt::Struct>,
7459
7460 /// It isn't always possible for Cloud Spanner to infer the right SQL type
7461 /// from a JSON value. For example, values of type `BYTES` and values
7462 /// of type `STRING` both appear in
7463 /// [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as
7464 /// JSON strings.
7465 ///
7466 /// In these cases, `param_types` can be used to specify the exact
7467 /// SQL type for some or all of the SQL statement parameters. See the
7468 /// definition of [Type][google.spanner.v1.Type] for more information
7469 /// about SQL types.
7470 ///
7471 /// [google.spanner.v1.ExecuteBatchDmlRequest.Statement.params]: crate::model::execute_batch_dml_request::Statement::params
7472 /// [google.spanner.v1.Type]: crate::model::Type
7473 pub param_types: std::collections::HashMap<std::string::String, crate::model::Type>,
7474
7475 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7476 }
7477
7478 impl Statement {
7479 /// Creates a new default instance.
7480 pub fn new() -> Self {
7481 std::default::Default::default()
7482 }
7483
7484 /// Sets the value of [sql][crate::model::execute_batch_dml_request::Statement::sql].
7485 pub fn set_sql<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7486 self.sql = v.into();
7487 self
7488 }
7489
7490 /// Sets the value of [params][crate::model::execute_batch_dml_request::Statement::params].
7491 pub fn set_params<T>(mut self, v: T) -> Self
7492 where
7493 T: std::convert::Into<wkt::Struct>,
7494 {
7495 self.params = std::option::Option::Some(v.into());
7496 self
7497 }
7498
7499 /// Sets or clears the value of [params][crate::model::execute_batch_dml_request::Statement::params].
7500 pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
7501 where
7502 T: std::convert::Into<wkt::Struct>,
7503 {
7504 self.params = v.map(|x| x.into());
7505 self
7506 }
7507
7508 /// Sets the value of [param_types][crate::model::execute_batch_dml_request::Statement::param_types].
7509 pub fn set_param_types<T, K, V>(mut self, v: T) -> Self
7510 where
7511 T: std::iter::IntoIterator<Item = (K, V)>,
7512 K: std::convert::Into<std::string::String>,
7513 V: std::convert::Into<crate::model::Type>,
7514 {
7515 use std::iter::Iterator;
7516 self.param_types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7517 self
7518 }
7519 }
7520
7521 impl wkt::message::Message for Statement {
7522 fn typename() -> &'static str {
7523 "type.googleapis.com/google.spanner.v1.ExecuteBatchDmlRequest.Statement"
7524 }
7525 }
7526}
7527
7528/// The response for
7529/// [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
7530/// of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML
7531/// statement that has successfully executed, in the same order as the statements
7532/// in the request. If a statement fails, the status in the response body
7533/// identifies the cause of the failure.
7534///
7535/// To check for DML statements that failed, use the following approach:
7536///
7537/// 1. Check the status in the response message. The
7538/// [google.rpc.Code][google.rpc.Code] enum
7539/// value `OK` indicates that all statements were executed successfully.
7540/// 1. If the status was not `OK`, check the number of result sets in the
7541/// response. If the response contains `N`
7542/// [ResultSet][google.spanner.v1.ResultSet] messages, then statement `N+1` in
7543/// the request failed.
7544///
7545/// Example 1:
7546///
7547/// * Request: 5 DML statements, all executed successfully.
7548/// * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the
7549/// status `OK`.
7550///
7551/// Example 2:
7552///
7553/// * Request: 5 DML statements. The third statement has a syntax error.
7554/// * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax
7555/// error (`INVALID_ARGUMENT`)
7556/// status. The number of [ResultSet][google.spanner.v1.ResultSet] messages
7557/// indicates that the third statement failed, and the fourth and fifth
7558/// statements were not executed.
7559///
7560/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
7561/// [google.spanner.v1.Spanner.ExecuteBatchDml]: crate::client::Spanner::execute_batch_dml
7562#[derive(Clone, Default, PartialEq)]
7563#[non_exhaustive]
7564pub struct ExecuteBatchDmlResponse {
7565 /// One [ResultSet][google.spanner.v1.ResultSet] for each statement in the
7566 /// request that ran successfully, in the same order as the statements in the
7567 /// request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any
7568 /// rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each
7569 /// [ResultSet][google.spanner.v1.ResultSet] contain the number of rows
7570 /// modified by the statement.
7571 ///
7572 /// Only the first [ResultSet][google.spanner.v1.ResultSet] in the response
7573 /// contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata].
7574 ///
7575 /// [google.spanner.v1.ResultSet]: crate::model::ResultSet
7576 /// [google.spanner.v1.ResultSetMetadata]: crate::model::ResultSetMetadata
7577 /// [google.spanner.v1.ResultSetStats]: crate::model::ResultSetStats
7578 pub result_sets: std::vec::Vec<crate::model::ResultSet>,
7579
7580 /// If all DML statements are executed successfully, the status is `OK`.
7581 /// Otherwise, the error status of the first failed statement.
7582 pub status: std::option::Option<google_cloud_rpc::model::Status>,
7583
7584 /// Optional. A precommit token is included if the read-write transaction
7585 /// is on a multiplexed session. Pass the precommit token with the highest
7586 /// sequence number from this transaction attempt should be passed to the
7587 /// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
7588 ///
7589 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
7590 pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
7591
7592 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7593}
7594
7595impl ExecuteBatchDmlResponse {
7596 /// Creates a new default instance.
7597 pub fn new() -> Self {
7598 std::default::Default::default()
7599 }
7600
7601 /// Sets the value of [result_sets][crate::model::ExecuteBatchDmlResponse::result_sets].
7602 pub fn set_result_sets<T, V>(mut self, v: T) -> Self
7603 where
7604 T: std::iter::IntoIterator<Item = V>,
7605 V: std::convert::Into<crate::model::ResultSet>,
7606 {
7607 use std::iter::Iterator;
7608 self.result_sets = v.into_iter().map(|i| i.into()).collect();
7609 self
7610 }
7611
7612 /// Sets the value of [status][crate::model::ExecuteBatchDmlResponse::status].
7613 pub fn set_status<T>(mut self, v: T) -> Self
7614 where
7615 T: std::convert::Into<google_cloud_rpc::model::Status>,
7616 {
7617 self.status = std::option::Option::Some(v.into());
7618 self
7619 }
7620
7621 /// Sets or clears the value of [status][crate::model::ExecuteBatchDmlResponse::status].
7622 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
7623 where
7624 T: std::convert::Into<google_cloud_rpc::model::Status>,
7625 {
7626 self.status = v.map(|x| x.into());
7627 self
7628 }
7629
7630 /// Sets the value of [precommit_token][crate::model::ExecuteBatchDmlResponse::precommit_token].
7631 pub fn set_precommit_token<T>(mut self, v: T) -> Self
7632 where
7633 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
7634 {
7635 self.precommit_token = std::option::Option::Some(v.into());
7636 self
7637 }
7638
7639 /// Sets or clears the value of [precommit_token][crate::model::ExecuteBatchDmlResponse::precommit_token].
7640 pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
7641 where
7642 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
7643 {
7644 self.precommit_token = v.map(|x| x.into());
7645 self
7646 }
7647}
7648
7649impl wkt::message::Message for ExecuteBatchDmlResponse {
7650 fn typename() -> &'static str {
7651 "type.googleapis.com/google.spanner.v1.ExecuteBatchDmlResponse"
7652 }
7653}
7654
7655/// Options for a `PartitionQueryRequest` and `PartitionReadRequest`.
7656#[derive(Clone, Default, PartialEq)]
7657#[non_exhaustive]
7658pub struct PartitionOptions {
7659 /// **Note:** This hint is currently ignored by `PartitionQuery` and
7660 /// `PartitionRead` requests.
7661 ///
7662 /// The desired data size for each partition generated. The default for this
7663 /// option is currently 1 GiB. This is only a hint. The actual size of each
7664 /// partition can be smaller or larger than this size request.
7665 pub partition_size_bytes: i64,
7666
7667 /// **Note:** This hint is currently ignored by `PartitionQuery` and
7668 /// `PartitionRead` requests.
7669 ///
7670 /// The desired maximum number of partitions to return. For example, this
7671 /// might be set to the number of workers available. The default for this
7672 /// option is currently 10,000. The maximum value is currently 200,000. This
7673 /// is only a hint. The actual number of partitions returned can be smaller or
7674 /// larger than this maximum count request.
7675 pub max_partitions: i64,
7676
7677 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7678}
7679
7680impl PartitionOptions {
7681 /// Creates a new default instance.
7682 pub fn new() -> Self {
7683 std::default::Default::default()
7684 }
7685
7686 /// Sets the value of [partition_size_bytes][crate::model::PartitionOptions::partition_size_bytes].
7687 pub fn set_partition_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7688 self.partition_size_bytes = v.into();
7689 self
7690 }
7691
7692 /// Sets the value of [max_partitions][crate::model::PartitionOptions::max_partitions].
7693 pub fn set_max_partitions<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7694 self.max_partitions = v.into();
7695 self
7696 }
7697}
7698
7699impl wkt::message::Message for PartitionOptions {
7700 fn typename() -> &'static str {
7701 "type.googleapis.com/google.spanner.v1.PartitionOptions"
7702 }
7703}
7704
7705/// The request for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
7706///
7707/// [google.spanner.v1.Spanner.PartitionQuery]: crate::client::Spanner::partition_query
7708#[derive(Clone, Default, PartialEq)]
7709#[non_exhaustive]
7710pub struct PartitionQueryRequest {
7711 /// Required. The session used to create the partitions.
7712 pub session: std::string::String,
7713
7714 /// Read-only snapshot transactions are supported, read and write and
7715 /// single-use transactions are not.
7716 pub transaction: std::option::Option<crate::model::TransactionSelector>,
7717
7718 /// Required. The query request to generate partitions for. The request fails
7719 /// if the query isn't root partitionable. For a query to be root
7720 /// partitionable, it needs to satisfy a few conditions. For example, if the
7721 /// query execution plan contains a distributed union operator, then it must be
7722 /// the first operator in the plan. For more information about other
7723 /// conditions, see [Read data in
7724 /// parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel).
7725 ///
7726 /// The query request must not contain DML commands, such as `INSERT`,
7727 /// `UPDATE`, or `DELETE`. Use
7728 /// [`ExecuteStreamingSql`][google.spanner.v1.Spanner.ExecuteStreamingSql] with
7729 /// a `PartitionedDml` transaction for large, partition-friendly DML
7730 /// operations.
7731 pub sql: std::string::String,
7732
7733 /// Optional. Parameter names and values that bind to placeholders in the SQL
7734 /// string.
7735 ///
7736 /// A parameter placeholder consists of the `@` character followed by the
7737 /// parameter name (for example, `@firstName`). Parameter names can contain
7738 /// letters, numbers, and underscores.
7739 ///
7740 /// Parameters can appear anywhere that a literal value is expected. The same
7741 /// parameter name can be used more than once, for example:
7742 ///
7743 /// `"WHERE id > @msg_id AND id < @msg_id + 100"`
7744 ///
7745 /// It's an error to execute a SQL statement with unbound parameters.
7746 pub params: std::option::Option<wkt::Struct>,
7747
7748 /// Optional. It isn't always possible for Cloud Spanner to infer the right SQL
7749 /// type from a JSON value. For example, values of type `BYTES` and values of
7750 /// type `STRING` both appear in
7751 /// [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings.
7752 ///
7753 /// In these cases, `param_types` can be used to specify the exact
7754 /// SQL type for some or all of the SQL query parameters. See the
7755 /// definition of [Type][google.spanner.v1.Type] for more information
7756 /// about SQL types.
7757 ///
7758 /// [google.spanner.v1.PartitionQueryRequest.params]: crate::model::PartitionQueryRequest::params
7759 /// [google.spanner.v1.Type]: crate::model::Type
7760 pub param_types: std::collections::HashMap<std::string::String, crate::model::Type>,
7761
7762 /// Additional options that affect how many partitions are created.
7763 pub partition_options: std::option::Option<crate::model::PartitionOptions>,
7764
7765 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7766}
7767
7768impl PartitionQueryRequest {
7769 /// Creates a new default instance.
7770 pub fn new() -> Self {
7771 std::default::Default::default()
7772 }
7773
7774 /// Sets the value of [session][crate::model::PartitionQueryRequest::session].
7775 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7776 self.session = v.into();
7777 self
7778 }
7779
7780 /// Sets the value of [transaction][crate::model::PartitionQueryRequest::transaction].
7781 pub fn set_transaction<T>(mut self, v: T) -> Self
7782 where
7783 T: std::convert::Into<crate::model::TransactionSelector>,
7784 {
7785 self.transaction = std::option::Option::Some(v.into());
7786 self
7787 }
7788
7789 /// Sets or clears the value of [transaction][crate::model::PartitionQueryRequest::transaction].
7790 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
7791 where
7792 T: std::convert::Into<crate::model::TransactionSelector>,
7793 {
7794 self.transaction = v.map(|x| x.into());
7795 self
7796 }
7797
7798 /// Sets the value of [sql][crate::model::PartitionQueryRequest::sql].
7799 pub fn set_sql<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7800 self.sql = v.into();
7801 self
7802 }
7803
7804 /// Sets the value of [params][crate::model::PartitionQueryRequest::params].
7805 pub fn set_params<T>(mut self, v: T) -> Self
7806 where
7807 T: std::convert::Into<wkt::Struct>,
7808 {
7809 self.params = std::option::Option::Some(v.into());
7810 self
7811 }
7812
7813 /// Sets or clears the value of [params][crate::model::PartitionQueryRequest::params].
7814 pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
7815 where
7816 T: std::convert::Into<wkt::Struct>,
7817 {
7818 self.params = v.map(|x| x.into());
7819 self
7820 }
7821
7822 /// Sets the value of [param_types][crate::model::PartitionQueryRequest::param_types].
7823 pub fn set_param_types<T, K, V>(mut self, v: T) -> Self
7824 where
7825 T: std::iter::IntoIterator<Item = (K, V)>,
7826 K: std::convert::Into<std::string::String>,
7827 V: std::convert::Into<crate::model::Type>,
7828 {
7829 use std::iter::Iterator;
7830 self.param_types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7831 self
7832 }
7833
7834 /// Sets the value of [partition_options][crate::model::PartitionQueryRequest::partition_options].
7835 pub fn set_partition_options<T>(mut self, v: T) -> Self
7836 where
7837 T: std::convert::Into<crate::model::PartitionOptions>,
7838 {
7839 self.partition_options = std::option::Option::Some(v.into());
7840 self
7841 }
7842
7843 /// Sets or clears the value of [partition_options][crate::model::PartitionQueryRequest::partition_options].
7844 pub fn set_or_clear_partition_options<T>(mut self, v: std::option::Option<T>) -> Self
7845 where
7846 T: std::convert::Into<crate::model::PartitionOptions>,
7847 {
7848 self.partition_options = v.map(|x| x.into());
7849 self
7850 }
7851}
7852
7853impl wkt::message::Message for PartitionQueryRequest {
7854 fn typename() -> &'static str {
7855 "type.googleapis.com/google.spanner.v1.PartitionQueryRequest"
7856 }
7857}
7858
7859/// The request for [PartitionRead][google.spanner.v1.Spanner.PartitionRead]
7860///
7861/// [google.spanner.v1.Spanner.PartitionRead]: crate::client::Spanner::partition_read
7862#[derive(Clone, Default, PartialEq)]
7863#[non_exhaustive]
7864pub struct PartitionReadRequest {
7865 /// Required. The session used to create the partitions.
7866 pub session: std::string::String,
7867
7868 /// Read only snapshot transactions are supported, read/write and single use
7869 /// transactions are not.
7870 pub transaction: std::option::Option<crate::model::TransactionSelector>,
7871
7872 /// Required. The name of the table in the database to be read.
7873 pub table: std::string::String,
7874
7875 /// If non-empty, the name of an index on
7876 /// [table][google.spanner.v1.PartitionReadRequest.table]. This index is used
7877 /// instead of the table primary key when interpreting
7878 /// [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting
7879 /// result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set]
7880 /// for further information.
7881 ///
7882 /// [google.spanner.v1.PartitionReadRequest.key_set]: crate::model::PartitionReadRequest::key_set
7883 /// [google.spanner.v1.PartitionReadRequest.table]: crate::model::PartitionReadRequest::table
7884 pub index: std::string::String,
7885
7886 /// The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be
7887 /// returned for each row matching this request.
7888 ///
7889 /// [google.spanner.v1.PartitionReadRequest.table]: crate::model::PartitionReadRequest::table
7890 pub columns: std::vec::Vec<std::string::String>,
7891
7892 /// Required. `key_set` identifies the rows to be yielded. `key_set` names the
7893 /// primary keys of the rows in
7894 /// [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless
7895 /// [index][google.spanner.v1.PartitionReadRequest.index] is present. If
7896 /// [index][google.spanner.v1.PartitionReadRequest.index] is present, then
7897 /// [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names
7898 /// index keys in [index][google.spanner.v1.PartitionReadRequest.index].
7899 ///
7900 /// It isn't an error for the `key_set` to name rows that don't
7901 /// exist in the database. Read yields nothing for nonexistent rows.
7902 ///
7903 /// [google.spanner.v1.PartitionReadRequest.index]: crate::model::PartitionReadRequest::index
7904 /// [google.spanner.v1.PartitionReadRequest.key_set]: crate::model::PartitionReadRequest::key_set
7905 /// [google.spanner.v1.PartitionReadRequest.table]: crate::model::PartitionReadRequest::table
7906 pub key_set: std::option::Option<crate::model::KeySet>,
7907
7908 /// Additional options that affect how many partitions are created.
7909 pub partition_options: std::option::Option<crate::model::PartitionOptions>,
7910
7911 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7912}
7913
7914impl PartitionReadRequest {
7915 /// Creates a new default instance.
7916 pub fn new() -> Self {
7917 std::default::Default::default()
7918 }
7919
7920 /// Sets the value of [session][crate::model::PartitionReadRequest::session].
7921 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7922 self.session = v.into();
7923 self
7924 }
7925
7926 /// Sets the value of [transaction][crate::model::PartitionReadRequest::transaction].
7927 pub fn set_transaction<T>(mut self, v: T) -> Self
7928 where
7929 T: std::convert::Into<crate::model::TransactionSelector>,
7930 {
7931 self.transaction = std::option::Option::Some(v.into());
7932 self
7933 }
7934
7935 /// Sets or clears the value of [transaction][crate::model::PartitionReadRequest::transaction].
7936 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
7937 where
7938 T: std::convert::Into<crate::model::TransactionSelector>,
7939 {
7940 self.transaction = v.map(|x| x.into());
7941 self
7942 }
7943
7944 /// Sets the value of [table][crate::model::PartitionReadRequest::table].
7945 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7946 self.table = v.into();
7947 self
7948 }
7949
7950 /// Sets the value of [index][crate::model::PartitionReadRequest::index].
7951 pub fn set_index<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7952 self.index = v.into();
7953 self
7954 }
7955
7956 /// Sets the value of [columns][crate::model::PartitionReadRequest::columns].
7957 pub fn set_columns<T, V>(mut self, v: T) -> Self
7958 where
7959 T: std::iter::IntoIterator<Item = V>,
7960 V: std::convert::Into<std::string::String>,
7961 {
7962 use std::iter::Iterator;
7963 self.columns = v.into_iter().map(|i| i.into()).collect();
7964 self
7965 }
7966
7967 /// Sets the value of [key_set][crate::model::PartitionReadRequest::key_set].
7968 pub fn set_key_set<T>(mut self, v: T) -> Self
7969 where
7970 T: std::convert::Into<crate::model::KeySet>,
7971 {
7972 self.key_set = std::option::Option::Some(v.into());
7973 self
7974 }
7975
7976 /// Sets or clears the value of [key_set][crate::model::PartitionReadRequest::key_set].
7977 pub fn set_or_clear_key_set<T>(mut self, v: std::option::Option<T>) -> Self
7978 where
7979 T: std::convert::Into<crate::model::KeySet>,
7980 {
7981 self.key_set = v.map(|x| x.into());
7982 self
7983 }
7984
7985 /// Sets the value of [partition_options][crate::model::PartitionReadRequest::partition_options].
7986 pub fn set_partition_options<T>(mut self, v: T) -> Self
7987 where
7988 T: std::convert::Into<crate::model::PartitionOptions>,
7989 {
7990 self.partition_options = std::option::Option::Some(v.into());
7991 self
7992 }
7993
7994 /// Sets or clears the value of [partition_options][crate::model::PartitionReadRequest::partition_options].
7995 pub fn set_or_clear_partition_options<T>(mut self, v: std::option::Option<T>) -> Self
7996 where
7997 T: std::convert::Into<crate::model::PartitionOptions>,
7998 {
7999 self.partition_options = v.map(|x| x.into());
8000 self
8001 }
8002}
8003
8004impl wkt::message::Message for PartitionReadRequest {
8005 fn typename() -> &'static str {
8006 "type.googleapis.com/google.spanner.v1.PartitionReadRequest"
8007 }
8008}
8009
8010/// Information returned for each partition returned in a
8011/// PartitionResponse.
8012#[derive(Clone, Default, PartialEq)]
8013#[non_exhaustive]
8014pub struct Partition {
8015 /// This token can be passed to `Read`, `StreamingRead`, `ExecuteSql`, or
8016 /// `ExecuteStreamingSql` requests to restrict the results to those identified
8017 /// by this partition token.
8018 pub partition_token: ::bytes::Bytes,
8019
8020 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8021}
8022
8023impl Partition {
8024 /// Creates a new default instance.
8025 pub fn new() -> Self {
8026 std::default::Default::default()
8027 }
8028
8029 /// Sets the value of [partition_token][crate::model::Partition::partition_token].
8030 pub fn set_partition_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
8031 self.partition_token = v.into();
8032 self
8033 }
8034}
8035
8036impl wkt::message::Message for Partition {
8037 fn typename() -> &'static str {
8038 "type.googleapis.com/google.spanner.v1.Partition"
8039 }
8040}
8041
8042/// The response for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
8043/// or [PartitionRead][google.spanner.v1.Spanner.PartitionRead]
8044///
8045/// [google.spanner.v1.Spanner.PartitionQuery]: crate::client::Spanner::partition_query
8046/// [google.spanner.v1.Spanner.PartitionRead]: crate::client::Spanner::partition_read
8047#[derive(Clone, Default, PartialEq)]
8048#[non_exhaustive]
8049pub struct PartitionResponse {
8050 /// Partitions created by this request.
8051 pub partitions: std::vec::Vec<crate::model::Partition>,
8052
8053 /// Transaction created by this request.
8054 pub transaction: std::option::Option<crate::model::Transaction>,
8055
8056 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8057}
8058
8059impl PartitionResponse {
8060 /// Creates a new default instance.
8061 pub fn new() -> Self {
8062 std::default::Default::default()
8063 }
8064
8065 /// Sets the value of [partitions][crate::model::PartitionResponse::partitions].
8066 pub fn set_partitions<T, V>(mut self, v: T) -> Self
8067 where
8068 T: std::iter::IntoIterator<Item = V>,
8069 V: std::convert::Into<crate::model::Partition>,
8070 {
8071 use std::iter::Iterator;
8072 self.partitions = v.into_iter().map(|i| i.into()).collect();
8073 self
8074 }
8075
8076 /// Sets the value of [transaction][crate::model::PartitionResponse::transaction].
8077 pub fn set_transaction<T>(mut self, v: T) -> Self
8078 where
8079 T: std::convert::Into<crate::model::Transaction>,
8080 {
8081 self.transaction = std::option::Option::Some(v.into());
8082 self
8083 }
8084
8085 /// Sets or clears the value of [transaction][crate::model::PartitionResponse::transaction].
8086 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
8087 where
8088 T: std::convert::Into<crate::model::Transaction>,
8089 {
8090 self.transaction = v.map(|x| x.into());
8091 self
8092 }
8093}
8094
8095impl wkt::message::Message for PartitionResponse {
8096 fn typename() -> &'static str {
8097 "type.googleapis.com/google.spanner.v1.PartitionResponse"
8098 }
8099}
8100
8101/// The request for [Read][google.spanner.v1.Spanner.Read] and
8102/// [StreamingRead][google.spanner.v1.Spanner.StreamingRead].
8103///
8104/// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
8105#[derive(Clone, Default, PartialEq)]
8106#[non_exhaustive]
8107pub struct ReadRequest {
8108 /// Required. The session in which the read should be performed.
8109 pub session: std::string::String,
8110
8111 /// The transaction to use. If none is provided, the default is a
8112 /// temporary read-only transaction with strong concurrency.
8113 pub transaction: std::option::Option<crate::model::TransactionSelector>,
8114
8115 /// Required. The name of the table in the database to be read.
8116 pub table: std::string::String,
8117
8118 /// If non-empty, the name of an index on
8119 /// [table][google.spanner.v1.ReadRequest.table]. This index is used instead of
8120 /// the table primary key when interpreting
8121 /// [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows.
8122 /// See [key_set][google.spanner.v1.ReadRequest.key_set] for further
8123 /// information.
8124 ///
8125 /// [google.spanner.v1.ReadRequest.key_set]: crate::model::ReadRequest::key_set
8126 /// [google.spanner.v1.ReadRequest.table]: crate::model::ReadRequest::table
8127 pub index: std::string::String,
8128
8129 /// Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be
8130 /// returned for each row matching this request.
8131 ///
8132 /// [google.spanner.v1.ReadRequest.table]: crate::model::ReadRequest::table
8133 pub columns: std::vec::Vec<std::string::String>,
8134
8135 /// Required. `key_set` identifies the rows to be yielded. `key_set` names the
8136 /// primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to
8137 /// be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present.
8138 /// If [index][google.spanner.v1.ReadRequest.index] is present, then
8139 /// [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys
8140 /// in [index][google.spanner.v1.ReadRequest.index].
8141 ///
8142 /// If the [partition_token][google.spanner.v1.ReadRequest.partition_token]
8143 /// field is empty, rows are yielded in table primary key order (if
8144 /// [index][google.spanner.v1.ReadRequest.index] is empty) or index key order
8145 /// (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the
8146 /// [partition_token][google.spanner.v1.ReadRequest.partition_token] field
8147 /// isn't empty, rows are yielded in an unspecified order.
8148 ///
8149 /// It isn't an error for the `key_set` to name rows that don't
8150 /// exist in the database. Read yields nothing for nonexistent rows.
8151 ///
8152 /// [google.spanner.v1.ReadRequest.index]: crate::model::ReadRequest::index
8153 /// [google.spanner.v1.ReadRequest.key_set]: crate::model::ReadRequest::key_set
8154 /// [google.spanner.v1.ReadRequest.partition_token]: crate::model::ReadRequest::partition_token
8155 /// [google.spanner.v1.ReadRequest.table]: crate::model::ReadRequest::table
8156 pub key_set: std::option::Option<crate::model::KeySet>,
8157
8158 /// If greater than zero, only the first `limit` rows are yielded. If `limit`
8159 /// is zero, the default is no limit. A limit can't be specified if
8160 /// `partition_token` is set.
8161 pub limit: i64,
8162
8163 /// If this request is resuming a previously interrupted read,
8164 /// `resume_token` should be copied from the last
8165 /// [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
8166 /// interruption. Doing this enables the new read to resume where the last read
8167 /// left off. The rest of the request parameters must exactly match the request
8168 /// that yielded this token.
8169 ///
8170 /// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
8171 pub resume_token: ::bytes::Bytes,
8172
8173 /// If present, results are restricted to the specified partition
8174 /// previously created using `PartitionRead`. There must be an exact
8175 /// match for the values of fields common to this message and the
8176 /// PartitionReadRequest message used to create this partition_token.
8177 pub partition_token: ::bytes::Bytes,
8178
8179 /// Common options for this request.
8180 pub request_options: std::option::Option<crate::model::RequestOptions>,
8181
8182 /// Directed read options for this request.
8183 pub directed_read_options: std::option::Option<crate::model::DirectedReadOptions>,
8184
8185 /// If this is for a partitioned read and this field is set to `true`, the
8186 /// request is executed with Spanner Data Boost independent compute resources.
8187 ///
8188 /// If the field is set to `true` but the request doesn't set
8189 /// `partition_token`, the API returns an `INVALID_ARGUMENT` error.
8190 pub data_boost_enabled: bool,
8191
8192 /// Optional. Order for the returned rows.
8193 ///
8194 /// By default, Spanner returns result rows in primary key order except for
8195 /// PartitionRead requests. For applications that don't require rows to be
8196 /// returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting
8197 /// `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval,
8198 /// resulting in lower latencies in certain cases (for example, bulk point
8199 /// lookups).
8200 pub order_by: crate::model::read_request::OrderBy,
8201
8202 /// Optional. Lock Hint for the request, it can only be used with read-write
8203 /// transactions.
8204 pub lock_hint: crate::model::read_request::LockHint,
8205
8206 /// Optional. Makes the Spanner requests location-aware if present.
8207 ///
8208 /// It gives the server hints that can be used to route the request
8209 /// to an appropriate server, potentially significantly decreasing latency and
8210 /// improving throughput. To achieve improved performance, most fields must be
8211 /// filled in with accurate values.
8212 pub routing_hint: std::option::Option<crate::model::RoutingHint>,
8213
8214 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8215}
8216
8217impl ReadRequest {
8218 /// Creates a new default instance.
8219 pub fn new() -> Self {
8220 std::default::Default::default()
8221 }
8222
8223 /// Sets the value of [session][crate::model::ReadRequest::session].
8224 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8225 self.session = v.into();
8226 self
8227 }
8228
8229 /// Sets the value of [transaction][crate::model::ReadRequest::transaction].
8230 pub fn set_transaction<T>(mut self, v: T) -> Self
8231 where
8232 T: std::convert::Into<crate::model::TransactionSelector>,
8233 {
8234 self.transaction = std::option::Option::Some(v.into());
8235 self
8236 }
8237
8238 /// Sets or clears the value of [transaction][crate::model::ReadRequest::transaction].
8239 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
8240 where
8241 T: std::convert::Into<crate::model::TransactionSelector>,
8242 {
8243 self.transaction = v.map(|x| x.into());
8244 self
8245 }
8246
8247 /// Sets the value of [table][crate::model::ReadRequest::table].
8248 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8249 self.table = v.into();
8250 self
8251 }
8252
8253 /// Sets the value of [index][crate::model::ReadRequest::index].
8254 pub fn set_index<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8255 self.index = v.into();
8256 self
8257 }
8258
8259 /// Sets the value of [columns][crate::model::ReadRequest::columns].
8260 pub fn set_columns<T, V>(mut self, v: T) -> Self
8261 where
8262 T: std::iter::IntoIterator<Item = V>,
8263 V: std::convert::Into<std::string::String>,
8264 {
8265 use std::iter::Iterator;
8266 self.columns = v.into_iter().map(|i| i.into()).collect();
8267 self
8268 }
8269
8270 /// Sets the value of [key_set][crate::model::ReadRequest::key_set].
8271 pub fn set_key_set<T>(mut self, v: T) -> Self
8272 where
8273 T: std::convert::Into<crate::model::KeySet>,
8274 {
8275 self.key_set = std::option::Option::Some(v.into());
8276 self
8277 }
8278
8279 /// Sets or clears the value of [key_set][crate::model::ReadRequest::key_set].
8280 pub fn set_or_clear_key_set<T>(mut self, v: std::option::Option<T>) -> Self
8281 where
8282 T: std::convert::Into<crate::model::KeySet>,
8283 {
8284 self.key_set = v.map(|x| x.into());
8285 self
8286 }
8287
8288 /// Sets the value of [limit][crate::model::ReadRequest::limit].
8289 pub fn set_limit<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
8290 self.limit = v.into();
8291 self
8292 }
8293
8294 /// Sets the value of [resume_token][crate::model::ReadRequest::resume_token].
8295 pub fn set_resume_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
8296 self.resume_token = v.into();
8297 self
8298 }
8299
8300 /// Sets the value of [partition_token][crate::model::ReadRequest::partition_token].
8301 pub fn set_partition_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
8302 self.partition_token = v.into();
8303 self
8304 }
8305
8306 /// Sets the value of [request_options][crate::model::ReadRequest::request_options].
8307 pub fn set_request_options<T>(mut self, v: T) -> Self
8308 where
8309 T: std::convert::Into<crate::model::RequestOptions>,
8310 {
8311 self.request_options = std::option::Option::Some(v.into());
8312 self
8313 }
8314
8315 /// Sets or clears the value of [request_options][crate::model::ReadRequest::request_options].
8316 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
8317 where
8318 T: std::convert::Into<crate::model::RequestOptions>,
8319 {
8320 self.request_options = v.map(|x| x.into());
8321 self
8322 }
8323
8324 /// Sets the value of [directed_read_options][crate::model::ReadRequest::directed_read_options].
8325 pub fn set_directed_read_options<T>(mut self, v: T) -> Self
8326 where
8327 T: std::convert::Into<crate::model::DirectedReadOptions>,
8328 {
8329 self.directed_read_options = std::option::Option::Some(v.into());
8330 self
8331 }
8332
8333 /// Sets or clears the value of [directed_read_options][crate::model::ReadRequest::directed_read_options].
8334 pub fn set_or_clear_directed_read_options<T>(mut self, v: std::option::Option<T>) -> Self
8335 where
8336 T: std::convert::Into<crate::model::DirectedReadOptions>,
8337 {
8338 self.directed_read_options = v.map(|x| x.into());
8339 self
8340 }
8341
8342 /// Sets the value of [data_boost_enabled][crate::model::ReadRequest::data_boost_enabled].
8343 pub fn set_data_boost_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8344 self.data_boost_enabled = v.into();
8345 self
8346 }
8347
8348 /// Sets the value of [order_by][crate::model::ReadRequest::order_by].
8349 pub fn set_order_by<T: std::convert::Into<crate::model::read_request::OrderBy>>(
8350 mut self,
8351 v: T,
8352 ) -> Self {
8353 self.order_by = v.into();
8354 self
8355 }
8356
8357 /// Sets the value of [lock_hint][crate::model::ReadRequest::lock_hint].
8358 pub fn set_lock_hint<T: std::convert::Into<crate::model::read_request::LockHint>>(
8359 mut self,
8360 v: T,
8361 ) -> Self {
8362 self.lock_hint = v.into();
8363 self
8364 }
8365
8366 /// Sets the value of [routing_hint][crate::model::ReadRequest::routing_hint].
8367 pub fn set_routing_hint<T>(mut self, v: T) -> Self
8368 where
8369 T: std::convert::Into<crate::model::RoutingHint>,
8370 {
8371 self.routing_hint = std::option::Option::Some(v.into());
8372 self
8373 }
8374
8375 /// Sets or clears the value of [routing_hint][crate::model::ReadRequest::routing_hint].
8376 pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
8377 where
8378 T: std::convert::Into<crate::model::RoutingHint>,
8379 {
8380 self.routing_hint = v.map(|x| x.into());
8381 self
8382 }
8383}
8384
8385impl wkt::message::Message for ReadRequest {
8386 fn typename() -> &'static str {
8387 "type.googleapis.com/google.spanner.v1.ReadRequest"
8388 }
8389}
8390
8391/// Defines additional types related to [ReadRequest].
8392pub mod read_request {
8393 #[allow(unused_imports)]
8394 use super::*;
8395
8396 /// An option to control the order in which rows are returned from a read.
8397 ///
8398 /// # Working with unknown values
8399 ///
8400 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8401 /// additional enum variants at any time. Adding new variants is not considered
8402 /// a breaking change. Applications should write their code in anticipation of:
8403 ///
8404 /// - New values appearing in future releases of the client library, **and**
8405 /// - New values received dynamically, without application changes.
8406 ///
8407 /// Please consult the [Working with enums] section in the user guide for some
8408 /// guidelines.
8409 ///
8410 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8411 #[derive(Clone, Debug, PartialEq)]
8412 #[non_exhaustive]
8413 pub enum OrderBy {
8414 /// Default value.
8415 ///
8416 /// `ORDER_BY_UNSPECIFIED` is equivalent to `ORDER_BY_PRIMARY_KEY`.
8417 Unspecified,
8418 /// Read rows are returned in primary key order.
8419 ///
8420 /// In the event that this option is used in conjunction with the
8421 /// `partition_token` field, the API returns an `INVALID_ARGUMENT` error.
8422 PrimaryKey,
8423 /// Read rows are returned in any order.
8424 NoOrder,
8425 /// If set, the enum was initialized with an unknown value.
8426 ///
8427 /// Applications can examine the value using [OrderBy::value] or
8428 /// [OrderBy::name].
8429 UnknownValue(order_by::UnknownValue),
8430 }
8431
8432 #[doc(hidden)]
8433 pub mod order_by {
8434 #[allow(unused_imports)]
8435 use super::*;
8436 #[derive(Clone, Debug, PartialEq)]
8437 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8438 }
8439
8440 impl OrderBy {
8441 /// Gets the enum value.
8442 ///
8443 /// Returns `None` if the enum contains an unknown value deserialized from
8444 /// the string representation of enums.
8445 pub fn value(&self) -> std::option::Option<i32> {
8446 match self {
8447 Self::Unspecified => std::option::Option::Some(0),
8448 Self::PrimaryKey => std::option::Option::Some(1),
8449 Self::NoOrder => std::option::Option::Some(2),
8450 Self::UnknownValue(u) => u.0.value(),
8451 }
8452 }
8453
8454 /// Gets the enum value as a string.
8455 ///
8456 /// Returns `None` if the enum contains an unknown value deserialized from
8457 /// the integer representation of enums.
8458 pub fn name(&self) -> std::option::Option<&str> {
8459 match self {
8460 Self::Unspecified => std::option::Option::Some("ORDER_BY_UNSPECIFIED"),
8461 Self::PrimaryKey => std::option::Option::Some("ORDER_BY_PRIMARY_KEY"),
8462 Self::NoOrder => std::option::Option::Some("ORDER_BY_NO_ORDER"),
8463 Self::UnknownValue(u) => u.0.name(),
8464 }
8465 }
8466 }
8467
8468 impl std::default::Default for OrderBy {
8469 fn default() -> Self {
8470 use std::convert::From;
8471 Self::from(0)
8472 }
8473 }
8474
8475 impl std::fmt::Display for OrderBy {
8476 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8477 wkt::internal::display_enum(f, self.name(), self.value())
8478 }
8479 }
8480
8481 impl std::convert::From<i32> for OrderBy {
8482 fn from(value: i32) -> Self {
8483 match value {
8484 0 => Self::Unspecified,
8485 1 => Self::PrimaryKey,
8486 2 => Self::NoOrder,
8487 _ => Self::UnknownValue(order_by::UnknownValue(
8488 wkt::internal::UnknownEnumValue::Integer(value),
8489 )),
8490 }
8491 }
8492 }
8493
8494 impl std::convert::From<&str> for OrderBy {
8495 fn from(value: &str) -> Self {
8496 use std::string::ToString;
8497 match value {
8498 "ORDER_BY_UNSPECIFIED" => Self::Unspecified,
8499 "ORDER_BY_PRIMARY_KEY" => Self::PrimaryKey,
8500 "ORDER_BY_NO_ORDER" => Self::NoOrder,
8501 _ => Self::UnknownValue(order_by::UnknownValue(
8502 wkt::internal::UnknownEnumValue::String(value.to_string()),
8503 )),
8504 }
8505 }
8506 }
8507
8508 impl serde::ser::Serialize for OrderBy {
8509 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8510 where
8511 S: serde::Serializer,
8512 {
8513 match self {
8514 Self::Unspecified => serializer.serialize_i32(0),
8515 Self::PrimaryKey => serializer.serialize_i32(1),
8516 Self::NoOrder => serializer.serialize_i32(2),
8517 Self::UnknownValue(u) => u.0.serialize(serializer),
8518 }
8519 }
8520 }
8521
8522 impl<'de> serde::de::Deserialize<'de> for OrderBy {
8523 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8524 where
8525 D: serde::Deserializer<'de>,
8526 {
8527 deserializer.deserialize_any(wkt::internal::EnumVisitor::<OrderBy>::new(
8528 ".google.spanner.v1.ReadRequest.OrderBy",
8529 ))
8530 }
8531 }
8532
8533 /// A lock hint mechanism for reads done within a transaction.
8534 ///
8535 /// # Working with unknown values
8536 ///
8537 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8538 /// additional enum variants at any time. Adding new variants is not considered
8539 /// a breaking change. Applications should write their code in anticipation of:
8540 ///
8541 /// - New values appearing in future releases of the client library, **and**
8542 /// - New values received dynamically, without application changes.
8543 ///
8544 /// Please consult the [Working with enums] section in the user guide for some
8545 /// guidelines.
8546 ///
8547 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8548 #[derive(Clone, Debug, PartialEq)]
8549 #[non_exhaustive]
8550 pub enum LockHint {
8551 /// Default value.
8552 ///
8553 /// `LOCK_HINT_UNSPECIFIED` is equivalent to `LOCK_HINT_SHARED`.
8554 Unspecified,
8555 /// Acquire shared locks.
8556 ///
8557 /// By default when you perform a read as part of a read-write transaction,
8558 /// Spanner acquires shared read locks, which allows other reads to still
8559 /// access the data until your transaction is ready to commit. When your
8560 /// transaction is committing and writes are being applied, the transaction
8561 /// attempts to upgrade to an exclusive lock for any data you are writing.
8562 /// For more information about locks, see [Lock
8563 /// modes](https://cloud.google.com/spanner/docs/introspection/lock-statistics#explain-lock-modes).
8564 Shared,
8565 /// Acquire exclusive locks.
8566 ///
8567 /// Requesting exclusive locks is beneficial if you observe high write
8568 /// contention, which means you notice that multiple transactions are
8569 /// concurrently trying to read and write to the same data, resulting in a
8570 /// large number of aborts. This problem occurs when two transactions
8571 /// initially acquire shared locks and then both try to upgrade to exclusive
8572 /// locks at the same time. In this situation both transactions are waiting
8573 /// for the other to give up their lock, resulting in a deadlocked situation.
8574 /// Spanner is able to detect this occurring and force one of the
8575 /// transactions to abort. However, this is a slow and expensive operation
8576 /// and results in lower performance. In this case it makes sense to acquire
8577 /// exclusive locks at the start of the transaction because then when
8578 /// multiple transactions try to act on the same data, they automatically get
8579 /// serialized. Each transaction waits its turn to acquire the lock and
8580 /// avoids getting into deadlock situations.
8581 ///
8582 /// Because the exclusive lock hint is just a hint, it shouldn't be
8583 /// considered equivalent to a mutex. In other words, you shouldn't use
8584 /// Spanner exclusive locks as a mutual exclusion mechanism for the execution
8585 /// of code outside of Spanner.
8586 ///
8587 /// **Note:** Request exclusive locks judiciously because they block others
8588 /// from reading that data for the entire transaction, rather than just when
8589 /// the writes are being performed. Unless you observe high write contention,
8590 /// you should use the default of shared read locks so you don't prematurely
8591 /// block other clients from reading the data that you're writing to.
8592 Exclusive,
8593 /// If set, the enum was initialized with an unknown value.
8594 ///
8595 /// Applications can examine the value using [LockHint::value] or
8596 /// [LockHint::name].
8597 UnknownValue(lock_hint::UnknownValue),
8598 }
8599
8600 #[doc(hidden)]
8601 pub mod lock_hint {
8602 #[allow(unused_imports)]
8603 use super::*;
8604 #[derive(Clone, Debug, PartialEq)]
8605 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8606 }
8607
8608 impl LockHint {
8609 /// Gets the enum value.
8610 ///
8611 /// Returns `None` if the enum contains an unknown value deserialized from
8612 /// the string representation of enums.
8613 pub fn value(&self) -> std::option::Option<i32> {
8614 match self {
8615 Self::Unspecified => std::option::Option::Some(0),
8616 Self::Shared => std::option::Option::Some(1),
8617 Self::Exclusive => std::option::Option::Some(2),
8618 Self::UnknownValue(u) => u.0.value(),
8619 }
8620 }
8621
8622 /// Gets the enum value as a string.
8623 ///
8624 /// Returns `None` if the enum contains an unknown value deserialized from
8625 /// the integer representation of enums.
8626 pub fn name(&self) -> std::option::Option<&str> {
8627 match self {
8628 Self::Unspecified => std::option::Option::Some("LOCK_HINT_UNSPECIFIED"),
8629 Self::Shared => std::option::Option::Some("LOCK_HINT_SHARED"),
8630 Self::Exclusive => std::option::Option::Some("LOCK_HINT_EXCLUSIVE"),
8631 Self::UnknownValue(u) => u.0.name(),
8632 }
8633 }
8634 }
8635
8636 impl std::default::Default for LockHint {
8637 fn default() -> Self {
8638 use std::convert::From;
8639 Self::from(0)
8640 }
8641 }
8642
8643 impl std::fmt::Display for LockHint {
8644 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8645 wkt::internal::display_enum(f, self.name(), self.value())
8646 }
8647 }
8648
8649 impl std::convert::From<i32> for LockHint {
8650 fn from(value: i32) -> Self {
8651 match value {
8652 0 => Self::Unspecified,
8653 1 => Self::Shared,
8654 2 => Self::Exclusive,
8655 _ => Self::UnknownValue(lock_hint::UnknownValue(
8656 wkt::internal::UnknownEnumValue::Integer(value),
8657 )),
8658 }
8659 }
8660 }
8661
8662 impl std::convert::From<&str> for LockHint {
8663 fn from(value: &str) -> Self {
8664 use std::string::ToString;
8665 match value {
8666 "LOCK_HINT_UNSPECIFIED" => Self::Unspecified,
8667 "LOCK_HINT_SHARED" => Self::Shared,
8668 "LOCK_HINT_EXCLUSIVE" => Self::Exclusive,
8669 _ => Self::UnknownValue(lock_hint::UnknownValue(
8670 wkt::internal::UnknownEnumValue::String(value.to_string()),
8671 )),
8672 }
8673 }
8674 }
8675
8676 impl serde::ser::Serialize for LockHint {
8677 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8678 where
8679 S: serde::Serializer,
8680 {
8681 match self {
8682 Self::Unspecified => serializer.serialize_i32(0),
8683 Self::Shared => serializer.serialize_i32(1),
8684 Self::Exclusive => serializer.serialize_i32(2),
8685 Self::UnknownValue(u) => u.0.serialize(serializer),
8686 }
8687 }
8688 }
8689
8690 impl<'de> serde::de::Deserialize<'de> for LockHint {
8691 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8692 where
8693 D: serde::Deserializer<'de>,
8694 {
8695 deserializer.deserialize_any(wkt::internal::EnumVisitor::<LockHint>::new(
8696 ".google.spanner.v1.ReadRequest.LockHint",
8697 ))
8698 }
8699 }
8700}
8701
8702/// The request for
8703/// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
8704///
8705/// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
8706#[derive(Clone, Default, PartialEq)]
8707#[non_exhaustive]
8708pub struct BeginTransactionRequest {
8709 /// Required. The session in which the transaction runs.
8710 pub session: std::string::String,
8711
8712 /// Required. Options for the new transaction.
8713 pub options: std::option::Option<crate::model::TransactionOptions>,
8714
8715 /// Common options for this request.
8716 /// Priority is ignored for this request. Setting the priority in this
8717 /// `request_options` struct doesn't do anything. To set the priority for a
8718 /// transaction, set it on the reads and writes that are part of this
8719 /// transaction instead.
8720 pub request_options: std::option::Option<crate::model::RequestOptions>,
8721
8722 /// Optional. Required for read-write transactions on a multiplexed session
8723 /// that commit mutations but don't perform any reads or queries. You must
8724 /// randomly select one of the mutations from the mutation set and send it as a
8725 /// part of this request.
8726 pub mutation_key: std::option::Option<crate::model::Mutation>,
8727
8728 /// Optional. Makes the Spanner requests location-aware if present.
8729 ///
8730 /// It gives the server hints that can be used to route the request
8731 /// to an appropriate server, potentially significantly decreasing latency and
8732 /// improving throughput. To achieve improved performance, most fields must be
8733 /// filled in with accurate values.
8734 pub routing_hint: std::option::Option<crate::model::RoutingHint>,
8735
8736 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8737}
8738
8739impl BeginTransactionRequest {
8740 /// Creates a new default instance.
8741 pub fn new() -> Self {
8742 std::default::Default::default()
8743 }
8744
8745 /// Sets the value of [session][crate::model::BeginTransactionRequest::session].
8746 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8747 self.session = v.into();
8748 self
8749 }
8750
8751 /// Sets the value of [options][crate::model::BeginTransactionRequest::options].
8752 pub fn set_options<T>(mut self, v: T) -> Self
8753 where
8754 T: std::convert::Into<crate::model::TransactionOptions>,
8755 {
8756 self.options = std::option::Option::Some(v.into());
8757 self
8758 }
8759
8760 /// Sets or clears the value of [options][crate::model::BeginTransactionRequest::options].
8761 pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
8762 where
8763 T: std::convert::Into<crate::model::TransactionOptions>,
8764 {
8765 self.options = v.map(|x| x.into());
8766 self
8767 }
8768
8769 /// Sets the value of [request_options][crate::model::BeginTransactionRequest::request_options].
8770 pub fn set_request_options<T>(mut self, v: T) -> Self
8771 where
8772 T: std::convert::Into<crate::model::RequestOptions>,
8773 {
8774 self.request_options = std::option::Option::Some(v.into());
8775 self
8776 }
8777
8778 /// Sets or clears the value of [request_options][crate::model::BeginTransactionRequest::request_options].
8779 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
8780 where
8781 T: std::convert::Into<crate::model::RequestOptions>,
8782 {
8783 self.request_options = v.map(|x| x.into());
8784 self
8785 }
8786
8787 /// Sets the value of [mutation_key][crate::model::BeginTransactionRequest::mutation_key].
8788 pub fn set_mutation_key<T>(mut self, v: T) -> Self
8789 where
8790 T: std::convert::Into<crate::model::Mutation>,
8791 {
8792 self.mutation_key = std::option::Option::Some(v.into());
8793 self
8794 }
8795
8796 /// Sets or clears the value of [mutation_key][crate::model::BeginTransactionRequest::mutation_key].
8797 pub fn set_or_clear_mutation_key<T>(mut self, v: std::option::Option<T>) -> Self
8798 where
8799 T: std::convert::Into<crate::model::Mutation>,
8800 {
8801 self.mutation_key = v.map(|x| x.into());
8802 self
8803 }
8804
8805 /// Sets the value of [routing_hint][crate::model::BeginTransactionRequest::routing_hint].
8806 pub fn set_routing_hint<T>(mut self, v: T) -> Self
8807 where
8808 T: std::convert::Into<crate::model::RoutingHint>,
8809 {
8810 self.routing_hint = std::option::Option::Some(v.into());
8811 self
8812 }
8813
8814 /// Sets or clears the value of [routing_hint][crate::model::BeginTransactionRequest::routing_hint].
8815 pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
8816 where
8817 T: std::convert::Into<crate::model::RoutingHint>,
8818 {
8819 self.routing_hint = v.map(|x| x.into());
8820 self
8821 }
8822}
8823
8824impl wkt::message::Message for BeginTransactionRequest {
8825 fn typename() -> &'static str {
8826 "type.googleapis.com/google.spanner.v1.BeginTransactionRequest"
8827 }
8828}
8829
8830/// The request for [Commit][google.spanner.v1.Spanner.Commit].
8831///
8832/// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
8833#[derive(Clone, Default, PartialEq)]
8834#[non_exhaustive]
8835pub struct CommitRequest {
8836 /// Required. The session in which the transaction to be committed is running.
8837 pub session: std::string::String,
8838
8839 /// The mutations to be executed when this transaction commits. All
8840 /// mutations are applied atomically, in the order they appear in
8841 /// this list.
8842 pub mutations: std::vec::Vec<crate::model::Mutation>,
8843
8844 /// If `true`, then statistics related to the transaction is included in
8845 /// the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats].
8846 /// Default value is `false`.
8847 ///
8848 /// [google.spanner.v1.CommitResponse.commit_stats]: crate::model::CommitResponse::commit_stats
8849 pub return_commit_stats: bool,
8850
8851 /// Optional. The amount of latency this request is configured to incur in
8852 /// order to improve throughput. If this field isn't set, Spanner assumes
8853 /// requests are relatively latency sensitive and automatically determines an
8854 /// appropriate delay time. You can specify a commit delay value between 0 and
8855 /// 500 ms.
8856 pub max_commit_delay: std::option::Option<wkt::Duration>,
8857
8858 /// Common options for this request.
8859 pub request_options: std::option::Option<crate::model::RequestOptions>,
8860
8861 /// Optional. If the read-write transaction was executed on a multiplexed
8862 /// session, then you must include the precommit token with the highest
8863 /// sequence number received in this transaction attempt. Failing to do so
8864 /// results in a `FailedPrecondition` error.
8865 pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
8866
8867 /// Optional. Makes the Spanner requests location-aware if present.
8868 ///
8869 /// It gives the server hints that can be used to route the request
8870 /// to an appropriate server, potentially significantly decreasing latency and
8871 /// improving throughput. To achieve improved performance, most fields must be
8872 /// filled in with accurate values.
8873 pub routing_hint: std::option::Option<crate::model::RoutingHint>,
8874
8875 /// Required. The transaction in which to commit.
8876 pub transaction: std::option::Option<crate::model::commit_request::Transaction>,
8877
8878 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8879}
8880
8881impl CommitRequest {
8882 /// Creates a new default instance.
8883 pub fn new() -> Self {
8884 std::default::Default::default()
8885 }
8886
8887 /// Sets the value of [session][crate::model::CommitRequest::session].
8888 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8889 self.session = v.into();
8890 self
8891 }
8892
8893 /// Sets the value of [mutations][crate::model::CommitRequest::mutations].
8894 pub fn set_mutations<T, V>(mut self, v: T) -> Self
8895 where
8896 T: std::iter::IntoIterator<Item = V>,
8897 V: std::convert::Into<crate::model::Mutation>,
8898 {
8899 use std::iter::Iterator;
8900 self.mutations = v.into_iter().map(|i| i.into()).collect();
8901 self
8902 }
8903
8904 /// Sets the value of [return_commit_stats][crate::model::CommitRequest::return_commit_stats].
8905 pub fn set_return_commit_stats<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8906 self.return_commit_stats = v.into();
8907 self
8908 }
8909
8910 /// Sets the value of [max_commit_delay][crate::model::CommitRequest::max_commit_delay].
8911 pub fn set_max_commit_delay<T>(mut self, v: T) -> Self
8912 where
8913 T: std::convert::Into<wkt::Duration>,
8914 {
8915 self.max_commit_delay = std::option::Option::Some(v.into());
8916 self
8917 }
8918
8919 /// Sets or clears the value of [max_commit_delay][crate::model::CommitRequest::max_commit_delay].
8920 pub fn set_or_clear_max_commit_delay<T>(mut self, v: std::option::Option<T>) -> Self
8921 where
8922 T: std::convert::Into<wkt::Duration>,
8923 {
8924 self.max_commit_delay = v.map(|x| x.into());
8925 self
8926 }
8927
8928 /// Sets the value of [request_options][crate::model::CommitRequest::request_options].
8929 pub fn set_request_options<T>(mut self, v: T) -> Self
8930 where
8931 T: std::convert::Into<crate::model::RequestOptions>,
8932 {
8933 self.request_options = std::option::Option::Some(v.into());
8934 self
8935 }
8936
8937 /// Sets or clears the value of [request_options][crate::model::CommitRequest::request_options].
8938 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
8939 where
8940 T: std::convert::Into<crate::model::RequestOptions>,
8941 {
8942 self.request_options = v.map(|x| x.into());
8943 self
8944 }
8945
8946 /// Sets the value of [precommit_token][crate::model::CommitRequest::precommit_token].
8947 pub fn set_precommit_token<T>(mut self, v: T) -> Self
8948 where
8949 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
8950 {
8951 self.precommit_token = std::option::Option::Some(v.into());
8952 self
8953 }
8954
8955 /// Sets or clears the value of [precommit_token][crate::model::CommitRequest::precommit_token].
8956 pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
8957 where
8958 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
8959 {
8960 self.precommit_token = v.map(|x| x.into());
8961 self
8962 }
8963
8964 /// Sets the value of [routing_hint][crate::model::CommitRequest::routing_hint].
8965 pub fn set_routing_hint<T>(mut self, v: T) -> Self
8966 where
8967 T: std::convert::Into<crate::model::RoutingHint>,
8968 {
8969 self.routing_hint = std::option::Option::Some(v.into());
8970 self
8971 }
8972
8973 /// Sets or clears the value of [routing_hint][crate::model::CommitRequest::routing_hint].
8974 pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
8975 where
8976 T: std::convert::Into<crate::model::RoutingHint>,
8977 {
8978 self.routing_hint = v.map(|x| x.into());
8979 self
8980 }
8981
8982 /// Sets the value of [transaction][crate::model::CommitRequest::transaction].
8983 ///
8984 /// Note that all the setters affecting `transaction` are mutually
8985 /// exclusive.
8986 pub fn set_transaction<
8987 T: std::convert::Into<std::option::Option<crate::model::commit_request::Transaction>>,
8988 >(
8989 mut self,
8990 v: T,
8991 ) -> Self {
8992 self.transaction = v.into();
8993 self
8994 }
8995
8996 /// The value of [transaction][crate::model::CommitRequest::transaction]
8997 /// if it holds a `TransactionId`, `None` if the field is not set or
8998 /// holds a different branch.
8999 pub fn transaction_id(&self) -> std::option::Option<&::bytes::Bytes> {
9000 #[allow(unreachable_patterns)]
9001 self.transaction.as_ref().and_then(|v| match v {
9002 crate::model::commit_request::Transaction::TransactionId(v) => {
9003 std::option::Option::Some(v)
9004 }
9005 _ => std::option::Option::None,
9006 })
9007 }
9008
9009 /// Sets the value of [transaction][crate::model::CommitRequest::transaction]
9010 /// to hold a `TransactionId`.
9011 ///
9012 /// Note that all the setters affecting `transaction` are
9013 /// mutually exclusive.
9014 pub fn set_transaction_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
9015 self.transaction = std::option::Option::Some(
9016 crate::model::commit_request::Transaction::TransactionId(v.into()),
9017 );
9018 self
9019 }
9020
9021 /// The value of [transaction][crate::model::CommitRequest::transaction]
9022 /// if it holds a `SingleUseTransaction`, `None` if the field is not set or
9023 /// holds a different branch.
9024 pub fn single_use_transaction(
9025 &self,
9026 ) -> std::option::Option<&std::boxed::Box<crate::model::TransactionOptions>> {
9027 #[allow(unreachable_patterns)]
9028 self.transaction.as_ref().and_then(|v| match v {
9029 crate::model::commit_request::Transaction::SingleUseTransaction(v) => {
9030 std::option::Option::Some(v)
9031 }
9032 _ => std::option::Option::None,
9033 })
9034 }
9035
9036 /// Sets the value of [transaction][crate::model::CommitRequest::transaction]
9037 /// to hold a `SingleUseTransaction`.
9038 ///
9039 /// Note that all the setters affecting `transaction` are
9040 /// mutually exclusive.
9041 pub fn set_single_use_transaction<
9042 T: std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
9043 >(
9044 mut self,
9045 v: T,
9046 ) -> Self {
9047 self.transaction = std::option::Option::Some(
9048 crate::model::commit_request::Transaction::SingleUseTransaction(v.into()),
9049 );
9050 self
9051 }
9052}
9053
9054impl wkt::message::Message for CommitRequest {
9055 fn typename() -> &'static str {
9056 "type.googleapis.com/google.spanner.v1.CommitRequest"
9057 }
9058}
9059
9060/// Defines additional types related to [CommitRequest].
9061pub mod commit_request {
9062 #[allow(unused_imports)]
9063 use super::*;
9064
9065 /// Required. The transaction in which to commit.
9066 #[derive(Clone, Debug, PartialEq)]
9067 #[non_exhaustive]
9068 pub enum Transaction {
9069 /// Commit a previously-started transaction.
9070 TransactionId(::bytes::Bytes),
9071 /// Execute mutations in a temporary transaction. Note that unlike
9072 /// commit of a previously-started transaction, commit with a
9073 /// temporary transaction is non-idempotent. That is, if the
9074 /// `CommitRequest` is sent to Cloud Spanner more than once (for
9075 /// instance, due to retries in the application, or in the
9076 /// transport library), it's possible that the mutations are
9077 /// executed more than once. If this is undesirable, use
9078 /// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and
9079 /// [Commit][google.spanner.v1.Spanner.Commit] instead.
9080 ///
9081 /// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
9082 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
9083 SingleUseTransaction(std::boxed::Box<crate::model::TransactionOptions>),
9084 }
9085
9086 impl Transaction {
9087 /// Initializes the enum to the [TransactionId](Self::TransactionId) branch.
9088 pub fn from_transaction_id(value: impl std::convert::Into<::bytes::Bytes>) -> Self {
9089 Self::TransactionId(value.into())
9090 }
9091 /// Initializes the enum to the [SingleUseTransaction](Self::SingleUseTransaction) branch.
9092 pub fn from_single_use_transaction(
9093 value: impl std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
9094 ) -> Self {
9095 Self::SingleUseTransaction(value.into())
9096 }
9097 }
9098}
9099
9100/// The request for [Rollback][google.spanner.v1.Spanner.Rollback].
9101///
9102/// [google.spanner.v1.Spanner.Rollback]: crate::client::Spanner::rollback
9103#[derive(Clone, Default, PartialEq)]
9104#[non_exhaustive]
9105pub struct RollbackRequest {
9106 /// Required. The session in which the transaction to roll back is running.
9107 pub session: std::string::String,
9108
9109 /// Required. The transaction to roll back.
9110 pub transaction_id: ::bytes::Bytes,
9111
9112 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9113}
9114
9115impl RollbackRequest {
9116 /// Creates a new default instance.
9117 pub fn new() -> Self {
9118 std::default::Default::default()
9119 }
9120
9121 /// Sets the value of [session][crate::model::RollbackRequest::session].
9122 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9123 self.session = v.into();
9124 self
9125 }
9126
9127 /// Sets the value of [transaction_id][crate::model::RollbackRequest::transaction_id].
9128 pub fn set_transaction_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
9129 self.transaction_id = v.into();
9130 self
9131 }
9132}
9133
9134impl wkt::message::Message for RollbackRequest {
9135 fn typename() -> &'static str {
9136 "type.googleapis.com/google.spanner.v1.RollbackRequest"
9137 }
9138}
9139
9140/// The request for [BatchWrite][google.spanner.v1.Spanner.BatchWrite].
9141#[derive(Clone, Default, PartialEq)]
9142#[non_exhaustive]
9143pub struct BatchWriteRequest {
9144 /// Required. The session in which the batch request is to be run.
9145 pub session: std::string::String,
9146
9147 /// Common options for this request.
9148 pub request_options: std::option::Option<crate::model::RequestOptions>,
9149
9150 /// Required. The groups of mutations to be applied.
9151 pub mutation_groups: std::vec::Vec<crate::model::batch_write_request::MutationGroup>,
9152
9153 /// Optional. If you don't set the `exclude_txn_from_change_streams` option or
9154 /// if it's set to `false`, then any change streams monitoring columns modified
9155 /// by transactions will capture the updates made within that transaction.
9156 pub exclude_txn_from_change_streams: bool,
9157
9158 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9159}
9160
9161impl BatchWriteRequest {
9162 /// Creates a new default instance.
9163 pub fn new() -> Self {
9164 std::default::Default::default()
9165 }
9166
9167 /// Sets the value of [session][crate::model::BatchWriteRequest::session].
9168 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9169 self.session = v.into();
9170 self
9171 }
9172
9173 /// Sets the value of [request_options][crate::model::BatchWriteRequest::request_options].
9174 pub fn set_request_options<T>(mut self, v: T) -> Self
9175 where
9176 T: std::convert::Into<crate::model::RequestOptions>,
9177 {
9178 self.request_options = std::option::Option::Some(v.into());
9179 self
9180 }
9181
9182 /// Sets or clears the value of [request_options][crate::model::BatchWriteRequest::request_options].
9183 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
9184 where
9185 T: std::convert::Into<crate::model::RequestOptions>,
9186 {
9187 self.request_options = v.map(|x| x.into());
9188 self
9189 }
9190
9191 /// Sets the value of [mutation_groups][crate::model::BatchWriteRequest::mutation_groups].
9192 pub fn set_mutation_groups<T, V>(mut self, v: T) -> Self
9193 where
9194 T: std::iter::IntoIterator<Item = V>,
9195 V: std::convert::Into<crate::model::batch_write_request::MutationGroup>,
9196 {
9197 use std::iter::Iterator;
9198 self.mutation_groups = v.into_iter().map(|i| i.into()).collect();
9199 self
9200 }
9201
9202 /// Sets the value of [exclude_txn_from_change_streams][crate::model::BatchWriteRequest::exclude_txn_from_change_streams].
9203 pub fn set_exclude_txn_from_change_streams<T: std::convert::Into<bool>>(
9204 mut self,
9205 v: T,
9206 ) -> Self {
9207 self.exclude_txn_from_change_streams = v.into();
9208 self
9209 }
9210}
9211
9212impl wkt::message::Message for BatchWriteRequest {
9213 fn typename() -> &'static str {
9214 "type.googleapis.com/google.spanner.v1.BatchWriteRequest"
9215 }
9216}
9217
9218/// Defines additional types related to [BatchWriteRequest].
9219pub mod batch_write_request {
9220 #[allow(unused_imports)]
9221 use super::*;
9222
9223 /// A group of mutations to be committed together. Related mutations should be
9224 /// placed in a group. For example, two mutations inserting rows with the same
9225 /// primary key prefix in both parent and child tables are related.
9226 #[derive(Clone, Default, PartialEq)]
9227 #[non_exhaustive]
9228 pub struct MutationGroup {
9229 /// Required. The mutations in this group.
9230 pub mutations: std::vec::Vec<crate::model::Mutation>,
9231
9232 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9233 }
9234
9235 impl MutationGroup {
9236 /// Creates a new default instance.
9237 pub fn new() -> Self {
9238 std::default::Default::default()
9239 }
9240
9241 /// Sets the value of [mutations][crate::model::batch_write_request::MutationGroup::mutations].
9242 pub fn set_mutations<T, V>(mut self, v: T) -> Self
9243 where
9244 T: std::iter::IntoIterator<Item = V>,
9245 V: std::convert::Into<crate::model::Mutation>,
9246 {
9247 use std::iter::Iterator;
9248 self.mutations = v.into_iter().map(|i| i.into()).collect();
9249 self
9250 }
9251 }
9252
9253 impl wkt::message::Message for MutationGroup {
9254 fn typename() -> &'static str {
9255 "type.googleapis.com/google.spanner.v1.BatchWriteRequest.MutationGroup"
9256 }
9257 }
9258}
9259
9260/// The result of applying a batch of mutations.
9261#[derive(Clone, Default, PartialEq)]
9262#[non_exhaustive]
9263pub struct BatchWriteResponse {
9264 /// The mutation groups applied in this batch. The values index into the
9265 /// `mutation_groups` field in the corresponding `BatchWriteRequest`.
9266 pub indexes: std::vec::Vec<i32>,
9267
9268 /// An `OK` status indicates success. Any other status indicates a failure.
9269 pub status: std::option::Option<google_cloud_rpc::model::Status>,
9270
9271 /// The commit timestamp of the transaction that applied this batch.
9272 /// Present if status is OK and the mutation groups were applied, absent
9273 /// otherwise.
9274 ///
9275 /// For mutation groups with conditions, a status=OK and missing
9276 /// commit_timestamp means that the mutation groups were not applied due to the
9277 /// condition not being satisfied after evaluation.
9278 pub commit_timestamp: std::option::Option<wkt::Timestamp>,
9279
9280 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9281}
9282
9283impl BatchWriteResponse {
9284 /// Creates a new default instance.
9285 pub fn new() -> Self {
9286 std::default::Default::default()
9287 }
9288
9289 /// Sets the value of [indexes][crate::model::BatchWriteResponse::indexes].
9290 pub fn set_indexes<T, V>(mut self, v: T) -> Self
9291 where
9292 T: std::iter::IntoIterator<Item = V>,
9293 V: std::convert::Into<i32>,
9294 {
9295 use std::iter::Iterator;
9296 self.indexes = v.into_iter().map(|i| i.into()).collect();
9297 self
9298 }
9299
9300 /// Sets the value of [status][crate::model::BatchWriteResponse::status].
9301 pub fn set_status<T>(mut self, v: T) -> Self
9302 where
9303 T: std::convert::Into<google_cloud_rpc::model::Status>,
9304 {
9305 self.status = std::option::Option::Some(v.into());
9306 self
9307 }
9308
9309 /// Sets or clears the value of [status][crate::model::BatchWriteResponse::status].
9310 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
9311 where
9312 T: std::convert::Into<google_cloud_rpc::model::Status>,
9313 {
9314 self.status = v.map(|x| x.into());
9315 self
9316 }
9317
9318 /// Sets the value of [commit_timestamp][crate::model::BatchWriteResponse::commit_timestamp].
9319 pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
9320 where
9321 T: std::convert::Into<wkt::Timestamp>,
9322 {
9323 self.commit_timestamp = std::option::Option::Some(v.into());
9324 self
9325 }
9326
9327 /// Sets or clears the value of [commit_timestamp][crate::model::BatchWriteResponse::commit_timestamp].
9328 pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
9329 where
9330 T: std::convert::Into<wkt::Timestamp>,
9331 {
9332 self.commit_timestamp = v.map(|x| x.into());
9333 self
9334 }
9335}
9336
9337impl wkt::message::Message for BatchWriteResponse {
9338 fn typename() -> &'static str {
9339 "type.googleapis.com/google.spanner.v1.BatchWriteResponse"
9340 }
9341}
9342
9343/// The request for
9344/// [FetchCacheUpdate][google.spanner.v1.Spanner.FetchCacheUpdate].
9345#[derive(Clone, Default, PartialEq)]
9346#[non_exhaustive]
9347pub struct FetchCacheUpdateRequest {
9348 /// Required. The database for which to retrieve the cache update.
9349 pub database: std::string::String,
9350
9351 /// Optional. The maximum number of key recipes to return in the response.
9352 /// If not set, a default limit of 100 will be used.
9353 pub max_recipe_count: i32,
9354
9355 /// Optional. The maximum number of ranges to return in the response.
9356 /// If not set, a default limit of 10000 will be used.
9357 pub max_range_count: i32,
9358
9359 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9360}
9361
9362impl FetchCacheUpdateRequest {
9363 /// Creates a new default instance.
9364 pub fn new() -> Self {
9365 std::default::Default::default()
9366 }
9367
9368 /// Sets the value of [database][crate::model::FetchCacheUpdateRequest::database].
9369 pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9370 self.database = v.into();
9371 self
9372 }
9373
9374 /// Sets the value of [max_recipe_count][crate::model::FetchCacheUpdateRequest::max_recipe_count].
9375 pub fn set_max_recipe_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9376 self.max_recipe_count = v.into();
9377 self
9378 }
9379
9380 /// Sets the value of [max_range_count][crate::model::FetchCacheUpdateRequest::max_range_count].
9381 pub fn set_max_range_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9382 self.max_range_count = v.into();
9383 self
9384 }
9385}
9386
9387impl wkt::message::Message for FetchCacheUpdateRequest {
9388 fn typename() -> &'static str {
9389 "type.googleapis.com/google.spanner.v1.FetchCacheUpdateRequest"
9390 }
9391}
9392
9393/// Options to use for transactions.
9394#[derive(Clone, Default, PartialEq)]
9395#[non_exhaustive]
9396pub struct TransactionOptions {
9397 /// When `exclude_txn_from_change_streams` is set to `true`, it prevents read
9398 /// or write transactions from being tracked in change streams.
9399 ///
9400 /// * If the DDL option `allow_txn_exclusion` is set to `true`, then the
9401 /// updates
9402 /// made within this transaction aren't recorded in the change stream.
9403 ///
9404 /// * If you don't set the DDL option `allow_txn_exclusion` or if it's
9405 /// set to `false`, then the updates made within this transaction are
9406 /// recorded in the change stream.
9407 ///
9408 ///
9409 /// When `exclude_txn_from_change_streams` is set to `false` or not set,
9410 /// modifications from this transaction are recorded in all change streams
9411 /// that are tracking columns modified by these transactions.
9412 ///
9413 /// The `exclude_txn_from_change_streams` option can only be specified
9414 /// for read-write or partitioned DML transactions, otherwise the API returns
9415 /// an `INVALID_ARGUMENT` error.
9416 pub exclude_txn_from_change_streams: bool,
9417
9418 /// Isolation level for the transaction.
9419 pub isolation_level: crate::model::transaction_options::IsolationLevel,
9420
9421 /// Required. The type of transaction.
9422 pub mode: std::option::Option<crate::model::transaction_options::Mode>,
9423
9424 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9425}
9426
9427impl TransactionOptions {
9428 /// Creates a new default instance.
9429 pub fn new() -> Self {
9430 std::default::Default::default()
9431 }
9432
9433 /// Sets the value of [exclude_txn_from_change_streams][crate::model::TransactionOptions::exclude_txn_from_change_streams].
9434 pub fn set_exclude_txn_from_change_streams<T: std::convert::Into<bool>>(
9435 mut self,
9436 v: T,
9437 ) -> Self {
9438 self.exclude_txn_from_change_streams = v.into();
9439 self
9440 }
9441
9442 /// Sets the value of [isolation_level][crate::model::TransactionOptions::isolation_level].
9443 pub fn set_isolation_level<
9444 T: std::convert::Into<crate::model::transaction_options::IsolationLevel>,
9445 >(
9446 mut self,
9447 v: T,
9448 ) -> Self {
9449 self.isolation_level = v.into();
9450 self
9451 }
9452
9453 /// Sets the value of [mode][crate::model::TransactionOptions::mode].
9454 ///
9455 /// Note that all the setters affecting `mode` are mutually
9456 /// exclusive.
9457 pub fn set_mode<
9458 T: std::convert::Into<std::option::Option<crate::model::transaction_options::Mode>>,
9459 >(
9460 mut self,
9461 v: T,
9462 ) -> Self {
9463 self.mode = v.into();
9464 self
9465 }
9466
9467 /// The value of [mode][crate::model::TransactionOptions::mode]
9468 /// if it holds a `ReadWrite`, `None` if the field is not set or
9469 /// holds a different branch.
9470 pub fn read_write(
9471 &self,
9472 ) -> std::option::Option<&std::boxed::Box<crate::model::transaction_options::ReadWrite>> {
9473 #[allow(unreachable_patterns)]
9474 self.mode.as_ref().and_then(|v| match v {
9475 crate::model::transaction_options::Mode::ReadWrite(v) => std::option::Option::Some(v),
9476 _ => std::option::Option::None,
9477 })
9478 }
9479
9480 /// Sets the value of [mode][crate::model::TransactionOptions::mode]
9481 /// to hold a `ReadWrite`.
9482 ///
9483 /// Note that all the setters affecting `mode` are
9484 /// mutually exclusive.
9485 pub fn set_read_write<
9486 T: std::convert::Into<std::boxed::Box<crate::model::transaction_options::ReadWrite>>,
9487 >(
9488 mut self,
9489 v: T,
9490 ) -> Self {
9491 self.mode =
9492 std::option::Option::Some(crate::model::transaction_options::Mode::ReadWrite(v.into()));
9493 self
9494 }
9495
9496 /// The value of [mode][crate::model::TransactionOptions::mode]
9497 /// if it holds a `PartitionedDml`, `None` if the field is not set or
9498 /// holds a different branch.
9499 pub fn partitioned_dml(
9500 &self,
9501 ) -> std::option::Option<&std::boxed::Box<crate::model::transaction_options::PartitionedDml>>
9502 {
9503 #[allow(unreachable_patterns)]
9504 self.mode.as_ref().and_then(|v| match v {
9505 crate::model::transaction_options::Mode::PartitionedDml(v) => {
9506 std::option::Option::Some(v)
9507 }
9508 _ => std::option::Option::None,
9509 })
9510 }
9511
9512 /// Sets the value of [mode][crate::model::TransactionOptions::mode]
9513 /// to hold a `PartitionedDml`.
9514 ///
9515 /// Note that all the setters affecting `mode` are
9516 /// mutually exclusive.
9517 pub fn set_partitioned_dml<
9518 T: std::convert::Into<std::boxed::Box<crate::model::transaction_options::PartitionedDml>>,
9519 >(
9520 mut self,
9521 v: T,
9522 ) -> Self {
9523 self.mode = std::option::Option::Some(
9524 crate::model::transaction_options::Mode::PartitionedDml(v.into()),
9525 );
9526 self
9527 }
9528
9529 /// The value of [mode][crate::model::TransactionOptions::mode]
9530 /// if it holds a `ReadOnly`, `None` if the field is not set or
9531 /// holds a different branch.
9532 pub fn read_only(
9533 &self,
9534 ) -> std::option::Option<&std::boxed::Box<crate::model::transaction_options::ReadOnly>> {
9535 #[allow(unreachable_patterns)]
9536 self.mode.as_ref().and_then(|v| match v {
9537 crate::model::transaction_options::Mode::ReadOnly(v) => std::option::Option::Some(v),
9538 _ => std::option::Option::None,
9539 })
9540 }
9541
9542 /// Sets the value of [mode][crate::model::TransactionOptions::mode]
9543 /// to hold a `ReadOnly`.
9544 ///
9545 /// Note that all the setters affecting `mode` are
9546 /// mutually exclusive.
9547 pub fn set_read_only<
9548 T: std::convert::Into<std::boxed::Box<crate::model::transaction_options::ReadOnly>>,
9549 >(
9550 mut self,
9551 v: T,
9552 ) -> Self {
9553 self.mode =
9554 std::option::Option::Some(crate::model::transaction_options::Mode::ReadOnly(v.into()));
9555 self
9556 }
9557}
9558
9559impl wkt::message::Message for TransactionOptions {
9560 fn typename() -> &'static str {
9561 "type.googleapis.com/google.spanner.v1.TransactionOptions"
9562 }
9563}
9564
9565/// Defines additional types related to [TransactionOptions].
9566pub mod transaction_options {
9567 #[allow(unused_imports)]
9568 use super::*;
9569
9570 /// Message type to initiate a read-write transaction. Currently this
9571 /// transaction type has no options.
9572 #[derive(Clone, Default, PartialEq)]
9573 #[non_exhaustive]
9574 pub struct ReadWrite {
9575 /// Read lock mode for the transaction.
9576 pub read_lock_mode: crate::model::transaction_options::read_write::ReadLockMode,
9577
9578 /// Optional. Clients should pass the transaction ID of the previous
9579 /// transaction attempt that was aborted if this transaction is being
9580 /// executed on a multiplexed session.
9581 pub multiplexed_session_previous_transaction_id: ::bytes::Bytes,
9582
9583 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9584 }
9585
9586 impl ReadWrite {
9587 /// Creates a new default instance.
9588 pub fn new() -> Self {
9589 std::default::Default::default()
9590 }
9591
9592 /// Sets the value of [read_lock_mode][crate::model::transaction_options::ReadWrite::read_lock_mode].
9593 pub fn set_read_lock_mode<
9594 T: std::convert::Into<crate::model::transaction_options::read_write::ReadLockMode>,
9595 >(
9596 mut self,
9597 v: T,
9598 ) -> Self {
9599 self.read_lock_mode = v.into();
9600 self
9601 }
9602
9603 /// Sets the value of [multiplexed_session_previous_transaction_id][crate::model::transaction_options::ReadWrite::multiplexed_session_previous_transaction_id].
9604 pub fn set_multiplexed_session_previous_transaction_id<
9605 T: std::convert::Into<::bytes::Bytes>,
9606 >(
9607 mut self,
9608 v: T,
9609 ) -> Self {
9610 self.multiplexed_session_previous_transaction_id = v.into();
9611 self
9612 }
9613 }
9614
9615 impl wkt::message::Message for ReadWrite {
9616 fn typename() -> &'static str {
9617 "type.googleapis.com/google.spanner.v1.TransactionOptions.ReadWrite"
9618 }
9619 }
9620
9621 /// Defines additional types related to [ReadWrite].
9622 pub mod read_write {
9623 #[allow(unused_imports)]
9624 use super::*;
9625
9626 /// `ReadLockMode` is used to set the read lock mode for read-write
9627 /// transactions.
9628 ///
9629 /// # Working with unknown values
9630 ///
9631 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
9632 /// additional enum variants at any time. Adding new variants is not considered
9633 /// a breaking change. Applications should write their code in anticipation of:
9634 ///
9635 /// - New values appearing in future releases of the client library, **and**
9636 /// - New values received dynamically, without application changes.
9637 ///
9638 /// Please consult the [Working with enums] section in the user guide for some
9639 /// guidelines.
9640 ///
9641 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
9642 #[derive(Clone, Debug, PartialEq)]
9643 #[non_exhaustive]
9644 pub enum ReadLockMode {
9645 /// Default value.
9646 ///
9647 /// * If isolation level is
9648 /// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE],
9649 /// locking semantics default to `PESSIMISTIC`.
9650 /// * If isolation level is
9651 /// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ],
9652 /// locking semantics default to `OPTIMISTIC`.
9653 /// * See
9654 /// [Concurrency
9655 /// control](https://cloud.google.com/spanner/docs/concurrency-control)
9656 /// for more details.
9657 ///
9658 /// [google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]: crate::model::transaction_options::IsolationLevel::RepeatableRead
9659 /// [google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]: crate::model::transaction_options::IsolationLevel::Serializable
9660 Unspecified,
9661 /// Pessimistic lock mode.
9662 ///
9663 /// Lock acquisition behavior depends on the isolation level in use. In
9664 /// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]
9665 /// isolation, reads and writes acquire necessary locks during transaction
9666 /// statement execution. In
9667 /// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]
9668 /// isolation, reads that explicitly request to be locked and writes
9669 /// acquire locks.
9670 /// See
9671 /// [Concurrency
9672 /// control](https://cloud.google.com/spanner/docs/concurrency-control) for
9673 /// details on the types of locks acquired at each transaction step.
9674 ///
9675 /// [google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]: crate::model::transaction_options::IsolationLevel::RepeatableRead
9676 /// [google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]: crate::model::transaction_options::IsolationLevel::Serializable
9677 Pessimistic,
9678 /// Optimistic lock mode.
9679 ///
9680 /// Lock acquisition behavior depends on the isolation level in use. In
9681 /// both
9682 /// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]
9683 /// and
9684 /// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]
9685 /// isolation, reads and writes do not acquire locks during transaction
9686 /// statement execution.
9687 /// See
9688 /// [Concurrency
9689 /// control](https://cloud.google.com/spanner/docs/concurrency-control) for
9690 /// details on how the guarantees of each isolation level are provided at
9691 /// commit time.
9692 ///
9693 /// [google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]: crate::model::transaction_options::IsolationLevel::RepeatableRead
9694 /// [google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]: crate::model::transaction_options::IsolationLevel::Serializable
9695 Optimistic,
9696 /// If set, the enum was initialized with an unknown value.
9697 ///
9698 /// Applications can examine the value using [ReadLockMode::value] or
9699 /// [ReadLockMode::name].
9700 UnknownValue(read_lock_mode::UnknownValue),
9701 }
9702
9703 #[doc(hidden)]
9704 pub mod read_lock_mode {
9705 #[allow(unused_imports)]
9706 use super::*;
9707 #[derive(Clone, Debug, PartialEq)]
9708 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
9709 }
9710
9711 impl ReadLockMode {
9712 /// Gets the enum value.
9713 ///
9714 /// Returns `None` if the enum contains an unknown value deserialized from
9715 /// the string representation of enums.
9716 pub fn value(&self) -> std::option::Option<i32> {
9717 match self {
9718 Self::Unspecified => std::option::Option::Some(0),
9719 Self::Pessimistic => std::option::Option::Some(1),
9720 Self::Optimistic => std::option::Option::Some(2),
9721 Self::UnknownValue(u) => u.0.value(),
9722 }
9723 }
9724
9725 /// Gets the enum value as a string.
9726 ///
9727 /// Returns `None` if the enum contains an unknown value deserialized from
9728 /// the integer representation of enums.
9729 pub fn name(&self) -> std::option::Option<&str> {
9730 match self {
9731 Self::Unspecified => std::option::Option::Some("READ_LOCK_MODE_UNSPECIFIED"),
9732 Self::Pessimistic => std::option::Option::Some("PESSIMISTIC"),
9733 Self::Optimistic => std::option::Option::Some("OPTIMISTIC"),
9734 Self::UnknownValue(u) => u.0.name(),
9735 }
9736 }
9737 }
9738
9739 impl std::default::Default for ReadLockMode {
9740 fn default() -> Self {
9741 use std::convert::From;
9742 Self::from(0)
9743 }
9744 }
9745
9746 impl std::fmt::Display for ReadLockMode {
9747 fn fmt(
9748 &self,
9749 f: &mut std::fmt::Formatter<'_>,
9750 ) -> std::result::Result<(), std::fmt::Error> {
9751 wkt::internal::display_enum(f, self.name(), self.value())
9752 }
9753 }
9754
9755 impl std::convert::From<i32> for ReadLockMode {
9756 fn from(value: i32) -> Self {
9757 match value {
9758 0 => Self::Unspecified,
9759 1 => Self::Pessimistic,
9760 2 => Self::Optimistic,
9761 _ => Self::UnknownValue(read_lock_mode::UnknownValue(
9762 wkt::internal::UnknownEnumValue::Integer(value),
9763 )),
9764 }
9765 }
9766 }
9767
9768 impl std::convert::From<&str> for ReadLockMode {
9769 fn from(value: &str) -> Self {
9770 use std::string::ToString;
9771 match value {
9772 "READ_LOCK_MODE_UNSPECIFIED" => Self::Unspecified,
9773 "PESSIMISTIC" => Self::Pessimistic,
9774 "OPTIMISTIC" => Self::Optimistic,
9775 _ => Self::UnknownValue(read_lock_mode::UnknownValue(
9776 wkt::internal::UnknownEnumValue::String(value.to_string()),
9777 )),
9778 }
9779 }
9780 }
9781
9782 impl serde::ser::Serialize for ReadLockMode {
9783 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9784 where
9785 S: serde::Serializer,
9786 {
9787 match self {
9788 Self::Unspecified => serializer.serialize_i32(0),
9789 Self::Pessimistic => serializer.serialize_i32(1),
9790 Self::Optimistic => serializer.serialize_i32(2),
9791 Self::UnknownValue(u) => u.0.serialize(serializer),
9792 }
9793 }
9794 }
9795
9796 impl<'de> serde::de::Deserialize<'de> for ReadLockMode {
9797 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9798 where
9799 D: serde::Deserializer<'de>,
9800 {
9801 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ReadLockMode>::new(
9802 ".google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode",
9803 ))
9804 }
9805 }
9806 }
9807
9808 /// Message type to initiate a Partitioned DML transaction.
9809 #[derive(Clone, Default, PartialEq)]
9810 #[non_exhaustive]
9811 pub struct PartitionedDml {
9812 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9813 }
9814
9815 impl PartitionedDml {
9816 /// Creates a new default instance.
9817 pub fn new() -> Self {
9818 std::default::Default::default()
9819 }
9820 }
9821
9822 impl wkt::message::Message for PartitionedDml {
9823 fn typename() -> &'static str {
9824 "type.googleapis.com/google.spanner.v1.TransactionOptions.PartitionedDml"
9825 }
9826 }
9827
9828 /// Message type to initiate a read-only transaction.
9829 #[derive(Clone, Default, PartialEq)]
9830 #[non_exhaustive]
9831 pub struct ReadOnly {
9832 /// If true, the Cloud Spanner-selected read timestamp is included in
9833 /// the [Transaction][google.spanner.v1.Transaction] message that describes
9834 /// the transaction.
9835 ///
9836 /// [google.spanner.v1.Transaction]: crate::model::Transaction
9837 pub return_read_timestamp: bool,
9838
9839 /// How to choose the timestamp for the read-only transaction.
9840 pub timestamp_bound:
9841 std::option::Option<crate::model::transaction_options::read_only::TimestampBound>,
9842
9843 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9844 }
9845
9846 impl ReadOnly {
9847 /// Creates a new default instance.
9848 pub fn new() -> Self {
9849 std::default::Default::default()
9850 }
9851
9852 /// Sets the value of [return_read_timestamp][crate::model::transaction_options::ReadOnly::return_read_timestamp].
9853 pub fn set_return_read_timestamp<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9854 self.return_read_timestamp = v.into();
9855 self
9856 }
9857
9858 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound].
9859 ///
9860 /// Note that all the setters affecting `timestamp_bound` are mutually
9861 /// exclusive.
9862 pub fn set_timestamp_bound<
9863 T: std::convert::Into<
9864 std::option::Option<
9865 crate::model::transaction_options::read_only::TimestampBound,
9866 >,
9867 >,
9868 >(
9869 mut self,
9870 v: T,
9871 ) -> Self {
9872 self.timestamp_bound = v.into();
9873 self
9874 }
9875
9876 /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9877 /// if it holds a `Strong`, `None` if the field is not set or
9878 /// holds a different branch.
9879 pub fn strong(&self) -> std::option::Option<&bool> {
9880 #[allow(unreachable_patterns)]
9881 self.timestamp_bound.as_ref().and_then(|v| match v {
9882 crate::model::transaction_options::read_only::TimestampBound::Strong(v) => {
9883 std::option::Option::Some(v)
9884 }
9885 _ => std::option::Option::None,
9886 })
9887 }
9888
9889 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9890 /// to hold a `Strong`.
9891 ///
9892 /// Note that all the setters affecting `timestamp_bound` are
9893 /// mutually exclusive.
9894 pub fn set_strong<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9895 self.timestamp_bound = std::option::Option::Some(
9896 crate::model::transaction_options::read_only::TimestampBound::Strong(v.into()),
9897 );
9898 self
9899 }
9900
9901 /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9902 /// if it holds a `MinReadTimestamp`, `None` if the field is not set or
9903 /// holds a different branch.
9904 pub fn min_read_timestamp(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
9905 #[allow(unreachable_patterns)]
9906 self.timestamp_bound.as_ref().and_then(|v| match v {
9907 crate::model::transaction_options::read_only::TimestampBound::MinReadTimestamp(
9908 v,
9909 ) => std::option::Option::Some(v),
9910 _ => std::option::Option::None,
9911 })
9912 }
9913
9914 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9915 /// to hold a `MinReadTimestamp`.
9916 ///
9917 /// Note that all the setters affecting `timestamp_bound` are
9918 /// mutually exclusive.
9919 pub fn set_min_read_timestamp<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
9920 mut self,
9921 v: T,
9922 ) -> Self {
9923 self.timestamp_bound = std::option::Option::Some(
9924 crate::model::transaction_options::read_only::TimestampBound::MinReadTimestamp(
9925 v.into(),
9926 ),
9927 );
9928 self
9929 }
9930
9931 /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9932 /// if it holds a `MaxStaleness`, `None` if the field is not set or
9933 /// holds a different branch.
9934 pub fn max_staleness(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
9935 #[allow(unreachable_patterns)]
9936 self.timestamp_bound.as_ref().and_then(|v| match v {
9937 crate::model::transaction_options::read_only::TimestampBound::MaxStaleness(v) => {
9938 std::option::Option::Some(v)
9939 }
9940 _ => std::option::Option::None,
9941 })
9942 }
9943
9944 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9945 /// to hold a `MaxStaleness`.
9946 ///
9947 /// Note that all the setters affecting `timestamp_bound` are
9948 /// mutually exclusive.
9949 pub fn set_max_staleness<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
9950 mut self,
9951 v: T,
9952 ) -> Self {
9953 self.timestamp_bound = std::option::Option::Some(
9954 crate::model::transaction_options::read_only::TimestampBound::MaxStaleness(
9955 v.into(),
9956 ),
9957 );
9958 self
9959 }
9960
9961 /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9962 /// if it holds a `ReadTimestamp`, `None` if the field is not set or
9963 /// holds a different branch.
9964 pub fn read_timestamp(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
9965 #[allow(unreachable_patterns)]
9966 self.timestamp_bound.as_ref().and_then(|v| match v {
9967 crate::model::transaction_options::read_only::TimestampBound::ReadTimestamp(v) => {
9968 std::option::Option::Some(v)
9969 }
9970 _ => std::option::Option::None,
9971 })
9972 }
9973
9974 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9975 /// to hold a `ReadTimestamp`.
9976 ///
9977 /// Note that all the setters affecting `timestamp_bound` are
9978 /// mutually exclusive.
9979 pub fn set_read_timestamp<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
9980 mut self,
9981 v: T,
9982 ) -> Self {
9983 self.timestamp_bound = std::option::Option::Some(
9984 crate::model::transaction_options::read_only::TimestampBound::ReadTimestamp(
9985 v.into(),
9986 ),
9987 );
9988 self
9989 }
9990
9991 /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9992 /// if it holds a `ExactStaleness`, `None` if the field is not set or
9993 /// holds a different branch.
9994 pub fn exact_staleness(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
9995 #[allow(unreachable_patterns)]
9996 self.timestamp_bound.as_ref().and_then(|v| match v {
9997 crate::model::transaction_options::read_only::TimestampBound::ExactStaleness(v) => {
9998 std::option::Option::Some(v)
9999 }
10000 _ => std::option::Option::None,
10001 })
10002 }
10003
10004 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
10005 /// to hold a `ExactStaleness`.
10006 ///
10007 /// Note that all the setters affecting `timestamp_bound` are
10008 /// mutually exclusive.
10009 pub fn set_exact_staleness<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
10010 mut self,
10011 v: T,
10012 ) -> Self {
10013 self.timestamp_bound = std::option::Option::Some(
10014 crate::model::transaction_options::read_only::TimestampBound::ExactStaleness(
10015 v.into(),
10016 ),
10017 );
10018 self
10019 }
10020 }
10021
10022 impl wkt::message::Message for ReadOnly {
10023 fn typename() -> &'static str {
10024 "type.googleapis.com/google.spanner.v1.TransactionOptions.ReadOnly"
10025 }
10026 }
10027
10028 /// Defines additional types related to [ReadOnly].
10029 pub mod read_only {
10030 #[allow(unused_imports)]
10031 use super::*;
10032
10033 /// How to choose the timestamp for the read-only transaction.
10034 #[derive(Clone, Debug, PartialEq)]
10035 #[non_exhaustive]
10036 pub enum TimestampBound {
10037 /// Read at a timestamp where all previously committed transactions
10038 /// are visible.
10039 Strong(bool),
10040 /// Executes all reads at a timestamp >= `min_read_timestamp`.
10041 ///
10042 /// This is useful for requesting fresher data than some previous
10043 /// read, or data that is fresh enough to observe the effects of some
10044 /// previously committed transaction whose timestamp is known.
10045 ///
10046 /// Note that this option can only be used in single-use transactions.
10047 ///
10048 /// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
10049 /// Example: `"2014-10-02T15:01:23.045123456Z"`.
10050 MinReadTimestamp(std::boxed::Box<wkt::Timestamp>),
10051 /// Read data at a timestamp >= `NOW - max_staleness`
10052 /// seconds. Guarantees that all writes that have committed more
10053 /// than the specified number of seconds ago are visible. Because
10054 /// Cloud Spanner chooses the exact timestamp, this mode works even if
10055 /// the client's local clock is substantially skewed from Cloud Spanner
10056 /// commit timestamps.
10057 ///
10058 /// Useful for reading the freshest data available at a nearby
10059 /// replica, while bounding the possible staleness if the local
10060 /// replica has fallen behind.
10061 ///
10062 /// Note that this option can only be used in single-use
10063 /// transactions.
10064 MaxStaleness(std::boxed::Box<wkt::Duration>),
10065 /// Executes all reads at the given timestamp. Unlike other modes,
10066 /// reads at a specific timestamp are repeatable; the same read at
10067 /// the same timestamp always returns the same data. If the
10068 /// timestamp is in the future, the read is blocked until the
10069 /// specified timestamp, modulo the read's deadline.
10070 ///
10071 /// Useful for large scale consistent reads such as mapreduces, or
10072 /// for coordinating many reads against a consistent snapshot of the
10073 /// data.
10074 ///
10075 /// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
10076 /// Example: `"2014-10-02T15:01:23.045123456Z"`.
10077 ReadTimestamp(std::boxed::Box<wkt::Timestamp>),
10078 /// Executes all reads at a timestamp that is `exact_staleness`
10079 /// old. The timestamp is chosen soon after the read is started.
10080 ///
10081 /// Guarantees that all writes that have committed more than the
10082 /// specified number of seconds ago are visible. Because Cloud Spanner
10083 /// chooses the exact timestamp, this mode works even if the client's
10084 /// local clock is substantially skewed from Cloud Spanner commit
10085 /// timestamps.
10086 ///
10087 /// Useful for reading at nearby replicas without the distributed
10088 /// timestamp negotiation overhead of `max_staleness`.
10089 ExactStaleness(std::boxed::Box<wkt::Duration>),
10090 }
10091
10092 impl TimestampBound {
10093 /// Initializes the enum to the [Strong](Self::Strong) branch.
10094 pub fn from_strong(value: impl std::convert::Into<bool>) -> Self {
10095 Self::Strong(value.into())
10096 }
10097 /// Initializes the enum to the [MinReadTimestamp](Self::MinReadTimestamp) branch.
10098 pub fn from_min_read_timestamp(
10099 value: impl std::convert::Into<std::boxed::Box<wkt::Timestamp>>,
10100 ) -> Self {
10101 Self::MinReadTimestamp(value.into())
10102 }
10103 /// Initializes the enum to the [MaxStaleness](Self::MaxStaleness) branch.
10104 pub fn from_max_staleness(
10105 value: impl std::convert::Into<std::boxed::Box<wkt::Duration>>,
10106 ) -> Self {
10107 Self::MaxStaleness(value.into())
10108 }
10109 /// Initializes the enum to the [ReadTimestamp](Self::ReadTimestamp) branch.
10110 pub fn from_read_timestamp(
10111 value: impl std::convert::Into<std::boxed::Box<wkt::Timestamp>>,
10112 ) -> Self {
10113 Self::ReadTimestamp(value.into())
10114 }
10115 /// Initializes the enum to the [ExactStaleness](Self::ExactStaleness) branch.
10116 pub fn from_exact_staleness(
10117 value: impl std::convert::Into<std::boxed::Box<wkt::Duration>>,
10118 ) -> Self {
10119 Self::ExactStaleness(value.into())
10120 }
10121 }
10122 }
10123
10124 /// `IsolationLevel` is used when setting the [isolation
10125 /// level](https://cloud.google.com/spanner/docs/isolation-levels) for a
10126 /// transaction.
10127 ///
10128 /// # Working with unknown values
10129 ///
10130 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10131 /// additional enum variants at any time. Adding new variants is not considered
10132 /// a breaking change. Applications should write their code in anticipation of:
10133 ///
10134 /// - New values appearing in future releases of the client library, **and**
10135 /// - New values received dynamically, without application changes.
10136 ///
10137 /// Please consult the [Working with enums] section in the user guide for some
10138 /// guidelines.
10139 ///
10140 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10141 #[derive(Clone, Debug, PartialEq)]
10142 #[non_exhaustive]
10143 pub enum IsolationLevel {
10144 /// Default value.
10145 ///
10146 /// If the value is not specified, the `SERIALIZABLE` isolation level is
10147 /// used.
10148 Unspecified,
10149 /// All transactions appear as if they executed in a serial order, even if
10150 /// some of the reads, writes, and other operations of distinct transactions
10151 /// actually occurred in parallel. Spanner assigns commit timestamps that
10152 /// reflect the order of committed transactions to implement this property.
10153 /// Spanner offers a stronger guarantee than serializability called external
10154 /// consistency. For more information, see
10155 /// [TrueTime and external
10156 /// consistency](https://cloud.google.com/spanner/docs/true-time-external-consistency#serializability).
10157 Serializable,
10158 /// All reads performed during the transaction observe a consistent snapshot
10159 /// of the database, and the transaction is only successfully committed in
10160 /// the absence of conflicts between its updates and any concurrent updates
10161 /// that have occurred since that snapshot. Consequently, in contrast to
10162 /// `SERIALIZABLE` transactions, only write-write conflicts are detected in
10163 /// snapshot transactions.
10164 ///
10165 /// This isolation level does not support read-only and partitioned DML
10166 /// transactions.
10167 ///
10168 /// When `REPEATABLE_READ` is specified on a read-write transaction, the
10169 /// locking semantics default to `OPTIMISTIC`.
10170 RepeatableRead,
10171 /// If set, the enum was initialized with an unknown value.
10172 ///
10173 /// Applications can examine the value using [IsolationLevel::value] or
10174 /// [IsolationLevel::name].
10175 UnknownValue(isolation_level::UnknownValue),
10176 }
10177
10178 #[doc(hidden)]
10179 pub mod isolation_level {
10180 #[allow(unused_imports)]
10181 use super::*;
10182 #[derive(Clone, Debug, PartialEq)]
10183 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10184 }
10185
10186 impl IsolationLevel {
10187 /// Gets the enum value.
10188 ///
10189 /// Returns `None` if the enum contains an unknown value deserialized from
10190 /// the string representation of enums.
10191 pub fn value(&self) -> std::option::Option<i32> {
10192 match self {
10193 Self::Unspecified => std::option::Option::Some(0),
10194 Self::Serializable => std::option::Option::Some(1),
10195 Self::RepeatableRead => std::option::Option::Some(2),
10196 Self::UnknownValue(u) => u.0.value(),
10197 }
10198 }
10199
10200 /// Gets the enum value as a string.
10201 ///
10202 /// Returns `None` if the enum contains an unknown value deserialized from
10203 /// the integer representation of enums.
10204 pub fn name(&self) -> std::option::Option<&str> {
10205 match self {
10206 Self::Unspecified => std::option::Option::Some("ISOLATION_LEVEL_UNSPECIFIED"),
10207 Self::Serializable => std::option::Option::Some("SERIALIZABLE"),
10208 Self::RepeatableRead => std::option::Option::Some("REPEATABLE_READ"),
10209 Self::UnknownValue(u) => u.0.name(),
10210 }
10211 }
10212 }
10213
10214 impl std::default::Default for IsolationLevel {
10215 fn default() -> Self {
10216 use std::convert::From;
10217 Self::from(0)
10218 }
10219 }
10220
10221 impl std::fmt::Display for IsolationLevel {
10222 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
10223 wkt::internal::display_enum(f, self.name(), self.value())
10224 }
10225 }
10226
10227 impl std::convert::From<i32> for IsolationLevel {
10228 fn from(value: i32) -> Self {
10229 match value {
10230 0 => Self::Unspecified,
10231 1 => Self::Serializable,
10232 2 => Self::RepeatableRead,
10233 _ => Self::UnknownValue(isolation_level::UnknownValue(
10234 wkt::internal::UnknownEnumValue::Integer(value),
10235 )),
10236 }
10237 }
10238 }
10239
10240 impl std::convert::From<&str> for IsolationLevel {
10241 fn from(value: &str) -> Self {
10242 use std::string::ToString;
10243 match value {
10244 "ISOLATION_LEVEL_UNSPECIFIED" => Self::Unspecified,
10245 "SERIALIZABLE" => Self::Serializable,
10246 "REPEATABLE_READ" => Self::RepeatableRead,
10247 _ => Self::UnknownValue(isolation_level::UnknownValue(
10248 wkt::internal::UnknownEnumValue::String(value.to_string()),
10249 )),
10250 }
10251 }
10252 }
10253
10254 impl serde::ser::Serialize for IsolationLevel {
10255 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10256 where
10257 S: serde::Serializer,
10258 {
10259 match self {
10260 Self::Unspecified => serializer.serialize_i32(0),
10261 Self::Serializable => serializer.serialize_i32(1),
10262 Self::RepeatableRead => serializer.serialize_i32(2),
10263 Self::UnknownValue(u) => u.0.serialize(serializer),
10264 }
10265 }
10266 }
10267
10268 impl<'de> serde::de::Deserialize<'de> for IsolationLevel {
10269 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10270 where
10271 D: serde::Deserializer<'de>,
10272 {
10273 deserializer.deserialize_any(wkt::internal::EnumVisitor::<IsolationLevel>::new(
10274 ".google.spanner.v1.TransactionOptions.IsolationLevel",
10275 ))
10276 }
10277 }
10278
10279 /// Required. The type of transaction.
10280 #[derive(Clone, Debug, PartialEq)]
10281 #[non_exhaustive]
10282 pub enum Mode {
10283 /// Transaction may write.
10284 ///
10285 /// Authorization to begin a read-write transaction requires
10286 /// `spanner.databases.beginOrRollbackReadWriteTransaction` permission
10287 /// on the `session` resource.
10288 ReadWrite(std::boxed::Box<crate::model::transaction_options::ReadWrite>),
10289 /// Partitioned DML transaction.
10290 ///
10291 /// Authorization to begin a Partitioned DML transaction requires
10292 /// `spanner.databases.beginPartitionedDmlTransaction` permission
10293 /// on the `session` resource.
10294 PartitionedDml(std::boxed::Box<crate::model::transaction_options::PartitionedDml>),
10295 /// Transaction does not write.
10296 ///
10297 /// Authorization to begin a read-only transaction requires
10298 /// `spanner.databases.beginReadOnlyTransaction` permission
10299 /// on the `session` resource.
10300 ReadOnly(std::boxed::Box<crate::model::transaction_options::ReadOnly>),
10301 }
10302
10303 impl Mode {
10304 /// Initializes the enum to the [ReadWrite](Self::ReadWrite) branch.
10305 pub fn from_read_write(
10306 value: impl std::convert::Into<
10307 std::boxed::Box<crate::model::transaction_options::ReadWrite>,
10308 >,
10309 ) -> Self {
10310 Self::ReadWrite(value.into())
10311 }
10312 /// Initializes the enum to the [PartitionedDml](Self::PartitionedDml) branch.
10313 pub fn from_partitioned_dml(
10314 value: impl std::convert::Into<
10315 std::boxed::Box<crate::model::transaction_options::PartitionedDml>,
10316 >,
10317 ) -> Self {
10318 Self::PartitionedDml(value.into())
10319 }
10320 /// Initializes the enum to the [ReadOnly](Self::ReadOnly) branch.
10321 pub fn from_read_only(
10322 value: impl std::convert::Into<std::boxed::Box<crate::model::transaction_options::ReadOnly>>,
10323 ) -> Self {
10324 Self::ReadOnly(value.into())
10325 }
10326 }
10327}
10328
10329/// A transaction.
10330#[derive(Clone, Default, PartialEq)]
10331#[non_exhaustive]
10332pub struct Transaction {
10333 /// `id` may be used to identify the transaction in subsequent
10334 /// [Read][google.spanner.v1.Spanner.Read],
10335 /// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql],
10336 /// [Commit][google.spanner.v1.Spanner.Commit], or
10337 /// [Rollback][google.spanner.v1.Spanner.Rollback] calls.
10338 ///
10339 /// Single-use read-only transactions do not have IDs, because
10340 /// single-use transactions do not support multiple requests.
10341 ///
10342 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
10343 /// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
10344 /// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
10345 /// [google.spanner.v1.Spanner.Rollback]: crate::client::Spanner::rollback
10346 pub id: ::bytes::Bytes,
10347
10348 /// For snapshot read-only transactions, the read timestamp chosen
10349 /// for the transaction. Not returned by default: see
10350 /// [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp].
10351 ///
10352 /// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
10353 /// Example: `"2014-10-02T15:01:23.045123456Z"`.
10354 ///
10355 /// [google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp]: crate::model::transaction_options::ReadOnly::return_read_timestamp
10356 pub read_timestamp: std::option::Option<wkt::Timestamp>,
10357
10358 /// A precommit token is included in the response of a BeginTransaction
10359 /// request if the read-write transaction is on a multiplexed session and
10360 /// a mutation_key was specified in the
10361 /// [BeginTransaction][google.spanner.v1.BeginTransactionRequest].
10362 /// The precommit token with the highest sequence number from this transaction
10363 /// attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit]
10364 /// request for this transaction.
10365 ///
10366 /// [google.spanner.v1.BeginTransactionRequest]: crate::model::BeginTransactionRequest
10367 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
10368 pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
10369
10370 /// Optional. A cache update expresses a set of changes the client should
10371 /// incorporate into its location cache. The client should discard the changes
10372 /// if they are older than the data it already has. This data can be obtained
10373 /// in response to requests that included a `RoutingHint` field, but may also
10374 /// be obtained by explicit location-fetching RPCs which may be added in the
10375 /// future.
10376 pub cache_update: std::option::Option<crate::model::CacheUpdate>,
10377
10378 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10379}
10380
10381impl Transaction {
10382 /// Creates a new default instance.
10383 pub fn new() -> Self {
10384 std::default::Default::default()
10385 }
10386
10387 /// Sets the value of [id][crate::model::Transaction::id].
10388 pub fn set_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
10389 self.id = v.into();
10390 self
10391 }
10392
10393 /// Sets the value of [read_timestamp][crate::model::Transaction::read_timestamp].
10394 pub fn set_read_timestamp<T>(mut self, v: T) -> Self
10395 where
10396 T: std::convert::Into<wkt::Timestamp>,
10397 {
10398 self.read_timestamp = std::option::Option::Some(v.into());
10399 self
10400 }
10401
10402 /// Sets or clears the value of [read_timestamp][crate::model::Transaction::read_timestamp].
10403 pub fn set_or_clear_read_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
10404 where
10405 T: std::convert::Into<wkt::Timestamp>,
10406 {
10407 self.read_timestamp = v.map(|x| x.into());
10408 self
10409 }
10410
10411 /// Sets the value of [precommit_token][crate::model::Transaction::precommit_token].
10412 pub fn set_precommit_token<T>(mut self, v: T) -> Self
10413 where
10414 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
10415 {
10416 self.precommit_token = std::option::Option::Some(v.into());
10417 self
10418 }
10419
10420 /// Sets or clears the value of [precommit_token][crate::model::Transaction::precommit_token].
10421 pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
10422 where
10423 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
10424 {
10425 self.precommit_token = v.map(|x| x.into());
10426 self
10427 }
10428
10429 /// Sets the value of [cache_update][crate::model::Transaction::cache_update].
10430 pub fn set_cache_update<T>(mut self, v: T) -> Self
10431 where
10432 T: std::convert::Into<crate::model::CacheUpdate>,
10433 {
10434 self.cache_update = std::option::Option::Some(v.into());
10435 self
10436 }
10437
10438 /// Sets or clears the value of [cache_update][crate::model::Transaction::cache_update].
10439 pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
10440 where
10441 T: std::convert::Into<crate::model::CacheUpdate>,
10442 {
10443 self.cache_update = v.map(|x| x.into());
10444 self
10445 }
10446}
10447
10448impl wkt::message::Message for Transaction {
10449 fn typename() -> &'static str {
10450 "type.googleapis.com/google.spanner.v1.Transaction"
10451 }
10452}
10453
10454/// This message is used to select the transaction in which a
10455/// [Read][google.spanner.v1.Spanner.Read] or
10456/// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs.
10457///
10458/// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more
10459/// information about transactions.
10460///
10461/// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
10462/// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
10463/// [google.spanner.v1.TransactionOptions]: crate::model::TransactionOptions
10464#[derive(Clone, Default, PartialEq)]
10465#[non_exhaustive]
10466pub struct TransactionSelector {
10467 /// If no fields are set, the default is a single use transaction
10468 /// with strong concurrency.
10469 pub selector: std::option::Option<crate::model::transaction_selector::Selector>,
10470
10471 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10472}
10473
10474impl TransactionSelector {
10475 /// Creates a new default instance.
10476 pub fn new() -> Self {
10477 std::default::Default::default()
10478 }
10479
10480 /// Sets the value of [selector][crate::model::TransactionSelector::selector].
10481 ///
10482 /// Note that all the setters affecting `selector` are mutually
10483 /// exclusive.
10484 pub fn set_selector<
10485 T: std::convert::Into<std::option::Option<crate::model::transaction_selector::Selector>>,
10486 >(
10487 mut self,
10488 v: T,
10489 ) -> Self {
10490 self.selector = v.into();
10491 self
10492 }
10493
10494 /// The value of [selector][crate::model::TransactionSelector::selector]
10495 /// if it holds a `SingleUse`, `None` if the field is not set or
10496 /// holds a different branch.
10497 pub fn single_use(
10498 &self,
10499 ) -> std::option::Option<&std::boxed::Box<crate::model::TransactionOptions>> {
10500 #[allow(unreachable_patterns)]
10501 self.selector.as_ref().and_then(|v| match v {
10502 crate::model::transaction_selector::Selector::SingleUse(v) => {
10503 std::option::Option::Some(v)
10504 }
10505 _ => std::option::Option::None,
10506 })
10507 }
10508
10509 /// Sets the value of [selector][crate::model::TransactionSelector::selector]
10510 /// to hold a `SingleUse`.
10511 ///
10512 /// Note that all the setters affecting `selector` are
10513 /// mutually exclusive.
10514 pub fn set_single_use<
10515 T: std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
10516 >(
10517 mut self,
10518 v: T,
10519 ) -> Self {
10520 self.selector = std::option::Option::Some(
10521 crate::model::transaction_selector::Selector::SingleUse(v.into()),
10522 );
10523 self
10524 }
10525
10526 /// The value of [selector][crate::model::TransactionSelector::selector]
10527 /// if it holds a `Id`, `None` if the field is not set or
10528 /// holds a different branch.
10529 pub fn id(&self) -> std::option::Option<&::bytes::Bytes> {
10530 #[allow(unreachable_patterns)]
10531 self.selector.as_ref().and_then(|v| match v {
10532 crate::model::transaction_selector::Selector::Id(v) => std::option::Option::Some(v),
10533 _ => std::option::Option::None,
10534 })
10535 }
10536
10537 /// Sets the value of [selector][crate::model::TransactionSelector::selector]
10538 /// to hold a `Id`.
10539 ///
10540 /// Note that all the setters affecting `selector` are
10541 /// mutually exclusive.
10542 pub fn set_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
10543 self.selector =
10544 std::option::Option::Some(crate::model::transaction_selector::Selector::Id(v.into()));
10545 self
10546 }
10547
10548 /// The value of [selector][crate::model::TransactionSelector::selector]
10549 /// if it holds a `Begin`, `None` if the field is not set or
10550 /// holds a different branch.
10551 pub fn begin(&self) -> std::option::Option<&std::boxed::Box<crate::model::TransactionOptions>> {
10552 #[allow(unreachable_patterns)]
10553 self.selector.as_ref().and_then(|v| match v {
10554 crate::model::transaction_selector::Selector::Begin(v) => std::option::Option::Some(v),
10555 _ => std::option::Option::None,
10556 })
10557 }
10558
10559 /// Sets the value of [selector][crate::model::TransactionSelector::selector]
10560 /// to hold a `Begin`.
10561 ///
10562 /// Note that all the setters affecting `selector` are
10563 /// mutually exclusive.
10564 pub fn set_begin<T: std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>>(
10565 mut self,
10566 v: T,
10567 ) -> Self {
10568 self.selector = std::option::Option::Some(
10569 crate::model::transaction_selector::Selector::Begin(v.into()),
10570 );
10571 self
10572 }
10573}
10574
10575impl wkt::message::Message for TransactionSelector {
10576 fn typename() -> &'static str {
10577 "type.googleapis.com/google.spanner.v1.TransactionSelector"
10578 }
10579}
10580
10581/// Defines additional types related to [TransactionSelector].
10582pub mod transaction_selector {
10583 #[allow(unused_imports)]
10584 use super::*;
10585
10586 /// If no fields are set, the default is a single use transaction
10587 /// with strong concurrency.
10588 #[derive(Clone, Debug, PartialEq)]
10589 #[non_exhaustive]
10590 pub enum Selector {
10591 /// Execute the read or SQL query in a temporary transaction.
10592 /// This is the most efficient way to execute a transaction that
10593 /// consists of a single SQL query.
10594 SingleUse(std::boxed::Box<crate::model::TransactionOptions>),
10595 /// Execute the read or SQL query in a previously-started transaction.
10596 Id(::bytes::Bytes),
10597 /// Begin a new transaction and execute this read or SQL query in
10598 /// it. The transaction ID of the new transaction is returned in
10599 /// [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction],
10600 /// which is a [Transaction][google.spanner.v1.Transaction].
10601 ///
10602 /// [google.spanner.v1.ResultSetMetadata.transaction]: crate::model::ResultSetMetadata::transaction
10603 /// [google.spanner.v1.Transaction]: crate::model::Transaction
10604 Begin(std::boxed::Box<crate::model::TransactionOptions>),
10605 }
10606
10607 impl Selector {
10608 /// Initializes the enum to the [SingleUse](Self::SingleUse) branch.
10609 pub fn from_single_use(
10610 value: impl std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
10611 ) -> Self {
10612 Self::SingleUse(value.into())
10613 }
10614 /// Initializes the enum to the [Id](Self::Id) branch.
10615 pub fn from_id(value: impl std::convert::Into<::bytes::Bytes>) -> Self {
10616 Self::Id(value.into())
10617 }
10618 /// Initializes the enum to the [Begin](Self::Begin) branch.
10619 pub fn from_begin(
10620 value: impl std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
10621 ) -> Self {
10622 Self::Begin(value.into())
10623 }
10624 }
10625}
10626
10627/// When a read-write transaction is executed on a multiplexed session,
10628/// this precommit token is sent back to the client
10629/// as a part of the [Transaction][google.spanner.v1.Transaction] message in the
10630/// [BeginTransaction][google.spanner.v1.BeginTransactionRequest] response and
10631/// also as a part of the [ResultSet][google.spanner.v1.ResultSet] and
10632/// [PartialResultSet][google.spanner.v1.PartialResultSet] responses.
10633///
10634/// [google.spanner.v1.BeginTransactionRequest]: crate::model::BeginTransactionRequest
10635/// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
10636/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
10637/// [google.spanner.v1.Transaction]: crate::model::Transaction
10638#[derive(Clone, Default, PartialEq)]
10639#[non_exhaustive]
10640pub struct MultiplexedSessionPrecommitToken {
10641 /// Opaque precommit token.
10642 pub precommit_token: ::bytes::Bytes,
10643
10644 /// An incrementing seq number is generated on every precommit token
10645 /// that is returned. Clients should remember the precommit token with the
10646 /// highest sequence number from the current transaction attempt.
10647 pub seq_num: i32,
10648
10649 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10650}
10651
10652impl MultiplexedSessionPrecommitToken {
10653 /// Creates a new default instance.
10654 pub fn new() -> Self {
10655 std::default::Default::default()
10656 }
10657
10658 /// Sets the value of [precommit_token][crate::model::MultiplexedSessionPrecommitToken::precommit_token].
10659 pub fn set_precommit_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
10660 self.precommit_token = v.into();
10661 self
10662 }
10663
10664 /// Sets the value of [seq_num][crate::model::MultiplexedSessionPrecommitToken::seq_num].
10665 pub fn set_seq_num<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10666 self.seq_num = v.into();
10667 self
10668 }
10669}
10670
10671impl wkt::message::Message for MultiplexedSessionPrecommitToken {
10672 fn typename() -> &'static str {
10673 "type.googleapis.com/google.spanner.v1.MultiplexedSessionPrecommitToken"
10674 }
10675}
10676
10677/// `Type` indicates the type of a Cloud Spanner value, as might be stored in a
10678/// table cell or returned from an SQL query.
10679#[derive(Clone, Default, PartialEq)]
10680#[non_exhaustive]
10681pub struct Type {
10682 /// Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
10683 ///
10684 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
10685 pub code: crate::model::TypeCode,
10686
10687 /// If [code][google.spanner.v1.Type.code] ==
10688 /// [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the
10689 /// type of the array elements.
10690 ///
10691 /// [google.spanner.v1.Type.code]: crate::model::Type::code
10692 /// [google.spanner.v1.TypeCode.ARRAY]: crate::model::TypeCode::Array
10693 pub array_element_type: std::option::Option<std::boxed::Box<crate::model::Type>>,
10694
10695 /// If [code][google.spanner.v1.Type.code] ==
10696 /// [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides
10697 /// type information for the struct's fields.
10698 ///
10699 /// [google.spanner.v1.Type.code]: crate::model::Type::code
10700 /// [google.spanner.v1.TypeCode.STRUCT]: crate::model::TypeCode::Struct
10701 pub struct_type: std::option::Option<std::boxed::Box<crate::model::StructType>>,
10702
10703 /// The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that
10704 /// disambiguates SQL type that Spanner will use to represent values of this
10705 /// type during query processing. This is necessary for some type codes because
10706 /// a single [TypeCode][google.spanner.v1.TypeCode] can be mapped to different
10707 /// SQL types depending on the SQL dialect.
10708 /// [type_annotation][google.spanner.v1.Type.type_annotation] typically is not
10709 /// needed to process the content of a value (it doesn't affect serialization)
10710 /// and clients can ignore it on the read path.
10711 ///
10712 /// [google.spanner.v1.Type.type_annotation]: crate::model::Type::type_annotation
10713 /// [google.spanner.v1.TypeAnnotationCode]: crate::model::TypeAnnotationCode
10714 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
10715 pub type_annotation: crate::model::TypeAnnotationCode,
10716
10717 /// If [code][google.spanner.v1.Type.code] ==
10718 /// [PROTO][google.spanner.v1.TypeCode.PROTO] or
10719 /// [code][google.spanner.v1.Type.code] ==
10720 /// [ENUM][google.spanner.v1.TypeCode.ENUM], then `proto_type_fqn` is the fully
10721 /// qualified name of the proto type representing the proto/enum definition.
10722 ///
10723 /// [google.spanner.v1.Type.code]: crate::model::Type::code
10724 /// [google.spanner.v1.TypeCode.ENUM]: crate::model::TypeCode::Enum
10725 /// [google.spanner.v1.TypeCode.PROTO]: crate::model::TypeCode::Proto
10726 pub proto_type_fqn: std::string::String,
10727
10728 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10729}
10730
10731impl Type {
10732 /// Creates a new default instance.
10733 pub fn new() -> Self {
10734 std::default::Default::default()
10735 }
10736
10737 /// Sets the value of [code][crate::model::Type::code].
10738 pub fn set_code<T: std::convert::Into<crate::model::TypeCode>>(mut self, v: T) -> Self {
10739 self.code = v.into();
10740 self
10741 }
10742
10743 /// Sets the value of [array_element_type][crate::model::Type::array_element_type].
10744 pub fn set_array_element_type<T>(mut self, v: T) -> Self
10745 where
10746 T: std::convert::Into<crate::model::Type>,
10747 {
10748 self.array_element_type = std::option::Option::Some(std::boxed::Box::new(v.into()));
10749 self
10750 }
10751
10752 /// Sets or clears the value of [array_element_type][crate::model::Type::array_element_type].
10753 pub fn set_or_clear_array_element_type<T>(mut self, v: std::option::Option<T>) -> Self
10754 where
10755 T: std::convert::Into<crate::model::Type>,
10756 {
10757 self.array_element_type = v.map(|x| std::boxed::Box::new(x.into()));
10758 self
10759 }
10760
10761 /// Sets the value of [struct_type][crate::model::Type::struct_type].
10762 pub fn set_struct_type<T>(mut self, v: T) -> Self
10763 where
10764 T: std::convert::Into<crate::model::StructType>,
10765 {
10766 self.struct_type = std::option::Option::Some(std::boxed::Box::new(v.into()));
10767 self
10768 }
10769
10770 /// Sets or clears the value of [struct_type][crate::model::Type::struct_type].
10771 pub fn set_or_clear_struct_type<T>(mut self, v: std::option::Option<T>) -> Self
10772 where
10773 T: std::convert::Into<crate::model::StructType>,
10774 {
10775 self.struct_type = v.map(|x| std::boxed::Box::new(x.into()));
10776 self
10777 }
10778
10779 /// Sets the value of [type_annotation][crate::model::Type::type_annotation].
10780 pub fn set_type_annotation<T: std::convert::Into<crate::model::TypeAnnotationCode>>(
10781 mut self,
10782 v: T,
10783 ) -> Self {
10784 self.type_annotation = v.into();
10785 self
10786 }
10787
10788 /// Sets the value of [proto_type_fqn][crate::model::Type::proto_type_fqn].
10789 pub fn set_proto_type_fqn<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10790 self.proto_type_fqn = v.into();
10791 self
10792 }
10793}
10794
10795impl wkt::message::Message for Type {
10796 fn typename() -> &'static str {
10797 "type.googleapis.com/google.spanner.v1.Type"
10798 }
10799}
10800
10801/// `StructType` defines the fields of a
10802/// [STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
10803///
10804/// [google.spanner.v1.TypeCode.STRUCT]: crate::model::TypeCode::Struct
10805#[derive(Clone, Default, PartialEq)]
10806#[non_exhaustive]
10807pub struct StructType {
10808 /// The list of fields that make up this struct. Order is
10809 /// significant, because values of this struct type are represented as
10810 /// lists, where the order of field values matches the order of
10811 /// fields in the [StructType][google.spanner.v1.StructType]. In turn, the
10812 /// order of fields matches the order of columns in a read request, or the
10813 /// order of fields in the `SELECT` clause of a query.
10814 ///
10815 /// [google.spanner.v1.StructType]: crate::model::StructType
10816 pub fields: std::vec::Vec<crate::model::struct_type::Field>,
10817
10818 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10819}
10820
10821impl StructType {
10822 /// Creates a new default instance.
10823 pub fn new() -> Self {
10824 std::default::Default::default()
10825 }
10826
10827 /// Sets the value of [fields][crate::model::StructType::fields].
10828 pub fn set_fields<T, V>(mut self, v: T) -> Self
10829 where
10830 T: std::iter::IntoIterator<Item = V>,
10831 V: std::convert::Into<crate::model::struct_type::Field>,
10832 {
10833 use std::iter::Iterator;
10834 self.fields = v.into_iter().map(|i| i.into()).collect();
10835 self
10836 }
10837}
10838
10839impl wkt::message::Message for StructType {
10840 fn typename() -> &'static str {
10841 "type.googleapis.com/google.spanner.v1.StructType"
10842 }
10843}
10844
10845/// Defines additional types related to [StructType].
10846pub mod struct_type {
10847 #[allow(unused_imports)]
10848 use super::*;
10849
10850 /// Message representing a single field of a struct.
10851 #[derive(Clone, Default, PartialEq)]
10852 #[non_exhaustive]
10853 pub struct Field {
10854 /// The name of the field. For reads, this is the column name. For
10855 /// SQL queries, it is the column alias (e.g., `"Word"` in the
10856 /// query `"SELECT 'hello' AS Word"`), or the column name (e.g.,
10857 /// `"ColName"` in the query `"SELECT ColName FROM Table"`). Some
10858 /// columns might have an empty name (e.g., `"SELECT
10859 /// UPPER(ColName)"`). Note that a query result can contain
10860 /// multiple fields with the same name.
10861 pub name: std::string::String,
10862
10863 /// The type of the field.
10864 pub r#type: std::option::Option<std::boxed::Box<crate::model::Type>>,
10865
10866 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10867 }
10868
10869 impl Field {
10870 /// Creates a new default instance.
10871 pub fn new() -> Self {
10872 std::default::Default::default()
10873 }
10874
10875 /// Sets the value of [name][crate::model::struct_type::Field::name].
10876 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10877 self.name = v.into();
10878 self
10879 }
10880
10881 /// Sets the value of [r#type][crate::model::struct_type::Field::type].
10882 pub fn set_type<T>(mut self, v: T) -> Self
10883 where
10884 T: std::convert::Into<crate::model::Type>,
10885 {
10886 self.r#type = std::option::Option::Some(std::boxed::Box::new(v.into()));
10887 self
10888 }
10889
10890 /// Sets or clears the value of [r#type][crate::model::struct_type::Field::type].
10891 pub fn set_or_clear_type<T>(mut self, v: std::option::Option<T>) -> Self
10892 where
10893 T: std::convert::Into<crate::model::Type>,
10894 {
10895 self.r#type = v.map(|x| std::boxed::Box::new(x.into()));
10896 self
10897 }
10898 }
10899
10900 impl wkt::message::Message for Field {
10901 fn typename() -> &'static str {
10902 "type.googleapis.com/google.spanner.v1.StructType.Field"
10903 }
10904 }
10905}
10906
10907/// `TypeCode` is used as part of [Type][google.spanner.v1.Type] to
10908/// indicate the type of a Cloud Spanner value.
10909///
10910/// Each legal value of a type can be encoded to or decoded from a JSON
10911/// value, using the encodings described below. All Cloud Spanner values can
10912/// be `null`, regardless of type; `null`s are always encoded as a JSON
10913/// `null`.
10914///
10915/// [google.spanner.v1.Type]: crate::model::Type
10916///
10917/// # Working with unknown values
10918///
10919/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10920/// additional enum variants at any time. Adding new variants is not considered
10921/// a breaking change. Applications should write their code in anticipation of:
10922///
10923/// - New values appearing in future releases of the client library, **and**
10924/// - New values received dynamically, without application changes.
10925///
10926/// Please consult the [Working with enums] section in the user guide for some
10927/// guidelines.
10928///
10929/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10930#[derive(Clone, Debug, PartialEq)]
10931#[non_exhaustive]
10932pub enum TypeCode {
10933 /// Not specified.
10934 Unspecified,
10935 /// Encoded as JSON `true` or `false`.
10936 Bool,
10937 /// Encoded as `string`, in decimal format.
10938 Int64,
10939 /// Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or
10940 /// `"-Infinity"`.
10941 Float64,
10942 /// Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or
10943 /// `"-Infinity"`.
10944 Float32,
10945 /// Encoded as `string` in RFC 3339 timestamp format. The time zone
10946 /// must be present, and must be `"Z"`.
10947 ///
10948 /// If the schema has the column option
10949 /// `allow_commit_timestamp=true`, the placeholder string
10950 /// `"spanner.commit_timestamp()"` can be used to instruct the system
10951 /// to insert the commit timestamp associated with the transaction
10952 /// commit.
10953 Timestamp,
10954 /// Encoded as `string` in RFC 3339 date format.
10955 Date,
10956 /// Encoded as `string`.
10957 String,
10958 /// Encoded as a base64-encoded `string`, as described in RFC 4648,
10959 /// section 4.
10960 Bytes,
10961 /// Encoded as `list`, where the list elements are represented
10962 /// according to
10963 /// [array_element_type][google.spanner.v1.Type.array_element_type].
10964 ///
10965 /// [google.spanner.v1.Type.array_element_type]: crate::model::Type::array_element_type
10966 Array,
10967 /// Encoded as `list`, where list element `i` is represented according
10968 /// to [struct_type.fields[i]][google.spanner.v1.StructType.fields].
10969 ///
10970 /// [google.spanner.v1.StructType.fields]: crate::model::StructType::fields
10971 Struct,
10972 /// Encoded as `string`, in decimal format or scientific notation format.
10973 /// Decimal format:
10974 /// `[+-]Digits[.[Digits]]` or
10975 /// `[+-][Digits].Digits`
10976 ///
10977 /// Scientific notation:
10978 /// `[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
10979 /// `[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
10980 /// (ExponentIndicator is `"e"` or `"E"`)
10981 Numeric,
10982 /// Encoded as a JSON-formatted `string` as described in RFC 7159. The
10983 /// following rules are applied when parsing JSON input:
10984 ///
10985 /// - Whitespace characters are not preserved.
10986 /// - If a JSON object has duplicate keys, only the first key is preserved.
10987 /// - Members of a JSON object are not guaranteed to have their order
10988 /// preserved.
10989 /// - JSON array elements will have their order preserved.
10990 Json,
10991 /// Encoded as a base64-encoded `string`, as described in RFC 4648,
10992 /// section 4.
10993 Proto,
10994 /// Encoded as `string`, in decimal format.
10995 Enum,
10996 /// Encoded as `string`, in `ISO8601` duration format -
10997 /// `P[n]Y[n]M[n]DT[n]H[n]M[n[.fraction]]S`
10998 /// where `n` is an integer.
10999 /// For example, `P1Y2M3DT4H5M6.5S` represents time duration of 1 year, 2
11000 /// months, 3 days, 4 hours, 5 minutes, and 6.5 seconds.
11001 Interval,
11002 /// Encoded as `string`, in lower-case hexa-decimal format, as described
11003 /// in RFC 9562, section 4.
11004 Uuid,
11005 /// If set, the enum was initialized with an unknown value.
11006 ///
11007 /// Applications can examine the value using [TypeCode::value] or
11008 /// [TypeCode::name].
11009 UnknownValue(type_code::UnknownValue),
11010}
11011
11012#[doc(hidden)]
11013pub mod type_code {
11014 #[allow(unused_imports)]
11015 use super::*;
11016 #[derive(Clone, Debug, PartialEq)]
11017 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11018}
11019
11020impl TypeCode {
11021 /// Gets the enum value.
11022 ///
11023 /// Returns `None` if the enum contains an unknown value deserialized from
11024 /// the string representation of enums.
11025 pub fn value(&self) -> std::option::Option<i32> {
11026 match self {
11027 Self::Unspecified => std::option::Option::Some(0),
11028 Self::Bool => std::option::Option::Some(1),
11029 Self::Int64 => std::option::Option::Some(2),
11030 Self::Float64 => std::option::Option::Some(3),
11031 Self::Float32 => std::option::Option::Some(15),
11032 Self::Timestamp => std::option::Option::Some(4),
11033 Self::Date => std::option::Option::Some(5),
11034 Self::String => std::option::Option::Some(6),
11035 Self::Bytes => std::option::Option::Some(7),
11036 Self::Array => std::option::Option::Some(8),
11037 Self::Struct => std::option::Option::Some(9),
11038 Self::Numeric => std::option::Option::Some(10),
11039 Self::Json => std::option::Option::Some(11),
11040 Self::Proto => std::option::Option::Some(13),
11041 Self::Enum => std::option::Option::Some(14),
11042 Self::Interval => std::option::Option::Some(16),
11043 Self::Uuid => std::option::Option::Some(17),
11044 Self::UnknownValue(u) => u.0.value(),
11045 }
11046 }
11047
11048 /// Gets the enum value as a string.
11049 ///
11050 /// Returns `None` if the enum contains an unknown value deserialized from
11051 /// the integer representation of enums.
11052 pub fn name(&self) -> std::option::Option<&str> {
11053 match self {
11054 Self::Unspecified => std::option::Option::Some("TYPE_CODE_UNSPECIFIED"),
11055 Self::Bool => std::option::Option::Some("BOOL"),
11056 Self::Int64 => std::option::Option::Some("INT64"),
11057 Self::Float64 => std::option::Option::Some("FLOAT64"),
11058 Self::Float32 => std::option::Option::Some("FLOAT32"),
11059 Self::Timestamp => std::option::Option::Some("TIMESTAMP"),
11060 Self::Date => std::option::Option::Some("DATE"),
11061 Self::String => std::option::Option::Some("STRING"),
11062 Self::Bytes => std::option::Option::Some("BYTES"),
11063 Self::Array => std::option::Option::Some("ARRAY"),
11064 Self::Struct => std::option::Option::Some("STRUCT"),
11065 Self::Numeric => std::option::Option::Some("NUMERIC"),
11066 Self::Json => std::option::Option::Some("JSON"),
11067 Self::Proto => std::option::Option::Some("PROTO"),
11068 Self::Enum => std::option::Option::Some("ENUM"),
11069 Self::Interval => std::option::Option::Some("INTERVAL"),
11070 Self::Uuid => std::option::Option::Some("UUID"),
11071 Self::UnknownValue(u) => u.0.name(),
11072 }
11073 }
11074}
11075
11076impl std::default::Default for TypeCode {
11077 fn default() -> Self {
11078 use std::convert::From;
11079 Self::from(0)
11080 }
11081}
11082
11083impl std::fmt::Display for TypeCode {
11084 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11085 wkt::internal::display_enum(f, self.name(), self.value())
11086 }
11087}
11088
11089impl std::convert::From<i32> for TypeCode {
11090 fn from(value: i32) -> Self {
11091 match value {
11092 0 => Self::Unspecified,
11093 1 => Self::Bool,
11094 2 => Self::Int64,
11095 3 => Self::Float64,
11096 4 => Self::Timestamp,
11097 5 => Self::Date,
11098 6 => Self::String,
11099 7 => Self::Bytes,
11100 8 => Self::Array,
11101 9 => Self::Struct,
11102 10 => Self::Numeric,
11103 11 => Self::Json,
11104 13 => Self::Proto,
11105 14 => Self::Enum,
11106 15 => Self::Float32,
11107 16 => Self::Interval,
11108 17 => Self::Uuid,
11109 _ => Self::UnknownValue(type_code::UnknownValue(
11110 wkt::internal::UnknownEnumValue::Integer(value),
11111 )),
11112 }
11113 }
11114}
11115
11116impl std::convert::From<&str> for TypeCode {
11117 fn from(value: &str) -> Self {
11118 use std::string::ToString;
11119 match value {
11120 "TYPE_CODE_UNSPECIFIED" => Self::Unspecified,
11121 "BOOL" => Self::Bool,
11122 "INT64" => Self::Int64,
11123 "FLOAT64" => Self::Float64,
11124 "FLOAT32" => Self::Float32,
11125 "TIMESTAMP" => Self::Timestamp,
11126 "DATE" => Self::Date,
11127 "STRING" => Self::String,
11128 "BYTES" => Self::Bytes,
11129 "ARRAY" => Self::Array,
11130 "STRUCT" => Self::Struct,
11131 "NUMERIC" => Self::Numeric,
11132 "JSON" => Self::Json,
11133 "PROTO" => Self::Proto,
11134 "ENUM" => Self::Enum,
11135 "INTERVAL" => Self::Interval,
11136 "UUID" => Self::Uuid,
11137 _ => Self::UnknownValue(type_code::UnknownValue(
11138 wkt::internal::UnknownEnumValue::String(value.to_string()),
11139 )),
11140 }
11141 }
11142}
11143
11144impl serde::ser::Serialize for TypeCode {
11145 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11146 where
11147 S: serde::Serializer,
11148 {
11149 match self {
11150 Self::Unspecified => serializer.serialize_i32(0),
11151 Self::Bool => serializer.serialize_i32(1),
11152 Self::Int64 => serializer.serialize_i32(2),
11153 Self::Float64 => serializer.serialize_i32(3),
11154 Self::Float32 => serializer.serialize_i32(15),
11155 Self::Timestamp => serializer.serialize_i32(4),
11156 Self::Date => serializer.serialize_i32(5),
11157 Self::String => serializer.serialize_i32(6),
11158 Self::Bytes => serializer.serialize_i32(7),
11159 Self::Array => serializer.serialize_i32(8),
11160 Self::Struct => serializer.serialize_i32(9),
11161 Self::Numeric => serializer.serialize_i32(10),
11162 Self::Json => serializer.serialize_i32(11),
11163 Self::Proto => serializer.serialize_i32(13),
11164 Self::Enum => serializer.serialize_i32(14),
11165 Self::Interval => serializer.serialize_i32(16),
11166 Self::Uuid => serializer.serialize_i32(17),
11167 Self::UnknownValue(u) => u.0.serialize(serializer),
11168 }
11169 }
11170}
11171
11172impl<'de> serde::de::Deserialize<'de> for TypeCode {
11173 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11174 where
11175 D: serde::Deserializer<'de>,
11176 {
11177 deserializer.deserialize_any(wkt::internal::EnumVisitor::<TypeCode>::new(
11178 ".google.spanner.v1.TypeCode",
11179 ))
11180 }
11181}
11182
11183/// `TypeAnnotationCode` is used as a part of [Type][google.spanner.v1.Type] to
11184/// disambiguate SQL types that should be used for a given Cloud Spanner value.
11185/// Disambiguation is needed because the same Cloud Spanner type can be mapped to
11186/// different SQL types depending on SQL dialect. TypeAnnotationCode doesn't
11187/// affect the way value is serialized.
11188///
11189/// [google.spanner.v1.Type]: crate::model::Type
11190///
11191/// # Working with unknown values
11192///
11193/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11194/// additional enum variants at any time. Adding new variants is not considered
11195/// a breaking change. Applications should write their code in anticipation of:
11196///
11197/// - New values appearing in future releases of the client library, **and**
11198/// - New values received dynamically, without application changes.
11199///
11200/// Please consult the [Working with enums] section in the user guide for some
11201/// guidelines.
11202///
11203/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
11204#[derive(Clone, Debug, PartialEq)]
11205#[non_exhaustive]
11206pub enum TypeAnnotationCode {
11207 /// Not specified.
11208 Unspecified,
11209 /// PostgreSQL compatible NUMERIC type. This annotation needs to be applied to
11210 /// [Type][google.spanner.v1.Type] instances having
11211 /// [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] type code to specify that
11212 /// values of this type should be treated as PostgreSQL NUMERIC values.
11213 /// Currently this annotation is always needed for
11214 /// [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] when a client interacts with
11215 /// PostgreSQL-enabled Spanner databases.
11216 ///
11217 /// [google.spanner.v1.Type]: crate::model::Type
11218 /// [google.spanner.v1.TypeCode.NUMERIC]: crate::model::TypeCode::Numeric
11219 PgNumeric,
11220 /// PostgreSQL compatible JSONB type. This annotation needs to be applied to
11221 /// [Type][google.spanner.v1.Type] instances having
11222 /// [JSON][google.spanner.v1.TypeCode.JSON] type code to specify that values of
11223 /// this type should be treated as PostgreSQL JSONB values. Currently this
11224 /// annotation is always needed for [JSON][google.spanner.v1.TypeCode.JSON]
11225 /// when a client interacts with PostgreSQL-enabled Spanner databases.
11226 ///
11227 /// [google.spanner.v1.Type]: crate::model::Type
11228 /// [google.spanner.v1.TypeCode.JSON]: crate::model::TypeCode::Json
11229 PgJsonb,
11230 /// PostgreSQL compatible OID type. This annotation can be used by a client
11231 /// interacting with PostgreSQL-enabled Spanner database to specify that a
11232 /// value should be treated using the semantics of the OID type.
11233 PgOid,
11234 /// If set, the enum was initialized with an unknown value.
11235 ///
11236 /// Applications can examine the value using [TypeAnnotationCode::value] or
11237 /// [TypeAnnotationCode::name].
11238 UnknownValue(type_annotation_code::UnknownValue),
11239}
11240
11241#[doc(hidden)]
11242pub mod type_annotation_code {
11243 #[allow(unused_imports)]
11244 use super::*;
11245 #[derive(Clone, Debug, PartialEq)]
11246 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11247}
11248
11249impl TypeAnnotationCode {
11250 /// Gets the enum value.
11251 ///
11252 /// Returns `None` if the enum contains an unknown value deserialized from
11253 /// the string representation of enums.
11254 pub fn value(&self) -> std::option::Option<i32> {
11255 match self {
11256 Self::Unspecified => std::option::Option::Some(0),
11257 Self::PgNumeric => std::option::Option::Some(2),
11258 Self::PgJsonb => std::option::Option::Some(3),
11259 Self::PgOid => std::option::Option::Some(4),
11260 Self::UnknownValue(u) => u.0.value(),
11261 }
11262 }
11263
11264 /// Gets the enum value as a string.
11265 ///
11266 /// Returns `None` if the enum contains an unknown value deserialized from
11267 /// the integer representation of enums.
11268 pub fn name(&self) -> std::option::Option<&str> {
11269 match self {
11270 Self::Unspecified => std::option::Option::Some("TYPE_ANNOTATION_CODE_UNSPECIFIED"),
11271 Self::PgNumeric => std::option::Option::Some("PG_NUMERIC"),
11272 Self::PgJsonb => std::option::Option::Some("PG_JSONB"),
11273 Self::PgOid => std::option::Option::Some("PG_OID"),
11274 Self::UnknownValue(u) => u.0.name(),
11275 }
11276 }
11277}
11278
11279impl std::default::Default for TypeAnnotationCode {
11280 fn default() -> Self {
11281 use std::convert::From;
11282 Self::from(0)
11283 }
11284}
11285
11286impl std::fmt::Display for TypeAnnotationCode {
11287 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11288 wkt::internal::display_enum(f, self.name(), self.value())
11289 }
11290}
11291
11292impl std::convert::From<i32> for TypeAnnotationCode {
11293 fn from(value: i32) -> Self {
11294 match value {
11295 0 => Self::Unspecified,
11296 2 => Self::PgNumeric,
11297 3 => Self::PgJsonb,
11298 4 => Self::PgOid,
11299 _ => Self::UnknownValue(type_annotation_code::UnknownValue(
11300 wkt::internal::UnknownEnumValue::Integer(value),
11301 )),
11302 }
11303 }
11304}
11305
11306impl std::convert::From<&str> for TypeAnnotationCode {
11307 fn from(value: &str) -> Self {
11308 use std::string::ToString;
11309 match value {
11310 "TYPE_ANNOTATION_CODE_UNSPECIFIED" => Self::Unspecified,
11311 "PG_NUMERIC" => Self::PgNumeric,
11312 "PG_JSONB" => Self::PgJsonb,
11313 "PG_OID" => Self::PgOid,
11314 _ => Self::UnknownValue(type_annotation_code::UnknownValue(
11315 wkt::internal::UnknownEnumValue::String(value.to_string()),
11316 )),
11317 }
11318 }
11319}
11320
11321impl serde::ser::Serialize for TypeAnnotationCode {
11322 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11323 where
11324 S: serde::Serializer,
11325 {
11326 match self {
11327 Self::Unspecified => serializer.serialize_i32(0),
11328 Self::PgNumeric => serializer.serialize_i32(2),
11329 Self::PgJsonb => serializer.serialize_i32(3),
11330 Self::PgOid => serializer.serialize_i32(4),
11331 Self::UnknownValue(u) => u.0.serialize(serializer),
11332 }
11333 }
11334}
11335
11336impl<'de> serde::de::Deserialize<'de> for TypeAnnotationCode {
11337 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11338 where
11339 D: serde::Deserializer<'de>,
11340 {
11341 deserializer.deserialize_any(wkt::internal::EnumVisitor::<TypeAnnotationCode>::new(
11342 ".google.spanner.v1.TypeAnnotationCode",
11343 ))
11344 }
11345}