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::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19
20mod debug;
21mod deserialize;
22mod serialize;
23
24/// Spanner Change Streams enable customers to capture and stream out changes to
25/// their Spanner databases in real-time. A change stream
26/// can be created with option partition_mode='IMMUTABLE_KEY_RANGE' or
27/// partition_mode='MUTABLE_KEY_RANGE'.
28///
29/// This message is only used in Change Streams created with the option
30/// partition_mode='MUTABLE_KEY_RANGE'. Spanner automatically creates a special
31/// Table-Valued Function (TVF) along with each Change Streams. The function
32/// provides access to the change stream's records. The function is named
33/// READ_<change_stream_name> (where <change_stream_name> is the
34/// name of the change stream), and it returns a table with only one column
35/// called ChangeRecord.
36#[derive(Clone, Default, PartialEq)]
37#[non_exhaustive]
38pub struct ChangeStreamRecord {
39 /// One of the change stream subrecords.
40 pub record: std::option::Option<crate::model::change_stream_record::Record>,
41
42 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
43}
44
45impl ChangeStreamRecord {
46 /// Creates a new default instance.
47 pub fn new() -> Self {
48 std::default::Default::default()
49 }
50
51 /// Sets the value of [record][crate::model::ChangeStreamRecord::record].
52 ///
53 /// Note that all the setters affecting `record` are mutually
54 /// exclusive.
55 pub fn set_record<
56 T: std::convert::Into<std::option::Option<crate::model::change_stream_record::Record>>,
57 >(
58 mut self,
59 v: T,
60 ) -> Self {
61 self.record = v.into();
62 self
63 }
64
65 /// The value of [record][crate::model::ChangeStreamRecord::record]
66 /// if it holds a `DataChangeRecord`, `None` if the field is not set or
67 /// holds a different branch.
68 pub fn data_change_record(
69 &self,
70 ) -> std::option::Option<&std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>>
71 {
72 #[allow(unreachable_patterns)]
73 self.record.as_ref().and_then(|v| match v {
74 crate::model::change_stream_record::Record::DataChangeRecord(v) => {
75 std::option::Option::Some(v)
76 }
77 _ => std::option::Option::None,
78 })
79 }
80
81 /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
82 /// to hold a `DataChangeRecord`.
83 ///
84 /// Note that all the setters affecting `record` are
85 /// mutually exclusive.
86 pub fn set_data_change_record<
87 T: std::convert::Into<std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>>,
88 >(
89 mut self,
90 v: T,
91 ) -> Self {
92 self.record = std::option::Option::Some(
93 crate::model::change_stream_record::Record::DataChangeRecord(v.into()),
94 );
95 self
96 }
97
98 /// The value of [record][crate::model::ChangeStreamRecord::record]
99 /// if it holds a `HeartbeatRecord`, `None` if the field is not set or
100 /// holds a different branch.
101 pub fn heartbeat_record(
102 &self,
103 ) -> std::option::Option<&std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>>
104 {
105 #[allow(unreachable_patterns)]
106 self.record.as_ref().and_then(|v| match v {
107 crate::model::change_stream_record::Record::HeartbeatRecord(v) => {
108 std::option::Option::Some(v)
109 }
110 _ => std::option::Option::None,
111 })
112 }
113
114 /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
115 /// to hold a `HeartbeatRecord`.
116 ///
117 /// Note that all the setters affecting `record` are
118 /// mutually exclusive.
119 pub fn set_heartbeat_record<
120 T: std::convert::Into<std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>>,
121 >(
122 mut self,
123 v: T,
124 ) -> Self {
125 self.record = std::option::Option::Some(
126 crate::model::change_stream_record::Record::HeartbeatRecord(v.into()),
127 );
128 self
129 }
130
131 /// The value of [record][crate::model::ChangeStreamRecord::record]
132 /// if it holds a `PartitionStartRecord`, `None` if the field is not set or
133 /// holds a different branch.
134 pub fn partition_start_record(
135 &self,
136 ) -> std::option::Option<
137 &std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
138 > {
139 #[allow(unreachable_patterns)]
140 self.record.as_ref().and_then(|v| match v {
141 crate::model::change_stream_record::Record::PartitionStartRecord(v) => {
142 std::option::Option::Some(v)
143 }
144 _ => std::option::Option::None,
145 })
146 }
147
148 /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
149 /// to hold a `PartitionStartRecord`.
150 ///
151 /// Note that all the setters affecting `record` are
152 /// mutually exclusive.
153 pub fn set_partition_start_record<
154 T: std::convert::Into<
155 std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
156 >,
157 >(
158 mut self,
159 v: T,
160 ) -> Self {
161 self.record = std::option::Option::Some(
162 crate::model::change_stream_record::Record::PartitionStartRecord(v.into()),
163 );
164 self
165 }
166
167 /// The value of [record][crate::model::ChangeStreamRecord::record]
168 /// if it holds a `PartitionEndRecord`, `None` if the field is not set or
169 /// holds a different branch.
170 pub fn partition_end_record(
171 &self,
172 ) -> std::option::Option<&std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>>
173 {
174 #[allow(unreachable_patterns)]
175 self.record.as_ref().and_then(|v| match v {
176 crate::model::change_stream_record::Record::PartitionEndRecord(v) => {
177 std::option::Option::Some(v)
178 }
179 _ => std::option::Option::None,
180 })
181 }
182
183 /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
184 /// to hold a `PartitionEndRecord`.
185 ///
186 /// Note that all the setters affecting `record` are
187 /// mutually exclusive.
188 pub fn set_partition_end_record<
189 T: std::convert::Into<std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>>,
190 >(
191 mut self,
192 v: T,
193 ) -> Self {
194 self.record = std::option::Option::Some(
195 crate::model::change_stream_record::Record::PartitionEndRecord(v.into()),
196 );
197 self
198 }
199
200 /// The value of [record][crate::model::ChangeStreamRecord::record]
201 /// if it holds a `PartitionEventRecord`, `None` if the field is not set or
202 /// holds a different branch.
203 pub fn partition_event_record(
204 &self,
205 ) -> std::option::Option<
206 &std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
207 > {
208 #[allow(unreachable_patterns)]
209 self.record.as_ref().and_then(|v| match v {
210 crate::model::change_stream_record::Record::PartitionEventRecord(v) => {
211 std::option::Option::Some(v)
212 }
213 _ => std::option::Option::None,
214 })
215 }
216
217 /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
218 /// to hold a `PartitionEventRecord`.
219 ///
220 /// Note that all the setters affecting `record` are
221 /// mutually exclusive.
222 pub fn set_partition_event_record<
223 T: std::convert::Into<
224 std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
225 >,
226 >(
227 mut self,
228 v: T,
229 ) -> Self {
230 self.record = std::option::Option::Some(
231 crate::model::change_stream_record::Record::PartitionEventRecord(v.into()),
232 );
233 self
234 }
235}
236
237impl wkt::message::Message for ChangeStreamRecord {
238 fn typename() -> &'static str {
239 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord"
240 }
241}
242
243/// Defines additional types related to [ChangeStreamRecord].
244pub mod change_stream_record {
245 #[allow(unused_imports)]
246 use super::*;
247
248 /// A data change record contains a set of changes to a table with the same
249 /// modification type (insert, update, or delete) committed at the same commit
250 /// timestamp in one change stream partition for the same transaction. Multiple
251 /// data change records can be returned for the same transaction across
252 /// multiple change stream partitions.
253 #[derive(Clone, Default, PartialEq)]
254 #[non_exhaustive]
255 pub struct DataChangeRecord {
256 /// Indicates the timestamp in which the change was committed.
257 /// DataChangeRecord.commit_timestamps,
258 /// PartitionStartRecord.start_timestamps,
259 /// PartitionEventRecord.commit_timestamps, and
260 /// PartitionEndRecord.end_timestamps can have the same value in the same
261 /// partition.
262 pub commit_timestamp: std::option::Option<wkt::Timestamp>,
263
264 /// Record sequence numbers are unique and monotonically increasing (but not
265 /// necessarily contiguous) for a specific timestamp across record
266 /// types in the same partition. To guarantee ordered processing, the reader
267 /// should process records (of potentially different types) in
268 /// record_sequence order for a specific timestamp in the same partition.
269 ///
270 /// The record sequence number ordering across partitions is only meaningful
271 /// in the context of a specific transaction. Record sequence numbers are
272 /// unique across partitions for a specific transaction. Sort the
273 /// DataChangeRecords for the same
274 /// [server_transaction_id][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.server_transaction_id]
275 /// by
276 /// [record_sequence][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.record_sequence]
277 /// to reconstruct the ordering of the changes within the transaction.
278 ///
279 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.record_sequence]: crate::model::change_stream_record::DataChangeRecord::record_sequence
280 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.server_transaction_id]: crate::model::change_stream_record::DataChangeRecord::server_transaction_id
281 pub record_sequence: std::string::String,
282
283 /// Provides a globally unique string that represents the transaction in
284 /// which the change was committed. Multiple transactions can have the same
285 /// commit timestamp, but each transaction has a unique
286 /// server_transaction_id.
287 pub server_transaction_id: std::string::String,
288
289 /// Indicates whether this is the last record for a transaction in the
290 /// current partition. Clients can use this field to determine when all
291 /// records for a transaction in the current partition have been received.
292 pub is_last_record_in_transaction_in_partition: bool,
293
294 /// Name of the table affected by the change.
295 pub table: std::string::String,
296
297 /// Provides metadata describing the columns associated with the
298 /// [mods][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.mods] listed
299 /// below.
300 ///
301 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.mods]: crate::model::change_stream_record::DataChangeRecord::mods
302 pub column_metadata:
303 std::vec::Vec<crate::model::change_stream_record::data_change_record::ColumnMetadata>,
304
305 /// Describes the changes that were made.
306 pub mods: std::vec::Vec<crate::model::change_stream_record::data_change_record::Mod>,
307
308 /// Describes the type of change.
309 pub mod_type: crate::model::change_stream_record::data_change_record::ModType,
310
311 /// Describes the value capture type that was specified in the change stream
312 /// configuration when this change was captured.
313 pub value_capture_type:
314 crate::model::change_stream_record::data_change_record::ValueCaptureType,
315
316 /// Indicates the number of data change records that are part of this
317 /// transaction across all change stream partitions. This value can be used
318 /// to assemble all the records associated with a particular transaction.
319 pub number_of_records_in_transaction: i32,
320
321 /// Indicates the number of partitions that return data change records for
322 /// this transaction. This value can be helpful in assembling all records
323 /// associated with a particular transaction.
324 pub number_of_partitions_in_transaction: i32,
325
326 /// Indicates the transaction tag associated with this transaction.
327 pub transaction_tag: std::string::String,
328
329 /// Indicates whether the transaction is a system transaction. System
330 /// transactions include those issued by time-to-live (TTL), column backfill,
331 /// etc.
332 pub is_system_transaction: bool,
333
334 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
335 }
336
337 impl DataChangeRecord {
338 /// Creates a new default instance.
339 pub fn new() -> Self {
340 std::default::Default::default()
341 }
342
343 /// Sets the value of [commit_timestamp][crate::model::change_stream_record::DataChangeRecord::commit_timestamp].
344 pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
345 where
346 T: std::convert::Into<wkt::Timestamp>,
347 {
348 self.commit_timestamp = std::option::Option::Some(v.into());
349 self
350 }
351
352 /// Sets or clears the value of [commit_timestamp][crate::model::change_stream_record::DataChangeRecord::commit_timestamp].
353 pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
354 where
355 T: std::convert::Into<wkt::Timestamp>,
356 {
357 self.commit_timestamp = v.map(|x| x.into());
358 self
359 }
360
361 /// Sets the value of [record_sequence][crate::model::change_stream_record::DataChangeRecord::record_sequence].
362 pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
363 mut self,
364 v: T,
365 ) -> Self {
366 self.record_sequence = v.into();
367 self
368 }
369
370 /// Sets the value of [server_transaction_id][crate::model::change_stream_record::DataChangeRecord::server_transaction_id].
371 pub fn set_server_transaction_id<T: std::convert::Into<std::string::String>>(
372 mut self,
373 v: T,
374 ) -> Self {
375 self.server_transaction_id = v.into();
376 self
377 }
378
379 /// Sets the value of [is_last_record_in_transaction_in_partition][crate::model::change_stream_record::DataChangeRecord::is_last_record_in_transaction_in_partition].
380 pub fn set_is_last_record_in_transaction_in_partition<T: std::convert::Into<bool>>(
381 mut self,
382 v: T,
383 ) -> Self {
384 self.is_last_record_in_transaction_in_partition = v.into();
385 self
386 }
387
388 /// Sets the value of [table][crate::model::change_stream_record::DataChangeRecord::table].
389 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
390 self.table = v.into();
391 self
392 }
393
394 /// Sets the value of [column_metadata][crate::model::change_stream_record::DataChangeRecord::column_metadata].
395 pub fn set_column_metadata<T, V>(mut self, v: T) -> Self
396 where
397 T: std::iter::IntoIterator<Item = V>,
398 V: std::convert::Into<
399 crate::model::change_stream_record::data_change_record::ColumnMetadata,
400 >,
401 {
402 use std::iter::Iterator;
403 self.column_metadata = v.into_iter().map(|i| i.into()).collect();
404 self
405 }
406
407 /// Sets the value of [mods][crate::model::change_stream_record::DataChangeRecord::mods].
408 pub fn set_mods<T, V>(mut self, v: T) -> Self
409 where
410 T: std::iter::IntoIterator<Item = V>,
411 V: std::convert::Into<crate::model::change_stream_record::data_change_record::Mod>,
412 {
413 use std::iter::Iterator;
414 self.mods = v.into_iter().map(|i| i.into()).collect();
415 self
416 }
417
418 /// Sets the value of [mod_type][crate::model::change_stream_record::DataChangeRecord::mod_type].
419 pub fn set_mod_type<
420 T: std::convert::Into<crate::model::change_stream_record::data_change_record::ModType>,
421 >(
422 mut self,
423 v: T,
424 ) -> Self {
425 self.mod_type = v.into();
426 self
427 }
428
429 /// Sets the value of [value_capture_type][crate::model::change_stream_record::DataChangeRecord::value_capture_type].
430 pub fn set_value_capture_type<
431 T: std::convert::Into<
432 crate::model::change_stream_record::data_change_record::ValueCaptureType,
433 >,
434 >(
435 mut self,
436 v: T,
437 ) -> Self {
438 self.value_capture_type = v.into();
439 self
440 }
441
442 /// Sets the value of [number_of_records_in_transaction][crate::model::change_stream_record::DataChangeRecord::number_of_records_in_transaction].
443 pub fn set_number_of_records_in_transaction<T: std::convert::Into<i32>>(
444 mut self,
445 v: T,
446 ) -> Self {
447 self.number_of_records_in_transaction = v.into();
448 self
449 }
450
451 /// Sets the value of [number_of_partitions_in_transaction][crate::model::change_stream_record::DataChangeRecord::number_of_partitions_in_transaction].
452 pub fn set_number_of_partitions_in_transaction<T: std::convert::Into<i32>>(
453 mut self,
454 v: T,
455 ) -> Self {
456 self.number_of_partitions_in_transaction = v.into();
457 self
458 }
459
460 /// Sets the value of [transaction_tag][crate::model::change_stream_record::DataChangeRecord::transaction_tag].
461 pub fn set_transaction_tag<T: std::convert::Into<std::string::String>>(
462 mut self,
463 v: T,
464 ) -> Self {
465 self.transaction_tag = v.into();
466 self
467 }
468
469 /// Sets the value of [is_system_transaction][crate::model::change_stream_record::DataChangeRecord::is_system_transaction].
470 pub fn set_is_system_transaction<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
471 self.is_system_transaction = v.into();
472 self
473 }
474 }
475
476 impl wkt::message::Message for DataChangeRecord {
477 fn typename() -> &'static str {
478 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord"
479 }
480 }
481
482 /// Defines additional types related to [DataChangeRecord].
483 pub mod data_change_record {
484 #[allow(unused_imports)]
485 use super::*;
486
487 /// Metadata for a column.
488 #[derive(Clone, Default, PartialEq)]
489 #[non_exhaustive]
490 pub struct ColumnMetadata {
491 /// Name of the column.
492 pub name: std::string::String,
493
494 /// Type of the column.
495 pub r#type: std::option::Option<crate::model::Type>,
496
497 /// Indicates whether the column is a primary key column.
498 pub is_primary_key: bool,
499
500 /// Ordinal position of the column based on the original table definition
501 /// in the schema starting with a value of 1.
502 pub ordinal_position: i64,
503
504 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
505 }
506
507 impl ColumnMetadata {
508 /// Creates a new default instance.
509 pub fn new() -> Self {
510 std::default::Default::default()
511 }
512
513 /// Sets the value of [name][crate::model::change_stream_record::data_change_record::ColumnMetadata::name].
514 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
515 self.name = v.into();
516 self
517 }
518
519 /// Sets the value of [r#type][crate::model::change_stream_record::data_change_record::ColumnMetadata::type].
520 pub fn set_type<T>(mut self, v: T) -> Self
521 where
522 T: std::convert::Into<crate::model::Type>,
523 {
524 self.r#type = std::option::Option::Some(v.into());
525 self
526 }
527
528 /// Sets or clears the value of [r#type][crate::model::change_stream_record::data_change_record::ColumnMetadata::type].
529 pub fn set_or_clear_type<T>(mut self, v: std::option::Option<T>) -> Self
530 where
531 T: std::convert::Into<crate::model::Type>,
532 {
533 self.r#type = v.map(|x| x.into());
534 self
535 }
536
537 /// Sets the value of [is_primary_key][crate::model::change_stream_record::data_change_record::ColumnMetadata::is_primary_key].
538 pub fn set_is_primary_key<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
539 self.is_primary_key = v.into();
540 self
541 }
542
543 /// Sets the value of [ordinal_position][crate::model::change_stream_record::data_change_record::ColumnMetadata::ordinal_position].
544 pub fn set_ordinal_position<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
545 self.ordinal_position = v.into();
546 self
547 }
548 }
549
550 impl wkt::message::Message for ColumnMetadata {
551 fn typename() -> &'static str {
552 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ColumnMetadata"
553 }
554 }
555
556 /// Returns the value and associated metadata for a particular field of the
557 /// [Mod][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.Mod].
558 ///
559 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.Mod]: crate::model::change_stream_record::data_change_record::Mod
560 #[derive(Clone, Default, PartialEq)]
561 #[non_exhaustive]
562 pub struct ModValue {
563 /// Index within the repeated
564 /// [column_metadata][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.column_metadata]
565 /// field, to obtain the column metadata for the column that was modified.
566 ///
567 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.column_metadata]: crate::model::change_stream_record::DataChangeRecord::column_metadata
568 pub column_metadata_index: i32,
569
570 /// The value of the column.
571 pub value: std::option::Option<wkt::Value>,
572
573 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
574 }
575
576 impl ModValue {
577 /// Creates a new default instance.
578 pub fn new() -> Self {
579 std::default::Default::default()
580 }
581
582 /// Sets the value of [column_metadata_index][crate::model::change_stream_record::data_change_record::ModValue::column_metadata_index].
583 pub fn set_column_metadata_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
584 self.column_metadata_index = v.into();
585 self
586 }
587
588 /// Sets the value of [value][crate::model::change_stream_record::data_change_record::ModValue::value].
589 pub fn set_value<T>(mut self, v: T) -> Self
590 where
591 T: std::convert::Into<wkt::Value>,
592 {
593 self.value = std::option::Option::Some(v.into());
594 self
595 }
596
597 /// Sets or clears the value of [value][crate::model::change_stream_record::data_change_record::ModValue::value].
598 pub fn set_or_clear_value<T>(mut self, v: std::option::Option<T>) -> Self
599 where
600 T: std::convert::Into<wkt::Value>,
601 {
602 self.value = v.map(|x| x.into());
603 self
604 }
605 }
606
607 impl wkt::message::Message for ModValue {
608 fn typename() -> &'static str {
609 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModValue"
610 }
611 }
612
613 /// A mod describes all data changes in a watched table row.
614 #[derive(Clone, Default, PartialEq)]
615 #[non_exhaustive]
616 pub struct Mod {
617 /// Returns the value of the primary key of the modified row.
618 pub keys:
619 std::vec::Vec<crate::model::change_stream_record::data_change_record::ModValue>,
620
621 /// Returns the old values before the change for the modified columns.
622 /// Always empty for
623 /// [INSERT][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.INSERT],
624 /// or if old values are not being captured specified by
625 /// [value_capture_type][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ValueCaptureType].
626 ///
627 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.INSERT]: crate::model::change_stream_record::data_change_record::ModType::Insert
628 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ValueCaptureType]: crate::model::change_stream_record::data_change_record::ValueCaptureType
629 pub old_values:
630 std::vec::Vec<crate::model::change_stream_record::data_change_record::ModValue>,
631
632 /// Returns the new values after the change for the modified columns.
633 /// Always empty for
634 /// [DELETE][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.DELETE].
635 ///
636 /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.DELETE]: crate::model::change_stream_record::data_change_record::ModType::Delete
637 pub new_values:
638 std::vec::Vec<crate::model::change_stream_record::data_change_record::ModValue>,
639
640 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
641 }
642
643 impl Mod {
644 /// Creates a new default instance.
645 pub fn new() -> Self {
646 std::default::Default::default()
647 }
648
649 /// Sets the value of [keys][crate::model::change_stream_record::data_change_record::Mod::keys].
650 pub fn set_keys<T, V>(mut self, v: T) -> Self
651 where
652 T: std::iter::IntoIterator<Item = V>,
653 V: std::convert::Into<
654 crate::model::change_stream_record::data_change_record::ModValue,
655 >,
656 {
657 use std::iter::Iterator;
658 self.keys = v.into_iter().map(|i| i.into()).collect();
659 self
660 }
661
662 /// Sets the value of [old_values][crate::model::change_stream_record::data_change_record::Mod::old_values].
663 pub fn set_old_values<T, V>(mut self, v: T) -> Self
664 where
665 T: std::iter::IntoIterator<Item = V>,
666 V: std::convert::Into<
667 crate::model::change_stream_record::data_change_record::ModValue,
668 >,
669 {
670 use std::iter::Iterator;
671 self.old_values = v.into_iter().map(|i| i.into()).collect();
672 self
673 }
674
675 /// Sets the value of [new_values][crate::model::change_stream_record::data_change_record::Mod::new_values].
676 pub fn set_new_values<T, V>(mut self, v: T) -> Self
677 where
678 T: std::iter::IntoIterator<Item = V>,
679 V: std::convert::Into<
680 crate::model::change_stream_record::data_change_record::ModValue,
681 >,
682 {
683 use std::iter::Iterator;
684 self.new_values = v.into_iter().map(|i| i.into()).collect();
685 self
686 }
687 }
688
689 impl wkt::message::Message for Mod {
690 fn typename() -> &'static str {
691 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord.Mod"
692 }
693 }
694
695 /// Mod type describes the type of change Spanner applied to the data. For
696 /// example, if the client submits an INSERT_OR_UPDATE request, Spanner will
697 /// perform an insert if there is no existing row and return ModType INSERT.
698 /// Alternatively, if there is an existing row, Spanner will perform an
699 /// update and return ModType UPDATE.
700 ///
701 /// # Working with unknown values
702 ///
703 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
704 /// additional enum variants at any time. Adding new variants is not considered
705 /// a breaking change. Applications should write their code in anticipation of:
706 ///
707 /// - New values appearing in future releases of the client library, **and**
708 /// - New values received dynamically, without application changes.
709 ///
710 /// Please consult the [Working with enums] section in the user guide for some
711 /// guidelines.
712 ///
713 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
714 #[derive(Clone, Debug, PartialEq)]
715 #[non_exhaustive]
716 pub enum ModType {
717 /// Not specified.
718 Unspecified,
719 /// Indicates data was inserted.
720 Insert,
721 /// Indicates existing data was updated.
722 Update,
723 /// Indicates existing data was deleted.
724 Delete,
725 /// If set, the enum was initialized with an unknown value.
726 ///
727 /// Applications can examine the value using [ModType::value] or
728 /// [ModType::name].
729 UnknownValue(mod_type::UnknownValue),
730 }
731
732 #[doc(hidden)]
733 pub mod mod_type {
734 #[allow(unused_imports)]
735 use super::*;
736 #[derive(Clone, Debug, PartialEq)]
737 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
738 }
739
740 impl ModType {
741 /// Gets the enum value.
742 ///
743 /// Returns `None` if the enum contains an unknown value deserialized from
744 /// the string representation of enums.
745 pub fn value(&self) -> std::option::Option<i32> {
746 match self {
747 Self::Unspecified => std::option::Option::Some(0),
748 Self::Insert => std::option::Option::Some(10),
749 Self::Update => std::option::Option::Some(20),
750 Self::Delete => std::option::Option::Some(30),
751 Self::UnknownValue(u) => u.0.value(),
752 }
753 }
754
755 /// Gets the enum value as a string.
756 ///
757 /// Returns `None` if the enum contains an unknown value deserialized from
758 /// the integer representation of enums.
759 pub fn name(&self) -> std::option::Option<&str> {
760 match self {
761 Self::Unspecified => std::option::Option::Some("MOD_TYPE_UNSPECIFIED"),
762 Self::Insert => std::option::Option::Some("INSERT"),
763 Self::Update => std::option::Option::Some("UPDATE"),
764 Self::Delete => std::option::Option::Some("DELETE"),
765 Self::UnknownValue(u) => u.0.name(),
766 }
767 }
768 }
769
770 impl std::default::Default for ModType {
771 fn default() -> Self {
772 use std::convert::From;
773 Self::from(0)
774 }
775 }
776
777 impl std::fmt::Display for ModType {
778 fn fmt(
779 &self,
780 f: &mut std::fmt::Formatter<'_>,
781 ) -> std::result::Result<(), std::fmt::Error> {
782 wkt::internal::display_enum(f, self.name(), self.value())
783 }
784 }
785
786 impl std::convert::From<i32> for ModType {
787 fn from(value: i32) -> Self {
788 match value {
789 0 => Self::Unspecified,
790 10 => Self::Insert,
791 20 => Self::Update,
792 30 => Self::Delete,
793 _ => Self::UnknownValue(mod_type::UnknownValue(
794 wkt::internal::UnknownEnumValue::Integer(value),
795 )),
796 }
797 }
798 }
799
800 impl std::convert::From<&str> for ModType {
801 fn from(value: &str) -> Self {
802 use std::string::ToString;
803 match value {
804 "MOD_TYPE_UNSPECIFIED" => Self::Unspecified,
805 "INSERT" => Self::Insert,
806 "UPDATE" => Self::Update,
807 "DELETE" => Self::Delete,
808 _ => Self::UnknownValue(mod_type::UnknownValue(
809 wkt::internal::UnknownEnumValue::String(value.to_string()),
810 )),
811 }
812 }
813 }
814
815 impl serde::ser::Serialize for ModType {
816 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
817 where
818 S: serde::Serializer,
819 {
820 match self {
821 Self::Unspecified => serializer.serialize_i32(0),
822 Self::Insert => serializer.serialize_i32(10),
823 Self::Update => serializer.serialize_i32(20),
824 Self::Delete => serializer.serialize_i32(30),
825 Self::UnknownValue(u) => u.0.serialize(serializer),
826 }
827 }
828 }
829
830 impl<'de> serde::de::Deserialize<'de> for ModType {
831 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
832 where
833 D: serde::Deserializer<'de>,
834 {
835 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ModType>::new(
836 ".google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType",
837 ))
838 }
839 }
840
841 /// Value capture type describes which values are recorded in the data
842 /// change record.
843 ///
844 /// # Working with unknown values
845 ///
846 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
847 /// additional enum variants at any time. Adding new variants is not considered
848 /// a breaking change. Applications should write their code in anticipation of:
849 ///
850 /// - New values appearing in future releases of the client library, **and**
851 /// - New values received dynamically, without application changes.
852 ///
853 /// Please consult the [Working with enums] section in the user guide for some
854 /// guidelines.
855 ///
856 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
857 #[derive(Clone, Debug, PartialEq)]
858 #[non_exhaustive]
859 pub enum ValueCaptureType {
860 /// Not specified.
861 Unspecified,
862 /// Records both old and new values of the modified watched columns.
863 OldAndNewValues,
864 /// Records only new values of the modified watched columns.
865 NewValues,
866 /// Records new values of all watched columns, including modified and
867 /// unmodified columns.
868 NewRow,
869 /// Records the new values of all watched columns, including modified and
870 /// unmodified columns. Also records the old values of the modified
871 /// columns.
872 NewRowAndOldValues,
873 /// If set, the enum was initialized with an unknown value.
874 ///
875 /// Applications can examine the value using [ValueCaptureType::value] or
876 /// [ValueCaptureType::name].
877 UnknownValue(value_capture_type::UnknownValue),
878 }
879
880 #[doc(hidden)]
881 pub mod value_capture_type {
882 #[allow(unused_imports)]
883 use super::*;
884 #[derive(Clone, Debug, PartialEq)]
885 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
886 }
887
888 impl ValueCaptureType {
889 /// Gets the enum value.
890 ///
891 /// Returns `None` if the enum contains an unknown value deserialized from
892 /// the string representation of enums.
893 pub fn value(&self) -> std::option::Option<i32> {
894 match self {
895 Self::Unspecified => std::option::Option::Some(0),
896 Self::OldAndNewValues => std::option::Option::Some(10),
897 Self::NewValues => std::option::Option::Some(20),
898 Self::NewRow => std::option::Option::Some(30),
899 Self::NewRowAndOldValues => std::option::Option::Some(40),
900 Self::UnknownValue(u) => u.0.value(),
901 }
902 }
903
904 /// Gets the enum value as a string.
905 ///
906 /// Returns `None` if the enum contains an unknown value deserialized from
907 /// the integer representation of enums.
908 pub fn name(&self) -> std::option::Option<&str> {
909 match self {
910 Self::Unspecified => {
911 std::option::Option::Some("VALUE_CAPTURE_TYPE_UNSPECIFIED")
912 }
913 Self::OldAndNewValues => std::option::Option::Some("OLD_AND_NEW_VALUES"),
914 Self::NewValues => std::option::Option::Some("NEW_VALUES"),
915 Self::NewRow => std::option::Option::Some("NEW_ROW"),
916 Self::NewRowAndOldValues => std::option::Option::Some("NEW_ROW_AND_OLD_VALUES"),
917 Self::UnknownValue(u) => u.0.name(),
918 }
919 }
920 }
921
922 impl std::default::Default for ValueCaptureType {
923 fn default() -> Self {
924 use std::convert::From;
925 Self::from(0)
926 }
927 }
928
929 impl std::fmt::Display for ValueCaptureType {
930 fn fmt(
931 &self,
932 f: &mut std::fmt::Formatter<'_>,
933 ) -> std::result::Result<(), std::fmt::Error> {
934 wkt::internal::display_enum(f, self.name(), self.value())
935 }
936 }
937
938 impl std::convert::From<i32> for ValueCaptureType {
939 fn from(value: i32) -> Self {
940 match value {
941 0 => Self::Unspecified,
942 10 => Self::OldAndNewValues,
943 20 => Self::NewValues,
944 30 => Self::NewRow,
945 40 => Self::NewRowAndOldValues,
946 _ => Self::UnknownValue(value_capture_type::UnknownValue(
947 wkt::internal::UnknownEnumValue::Integer(value),
948 )),
949 }
950 }
951 }
952
953 impl std::convert::From<&str> for ValueCaptureType {
954 fn from(value: &str) -> Self {
955 use std::string::ToString;
956 match value {
957 "VALUE_CAPTURE_TYPE_UNSPECIFIED" => Self::Unspecified,
958 "OLD_AND_NEW_VALUES" => Self::OldAndNewValues,
959 "NEW_VALUES" => Self::NewValues,
960 "NEW_ROW" => Self::NewRow,
961 "NEW_ROW_AND_OLD_VALUES" => Self::NewRowAndOldValues,
962 _ => Self::UnknownValue(value_capture_type::UnknownValue(
963 wkt::internal::UnknownEnumValue::String(value.to_string()),
964 )),
965 }
966 }
967 }
968
969 impl serde::ser::Serialize for ValueCaptureType {
970 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
971 where
972 S: serde::Serializer,
973 {
974 match self {
975 Self::Unspecified => serializer.serialize_i32(0),
976 Self::OldAndNewValues => serializer.serialize_i32(10),
977 Self::NewValues => serializer.serialize_i32(20),
978 Self::NewRow => serializer.serialize_i32(30),
979 Self::NewRowAndOldValues => serializer.serialize_i32(40),
980 Self::UnknownValue(u) => u.0.serialize(serializer),
981 }
982 }
983 }
984
985 impl<'de> serde::de::Deserialize<'de> for ValueCaptureType {
986 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
987 where
988 D: serde::Deserializer<'de>,
989 {
990 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ValueCaptureType>::new(
991 ".google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ValueCaptureType",
992 ))
993 }
994 }
995 }
996
997 /// A heartbeat record is returned as a progress indicator, when there are no
998 /// data changes or any other partition record types in the change stream
999 /// partition.
1000 #[derive(Clone, Default, PartialEq)]
1001 #[non_exhaustive]
1002 pub struct HeartbeatRecord {
1003 /// Indicates the timestamp at which the query has returned all the records
1004 /// in the change stream partition with timestamp <= heartbeat timestamp.
1005 /// The heartbeat timestamp will not be the same as the timestamps of other
1006 /// record types in the same partition.
1007 pub timestamp: std::option::Option<wkt::Timestamp>,
1008
1009 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1010 }
1011
1012 impl HeartbeatRecord {
1013 /// Creates a new default instance.
1014 pub fn new() -> Self {
1015 std::default::Default::default()
1016 }
1017
1018 /// Sets the value of [timestamp][crate::model::change_stream_record::HeartbeatRecord::timestamp].
1019 pub fn set_timestamp<T>(mut self, v: T) -> Self
1020 where
1021 T: std::convert::Into<wkt::Timestamp>,
1022 {
1023 self.timestamp = std::option::Option::Some(v.into());
1024 self
1025 }
1026
1027 /// Sets or clears the value of [timestamp][crate::model::change_stream_record::HeartbeatRecord::timestamp].
1028 pub fn set_or_clear_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1029 where
1030 T: std::convert::Into<wkt::Timestamp>,
1031 {
1032 self.timestamp = v.map(|x| x.into());
1033 self
1034 }
1035 }
1036
1037 impl wkt::message::Message for HeartbeatRecord {
1038 fn typename() -> &'static str {
1039 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.HeartbeatRecord"
1040 }
1041 }
1042
1043 /// A partition start record serves as a notification that the client should
1044 /// schedule the partitions to be queried. PartitionStartRecord returns
1045 /// information about one or more partitions.
1046 #[derive(Clone, Default, PartialEq)]
1047 #[non_exhaustive]
1048 pub struct PartitionStartRecord {
1049 /// Start timestamp at which the partitions should be queried to return
1050 /// change stream records with timestamps >= start_timestamp.
1051 /// DataChangeRecord.commit_timestamps,
1052 /// PartitionStartRecord.start_timestamps,
1053 /// PartitionEventRecord.commit_timestamps, and
1054 /// PartitionEndRecord.end_timestamps can have the same value in the same
1055 /// partition.
1056 pub start_timestamp: std::option::Option<wkt::Timestamp>,
1057
1058 /// Record sequence numbers are unique and monotonically increasing (but not
1059 /// necessarily contiguous) for a specific timestamp across record
1060 /// types in the same partition. To guarantee ordered processing, the reader
1061 /// should process records (of potentially different types) in
1062 /// record_sequence order for a specific timestamp in the same partition.
1063 pub record_sequence: std::string::String,
1064
1065 /// Unique partition identifiers to be used in queries.
1066 pub partition_tokens: std::vec::Vec<std::string::String>,
1067
1068 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1069 }
1070
1071 impl PartitionStartRecord {
1072 /// Creates a new default instance.
1073 pub fn new() -> Self {
1074 std::default::Default::default()
1075 }
1076
1077 /// Sets the value of [start_timestamp][crate::model::change_stream_record::PartitionStartRecord::start_timestamp].
1078 pub fn set_start_timestamp<T>(mut self, v: T) -> Self
1079 where
1080 T: std::convert::Into<wkt::Timestamp>,
1081 {
1082 self.start_timestamp = std::option::Option::Some(v.into());
1083 self
1084 }
1085
1086 /// Sets or clears the value of [start_timestamp][crate::model::change_stream_record::PartitionStartRecord::start_timestamp].
1087 pub fn set_or_clear_start_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1088 where
1089 T: std::convert::Into<wkt::Timestamp>,
1090 {
1091 self.start_timestamp = v.map(|x| x.into());
1092 self
1093 }
1094
1095 /// Sets the value of [record_sequence][crate::model::change_stream_record::PartitionStartRecord::record_sequence].
1096 pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
1097 mut self,
1098 v: T,
1099 ) -> Self {
1100 self.record_sequence = v.into();
1101 self
1102 }
1103
1104 /// Sets the value of [partition_tokens][crate::model::change_stream_record::PartitionStartRecord::partition_tokens].
1105 pub fn set_partition_tokens<T, V>(mut self, v: T) -> Self
1106 where
1107 T: std::iter::IntoIterator<Item = V>,
1108 V: std::convert::Into<std::string::String>,
1109 {
1110 use std::iter::Iterator;
1111 self.partition_tokens = v.into_iter().map(|i| i.into()).collect();
1112 self
1113 }
1114 }
1115
1116 impl wkt::message::Message for PartitionStartRecord {
1117 fn typename() -> &'static str {
1118 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionStartRecord"
1119 }
1120 }
1121
1122 /// A partition end record serves as a notification that the client should stop
1123 /// reading the partition. No further records are expected to be retrieved on
1124 /// it.
1125 #[derive(Clone, Default, PartialEq)]
1126 #[non_exhaustive]
1127 pub struct PartitionEndRecord {
1128 /// End timestamp at which the change stream partition is terminated. All
1129 /// changes generated by this partition will have timestamps <=
1130 /// end_timestamp. DataChangeRecord.commit_timestamps,
1131 /// PartitionStartRecord.start_timestamps,
1132 /// PartitionEventRecord.commit_timestamps, and
1133 /// PartitionEndRecord.end_timestamps can have the same value in the same
1134 /// partition. PartitionEndRecord is the last record returned for a
1135 /// partition.
1136 pub end_timestamp: std::option::Option<wkt::Timestamp>,
1137
1138 /// Record sequence numbers are unique and monotonically increasing (but not
1139 /// necessarily contiguous) for a specific timestamp across record
1140 /// types in the same partition. To guarantee ordered processing, the reader
1141 /// should process records (of potentially different types) in
1142 /// record_sequence order for a specific timestamp in the same partition.
1143 pub record_sequence: std::string::String,
1144
1145 /// Unique partition identifier describing the terminated change stream
1146 /// partition.
1147 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEndRecord.partition_token]
1148 /// is equal to the partition token of the change stream partition currently
1149 /// queried to return this PartitionEndRecord.
1150 ///
1151 /// [google.spanner.v1.ChangeStreamRecord.PartitionEndRecord.partition_token]: crate::model::change_stream_record::PartitionEndRecord::partition_token
1152 pub partition_token: std::string::String,
1153
1154 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1155 }
1156
1157 impl PartitionEndRecord {
1158 /// Creates a new default instance.
1159 pub fn new() -> Self {
1160 std::default::Default::default()
1161 }
1162
1163 /// Sets the value of [end_timestamp][crate::model::change_stream_record::PartitionEndRecord::end_timestamp].
1164 pub fn set_end_timestamp<T>(mut self, v: T) -> Self
1165 where
1166 T: std::convert::Into<wkt::Timestamp>,
1167 {
1168 self.end_timestamp = std::option::Option::Some(v.into());
1169 self
1170 }
1171
1172 /// Sets or clears the value of [end_timestamp][crate::model::change_stream_record::PartitionEndRecord::end_timestamp].
1173 pub fn set_or_clear_end_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1174 where
1175 T: std::convert::Into<wkt::Timestamp>,
1176 {
1177 self.end_timestamp = v.map(|x| x.into());
1178 self
1179 }
1180
1181 /// Sets the value of [record_sequence][crate::model::change_stream_record::PartitionEndRecord::record_sequence].
1182 pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
1183 mut self,
1184 v: T,
1185 ) -> Self {
1186 self.record_sequence = v.into();
1187 self
1188 }
1189
1190 /// Sets the value of [partition_token][crate::model::change_stream_record::PartitionEndRecord::partition_token].
1191 pub fn set_partition_token<T: std::convert::Into<std::string::String>>(
1192 mut self,
1193 v: T,
1194 ) -> Self {
1195 self.partition_token = v.into();
1196 self
1197 }
1198 }
1199
1200 impl wkt::message::Message for PartitionEndRecord {
1201 fn typename() -> &'static str {
1202 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEndRecord"
1203 }
1204 }
1205
1206 /// A partition event record describes key range changes for a change stream
1207 /// partition. The changes to a row defined by its primary key can be captured
1208 /// in one change stream partition for a specific time range, and then be
1209 /// captured in a different change stream partition for a different time range.
1210 /// This movement of key ranges across change stream partitions is a reflection
1211 /// of activities, such as Spanner's dynamic splitting and load balancing, etc.
1212 /// Processing this event is needed if users want to guarantee processing of
1213 /// the changes for any key in timestamp order. If time ordered processing of
1214 /// changes for a primary key is not needed, this event can be ignored.
1215 /// To guarantee time ordered processing for each primary key, if the event
1216 /// describes move-ins, the reader of this partition needs to wait until the
1217 /// readers of the source partitions have processed all records with timestamps
1218 /// <= this PartitionEventRecord.commit_timestamp, before advancing beyond this
1219 /// PartitionEventRecord. If the event describes move-outs, the reader can
1220 /// notify the readers of the destination partitions that they can continue
1221 /// processing.
1222 #[derive(Clone, Default, PartialEq)]
1223 #[non_exhaustive]
1224 pub struct PartitionEventRecord {
1225 /// Indicates the commit timestamp at which the key range change occurred.
1226 /// DataChangeRecord.commit_timestamps,
1227 /// PartitionStartRecord.start_timestamps,
1228 /// PartitionEventRecord.commit_timestamps, and
1229 /// PartitionEndRecord.end_timestamps can have the same value in the same
1230 /// partition.
1231 pub commit_timestamp: std::option::Option<wkt::Timestamp>,
1232
1233 /// Record sequence numbers are unique and monotonically increasing (but not
1234 /// necessarily contiguous) for a specific timestamp across record
1235 /// types in the same partition. To guarantee ordered processing, the reader
1236 /// should process records (of potentially different types) in
1237 /// record_sequence order for a specific timestamp in the same partition.
1238 pub record_sequence: std::string::String,
1239
1240 /// Unique partition identifier describing the partition this event
1241 /// occurred on.
1242 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]
1243 /// is equal to the partition token of the change stream partition currently
1244 /// queried to return this PartitionEventRecord.
1245 ///
1246 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1247 pub partition_token: std::string::String,
1248
1249 /// Set when one or more key ranges are moved into the change stream
1250 /// partition identified by
1251 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1252 ///
1253 /// Example: Two key ranges are moved into partition (P1) from partition (P2)
1254 /// and partition (P3) in a single transaction at timestamp T.
1255 ///
1256 /// The PartitionEventRecord returned in P1 will reflect the move as:
1257 ///
1258 /// PartitionEventRecord {
1259 /// commit_timestamp: T
1260 /// partition_token: "P1"
1261 /// move_in_events {
1262 /// source_partition_token: "P2"
1263 /// }
1264 /// move_in_events {
1265 /// source_partition_token: "P3"
1266 /// }
1267 /// }
1268 ///
1269 /// The PartitionEventRecord returned in P2 will reflect the move as:
1270 ///
1271 /// PartitionEventRecord {
1272 /// commit_timestamp: T
1273 /// partition_token: "P2"
1274 /// move_out_events {
1275 /// destination_partition_token: "P1"
1276 /// }
1277 /// }
1278 ///
1279 /// The PartitionEventRecord returned in P3 will reflect the move as:
1280 ///
1281 /// PartitionEventRecord {
1282 /// commit_timestamp: T
1283 /// partition_token: "P3"
1284 /// move_out_events {
1285 /// destination_partition_token: "P1"
1286 /// }
1287 /// }
1288 ///
1289 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1290 pub move_in_events:
1291 std::vec::Vec<crate::model::change_stream_record::partition_event_record::MoveInEvent>,
1292
1293 /// Set when one or more key ranges are moved out of the change stream
1294 /// partition identified by
1295 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1296 ///
1297 /// Example: Two key ranges are moved out of partition (P1) to partition (P2)
1298 /// and partition (P3) in a single transaction at timestamp T.
1299 ///
1300 /// The PartitionEventRecord returned in P1 will reflect the move as:
1301 ///
1302 /// PartitionEventRecord {
1303 /// commit_timestamp: T
1304 /// partition_token: "P1"
1305 /// move_out_events {
1306 /// destination_partition_token: "P2"
1307 /// }
1308 /// move_out_events {
1309 /// destination_partition_token: "P3"
1310 /// }
1311 /// }
1312 ///
1313 /// The PartitionEventRecord returned in P2 will reflect the move as:
1314 ///
1315 /// PartitionEventRecord {
1316 /// commit_timestamp: T
1317 /// partition_token: "P2"
1318 /// move_in_events {
1319 /// source_partition_token: "P1"
1320 /// }
1321 /// }
1322 ///
1323 /// The PartitionEventRecord returned in P3 will reflect the move as:
1324 ///
1325 /// PartitionEventRecord {
1326 /// commit_timestamp: T
1327 /// partition_token: "P3"
1328 /// move_in_events {
1329 /// source_partition_token: "P1"
1330 /// }
1331 /// }
1332 ///
1333 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1334 pub move_out_events:
1335 std::vec::Vec<crate::model::change_stream_record::partition_event_record::MoveOutEvent>,
1336
1337 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1338 }
1339
1340 impl PartitionEventRecord {
1341 /// Creates a new default instance.
1342 pub fn new() -> Self {
1343 std::default::Default::default()
1344 }
1345
1346 /// Sets the value of [commit_timestamp][crate::model::change_stream_record::PartitionEventRecord::commit_timestamp].
1347 pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
1348 where
1349 T: std::convert::Into<wkt::Timestamp>,
1350 {
1351 self.commit_timestamp = std::option::Option::Some(v.into());
1352 self
1353 }
1354
1355 /// Sets or clears the value of [commit_timestamp][crate::model::change_stream_record::PartitionEventRecord::commit_timestamp].
1356 pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1357 where
1358 T: std::convert::Into<wkt::Timestamp>,
1359 {
1360 self.commit_timestamp = v.map(|x| x.into());
1361 self
1362 }
1363
1364 /// Sets the value of [record_sequence][crate::model::change_stream_record::PartitionEventRecord::record_sequence].
1365 pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
1366 mut self,
1367 v: T,
1368 ) -> Self {
1369 self.record_sequence = v.into();
1370 self
1371 }
1372
1373 /// Sets the value of [partition_token][crate::model::change_stream_record::PartitionEventRecord::partition_token].
1374 pub fn set_partition_token<T: std::convert::Into<std::string::String>>(
1375 mut self,
1376 v: T,
1377 ) -> Self {
1378 self.partition_token = v.into();
1379 self
1380 }
1381
1382 /// Sets the value of [move_in_events][crate::model::change_stream_record::PartitionEventRecord::move_in_events].
1383 pub fn set_move_in_events<T, V>(mut self, v: T) -> Self
1384 where
1385 T: std::iter::IntoIterator<Item = V>,
1386 V: std::convert::Into<
1387 crate::model::change_stream_record::partition_event_record::MoveInEvent,
1388 >,
1389 {
1390 use std::iter::Iterator;
1391 self.move_in_events = v.into_iter().map(|i| i.into()).collect();
1392 self
1393 }
1394
1395 /// Sets the value of [move_out_events][crate::model::change_stream_record::PartitionEventRecord::move_out_events].
1396 pub fn set_move_out_events<T, V>(mut self, v: T) -> Self
1397 where
1398 T: std::iter::IntoIterator<Item = V>,
1399 V: std::convert::Into<
1400 crate::model::change_stream_record::partition_event_record::MoveOutEvent,
1401 >,
1402 {
1403 use std::iter::Iterator;
1404 self.move_out_events = v.into_iter().map(|i| i.into()).collect();
1405 self
1406 }
1407 }
1408
1409 impl wkt::message::Message for PartitionEventRecord {
1410 fn typename() -> &'static str {
1411 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEventRecord"
1412 }
1413 }
1414
1415 /// Defines additional types related to [PartitionEventRecord].
1416 pub mod partition_event_record {
1417 #[allow(unused_imports)]
1418 use super::*;
1419
1420 /// Describes move-in of the key ranges into the change stream partition
1421 /// identified by
1422 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1423 ///
1424 /// To maintain processing the changes for a particular key in timestamp
1425 /// order, the query processing the change stream partition identified by
1426 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]
1427 /// should not advance beyond the partition event record commit timestamp
1428 /// until the queries processing the source change stream partitions have
1429 /// processed all change stream records with timestamps <= the partition
1430 /// event record commit timestamp.
1431 ///
1432 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1433 #[derive(Clone, Default, PartialEq)]
1434 #[non_exhaustive]
1435 pub struct MoveInEvent {
1436 /// An unique partition identifier describing the source change stream
1437 /// partition that recorded changes for the key range that is moving
1438 /// into this partition.
1439 pub source_partition_token: std::string::String,
1440
1441 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1442 }
1443
1444 impl MoveInEvent {
1445 /// Creates a new default instance.
1446 pub fn new() -> Self {
1447 std::default::Default::default()
1448 }
1449
1450 /// Sets the value of [source_partition_token][crate::model::change_stream_record::partition_event_record::MoveInEvent::source_partition_token].
1451 pub fn set_source_partition_token<T: std::convert::Into<std::string::String>>(
1452 mut self,
1453 v: T,
1454 ) -> Self {
1455 self.source_partition_token = v.into();
1456 self
1457 }
1458 }
1459
1460 impl wkt::message::Message for MoveInEvent {
1461 fn typename() -> &'static str {
1462 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveInEvent"
1463 }
1464 }
1465
1466 /// Describes move-out of the key ranges out of the change stream partition
1467 /// identified by
1468 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1469 ///
1470 /// To maintain processing the changes for a particular key in timestamp
1471 /// order, the query processing the
1472 /// [MoveOutEvent][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveOutEvent]
1473 /// in the partition identified by
1474 /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]
1475 /// should inform the queries processing the destination partitions that
1476 /// they can unblock and proceed processing records past the
1477 /// [commit_timestamp][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.commit_timestamp].
1478 ///
1479 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveOutEvent]: crate::model::change_stream_record::partition_event_record::MoveOutEvent
1480 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.commit_timestamp]: crate::model::change_stream_record::PartitionEventRecord::commit_timestamp
1481 /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1482 #[derive(Clone, Default, PartialEq)]
1483 #[non_exhaustive]
1484 pub struct MoveOutEvent {
1485 /// An unique partition identifier describing the destination change
1486 /// stream partition that will record changes for the key range that is
1487 /// moving out of this partition.
1488 pub destination_partition_token: std::string::String,
1489
1490 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1491 }
1492
1493 impl MoveOutEvent {
1494 /// Creates a new default instance.
1495 pub fn new() -> Self {
1496 std::default::Default::default()
1497 }
1498
1499 /// Sets the value of [destination_partition_token][crate::model::change_stream_record::partition_event_record::MoveOutEvent::destination_partition_token].
1500 pub fn set_destination_partition_token<T: std::convert::Into<std::string::String>>(
1501 mut self,
1502 v: T,
1503 ) -> Self {
1504 self.destination_partition_token = v.into();
1505 self
1506 }
1507 }
1508
1509 impl wkt::message::Message for MoveOutEvent {
1510 fn typename() -> &'static str {
1511 "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveOutEvent"
1512 }
1513 }
1514 }
1515
1516 /// One of the change stream subrecords.
1517 #[derive(Clone, Debug, PartialEq)]
1518 #[non_exhaustive]
1519 pub enum Record {
1520 /// Data change record describing a data change for a change stream
1521 /// partition.
1522 DataChangeRecord(std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>),
1523 /// Heartbeat record describing a heartbeat for a change stream partition.
1524 HeartbeatRecord(std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>),
1525 /// Partition start record describing a new change stream partition.
1526 PartitionStartRecord(
1527 std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
1528 ),
1529 /// Partition end record describing a terminated change stream partition.
1530 PartitionEndRecord(std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>),
1531 /// Partition event record describing key range changes for a change stream
1532 /// partition.
1533 PartitionEventRecord(
1534 std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
1535 ),
1536 }
1537
1538 impl Record {
1539 /// Initializes the enum to the [DataChangeRecord](Self::DataChangeRecord) branch.
1540 pub fn from_data_change_record(
1541 value: impl std::convert::Into<
1542 std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>,
1543 >,
1544 ) -> Self {
1545 Self::DataChangeRecord(value.into())
1546 }
1547 /// Initializes the enum to the [HeartbeatRecord](Self::HeartbeatRecord) branch.
1548 pub fn from_heartbeat_record(
1549 value: impl std::convert::Into<
1550 std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>,
1551 >,
1552 ) -> Self {
1553 Self::HeartbeatRecord(value.into())
1554 }
1555 /// Initializes the enum to the [PartitionStartRecord](Self::PartitionStartRecord) branch.
1556 pub fn from_partition_start_record(
1557 value: impl std::convert::Into<
1558 std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
1559 >,
1560 ) -> Self {
1561 Self::PartitionStartRecord(value.into())
1562 }
1563 /// Initializes the enum to the [PartitionEndRecord](Self::PartitionEndRecord) branch.
1564 pub fn from_partition_end_record(
1565 value: impl std::convert::Into<
1566 std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>,
1567 >,
1568 ) -> Self {
1569 Self::PartitionEndRecord(value.into())
1570 }
1571 /// Initializes the enum to the [PartitionEventRecord](Self::PartitionEventRecord) branch.
1572 pub fn from_partition_event_record(
1573 value: impl std::convert::Into<
1574 std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
1575 >,
1576 ) -> Self {
1577 Self::PartitionEventRecord(value.into())
1578 }
1579 }
1580}
1581
1582/// The response for [Commit][google.spanner.v1.Spanner.Commit].
1583///
1584/// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
1585#[derive(Clone, Default, PartialEq)]
1586#[non_exhaustive]
1587pub struct CommitResponse {
1588 /// The Cloud Spanner timestamp at which the transaction committed.
1589 pub commit_timestamp: std::option::Option<wkt::Timestamp>,
1590
1591 /// The statistics about this `Commit`. Not returned by default.
1592 /// For more information, see
1593 /// [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats].
1594 ///
1595 /// [google.spanner.v1.CommitRequest.return_commit_stats]: crate::model::CommitRequest::return_commit_stats
1596 pub commit_stats: std::option::Option<crate::model::commit_response::CommitStats>,
1597
1598 /// If `TransactionOptions.isolation_level` is set to
1599 /// `IsolationLevel.REPEATABLE_READ`, then the snapshot timestamp is the
1600 /// timestamp at which all reads in the transaction ran. This timestamp is
1601 /// never returned.
1602 pub snapshot_timestamp: std::option::Option<wkt::Timestamp>,
1603
1604 /// Optional. A cache update expresses a set of changes the client should
1605 /// incorporate into its location cache. The client should discard the changes
1606 /// if they are older than the data it already has. This data can be obtained
1607 /// in response to requests that included a `RoutingHint` field, but may also
1608 /// be obtained by explicit location-fetching RPCs which may be added in the
1609 /// future.
1610 pub cache_update: std::option::Option<crate::model::CacheUpdate>,
1611
1612 /// The isolation level used for the read-write transaction.
1613 pub isolation_level: crate::model::transaction_options::IsolationLevel,
1614
1615 /// The read lock mode used for the read-write transaction.
1616 pub read_lock_mode: crate::model::transaction_options::read_write::ReadLockMode,
1617
1618 /// You must examine and retry the commit if the following is populated.
1619 pub multiplexed_session_retry:
1620 std::option::Option<crate::model::commit_response::MultiplexedSessionRetry>,
1621
1622 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1623}
1624
1625impl CommitResponse {
1626 /// Creates a new default instance.
1627 pub fn new() -> Self {
1628 std::default::Default::default()
1629 }
1630
1631 /// Sets the value of [commit_timestamp][crate::model::CommitResponse::commit_timestamp].
1632 pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
1633 where
1634 T: std::convert::Into<wkt::Timestamp>,
1635 {
1636 self.commit_timestamp = std::option::Option::Some(v.into());
1637 self
1638 }
1639
1640 /// Sets or clears the value of [commit_timestamp][crate::model::CommitResponse::commit_timestamp].
1641 pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1642 where
1643 T: std::convert::Into<wkt::Timestamp>,
1644 {
1645 self.commit_timestamp = v.map(|x| x.into());
1646 self
1647 }
1648
1649 /// Sets the value of [commit_stats][crate::model::CommitResponse::commit_stats].
1650 pub fn set_commit_stats<T>(mut self, v: T) -> Self
1651 where
1652 T: std::convert::Into<crate::model::commit_response::CommitStats>,
1653 {
1654 self.commit_stats = std::option::Option::Some(v.into());
1655 self
1656 }
1657
1658 /// Sets or clears the value of [commit_stats][crate::model::CommitResponse::commit_stats].
1659 pub fn set_or_clear_commit_stats<T>(mut self, v: std::option::Option<T>) -> Self
1660 where
1661 T: std::convert::Into<crate::model::commit_response::CommitStats>,
1662 {
1663 self.commit_stats = v.map(|x| x.into());
1664 self
1665 }
1666
1667 /// Sets the value of [snapshot_timestamp][crate::model::CommitResponse::snapshot_timestamp].
1668 pub fn set_snapshot_timestamp<T>(mut self, v: T) -> Self
1669 where
1670 T: std::convert::Into<wkt::Timestamp>,
1671 {
1672 self.snapshot_timestamp = std::option::Option::Some(v.into());
1673 self
1674 }
1675
1676 /// Sets or clears the value of [snapshot_timestamp][crate::model::CommitResponse::snapshot_timestamp].
1677 pub fn set_or_clear_snapshot_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1678 where
1679 T: std::convert::Into<wkt::Timestamp>,
1680 {
1681 self.snapshot_timestamp = v.map(|x| x.into());
1682 self
1683 }
1684
1685 /// Sets the value of [cache_update][crate::model::CommitResponse::cache_update].
1686 pub fn set_cache_update<T>(mut self, v: T) -> Self
1687 where
1688 T: std::convert::Into<crate::model::CacheUpdate>,
1689 {
1690 self.cache_update = std::option::Option::Some(v.into());
1691 self
1692 }
1693
1694 /// Sets or clears the value of [cache_update][crate::model::CommitResponse::cache_update].
1695 pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
1696 where
1697 T: std::convert::Into<crate::model::CacheUpdate>,
1698 {
1699 self.cache_update = v.map(|x| x.into());
1700 self
1701 }
1702
1703 /// Sets the value of [isolation_level][crate::model::CommitResponse::isolation_level].
1704 pub fn set_isolation_level<
1705 T: std::convert::Into<crate::model::transaction_options::IsolationLevel>,
1706 >(
1707 mut self,
1708 v: T,
1709 ) -> Self {
1710 self.isolation_level = v.into();
1711 self
1712 }
1713
1714 /// Sets the value of [read_lock_mode][crate::model::CommitResponse::read_lock_mode].
1715 pub fn set_read_lock_mode<
1716 T: std::convert::Into<crate::model::transaction_options::read_write::ReadLockMode>,
1717 >(
1718 mut self,
1719 v: T,
1720 ) -> Self {
1721 self.read_lock_mode = v.into();
1722 self
1723 }
1724
1725 /// Sets the value of [multiplexed_session_retry][crate::model::CommitResponse::multiplexed_session_retry].
1726 ///
1727 /// Note that all the setters affecting `multiplexed_session_retry` are mutually
1728 /// exclusive.
1729 pub fn set_multiplexed_session_retry<
1730 T: std::convert::Into<
1731 std::option::Option<crate::model::commit_response::MultiplexedSessionRetry>,
1732 >,
1733 >(
1734 mut self,
1735 v: T,
1736 ) -> Self {
1737 self.multiplexed_session_retry = v.into();
1738 self
1739 }
1740
1741 /// The value of [multiplexed_session_retry][crate::model::CommitResponse::multiplexed_session_retry]
1742 /// if it holds a `PrecommitToken`, `None` if the field is not set or
1743 /// holds a different branch.
1744 pub fn precommit_token(
1745 &self,
1746 ) -> std::option::Option<&std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>> {
1747 #[allow(unreachable_patterns)]
1748 self.multiplexed_session_retry
1749 .as_ref()
1750 .and_then(|v| match v {
1751 crate::model::commit_response::MultiplexedSessionRetry::PrecommitToken(v) => {
1752 std::option::Option::Some(v)
1753 }
1754 _ => std::option::Option::None,
1755 })
1756 }
1757
1758 /// Sets the value of [multiplexed_session_retry][crate::model::CommitResponse::multiplexed_session_retry]
1759 /// to hold a `PrecommitToken`.
1760 ///
1761 /// Note that all the setters affecting `multiplexed_session_retry` are
1762 /// mutually exclusive.
1763 pub fn set_precommit_token<
1764 T: std::convert::Into<std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>>,
1765 >(
1766 mut self,
1767 v: T,
1768 ) -> Self {
1769 self.multiplexed_session_retry = std::option::Option::Some(
1770 crate::model::commit_response::MultiplexedSessionRetry::PrecommitToken(v.into()),
1771 );
1772 self
1773 }
1774}
1775
1776impl wkt::message::Message for CommitResponse {
1777 fn typename() -> &'static str {
1778 "type.googleapis.com/google.spanner.v1.CommitResponse"
1779 }
1780}
1781
1782/// Defines additional types related to [CommitResponse].
1783pub mod commit_response {
1784 #[allow(unused_imports)]
1785 use super::*;
1786
1787 /// Additional statistics about a commit.
1788 #[derive(Clone, Default, PartialEq)]
1789 #[non_exhaustive]
1790 pub struct CommitStats {
1791 /// The total number of mutations for the transaction. Knowing the
1792 /// `mutation_count` value can help you maximize the number of mutations
1793 /// in a transaction and minimize the number of API round trips. You can
1794 /// also monitor this value to prevent transactions from exceeding the system
1795 /// [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data).
1796 /// If the number of mutations exceeds the limit, the server returns
1797 /// [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT).
1798 pub mutation_count: i64,
1799
1800 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1801 }
1802
1803 impl CommitStats {
1804 /// Creates a new default instance.
1805 pub fn new() -> Self {
1806 std::default::Default::default()
1807 }
1808
1809 /// Sets the value of [mutation_count][crate::model::commit_response::CommitStats::mutation_count].
1810 pub fn set_mutation_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1811 self.mutation_count = v.into();
1812 self
1813 }
1814 }
1815
1816 impl wkt::message::Message for CommitStats {
1817 fn typename() -> &'static str {
1818 "type.googleapis.com/google.spanner.v1.CommitResponse.CommitStats"
1819 }
1820 }
1821
1822 /// You must examine and retry the commit if the following is populated.
1823 #[derive(Clone, Debug, PartialEq)]
1824 #[non_exhaustive]
1825 pub enum MultiplexedSessionRetry {
1826 /// If specified, transaction has not committed yet.
1827 /// You must retry the commit with the new precommit token.
1828 PrecommitToken(std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>),
1829 }
1830
1831 impl MultiplexedSessionRetry {
1832 /// Initializes the enum to the [PrecommitToken](Self::PrecommitToken) branch.
1833 pub fn from_precommit_token(
1834 value: impl std::convert::Into<
1835 std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>,
1836 >,
1837 ) -> Self {
1838 Self::PrecommitToken(value.into())
1839 }
1840 }
1841}
1842
1843/// KeyRange represents a range of rows in a table or index.
1844///
1845/// A range has a start key and an end key. These keys can be open or
1846/// closed, indicating if the range includes rows with that key.
1847///
1848/// Keys are represented by lists, where the ith value in the list
1849/// corresponds to the ith component of the table or index primary key.
1850/// Individual values are encoded as described
1851/// [here][google.spanner.v1.TypeCode].
1852///
1853/// For example, consider the following table definition:
1854///
1855/// ```norust
1856/// CREATE TABLE UserEvents (
1857/// UserName STRING(MAX),
1858/// EventDate STRING(10)
1859/// ) PRIMARY KEY(UserName, EventDate);
1860/// ```
1861///
1862/// The following keys name rows in this table:
1863///
1864/// ```norust
1865/// ["Bob", "2014-09-23"]
1866/// ["Alfred", "2015-06-12"]
1867/// ```
1868///
1869/// Since the `UserEvents` table's `PRIMARY KEY` clause names two
1870/// columns, each `UserEvents` key has two elements; the first is the
1871/// `UserName`, and the second is the `EventDate`.
1872///
1873/// Key ranges with multiple components are interpreted
1874/// lexicographically by component using the table or index key's declared
1875/// sort order. For example, the following range returns all events for
1876/// user `"Bob"` that occurred in the year 2015:
1877///
1878/// ```norust
1879/// "start_closed": ["Bob", "2015-01-01"]
1880/// "end_closed": ["Bob", "2015-12-31"]
1881/// ```
1882///
1883/// Start and end keys can omit trailing key components. This affects the
1884/// inclusion and exclusion of rows that exactly match the provided key
1885/// components: if the key is closed, then rows that exactly match the
1886/// provided components are included; if the key is open, then rows
1887/// that exactly match are not included.
1888///
1889/// For example, the following range includes all events for `"Bob"` that
1890/// occurred during and after the year 2000:
1891///
1892/// ```norust
1893/// "start_closed": ["Bob", "2000-01-01"]
1894/// "end_closed": ["Bob"]
1895/// ```
1896///
1897/// The next example retrieves all events for `"Bob"`:
1898///
1899/// ```norust
1900/// "start_closed": ["Bob"]
1901/// "end_closed": ["Bob"]
1902/// ```
1903///
1904/// To retrieve events before the year 2000:
1905///
1906/// ```norust
1907/// "start_closed": ["Bob"]
1908/// "end_open": ["Bob", "2000-01-01"]
1909/// ```
1910///
1911/// The following range includes all rows in the table:
1912///
1913/// ```norust
1914/// "start_closed": []
1915/// "end_closed": []
1916/// ```
1917///
1918/// This range returns all users whose `UserName` begins with any
1919/// character from A to C:
1920///
1921/// ```norust
1922/// "start_closed": ["A"]
1923/// "end_open": ["D"]
1924/// ```
1925///
1926/// This range returns all users whose `UserName` begins with B:
1927///
1928/// ```norust
1929/// "start_closed": ["B"]
1930/// "end_open": ["C"]
1931/// ```
1932///
1933/// Key ranges honor column sort order. For example, suppose a table is
1934/// defined as follows:
1935///
1936/// ```norust
1937/// CREATE TABLE DescendingSortedTable {
1938/// Key INT64,
1939/// ...
1940/// ) PRIMARY KEY(Key DESC);
1941/// ```
1942///
1943/// The following range retrieves all rows with key values between 1
1944/// and 100 inclusive:
1945///
1946/// ```norust
1947/// "start_closed": ["100"]
1948/// "end_closed": ["1"]
1949/// ```
1950///
1951/// Note that 100 is passed as the start, and 1 is passed as the end,
1952/// because `Key` is a descending column in the schema.
1953///
1954/// [google.spanner.v1.TypeCode]: crate::model::TypeCode
1955#[derive(Clone, Default, PartialEq)]
1956#[non_exhaustive]
1957pub struct KeyRange {
1958 /// The start key must be provided. It can be either closed or open.
1959 pub start_key_type: std::option::Option<crate::model::key_range::StartKeyType>,
1960
1961 /// The end key must be provided. It can be either closed or open.
1962 pub end_key_type: std::option::Option<crate::model::key_range::EndKeyType>,
1963
1964 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1965}
1966
1967impl KeyRange {
1968 /// Creates a new default instance.
1969 pub fn new() -> Self {
1970 std::default::Default::default()
1971 }
1972
1973 /// Sets the value of [start_key_type][crate::model::KeyRange::start_key_type].
1974 ///
1975 /// Note that all the setters affecting `start_key_type` are mutually
1976 /// exclusive.
1977 pub fn set_start_key_type<
1978 T: std::convert::Into<std::option::Option<crate::model::key_range::StartKeyType>>,
1979 >(
1980 mut self,
1981 v: T,
1982 ) -> Self {
1983 self.start_key_type = v.into();
1984 self
1985 }
1986
1987 /// The value of [start_key_type][crate::model::KeyRange::start_key_type]
1988 /// if it holds a `StartClosed`, `None` if the field is not set or
1989 /// holds a different branch.
1990 pub fn start_closed(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
1991 #[allow(unreachable_patterns)]
1992 self.start_key_type.as_ref().and_then(|v| match v {
1993 crate::model::key_range::StartKeyType::StartClosed(v) => std::option::Option::Some(v),
1994 _ => std::option::Option::None,
1995 })
1996 }
1997
1998 /// Sets the value of [start_key_type][crate::model::KeyRange::start_key_type]
1999 /// to hold a `StartClosed`.
2000 ///
2001 /// Note that all the setters affecting `start_key_type` are
2002 /// mutually exclusive.
2003 pub fn set_start_closed<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2004 mut self,
2005 v: T,
2006 ) -> Self {
2007 self.start_key_type =
2008 std::option::Option::Some(crate::model::key_range::StartKeyType::StartClosed(v.into()));
2009 self
2010 }
2011
2012 /// The value of [start_key_type][crate::model::KeyRange::start_key_type]
2013 /// if it holds a `StartOpen`, `None` if the field is not set or
2014 /// holds a different branch.
2015 pub fn start_open(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
2016 #[allow(unreachable_patterns)]
2017 self.start_key_type.as_ref().and_then(|v| match v {
2018 crate::model::key_range::StartKeyType::StartOpen(v) => std::option::Option::Some(v),
2019 _ => std::option::Option::None,
2020 })
2021 }
2022
2023 /// Sets the value of [start_key_type][crate::model::KeyRange::start_key_type]
2024 /// to hold a `StartOpen`.
2025 ///
2026 /// Note that all the setters affecting `start_key_type` are
2027 /// mutually exclusive.
2028 pub fn set_start_open<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2029 mut self,
2030 v: T,
2031 ) -> Self {
2032 self.start_key_type =
2033 std::option::Option::Some(crate::model::key_range::StartKeyType::StartOpen(v.into()));
2034 self
2035 }
2036
2037 /// Sets the value of [end_key_type][crate::model::KeyRange::end_key_type].
2038 ///
2039 /// Note that all the setters affecting `end_key_type` are mutually
2040 /// exclusive.
2041 pub fn set_end_key_type<
2042 T: std::convert::Into<std::option::Option<crate::model::key_range::EndKeyType>>,
2043 >(
2044 mut self,
2045 v: T,
2046 ) -> Self {
2047 self.end_key_type = v.into();
2048 self
2049 }
2050
2051 /// The value of [end_key_type][crate::model::KeyRange::end_key_type]
2052 /// if it holds a `EndClosed`, `None` if the field is not set or
2053 /// holds a different branch.
2054 pub fn end_closed(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
2055 #[allow(unreachable_patterns)]
2056 self.end_key_type.as_ref().and_then(|v| match v {
2057 crate::model::key_range::EndKeyType::EndClosed(v) => std::option::Option::Some(v),
2058 _ => std::option::Option::None,
2059 })
2060 }
2061
2062 /// Sets the value of [end_key_type][crate::model::KeyRange::end_key_type]
2063 /// to hold a `EndClosed`.
2064 ///
2065 /// Note that all the setters affecting `end_key_type` are
2066 /// mutually exclusive.
2067 pub fn set_end_closed<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2068 mut self,
2069 v: T,
2070 ) -> Self {
2071 self.end_key_type =
2072 std::option::Option::Some(crate::model::key_range::EndKeyType::EndClosed(v.into()));
2073 self
2074 }
2075
2076 /// The value of [end_key_type][crate::model::KeyRange::end_key_type]
2077 /// if it holds a `EndOpen`, `None` if the field is not set or
2078 /// holds a different branch.
2079 pub fn end_open(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
2080 #[allow(unreachable_patterns)]
2081 self.end_key_type.as_ref().and_then(|v| match v {
2082 crate::model::key_range::EndKeyType::EndOpen(v) => std::option::Option::Some(v),
2083 _ => std::option::Option::None,
2084 })
2085 }
2086
2087 /// Sets the value of [end_key_type][crate::model::KeyRange::end_key_type]
2088 /// to hold a `EndOpen`.
2089 ///
2090 /// Note that all the setters affecting `end_key_type` are
2091 /// mutually exclusive.
2092 pub fn set_end_open<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2093 mut self,
2094 v: T,
2095 ) -> Self {
2096 self.end_key_type =
2097 std::option::Option::Some(crate::model::key_range::EndKeyType::EndOpen(v.into()));
2098 self
2099 }
2100}
2101
2102impl wkt::message::Message for KeyRange {
2103 fn typename() -> &'static str {
2104 "type.googleapis.com/google.spanner.v1.KeyRange"
2105 }
2106}
2107
2108/// Defines additional types related to [KeyRange].
2109pub mod key_range {
2110 #[allow(unused_imports)]
2111 use super::*;
2112
2113 /// The start key must be provided. It can be either closed or open.
2114 #[derive(Clone, Debug, PartialEq)]
2115 #[non_exhaustive]
2116 pub enum StartKeyType {
2117 /// If the start is closed, then the range includes all rows whose
2118 /// first `len(start_closed)` key columns exactly match `start_closed`.
2119 StartClosed(std::boxed::Box<wkt::ListValue>),
2120 /// If the start is open, then the range excludes rows whose first
2121 /// `len(start_open)` key columns exactly match `start_open`.
2122 StartOpen(std::boxed::Box<wkt::ListValue>),
2123 }
2124
2125 impl StartKeyType {
2126 /// Initializes the enum to the [StartClosed](Self::StartClosed) branch.
2127 pub fn from_start_closed(
2128 value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2129 ) -> Self {
2130 Self::StartClosed(value.into())
2131 }
2132 /// Initializes the enum to the [StartOpen](Self::StartOpen) branch.
2133 pub fn from_start_open(
2134 value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2135 ) -> Self {
2136 Self::StartOpen(value.into())
2137 }
2138 }
2139
2140 /// The end key must be provided. It can be either closed or open.
2141 #[derive(Clone, Debug, PartialEq)]
2142 #[non_exhaustive]
2143 pub enum EndKeyType {
2144 /// If the end is closed, then the range includes all rows whose
2145 /// first `len(end_closed)` key columns exactly match `end_closed`.
2146 EndClosed(std::boxed::Box<wkt::ListValue>),
2147 /// If the end is open, then the range excludes rows whose first
2148 /// `len(end_open)` key columns exactly match `end_open`.
2149 EndOpen(std::boxed::Box<wkt::ListValue>),
2150 }
2151
2152 impl EndKeyType {
2153 /// Initializes the enum to the [EndClosed](Self::EndClosed) branch.
2154 pub fn from_end_closed(
2155 value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2156 ) -> Self {
2157 Self::EndClosed(value.into())
2158 }
2159 /// Initializes the enum to the [EndOpen](Self::EndOpen) branch.
2160 pub fn from_end_open(
2161 value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2162 ) -> Self {
2163 Self::EndOpen(value.into())
2164 }
2165 }
2166}
2167
2168/// `KeySet` defines a collection of Cloud Spanner keys and/or key ranges. All
2169/// the keys are expected to be in the same table or index. The keys need
2170/// not be sorted in any particular way.
2171///
2172/// If the same key is specified multiple times in the set (for example
2173/// if two ranges, two keys, or a key and a range overlap), Cloud Spanner
2174/// behaves as if the key were only specified once.
2175#[derive(Clone, Default, PartialEq)]
2176#[non_exhaustive]
2177pub struct KeySet {
2178 /// A list of specific keys. Entries in `keys` should have exactly as
2179 /// many elements as there are columns in the primary or index key
2180 /// with which this `KeySet` is used. Individual key values are
2181 /// encoded as described [here][google.spanner.v1.TypeCode].
2182 ///
2183 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
2184 pub keys: std::vec::Vec<wkt::ListValue>,
2185
2186 /// A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more
2187 /// information about key range specifications.
2188 ///
2189 /// [google.spanner.v1.KeyRange]: crate::model::KeyRange
2190 pub ranges: std::vec::Vec<crate::model::KeyRange>,
2191
2192 /// For convenience `all` can be set to `true` to indicate that this
2193 /// `KeySet` matches all keys in the table or index. Note that any keys
2194 /// specified in `keys` or `ranges` are only yielded once.
2195 pub all: bool,
2196
2197 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2198}
2199
2200impl KeySet {
2201 /// Creates a new default instance.
2202 pub fn new() -> Self {
2203 std::default::Default::default()
2204 }
2205
2206 /// Sets the value of [keys][crate::model::KeySet::keys].
2207 pub fn set_keys<T, V>(mut self, v: T) -> Self
2208 where
2209 T: std::iter::IntoIterator<Item = V>,
2210 V: std::convert::Into<wkt::ListValue>,
2211 {
2212 use std::iter::Iterator;
2213 self.keys = v.into_iter().map(|i| i.into()).collect();
2214 self
2215 }
2216
2217 /// Sets the value of [ranges][crate::model::KeySet::ranges].
2218 pub fn set_ranges<T, V>(mut self, v: T) -> Self
2219 where
2220 T: std::iter::IntoIterator<Item = V>,
2221 V: std::convert::Into<crate::model::KeyRange>,
2222 {
2223 use std::iter::Iterator;
2224 self.ranges = v.into_iter().map(|i| i.into()).collect();
2225 self
2226 }
2227
2228 /// Sets the value of [all][crate::model::KeySet::all].
2229 pub fn set_all<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2230 self.all = v.into();
2231 self
2232 }
2233}
2234
2235impl wkt::message::Message for KeySet {
2236 fn typename() -> &'static str {
2237 "type.googleapis.com/google.spanner.v1.KeySet"
2238 }
2239}
2240
2241/// A `Range` represents a range of keys in a database. The keys themselves
2242/// are encoded in "sortable string format", also known as ssformat. Consult
2243/// Spanner's open source client libraries for details on the encoding.
2244///
2245/// Each range represents a contiguous range of rows, possibly from multiple
2246/// tables/indexes. Each range is associated with a single paxos group (known as
2247/// a "group" throughout this API), a split (which names the exact range within
2248/// the group), and a generation that can be used to determine whether a given
2249/// `Range` represents a newer or older location for the key range.
2250#[derive(Clone, Default, PartialEq)]
2251#[non_exhaustive]
2252pub struct Range {
2253 /// The start key of the range, inclusive. Encoded in "sortable string format"
2254 /// (ssformat).
2255 pub start_key: ::bytes::Bytes,
2256
2257 /// The limit key of the range, exclusive. Encoded in "sortable string format"
2258 /// (ssformat).
2259 pub limit_key: ::bytes::Bytes,
2260
2261 /// The UID of the paxos group where this range is stored. UIDs are unique
2262 /// within the database. References `Group.group_uid`.
2263 pub group_uid: u64,
2264
2265 /// A group can store multiple ranges of keys. Each key range is named by an
2266 /// ID (the split ID). Within a group, split IDs are unique. The `split_id`
2267 /// names the exact split in `group_uid` where this range is stored.
2268 pub split_id: u64,
2269
2270 /// `generation` indicates the freshness of the range information contained
2271 /// in this proto. Generations can be compared lexicographically; if generation
2272 /// A is greater than generation B, then the `Range` corresponding to A is
2273 /// newer than the `Range` corresponding to B, and should be used
2274 /// preferentially.
2275 pub generation: ::bytes::Bytes,
2276
2277 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2278}
2279
2280impl Range {
2281 /// Creates a new default instance.
2282 pub fn new() -> Self {
2283 std::default::Default::default()
2284 }
2285
2286 /// Sets the value of [start_key][crate::model::Range::start_key].
2287 pub fn set_start_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2288 self.start_key = v.into();
2289 self
2290 }
2291
2292 /// Sets the value of [limit_key][crate::model::Range::limit_key].
2293 pub fn set_limit_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2294 self.limit_key = v.into();
2295 self
2296 }
2297
2298 /// Sets the value of [group_uid][crate::model::Range::group_uid].
2299 pub fn set_group_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2300 self.group_uid = v.into();
2301 self
2302 }
2303
2304 /// Sets the value of [split_id][crate::model::Range::split_id].
2305 pub fn set_split_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2306 self.split_id = v.into();
2307 self
2308 }
2309
2310 /// Sets the value of [generation][crate::model::Range::generation].
2311 pub fn set_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2312 self.generation = v.into();
2313 self
2314 }
2315}
2316
2317impl wkt::message::Message for Range {
2318 fn typename() -> &'static str {
2319 "type.googleapis.com/google.spanner.v1.Range"
2320 }
2321}
2322
2323/// A `Tablet` represents a single replica of a `Group`. A tablet is served by a
2324/// single server at a time, and can move between servers due to server death or
2325/// simply load balancing.
2326#[derive(Clone, Default, PartialEq)]
2327#[non_exhaustive]
2328pub struct Tablet {
2329 /// The UID of the tablet, unique within the database. Matches the
2330 /// `tablet_uids` and `leader_tablet_uid` fields in `Group`.
2331 pub tablet_uid: u64,
2332
2333 /// The address of the server that is serving this tablet -- either an IP
2334 /// address or DNS hostname and a port number.
2335 pub server_address: std::string::String,
2336
2337 /// Where this tablet is located. This is the name of a Google Cloud region,
2338 /// such as "us-central1".
2339 pub location: std::string::String,
2340
2341 /// The role of the tablet.
2342 pub role: crate::model::tablet::Role,
2343
2344 /// `incarnation` indicates the freshness of the tablet information contained
2345 /// in this proto. Incarnations can be compared lexicographically; if
2346 /// incarnation A is greater than incarnation B, then the `Tablet`
2347 /// corresponding to A is newer than the `Tablet` corresponding to B, and
2348 /// should be used preferentially.
2349 pub incarnation: ::bytes::Bytes,
2350
2351 /// Distances help the client pick the closest tablet out of the list of
2352 /// tablets for a given request. Tablets with lower distances should generally
2353 /// be preferred. Tablets with the same distance are approximately equally
2354 /// close; the client can choose arbitrarily.
2355 ///
2356 /// Distances do not correspond precisely to expected latency, geographical
2357 /// distance, or anything else. Distances should be compared only between
2358 /// tablets of the same group; they are not meaningful between different
2359 /// groups.
2360 ///
2361 /// A value of zero indicates that the tablet may be in the same zone as
2362 /// the client, and have minimum network latency. A value less than or equal to
2363 /// five indicates that the tablet is thought to be in the same region as the
2364 /// client, and may have a few milliseconds of network latency. Values greater
2365 /// than five are most likely in a different region, with non-trivial network
2366 /// latency.
2367 ///
2368 /// Clients should use the following algorithm:
2369 ///
2370 /// * If the request is using a directed read, eliminate any tablets that
2371 /// do not match the directed read's target zone and/or replica type.
2372 /// * (Read-write transactions only) Choose leader tablet if it has an
2373 /// distance <=5.
2374 /// * Group and sort tablets by distance. Choose a random
2375 /// tablet with the lowest distance. If the request
2376 /// is not a directed read, only consider replicas with distances <=5.
2377 /// * Send the request to the fallback endpoint.
2378 ///
2379 /// The tablet picked by this algorithm may be skipped, either because it is
2380 /// marked as `skip` by the server or because the corresponding server is
2381 /// unreachable, flow controlled, etc. Skipped tablets should be added to the
2382 /// `skipped_tablet_uid` field in `RoutingHint`; the algorithm above should
2383 /// then be re-run without including the skipped tablet(s) to pick the next
2384 /// best tablet.
2385 pub distance: u32,
2386
2387 /// If true, the tablet should not be chosen by the client. Typically, this
2388 /// signals that the tablet is unhealthy in some way. Tablets with `skip`
2389 /// set to true should be reported back to the server in
2390 /// `RoutingHint.skipped_tablet_uid`; this cues the server to send updated
2391 /// information for this tablet should it become usable again.
2392 pub skip: bool,
2393
2394 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2395}
2396
2397impl Tablet {
2398 /// Creates a new default instance.
2399 pub fn new() -> Self {
2400 std::default::Default::default()
2401 }
2402
2403 /// Sets the value of [tablet_uid][crate::model::Tablet::tablet_uid].
2404 pub fn set_tablet_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2405 self.tablet_uid = v.into();
2406 self
2407 }
2408
2409 /// Sets the value of [server_address][crate::model::Tablet::server_address].
2410 pub fn set_server_address<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2411 self.server_address = v.into();
2412 self
2413 }
2414
2415 /// Sets the value of [location][crate::model::Tablet::location].
2416 pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2417 self.location = v.into();
2418 self
2419 }
2420
2421 /// Sets the value of [role][crate::model::Tablet::role].
2422 pub fn set_role<T: std::convert::Into<crate::model::tablet::Role>>(mut self, v: T) -> Self {
2423 self.role = v.into();
2424 self
2425 }
2426
2427 /// Sets the value of [incarnation][crate::model::Tablet::incarnation].
2428 pub fn set_incarnation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2429 self.incarnation = v.into();
2430 self
2431 }
2432
2433 /// Sets the value of [distance][crate::model::Tablet::distance].
2434 pub fn set_distance<T: std::convert::Into<u32>>(mut self, v: T) -> Self {
2435 self.distance = v.into();
2436 self
2437 }
2438
2439 /// Sets the value of [skip][crate::model::Tablet::skip].
2440 pub fn set_skip<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2441 self.skip = v.into();
2442 self
2443 }
2444}
2445
2446impl wkt::message::Message for Tablet {
2447 fn typename() -> &'static str {
2448 "type.googleapis.com/google.spanner.v1.Tablet"
2449 }
2450}
2451
2452/// Defines additional types related to [Tablet].
2453pub mod tablet {
2454 #[allow(unused_imports)]
2455 use super::*;
2456
2457 /// Indicates the role of the tablet.
2458 ///
2459 /// # Working with unknown values
2460 ///
2461 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2462 /// additional enum variants at any time. Adding new variants is not considered
2463 /// a breaking change. Applications should write their code in anticipation of:
2464 ///
2465 /// - New values appearing in future releases of the client library, **and**
2466 /// - New values received dynamically, without application changes.
2467 ///
2468 /// Please consult the [Working with enums] section in the user guide for some
2469 /// guidelines.
2470 ///
2471 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2472 #[derive(Clone, Debug, PartialEq)]
2473 #[non_exhaustive]
2474 pub enum Role {
2475 /// Not specified.
2476 Unspecified,
2477 /// The tablet can perform reads and (if elected leader) writes.
2478 ReadWrite,
2479 /// The tablet can only perform reads.
2480 ReadOnly,
2481 /// If set, the enum was initialized with an unknown value.
2482 ///
2483 /// Applications can examine the value using [Role::value] or
2484 /// [Role::name].
2485 UnknownValue(role::UnknownValue),
2486 }
2487
2488 #[doc(hidden)]
2489 pub mod role {
2490 #[allow(unused_imports)]
2491 use super::*;
2492 #[derive(Clone, Debug, PartialEq)]
2493 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2494 }
2495
2496 impl Role {
2497 /// Gets the enum value.
2498 ///
2499 /// Returns `None` if the enum contains an unknown value deserialized from
2500 /// the string representation of enums.
2501 pub fn value(&self) -> std::option::Option<i32> {
2502 match self {
2503 Self::Unspecified => std::option::Option::Some(0),
2504 Self::ReadWrite => std::option::Option::Some(1),
2505 Self::ReadOnly => std::option::Option::Some(2),
2506 Self::UnknownValue(u) => u.0.value(),
2507 }
2508 }
2509
2510 /// Gets the enum value as a string.
2511 ///
2512 /// Returns `None` if the enum contains an unknown value deserialized from
2513 /// the integer representation of enums.
2514 pub fn name(&self) -> std::option::Option<&str> {
2515 match self {
2516 Self::Unspecified => std::option::Option::Some("ROLE_UNSPECIFIED"),
2517 Self::ReadWrite => std::option::Option::Some("READ_WRITE"),
2518 Self::ReadOnly => std::option::Option::Some("READ_ONLY"),
2519 Self::UnknownValue(u) => u.0.name(),
2520 }
2521 }
2522 }
2523
2524 impl std::default::Default for Role {
2525 fn default() -> Self {
2526 use std::convert::From;
2527 Self::from(0)
2528 }
2529 }
2530
2531 impl std::fmt::Display for Role {
2532 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2533 wkt::internal::display_enum(f, self.name(), self.value())
2534 }
2535 }
2536
2537 impl std::convert::From<i32> for Role {
2538 fn from(value: i32) -> Self {
2539 match value {
2540 0 => Self::Unspecified,
2541 1 => Self::ReadWrite,
2542 2 => Self::ReadOnly,
2543 _ => Self::UnknownValue(role::UnknownValue(
2544 wkt::internal::UnknownEnumValue::Integer(value),
2545 )),
2546 }
2547 }
2548 }
2549
2550 impl std::convert::From<&str> for Role {
2551 fn from(value: &str) -> Self {
2552 use std::string::ToString;
2553 match value {
2554 "ROLE_UNSPECIFIED" => Self::Unspecified,
2555 "READ_WRITE" => Self::ReadWrite,
2556 "READ_ONLY" => Self::ReadOnly,
2557 _ => Self::UnknownValue(role::UnknownValue(
2558 wkt::internal::UnknownEnumValue::String(value.to_string()),
2559 )),
2560 }
2561 }
2562 }
2563
2564 impl serde::ser::Serialize for Role {
2565 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2566 where
2567 S: serde::Serializer,
2568 {
2569 match self {
2570 Self::Unspecified => serializer.serialize_i32(0),
2571 Self::ReadWrite => serializer.serialize_i32(1),
2572 Self::ReadOnly => serializer.serialize_i32(2),
2573 Self::UnknownValue(u) => u.0.serialize(serializer),
2574 }
2575 }
2576 }
2577
2578 impl<'de> serde::de::Deserialize<'de> for Role {
2579 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2580 where
2581 D: serde::Deserializer<'de>,
2582 {
2583 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Role>::new(
2584 ".google.spanner.v1.Tablet.Role",
2585 ))
2586 }
2587 }
2588}
2589
2590/// A `Group` represents a paxos group in a database. A group is a set of
2591/// tablets that are replicated across multiple servers. Groups may have a leader
2592/// tablet. Groups store one (or sometimes more) ranges of keys.
2593#[derive(Clone, Default, PartialEq)]
2594#[non_exhaustive]
2595pub struct Group {
2596 /// The UID of the paxos group, unique within the database. Matches the
2597 /// `group_uid` field in `Range`.
2598 pub group_uid: u64,
2599
2600 /// A list of tablets that are part of the group. Note that this list may not
2601 /// be exhaustive; it will only include tablets the server considers useful
2602 /// to the client. The returned list is ordered ascending by distance.
2603 ///
2604 /// Tablet UIDs reference `Tablet.tablet_uid`.
2605 pub tablets: std::vec::Vec<crate::model::Tablet>,
2606
2607 /// The last known leader tablet of the group as an index into `tablets`. May
2608 /// be negative if the group has no known leader.
2609 pub leader_index: i32,
2610
2611 /// `generation` indicates the freshness of the group information (including
2612 /// leader information) contained in this proto. Generations can be compared
2613 /// lexicographically; if generation A is greater than generation B, then the
2614 /// `Group` corresponding to A is newer than the `Group` corresponding to B,
2615 /// and should be used preferentially.
2616 pub generation: ::bytes::Bytes,
2617
2618 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2619}
2620
2621impl Group {
2622 /// Creates a new default instance.
2623 pub fn new() -> Self {
2624 std::default::Default::default()
2625 }
2626
2627 /// Sets the value of [group_uid][crate::model::Group::group_uid].
2628 pub fn set_group_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2629 self.group_uid = v.into();
2630 self
2631 }
2632
2633 /// Sets the value of [tablets][crate::model::Group::tablets].
2634 pub fn set_tablets<T, V>(mut self, v: T) -> Self
2635 where
2636 T: std::iter::IntoIterator<Item = V>,
2637 V: std::convert::Into<crate::model::Tablet>,
2638 {
2639 use std::iter::Iterator;
2640 self.tablets = v.into_iter().map(|i| i.into()).collect();
2641 self
2642 }
2643
2644 /// Sets the value of [leader_index][crate::model::Group::leader_index].
2645 pub fn set_leader_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2646 self.leader_index = v.into();
2647 self
2648 }
2649
2650 /// Sets the value of [generation][crate::model::Group::generation].
2651 pub fn set_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2652 self.generation = v.into();
2653 self
2654 }
2655}
2656
2657impl wkt::message::Message for Group {
2658 fn typename() -> &'static str {
2659 "type.googleapis.com/google.spanner.v1.Group"
2660 }
2661}
2662
2663/// A `KeyRecipe` provides the metadata required to translate reads, mutations,
2664/// and queries into a byte array in "sortable string format" (ssformat)that can
2665/// be used with `Range`s to route requests. Note that the client *must* tolerate
2666/// `KeyRecipe`s that appear to be invalid, since the `KeyRecipe` format may
2667/// change over time. Requests with invalid `KeyRecipe`s should be routed to a
2668/// default server.
2669#[derive(Clone, Default, PartialEq)]
2670#[non_exhaustive]
2671pub struct KeyRecipe {
2672 /// Parts are in the order they should appear in the encoded key.
2673 pub part: std::vec::Vec<crate::model::key_recipe::Part>,
2674
2675 /// A recipe can be associated with a table, index, or query. Tables recipes
2676 /// are used to encode read and write keys; index recipes are used for index
2677 /// reads, and query recipes are used only for SQL queries.
2678 pub target: std::option::Option<crate::model::key_recipe::Target>,
2679
2680 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2681}
2682
2683impl KeyRecipe {
2684 /// Creates a new default instance.
2685 pub fn new() -> Self {
2686 std::default::Default::default()
2687 }
2688
2689 /// Sets the value of [part][crate::model::KeyRecipe::part].
2690 pub fn set_part<T, V>(mut self, v: T) -> Self
2691 where
2692 T: std::iter::IntoIterator<Item = V>,
2693 V: std::convert::Into<crate::model::key_recipe::Part>,
2694 {
2695 use std::iter::Iterator;
2696 self.part = v.into_iter().map(|i| i.into()).collect();
2697 self
2698 }
2699
2700 /// Sets the value of [target][crate::model::KeyRecipe::target].
2701 ///
2702 /// Note that all the setters affecting `target` are mutually
2703 /// exclusive.
2704 pub fn set_target<
2705 T: std::convert::Into<std::option::Option<crate::model::key_recipe::Target>>,
2706 >(
2707 mut self,
2708 v: T,
2709 ) -> Self {
2710 self.target = v.into();
2711 self
2712 }
2713
2714 /// The value of [target][crate::model::KeyRecipe::target]
2715 /// if it holds a `TableName`, `None` if the field is not set or
2716 /// holds a different branch.
2717 pub fn table_name(&self) -> std::option::Option<&std::string::String> {
2718 #[allow(unreachable_patterns)]
2719 self.target.as_ref().and_then(|v| match v {
2720 crate::model::key_recipe::Target::TableName(v) => std::option::Option::Some(v),
2721 _ => std::option::Option::None,
2722 })
2723 }
2724
2725 /// Sets the value of [target][crate::model::KeyRecipe::target]
2726 /// to hold a `TableName`.
2727 ///
2728 /// Note that all the setters affecting `target` are
2729 /// mutually exclusive.
2730 pub fn set_table_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2731 self.target =
2732 std::option::Option::Some(crate::model::key_recipe::Target::TableName(v.into()));
2733 self
2734 }
2735
2736 /// The value of [target][crate::model::KeyRecipe::target]
2737 /// if it holds a `IndexName`, `None` if the field is not set or
2738 /// holds a different branch.
2739 pub fn index_name(&self) -> std::option::Option<&std::string::String> {
2740 #[allow(unreachable_patterns)]
2741 self.target.as_ref().and_then(|v| match v {
2742 crate::model::key_recipe::Target::IndexName(v) => std::option::Option::Some(v),
2743 _ => std::option::Option::None,
2744 })
2745 }
2746
2747 /// Sets the value of [target][crate::model::KeyRecipe::target]
2748 /// to hold a `IndexName`.
2749 ///
2750 /// Note that all the setters affecting `target` are
2751 /// mutually exclusive.
2752 pub fn set_index_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2753 self.target =
2754 std::option::Option::Some(crate::model::key_recipe::Target::IndexName(v.into()));
2755 self
2756 }
2757
2758 /// The value of [target][crate::model::KeyRecipe::target]
2759 /// if it holds a `OperationUid`, `None` if the field is not set or
2760 /// holds a different branch.
2761 pub fn operation_uid(&self) -> std::option::Option<&u64> {
2762 #[allow(unreachable_patterns)]
2763 self.target.as_ref().and_then(|v| match v {
2764 crate::model::key_recipe::Target::OperationUid(v) => std::option::Option::Some(v),
2765 _ => std::option::Option::None,
2766 })
2767 }
2768
2769 /// Sets the value of [target][crate::model::KeyRecipe::target]
2770 /// to hold a `OperationUid`.
2771 ///
2772 /// Note that all the setters affecting `target` are
2773 /// mutually exclusive.
2774 pub fn set_operation_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2775 self.target =
2776 std::option::Option::Some(crate::model::key_recipe::Target::OperationUid(v.into()));
2777 self
2778 }
2779}
2780
2781impl wkt::message::Message for KeyRecipe {
2782 fn typename() -> &'static str {
2783 "type.googleapis.com/google.spanner.v1.KeyRecipe"
2784 }
2785}
2786
2787/// Defines additional types related to [KeyRecipe].
2788pub mod key_recipe {
2789 #[allow(unused_imports)]
2790 use super::*;
2791
2792 /// An ssformat key is composed of a sequence of tag numbers and key column
2793 /// values. `Part` represents a single tag or key column value.
2794 #[derive(Clone, Default, PartialEq)]
2795 #[non_exhaustive]
2796 pub struct Part {
2797 /// If non-zero, `tag` is the only field present in this `Part`. The part
2798 /// is encoded by appending `tag` to the ssformat key.
2799 pub tag: u32,
2800
2801 /// Whether the key column is sorted ascending or descending. Only present
2802 /// if `tag` is zero.
2803 pub order: crate::model::key_recipe::part::Order,
2804
2805 /// How NULLs are represented in the encoded key part. Only present if `tag`
2806 /// is zero.
2807 pub null_order: crate::model::key_recipe::part::NullOrder,
2808
2809 /// The type of the key part. Only present if `tag` is zero.
2810 pub r#type: std::option::Option<crate::model::Type>,
2811
2812 /// It is a repeated field to support fetching key columns from nested
2813 /// structs, such as `STRUCT` query parameters.
2814 pub struct_identifiers: std::vec::Vec<i32>,
2815
2816 /// Only present if `tag` is zero.
2817 pub value_type: std::option::Option<crate::model::key_recipe::part::ValueType>,
2818
2819 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2820 }
2821
2822 impl Part {
2823 /// Creates a new default instance.
2824 pub fn new() -> Self {
2825 std::default::Default::default()
2826 }
2827
2828 /// Sets the value of [tag][crate::model::key_recipe::Part::tag].
2829 pub fn set_tag<T: std::convert::Into<u32>>(mut self, v: T) -> Self {
2830 self.tag = v.into();
2831 self
2832 }
2833
2834 /// Sets the value of [order][crate::model::key_recipe::Part::order].
2835 pub fn set_order<T: std::convert::Into<crate::model::key_recipe::part::Order>>(
2836 mut self,
2837 v: T,
2838 ) -> Self {
2839 self.order = v.into();
2840 self
2841 }
2842
2843 /// Sets the value of [null_order][crate::model::key_recipe::Part::null_order].
2844 pub fn set_null_order<T: std::convert::Into<crate::model::key_recipe::part::NullOrder>>(
2845 mut self,
2846 v: T,
2847 ) -> Self {
2848 self.null_order = v.into();
2849 self
2850 }
2851
2852 /// Sets the value of [r#type][crate::model::key_recipe::Part::type].
2853 pub fn set_type<T>(mut self, v: T) -> Self
2854 where
2855 T: std::convert::Into<crate::model::Type>,
2856 {
2857 self.r#type = std::option::Option::Some(v.into());
2858 self
2859 }
2860
2861 /// Sets or clears the value of [r#type][crate::model::key_recipe::Part::type].
2862 pub fn set_or_clear_type<T>(mut self, v: std::option::Option<T>) -> Self
2863 where
2864 T: std::convert::Into<crate::model::Type>,
2865 {
2866 self.r#type = v.map(|x| x.into());
2867 self
2868 }
2869
2870 /// Sets the value of [struct_identifiers][crate::model::key_recipe::Part::struct_identifiers].
2871 pub fn set_struct_identifiers<T, V>(mut self, v: T) -> Self
2872 where
2873 T: std::iter::IntoIterator<Item = V>,
2874 V: std::convert::Into<i32>,
2875 {
2876 use std::iter::Iterator;
2877 self.struct_identifiers = v.into_iter().map(|i| i.into()).collect();
2878 self
2879 }
2880
2881 /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type].
2882 ///
2883 /// Note that all the setters affecting `value_type` are mutually
2884 /// exclusive.
2885 pub fn set_value_type<
2886 T: std::convert::Into<std::option::Option<crate::model::key_recipe::part::ValueType>>,
2887 >(
2888 mut self,
2889 v: T,
2890 ) -> Self {
2891 self.value_type = v.into();
2892 self
2893 }
2894
2895 /// The value of [value_type][crate::model::key_recipe::Part::value_type]
2896 /// if it holds a `Identifier`, `None` if the field is not set or
2897 /// holds a different branch.
2898 pub fn identifier(&self) -> std::option::Option<&std::string::String> {
2899 #[allow(unreachable_patterns)]
2900 self.value_type.as_ref().and_then(|v| match v {
2901 crate::model::key_recipe::part::ValueType::Identifier(v) => {
2902 std::option::Option::Some(v)
2903 }
2904 _ => std::option::Option::None,
2905 })
2906 }
2907
2908 /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type]
2909 /// to hold a `Identifier`.
2910 ///
2911 /// Note that all the setters affecting `value_type` are
2912 /// mutually exclusive.
2913 pub fn set_identifier<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2914 self.value_type = std::option::Option::Some(
2915 crate::model::key_recipe::part::ValueType::Identifier(v.into()),
2916 );
2917 self
2918 }
2919
2920 /// The value of [value_type][crate::model::key_recipe::Part::value_type]
2921 /// if it holds a `Value`, `None` if the field is not set or
2922 /// holds a different branch.
2923 pub fn value(&self) -> std::option::Option<&std::boxed::Box<wkt::Value>> {
2924 #[allow(unreachable_patterns)]
2925 self.value_type.as_ref().and_then(|v| match v {
2926 crate::model::key_recipe::part::ValueType::Value(v) => std::option::Option::Some(v),
2927 _ => std::option::Option::None,
2928 })
2929 }
2930
2931 /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type]
2932 /// to hold a `Value`.
2933 ///
2934 /// Note that all the setters affecting `value_type` are
2935 /// mutually exclusive.
2936 pub fn set_value<T: std::convert::Into<std::boxed::Box<wkt::Value>>>(
2937 mut self,
2938 v: T,
2939 ) -> Self {
2940 self.value_type = std::option::Option::Some(
2941 crate::model::key_recipe::part::ValueType::Value(v.into()),
2942 );
2943 self
2944 }
2945
2946 /// The value of [value_type][crate::model::key_recipe::Part::value_type]
2947 /// if it holds a `Random`, `None` if the field is not set or
2948 /// holds a different branch.
2949 pub fn random(&self) -> std::option::Option<&bool> {
2950 #[allow(unreachable_patterns)]
2951 self.value_type.as_ref().and_then(|v| match v {
2952 crate::model::key_recipe::part::ValueType::Random(v) => {
2953 std::option::Option::Some(v)
2954 }
2955 _ => std::option::Option::None,
2956 })
2957 }
2958
2959 /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type]
2960 /// to hold a `Random`.
2961 ///
2962 /// Note that all the setters affecting `value_type` are
2963 /// mutually exclusive.
2964 pub fn set_random<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2965 self.value_type = std::option::Option::Some(
2966 crate::model::key_recipe::part::ValueType::Random(v.into()),
2967 );
2968 self
2969 }
2970 }
2971
2972 impl wkt::message::Message for Part {
2973 fn typename() -> &'static str {
2974 "type.googleapis.com/google.spanner.v1.KeyRecipe.Part"
2975 }
2976 }
2977
2978 /// Defines additional types related to [Part].
2979 pub mod part {
2980 #[allow(unused_imports)]
2981 use super::*;
2982
2983 /// The remaining fields encode column values.
2984 ///
2985 /// # Working with unknown values
2986 ///
2987 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2988 /// additional enum variants at any time. Adding new variants is not considered
2989 /// a breaking change. Applications should write their code in anticipation of:
2990 ///
2991 /// - New values appearing in future releases of the client library, **and**
2992 /// - New values received dynamically, without application changes.
2993 ///
2994 /// Please consult the [Working with enums] section in the user guide for some
2995 /// guidelines.
2996 ///
2997 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2998 #[derive(Clone, Debug, PartialEq)]
2999 #[non_exhaustive]
3000 pub enum Order {
3001 /// Default value, equivalent to `ASCENDING`.
3002 Unspecified,
3003 /// The key is ascending - corresponds to `ASC` in the schema definition.
3004 Ascending,
3005 /// The key is descending - corresponds to `DESC` in the schema definition.
3006 Descending,
3007 /// If set, the enum was initialized with an unknown value.
3008 ///
3009 /// Applications can examine the value using [Order::value] or
3010 /// [Order::name].
3011 UnknownValue(order::UnknownValue),
3012 }
3013
3014 #[doc(hidden)]
3015 pub mod order {
3016 #[allow(unused_imports)]
3017 use super::*;
3018 #[derive(Clone, Debug, PartialEq)]
3019 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3020 }
3021
3022 impl Order {
3023 /// Gets the enum value.
3024 ///
3025 /// Returns `None` if the enum contains an unknown value deserialized from
3026 /// the string representation of enums.
3027 pub fn value(&self) -> std::option::Option<i32> {
3028 match self {
3029 Self::Unspecified => std::option::Option::Some(0),
3030 Self::Ascending => std::option::Option::Some(1),
3031 Self::Descending => std::option::Option::Some(2),
3032 Self::UnknownValue(u) => u.0.value(),
3033 }
3034 }
3035
3036 /// Gets the enum value as a string.
3037 ///
3038 /// Returns `None` if the enum contains an unknown value deserialized from
3039 /// the integer representation of enums.
3040 pub fn name(&self) -> std::option::Option<&str> {
3041 match self {
3042 Self::Unspecified => std::option::Option::Some("ORDER_UNSPECIFIED"),
3043 Self::Ascending => std::option::Option::Some("ASCENDING"),
3044 Self::Descending => std::option::Option::Some("DESCENDING"),
3045 Self::UnknownValue(u) => u.0.name(),
3046 }
3047 }
3048 }
3049
3050 impl std::default::Default for Order {
3051 fn default() -> Self {
3052 use std::convert::From;
3053 Self::from(0)
3054 }
3055 }
3056
3057 impl std::fmt::Display for Order {
3058 fn fmt(
3059 &self,
3060 f: &mut std::fmt::Formatter<'_>,
3061 ) -> std::result::Result<(), std::fmt::Error> {
3062 wkt::internal::display_enum(f, self.name(), self.value())
3063 }
3064 }
3065
3066 impl std::convert::From<i32> for Order {
3067 fn from(value: i32) -> Self {
3068 match value {
3069 0 => Self::Unspecified,
3070 1 => Self::Ascending,
3071 2 => Self::Descending,
3072 _ => Self::UnknownValue(order::UnknownValue(
3073 wkt::internal::UnknownEnumValue::Integer(value),
3074 )),
3075 }
3076 }
3077 }
3078
3079 impl std::convert::From<&str> for Order {
3080 fn from(value: &str) -> Self {
3081 use std::string::ToString;
3082 match value {
3083 "ORDER_UNSPECIFIED" => Self::Unspecified,
3084 "ASCENDING" => Self::Ascending,
3085 "DESCENDING" => Self::Descending,
3086 _ => Self::UnknownValue(order::UnknownValue(
3087 wkt::internal::UnknownEnumValue::String(value.to_string()),
3088 )),
3089 }
3090 }
3091 }
3092
3093 impl serde::ser::Serialize for Order {
3094 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3095 where
3096 S: serde::Serializer,
3097 {
3098 match self {
3099 Self::Unspecified => serializer.serialize_i32(0),
3100 Self::Ascending => serializer.serialize_i32(1),
3101 Self::Descending => serializer.serialize_i32(2),
3102 Self::UnknownValue(u) => u.0.serialize(serializer),
3103 }
3104 }
3105 }
3106
3107 impl<'de> serde::de::Deserialize<'de> for Order {
3108 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3109 where
3110 D: serde::Deserializer<'de>,
3111 {
3112 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Order>::new(
3113 ".google.spanner.v1.KeyRecipe.Part.Order",
3114 ))
3115 }
3116 }
3117
3118 /// The null order of the key column. This dictates where NULL values sort
3119 /// in the sorted order. Note that columns which are `NOT NULL` can have a
3120 /// special encoding.
3121 ///
3122 /// # Working with unknown values
3123 ///
3124 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3125 /// additional enum variants at any time. Adding new variants is not considered
3126 /// a breaking change. Applications should write their code in anticipation of:
3127 ///
3128 /// - New values appearing in future releases of the client library, **and**
3129 /// - New values received dynamically, without application changes.
3130 ///
3131 /// Please consult the [Working with enums] section in the user guide for some
3132 /// guidelines.
3133 ///
3134 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3135 #[derive(Clone, Debug, PartialEq)]
3136 #[non_exhaustive]
3137 pub enum NullOrder {
3138 /// Default value. This value is unused.
3139 Unspecified,
3140 /// NULL values sort before any non-NULL values.
3141 NullsFirst,
3142 /// NULL values sort after any non-NULL values.
3143 NullsLast,
3144 /// The column does not support NULL values.
3145 NotNull,
3146 /// If set, the enum was initialized with an unknown value.
3147 ///
3148 /// Applications can examine the value using [NullOrder::value] or
3149 /// [NullOrder::name].
3150 UnknownValue(null_order::UnknownValue),
3151 }
3152
3153 #[doc(hidden)]
3154 pub mod null_order {
3155 #[allow(unused_imports)]
3156 use super::*;
3157 #[derive(Clone, Debug, PartialEq)]
3158 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3159 }
3160
3161 impl NullOrder {
3162 /// Gets the enum value.
3163 ///
3164 /// Returns `None` if the enum contains an unknown value deserialized from
3165 /// the string representation of enums.
3166 pub fn value(&self) -> std::option::Option<i32> {
3167 match self {
3168 Self::Unspecified => std::option::Option::Some(0),
3169 Self::NullsFirst => std::option::Option::Some(1),
3170 Self::NullsLast => std::option::Option::Some(2),
3171 Self::NotNull => std::option::Option::Some(3),
3172 Self::UnknownValue(u) => u.0.value(),
3173 }
3174 }
3175
3176 /// Gets the enum value as a string.
3177 ///
3178 /// Returns `None` if the enum contains an unknown value deserialized from
3179 /// the integer representation of enums.
3180 pub fn name(&self) -> std::option::Option<&str> {
3181 match self {
3182 Self::Unspecified => std::option::Option::Some("NULL_ORDER_UNSPECIFIED"),
3183 Self::NullsFirst => std::option::Option::Some("NULLS_FIRST"),
3184 Self::NullsLast => std::option::Option::Some("NULLS_LAST"),
3185 Self::NotNull => std::option::Option::Some("NOT_NULL"),
3186 Self::UnknownValue(u) => u.0.name(),
3187 }
3188 }
3189 }
3190
3191 impl std::default::Default for NullOrder {
3192 fn default() -> Self {
3193 use std::convert::From;
3194 Self::from(0)
3195 }
3196 }
3197
3198 impl std::fmt::Display for NullOrder {
3199 fn fmt(
3200 &self,
3201 f: &mut std::fmt::Formatter<'_>,
3202 ) -> std::result::Result<(), std::fmt::Error> {
3203 wkt::internal::display_enum(f, self.name(), self.value())
3204 }
3205 }
3206
3207 impl std::convert::From<i32> for NullOrder {
3208 fn from(value: i32) -> Self {
3209 match value {
3210 0 => Self::Unspecified,
3211 1 => Self::NullsFirst,
3212 2 => Self::NullsLast,
3213 3 => Self::NotNull,
3214 _ => Self::UnknownValue(null_order::UnknownValue(
3215 wkt::internal::UnknownEnumValue::Integer(value),
3216 )),
3217 }
3218 }
3219 }
3220
3221 impl std::convert::From<&str> for NullOrder {
3222 fn from(value: &str) -> Self {
3223 use std::string::ToString;
3224 match value {
3225 "NULL_ORDER_UNSPECIFIED" => Self::Unspecified,
3226 "NULLS_FIRST" => Self::NullsFirst,
3227 "NULLS_LAST" => Self::NullsLast,
3228 "NOT_NULL" => Self::NotNull,
3229 _ => Self::UnknownValue(null_order::UnknownValue(
3230 wkt::internal::UnknownEnumValue::String(value.to_string()),
3231 )),
3232 }
3233 }
3234 }
3235
3236 impl serde::ser::Serialize for NullOrder {
3237 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3238 where
3239 S: serde::Serializer,
3240 {
3241 match self {
3242 Self::Unspecified => serializer.serialize_i32(0),
3243 Self::NullsFirst => serializer.serialize_i32(1),
3244 Self::NullsLast => serializer.serialize_i32(2),
3245 Self::NotNull => serializer.serialize_i32(3),
3246 Self::UnknownValue(u) => u.0.serialize(serializer),
3247 }
3248 }
3249 }
3250
3251 impl<'de> serde::de::Deserialize<'de> for NullOrder {
3252 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3253 where
3254 D: serde::Deserializer<'de>,
3255 {
3256 deserializer.deserialize_any(wkt::internal::EnumVisitor::<NullOrder>::new(
3257 ".google.spanner.v1.KeyRecipe.Part.NullOrder",
3258 ))
3259 }
3260 }
3261
3262 /// Only present if `tag` is zero.
3263 #[derive(Clone, Debug, PartialEq)]
3264 #[non_exhaustive]
3265 pub enum ValueType {
3266 /// `identifier` is the name of the column or query parameter.
3267 Identifier(std::string::String),
3268 /// The constant value of the key part.
3269 /// It is present when query uses a constant as a part of the key.
3270 Value(std::boxed::Box<wkt::Value>),
3271 /// If true, the client is responsible to fill in the value randomly.
3272 /// It's relevant only for the INT64 type.
3273 Random(bool),
3274 }
3275
3276 impl ValueType {
3277 /// Initializes the enum to the [Identifier](Self::Identifier) branch.
3278 pub fn from_identifier(value: impl std::convert::Into<std::string::String>) -> Self {
3279 Self::Identifier(value.into())
3280 }
3281 /// Initializes the enum to the [Value](Self::Value) branch.
3282 pub fn from_value(value: impl std::convert::Into<std::boxed::Box<wkt::Value>>) -> Self {
3283 Self::Value(value.into())
3284 }
3285 /// Initializes the enum to the [Random](Self::Random) branch.
3286 pub fn from_random(value: impl std::convert::Into<bool>) -> Self {
3287 Self::Random(value.into())
3288 }
3289 }
3290 }
3291
3292 /// A recipe can be associated with a table, index, or query. Tables recipes
3293 /// are used to encode read and write keys; index recipes are used for index
3294 /// reads, and query recipes are used only for SQL queries.
3295 #[derive(Clone, Debug, PartialEq)]
3296 #[non_exhaustive]
3297 pub enum Target {
3298 /// A table name, matching the name from the database schema.
3299 TableName(std::string::String),
3300 /// An index name, matching the name from the database schema.
3301 IndexName(std::string::String),
3302 /// The UID of a query, matching the UID from `RoutingHint`.
3303 OperationUid(u64),
3304 }
3305
3306 impl Target {
3307 /// Initializes the enum to the [TableName](Self::TableName) branch.
3308 pub fn from_table_name(value: impl std::convert::Into<std::string::String>) -> Self {
3309 Self::TableName(value.into())
3310 }
3311 /// Initializes the enum to the [IndexName](Self::IndexName) branch.
3312 pub fn from_index_name(value: impl std::convert::Into<std::string::String>) -> Self {
3313 Self::IndexName(value.into())
3314 }
3315 /// Initializes the enum to the [OperationUid](Self::OperationUid) branch.
3316 pub fn from_operation_uid(value: impl std::convert::Into<u64>) -> Self {
3317 Self::OperationUid(value.into())
3318 }
3319 }
3320}
3321
3322/// A `RecipeList` contains a list of `KeyRecipe`s, which share the same
3323/// schema generation.
3324#[derive(Clone, Default, PartialEq)]
3325#[non_exhaustive]
3326pub struct RecipeList {
3327 /// The schema generation of the recipes. To be sent to the server in
3328 /// `RoutingHint.schema_generation` whenever one of the recipes is used.
3329 /// `schema_generation` values are comparable with each other; if generation A
3330 /// compares greater than generation B, then A is a more recent schema than B.
3331 /// Clients should in general aim to cache only the latest schema generation,
3332 /// and discard more stale recipes.
3333 pub schema_generation: ::bytes::Bytes,
3334
3335 /// A list of recipes to be cached.
3336 pub recipe: std::vec::Vec<crate::model::KeyRecipe>,
3337
3338 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3339}
3340
3341impl RecipeList {
3342 /// Creates a new default instance.
3343 pub fn new() -> Self {
3344 std::default::Default::default()
3345 }
3346
3347 /// Sets the value of [schema_generation][crate::model::RecipeList::schema_generation].
3348 pub fn set_schema_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3349 self.schema_generation = v.into();
3350 self
3351 }
3352
3353 /// Sets the value of [recipe][crate::model::RecipeList::recipe].
3354 pub fn set_recipe<T, V>(mut self, v: T) -> Self
3355 where
3356 T: std::iter::IntoIterator<Item = V>,
3357 V: std::convert::Into<crate::model::KeyRecipe>,
3358 {
3359 use std::iter::Iterator;
3360 self.recipe = v.into_iter().map(|i| i.into()).collect();
3361 self
3362 }
3363}
3364
3365impl wkt::message::Message for RecipeList {
3366 fn typename() -> &'static str {
3367 "type.googleapis.com/google.spanner.v1.RecipeList"
3368 }
3369}
3370
3371/// A `CacheUpdate` expresses a set of changes the client should incorporate into
3372/// its location cache. These changes may or may not be newer than what the
3373/// client has in its cache, and should be discarded if necessary. `CacheUpdate`s
3374/// can be obtained in response to requests that included a `RoutingHint`
3375/// field, but may also be obtained by explicit location-fetching RPCs which may
3376/// be added in the future.
3377#[derive(Clone, Default, PartialEq)]
3378#[non_exhaustive]
3379pub struct CacheUpdate {
3380 /// An internal ID for the database. Database names can be reused if a database
3381 /// is deleted and re-created. Each time the database is re-created, it will
3382 /// get a new database ID, which will never be re-used for any other database.
3383 pub database_id: u64,
3384
3385 /// A list of ranges to be cached.
3386 pub range: std::vec::Vec<crate::model::Range>,
3387
3388 /// A list of groups to be cached.
3389 pub group: std::vec::Vec<crate::model::Group>,
3390
3391 /// A list of recipes to be cached.
3392 pub key_recipes: std::option::Option<crate::model::RecipeList>,
3393
3394 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3395}
3396
3397impl CacheUpdate {
3398 /// Creates a new default instance.
3399 pub fn new() -> Self {
3400 std::default::Default::default()
3401 }
3402
3403 /// Sets the value of [database_id][crate::model::CacheUpdate::database_id].
3404 pub fn set_database_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3405 self.database_id = v.into();
3406 self
3407 }
3408
3409 /// Sets the value of [range][crate::model::CacheUpdate::range].
3410 pub fn set_range<T, V>(mut self, v: T) -> Self
3411 where
3412 T: std::iter::IntoIterator<Item = V>,
3413 V: std::convert::Into<crate::model::Range>,
3414 {
3415 use std::iter::Iterator;
3416 self.range = v.into_iter().map(|i| i.into()).collect();
3417 self
3418 }
3419
3420 /// Sets the value of [group][crate::model::CacheUpdate::group].
3421 pub fn set_group<T, V>(mut self, v: T) -> Self
3422 where
3423 T: std::iter::IntoIterator<Item = V>,
3424 V: std::convert::Into<crate::model::Group>,
3425 {
3426 use std::iter::Iterator;
3427 self.group = v.into_iter().map(|i| i.into()).collect();
3428 self
3429 }
3430
3431 /// Sets the value of [key_recipes][crate::model::CacheUpdate::key_recipes].
3432 pub fn set_key_recipes<T>(mut self, v: T) -> Self
3433 where
3434 T: std::convert::Into<crate::model::RecipeList>,
3435 {
3436 self.key_recipes = std::option::Option::Some(v.into());
3437 self
3438 }
3439
3440 /// Sets or clears the value of [key_recipes][crate::model::CacheUpdate::key_recipes].
3441 pub fn set_or_clear_key_recipes<T>(mut self, v: std::option::Option<T>) -> Self
3442 where
3443 T: std::convert::Into<crate::model::RecipeList>,
3444 {
3445 self.key_recipes = v.map(|x| x.into());
3446 self
3447 }
3448}
3449
3450impl wkt::message::Message for CacheUpdate {
3451 fn typename() -> &'static str {
3452 "type.googleapis.com/google.spanner.v1.CacheUpdate"
3453 }
3454}
3455
3456/// `RoutingHint` can be optionally added to location-aware Spanner
3457/// requests. It gives the server hints that can be used to route the request to
3458/// an appropriate server, potentially significantly decreasing latency and
3459/// improving throughput. To achieve improved performance, most fields must be
3460/// filled in with accurate values.
3461///
3462/// The presence of a valid `RoutingHint` tells the server that the client
3463/// is location-aware.
3464///
3465/// `RoutingHint` does not change the semantics of the request; it is
3466/// purely a performance hint; the request will perform the same actions on the
3467/// database's data as if `RoutingHint` were not present. However, if
3468/// the `RoutingHint` is incomplete or incorrect, the response may include
3469/// a `CacheUpdate` the client can use to correct its location cache.
3470#[derive(Clone, Default, PartialEq)]
3471#[non_exhaustive]
3472pub struct RoutingHint {
3473 /// A session-scoped unique ID for the operation, computed client-side.
3474 /// Requests with the same `operation_uid` should have a shared 'shape',
3475 /// meaning that some fields are expected to be the same, such as the SQL
3476 /// query, the target table/columns (for reads) etc. Requests with the same
3477 /// `operation_uid` are meant to differ only in fields like keys/key
3478 /// ranges/query parameters, transaction IDs, etc.
3479 ///
3480 /// `operation_uid` must be non-zero for `RoutingHint` to be valid.
3481 pub operation_uid: u64,
3482
3483 /// The database ID of the database being accessed, see
3484 /// `CacheUpdate.database_id`. Should match the cache entries that were used
3485 /// to generate the rest of the fields in this `RoutingHint`.
3486 pub database_id: u64,
3487
3488 /// The schema generation of the recipe that was used to generate `key` and
3489 /// `limit_key`. See also `RecipeList.schema_generation`.
3490 pub schema_generation: ::bytes::Bytes,
3491
3492 /// The key / key range that this request accesses. For operations that
3493 /// access a single key, `key` should be set and `limit_key` should be empty.
3494 /// For operations that access a key range, `key` and `limit_key` should both
3495 /// be set, to the inclusive start and exclusive end of the range respectively.
3496 ///
3497 /// The keys are encoded in "sortable string format" (ssformat), using a
3498 /// `KeyRecipe` that is appropriate for the request. See `KeyRecipe` for more
3499 /// details.
3500 pub key: ::bytes::Bytes,
3501
3502 /// If this request targets a key range, this is the exclusive end of the
3503 /// range. See `key` for more details.
3504 pub limit_key: ::bytes::Bytes,
3505
3506 /// The group UID of the group that the client believes serves the range
3507 /// defined by `key` and `limit_key`. See `Range.group_uid` for more details.
3508 pub group_uid: u64,
3509
3510 /// The split ID of the split that the client believes contains the range
3511 /// defined by `key` and `limit_key`. See `Range.split_id` for more details.
3512 pub split_id: u64,
3513
3514 /// The tablet UID of the tablet from group `group_uid` that the client
3515 /// believes is best to serve this request. See `Group.local_tablet_uids` and
3516 /// `Group.leader_tablet_uid`.
3517 pub tablet_uid: u64,
3518
3519 /// If the client had multiple options for tablet selection, and some of its
3520 /// first choices were unhealthy (e.g., the server is unreachable, or
3521 /// `Tablet.skip` is true), this field will contain the tablet UIDs of those
3522 /// tablets, with their incarnations. The server may include a `CacheUpdate`
3523 /// with new locations for those tablets.
3524 pub skipped_tablet_uid: std::vec::Vec<crate::model::routing_hint::SkippedTablet>,
3525
3526 /// If present, the client's current location. This should be the name of a
3527 /// Google Cloud zone or region, such as "us-central1".
3528 ///
3529 /// If absent, the client's location will be assumed to be the same as the
3530 /// location of the server the client ends up connected to.
3531 ///
3532 /// Locations are primarily valuable for clients that connect from regions
3533 /// other than the ones that contain the Spanner database.
3534 pub client_location: std::string::String,
3535
3536 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3537}
3538
3539impl RoutingHint {
3540 /// Creates a new default instance.
3541 pub fn new() -> Self {
3542 std::default::Default::default()
3543 }
3544
3545 /// Sets the value of [operation_uid][crate::model::RoutingHint::operation_uid].
3546 pub fn set_operation_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3547 self.operation_uid = v.into();
3548 self
3549 }
3550
3551 /// Sets the value of [database_id][crate::model::RoutingHint::database_id].
3552 pub fn set_database_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3553 self.database_id = v.into();
3554 self
3555 }
3556
3557 /// Sets the value of [schema_generation][crate::model::RoutingHint::schema_generation].
3558 pub fn set_schema_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3559 self.schema_generation = v.into();
3560 self
3561 }
3562
3563 /// Sets the value of [key][crate::model::RoutingHint::key].
3564 pub fn set_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3565 self.key = v.into();
3566 self
3567 }
3568
3569 /// Sets the value of [limit_key][crate::model::RoutingHint::limit_key].
3570 pub fn set_limit_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3571 self.limit_key = v.into();
3572 self
3573 }
3574
3575 /// Sets the value of [group_uid][crate::model::RoutingHint::group_uid].
3576 pub fn set_group_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3577 self.group_uid = v.into();
3578 self
3579 }
3580
3581 /// Sets the value of [split_id][crate::model::RoutingHint::split_id].
3582 pub fn set_split_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3583 self.split_id = v.into();
3584 self
3585 }
3586
3587 /// Sets the value of [tablet_uid][crate::model::RoutingHint::tablet_uid].
3588 pub fn set_tablet_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3589 self.tablet_uid = v.into();
3590 self
3591 }
3592
3593 /// Sets the value of [skipped_tablet_uid][crate::model::RoutingHint::skipped_tablet_uid].
3594 pub fn set_skipped_tablet_uid<T, V>(mut self, v: T) -> Self
3595 where
3596 T: std::iter::IntoIterator<Item = V>,
3597 V: std::convert::Into<crate::model::routing_hint::SkippedTablet>,
3598 {
3599 use std::iter::Iterator;
3600 self.skipped_tablet_uid = v.into_iter().map(|i| i.into()).collect();
3601 self
3602 }
3603
3604 /// Sets the value of [client_location][crate::model::RoutingHint::client_location].
3605 pub fn set_client_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3606 self.client_location = v.into();
3607 self
3608 }
3609}
3610
3611impl wkt::message::Message for RoutingHint {
3612 fn typename() -> &'static str {
3613 "type.googleapis.com/google.spanner.v1.RoutingHint"
3614 }
3615}
3616
3617/// Defines additional types related to [RoutingHint].
3618pub mod routing_hint {
3619 #[allow(unused_imports)]
3620 use super::*;
3621
3622 /// A tablet that was skipped by the client. See `Tablet.tablet_uid` and
3623 /// `Tablet.incarnation`.
3624 #[derive(Clone, Default, PartialEq)]
3625 #[non_exhaustive]
3626 pub struct SkippedTablet {
3627 /// The tablet UID of the tablet that was skipped. See `Tablet.tablet_uid`.
3628 pub tablet_uid: u64,
3629
3630 /// The incarnation of the tablet that was skipped. See `Tablet.incarnation`.
3631 pub incarnation: ::bytes::Bytes,
3632
3633 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3634 }
3635
3636 impl SkippedTablet {
3637 /// Creates a new default instance.
3638 pub fn new() -> Self {
3639 std::default::Default::default()
3640 }
3641
3642 /// Sets the value of [tablet_uid][crate::model::routing_hint::SkippedTablet::tablet_uid].
3643 pub fn set_tablet_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3644 self.tablet_uid = v.into();
3645 self
3646 }
3647
3648 /// Sets the value of [incarnation][crate::model::routing_hint::SkippedTablet::incarnation].
3649 pub fn set_incarnation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3650 self.incarnation = v.into();
3651 self
3652 }
3653 }
3654
3655 impl wkt::message::Message for SkippedTablet {
3656 fn typename() -> &'static str {
3657 "type.googleapis.com/google.spanner.v1.RoutingHint.SkippedTablet"
3658 }
3659 }
3660}
3661
3662/// A modification to one or more Cloud Spanner rows. Mutations can be
3663/// applied to a Cloud Spanner database by sending them in a
3664/// [Commit][google.spanner.v1.Spanner.Commit] call.
3665///
3666/// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
3667#[derive(Clone, Default, PartialEq)]
3668#[non_exhaustive]
3669pub struct Mutation {
3670 /// Required. The operation to perform.
3671 pub operation: std::option::Option<crate::model::mutation::Operation>,
3672
3673 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3674}
3675
3676impl Mutation {
3677 /// Creates a new default instance.
3678 pub fn new() -> Self {
3679 std::default::Default::default()
3680 }
3681
3682 /// Sets the value of [operation][crate::model::Mutation::operation].
3683 ///
3684 /// Note that all the setters affecting `operation` are mutually
3685 /// exclusive.
3686 pub fn set_operation<
3687 T: std::convert::Into<std::option::Option<crate::model::mutation::Operation>>,
3688 >(
3689 mut self,
3690 v: T,
3691 ) -> Self {
3692 self.operation = v.into();
3693 self
3694 }
3695
3696 /// The value of [operation][crate::model::Mutation::operation]
3697 /// if it holds a `Insert`, `None` if the field is not set or
3698 /// holds a different branch.
3699 pub fn insert(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3700 #[allow(unreachable_patterns)]
3701 self.operation.as_ref().and_then(|v| match v {
3702 crate::model::mutation::Operation::Insert(v) => std::option::Option::Some(v),
3703 _ => std::option::Option::None,
3704 })
3705 }
3706
3707 /// Sets the value of [operation][crate::model::Mutation::operation]
3708 /// to hold a `Insert`.
3709 ///
3710 /// Note that all the setters affecting `operation` are
3711 /// mutually exclusive.
3712 pub fn set_insert<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>>(
3713 mut self,
3714 v: T,
3715 ) -> Self {
3716 self.operation =
3717 std::option::Option::Some(crate::model::mutation::Operation::Insert(v.into()));
3718 self
3719 }
3720
3721 /// The value of [operation][crate::model::Mutation::operation]
3722 /// if it holds a `Update`, `None` if the field is not set or
3723 /// holds a different branch.
3724 pub fn update(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3725 #[allow(unreachable_patterns)]
3726 self.operation.as_ref().and_then(|v| match v {
3727 crate::model::mutation::Operation::Update(v) => std::option::Option::Some(v),
3728 _ => std::option::Option::None,
3729 })
3730 }
3731
3732 /// Sets the value of [operation][crate::model::Mutation::operation]
3733 /// to hold a `Update`.
3734 ///
3735 /// Note that all the setters affecting `operation` are
3736 /// mutually exclusive.
3737 pub fn set_update<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>>(
3738 mut self,
3739 v: T,
3740 ) -> Self {
3741 self.operation =
3742 std::option::Option::Some(crate::model::mutation::Operation::Update(v.into()));
3743 self
3744 }
3745
3746 /// The value of [operation][crate::model::Mutation::operation]
3747 /// if it holds a `InsertOrUpdate`, `None` if the field is not set or
3748 /// holds a different branch.
3749 pub fn insert_or_update(
3750 &self,
3751 ) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3752 #[allow(unreachable_patterns)]
3753 self.operation.as_ref().and_then(|v| match v {
3754 crate::model::mutation::Operation::InsertOrUpdate(v) => std::option::Option::Some(v),
3755 _ => std::option::Option::None,
3756 })
3757 }
3758
3759 /// Sets the value of [operation][crate::model::Mutation::operation]
3760 /// to hold a `InsertOrUpdate`.
3761 ///
3762 /// Note that all the setters affecting `operation` are
3763 /// mutually exclusive.
3764 pub fn set_insert_or_update<
3765 T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
3766 >(
3767 mut self,
3768 v: T,
3769 ) -> Self {
3770 self.operation =
3771 std::option::Option::Some(crate::model::mutation::Operation::InsertOrUpdate(v.into()));
3772 self
3773 }
3774
3775 /// The value of [operation][crate::model::Mutation::operation]
3776 /// if it holds a `Replace`, `None` if the field is not set or
3777 /// holds a different branch.
3778 pub fn replace(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3779 #[allow(unreachable_patterns)]
3780 self.operation.as_ref().and_then(|v| match v {
3781 crate::model::mutation::Operation::Replace(v) => std::option::Option::Some(v),
3782 _ => std::option::Option::None,
3783 })
3784 }
3785
3786 /// Sets the value of [operation][crate::model::Mutation::operation]
3787 /// to hold a `Replace`.
3788 ///
3789 /// Note that all the setters affecting `operation` are
3790 /// mutually exclusive.
3791 pub fn set_replace<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>>(
3792 mut self,
3793 v: T,
3794 ) -> Self {
3795 self.operation =
3796 std::option::Option::Some(crate::model::mutation::Operation::Replace(v.into()));
3797 self
3798 }
3799
3800 /// The value of [operation][crate::model::Mutation::operation]
3801 /// if it holds a `Delete`, `None` if the field is not set or
3802 /// holds a different branch.
3803 pub fn delete(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Delete>> {
3804 #[allow(unreachable_patterns)]
3805 self.operation.as_ref().and_then(|v| match v {
3806 crate::model::mutation::Operation::Delete(v) => std::option::Option::Some(v),
3807 _ => std::option::Option::None,
3808 })
3809 }
3810
3811 /// Sets the value of [operation][crate::model::Mutation::operation]
3812 /// to hold a `Delete`.
3813 ///
3814 /// Note that all the setters affecting `operation` are
3815 /// mutually exclusive.
3816 pub fn set_delete<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Delete>>>(
3817 mut self,
3818 v: T,
3819 ) -> Self {
3820 self.operation =
3821 std::option::Option::Some(crate::model::mutation::Operation::Delete(v.into()));
3822 self
3823 }
3824
3825 /// The value of [operation][crate::model::Mutation::operation]
3826 /// if it holds a `Send`, `None` if the field is not set or
3827 /// holds a different branch.
3828 pub fn send(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Send>> {
3829 #[allow(unreachable_patterns)]
3830 self.operation.as_ref().and_then(|v| match v {
3831 crate::model::mutation::Operation::Send(v) => std::option::Option::Some(v),
3832 _ => std::option::Option::None,
3833 })
3834 }
3835
3836 /// Sets the value of [operation][crate::model::Mutation::operation]
3837 /// to hold a `Send`.
3838 ///
3839 /// Note that all the setters affecting `operation` are
3840 /// mutually exclusive.
3841 pub fn set_send<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Send>>>(
3842 mut self,
3843 v: T,
3844 ) -> Self {
3845 self.operation =
3846 std::option::Option::Some(crate::model::mutation::Operation::Send(v.into()));
3847 self
3848 }
3849
3850 /// The value of [operation][crate::model::Mutation::operation]
3851 /// if it holds a `Ack`, `None` if the field is not set or
3852 /// holds a different branch.
3853 pub fn ack(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Ack>> {
3854 #[allow(unreachable_patterns)]
3855 self.operation.as_ref().and_then(|v| match v {
3856 crate::model::mutation::Operation::Ack(v) => std::option::Option::Some(v),
3857 _ => std::option::Option::None,
3858 })
3859 }
3860
3861 /// Sets the value of [operation][crate::model::Mutation::operation]
3862 /// to hold a `Ack`.
3863 ///
3864 /// Note that all the setters affecting `operation` are
3865 /// mutually exclusive.
3866 pub fn set_ack<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Ack>>>(
3867 mut self,
3868 v: T,
3869 ) -> Self {
3870 self.operation =
3871 std::option::Option::Some(crate::model::mutation::Operation::Ack(v.into()));
3872 self
3873 }
3874}
3875
3876impl wkt::message::Message for Mutation {
3877 fn typename() -> &'static str {
3878 "type.googleapis.com/google.spanner.v1.Mutation"
3879 }
3880}
3881
3882/// Defines additional types related to [Mutation].
3883pub mod mutation {
3884 #[allow(unused_imports)]
3885 use super::*;
3886
3887 /// Arguments to [insert][google.spanner.v1.Mutation.insert],
3888 /// [update][google.spanner.v1.Mutation.update],
3889 /// [insert_or_update][google.spanner.v1.Mutation.insert_or_update], and
3890 /// [replace][google.spanner.v1.Mutation.replace] operations.
3891 ///
3892 /// [google.spanner.v1.Mutation.insert]: crate::model::Mutation::operation
3893 /// [google.spanner.v1.Mutation.insert_or_update]: crate::model::Mutation::operation
3894 /// [google.spanner.v1.Mutation.replace]: crate::model::Mutation::operation
3895 /// [google.spanner.v1.Mutation.update]: crate::model::Mutation::operation
3896 #[derive(Clone, Default, PartialEq)]
3897 #[non_exhaustive]
3898 pub struct Write {
3899 /// Required. The table whose rows will be written.
3900 pub table: std::string::String,
3901
3902 /// The names of the columns in
3903 /// [table][google.spanner.v1.Mutation.Write.table] to be written.
3904 ///
3905 /// The list of columns must contain enough columns to allow
3906 /// Cloud Spanner to derive values for all primary key columns in the
3907 /// row(s) to be modified.
3908 ///
3909 /// [google.spanner.v1.Mutation.Write.table]: crate::model::mutation::Write::table
3910 pub columns: std::vec::Vec<std::string::String>,
3911
3912 /// The values to be written. `values` can contain more than one
3913 /// list of values. If it does, then multiple rows are written, one
3914 /// for each entry in `values`. Each list in `values` must have
3915 /// exactly as many entries as there are entries in
3916 /// [columns][google.spanner.v1.Mutation.Write.columns] above. Sending
3917 /// multiple lists is equivalent to sending multiple `Mutation`s, each
3918 /// containing one `values` entry and repeating
3919 /// [table][google.spanner.v1.Mutation.Write.table] and
3920 /// [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in
3921 /// each list are encoded as described [here][google.spanner.v1.TypeCode].
3922 ///
3923 /// [google.spanner.v1.Mutation.Write.columns]: crate::model::mutation::Write::columns
3924 /// [google.spanner.v1.Mutation.Write.table]: crate::model::mutation::Write::table
3925 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
3926 pub values: std::vec::Vec<wkt::ListValue>,
3927
3928 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3929 }
3930
3931 impl Write {
3932 /// Creates a new default instance.
3933 pub fn new() -> Self {
3934 std::default::Default::default()
3935 }
3936
3937 /// Sets the value of [table][crate::model::mutation::Write::table].
3938 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3939 self.table = v.into();
3940 self
3941 }
3942
3943 /// Sets the value of [columns][crate::model::mutation::Write::columns].
3944 pub fn set_columns<T, V>(mut self, v: T) -> Self
3945 where
3946 T: std::iter::IntoIterator<Item = V>,
3947 V: std::convert::Into<std::string::String>,
3948 {
3949 use std::iter::Iterator;
3950 self.columns = v.into_iter().map(|i| i.into()).collect();
3951 self
3952 }
3953
3954 /// Sets the value of [values][crate::model::mutation::Write::values].
3955 pub fn set_values<T, V>(mut self, v: T) -> Self
3956 where
3957 T: std::iter::IntoIterator<Item = V>,
3958 V: std::convert::Into<wkt::ListValue>,
3959 {
3960 use std::iter::Iterator;
3961 self.values = v.into_iter().map(|i| i.into()).collect();
3962 self
3963 }
3964 }
3965
3966 impl wkt::message::Message for Write {
3967 fn typename() -> &'static str {
3968 "type.googleapis.com/google.spanner.v1.Mutation.Write"
3969 }
3970 }
3971
3972 /// Arguments to [delete][google.spanner.v1.Mutation.delete] operations.
3973 ///
3974 /// [google.spanner.v1.Mutation.delete]: crate::model::Mutation::operation
3975 #[derive(Clone, Default, PartialEq)]
3976 #[non_exhaustive]
3977 pub struct Delete {
3978 /// Required. The table whose rows will be deleted.
3979 pub table: std::string::String,
3980
3981 /// Required. The primary keys of the rows within
3982 /// [table][google.spanner.v1.Mutation.Delete.table] to delete. The primary
3983 /// keys must be specified in the order in which they appear in the `PRIMARY
3984 /// KEY()` clause of the table's equivalent DDL statement (the DDL statement
3985 /// used to create the table). Delete is idempotent. The transaction will
3986 /// succeed even if some or all rows do not exist.
3987 ///
3988 /// [google.spanner.v1.Mutation.Delete.table]: crate::model::mutation::Delete::table
3989 pub key_set: std::option::Option<crate::model::KeySet>,
3990
3991 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3992 }
3993
3994 impl Delete {
3995 /// Creates a new default instance.
3996 pub fn new() -> Self {
3997 std::default::Default::default()
3998 }
3999
4000 /// Sets the value of [table][crate::model::mutation::Delete::table].
4001 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4002 self.table = v.into();
4003 self
4004 }
4005
4006 /// Sets the value of [key_set][crate::model::mutation::Delete::key_set].
4007 pub fn set_key_set<T>(mut self, v: T) -> Self
4008 where
4009 T: std::convert::Into<crate::model::KeySet>,
4010 {
4011 self.key_set = std::option::Option::Some(v.into());
4012 self
4013 }
4014
4015 /// Sets or clears the value of [key_set][crate::model::mutation::Delete::key_set].
4016 pub fn set_or_clear_key_set<T>(mut self, v: std::option::Option<T>) -> Self
4017 where
4018 T: std::convert::Into<crate::model::KeySet>,
4019 {
4020 self.key_set = v.map(|x| x.into());
4021 self
4022 }
4023 }
4024
4025 impl wkt::message::Message for Delete {
4026 fn typename() -> &'static str {
4027 "type.googleapis.com/google.spanner.v1.Mutation.Delete"
4028 }
4029 }
4030
4031 /// Arguments to [send][google.spanner.v1.Mutation.send] operations.
4032 ///
4033 /// [google.spanner.v1.Mutation.send]: crate::model::Mutation::operation
4034 #[derive(Clone, Default, PartialEq)]
4035 #[non_exhaustive]
4036 pub struct Send {
4037 /// Required. The queue to which the message will be sent.
4038 pub queue: std::string::String,
4039
4040 /// Required. The primary key of the message to be sent.
4041 pub key: std::option::Option<wkt::ListValue>,
4042
4043 /// The time at which Spanner will begin attempting to deliver the message.
4044 /// If `deliver_time` is not set, Spanner will deliver the message
4045 /// immediately. If `deliver_time` is in the past, Spanner will replace it
4046 /// with a value closer to the current time.
4047 pub deliver_time: std::option::Option<wkt::Timestamp>,
4048
4049 /// The payload of the message.
4050 pub payload: std::option::Option<wkt::Value>,
4051
4052 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4053 }
4054
4055 impl Send {
4056 /// Creates a new default instance.
4057 pub fn new() -> Self {
4058 std::default::Default::default()
4059 }
4060
4061 /// Sets the value of [queue][crate::model::mutation::Send::queue].
4062 pub fn set_queue<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4063 self.queue = v.into();
4064 self
4065 }
4066
4067 /// Sets the value of [key][crate::model::mutation::Send::key].
4068 pub fn set_key<T>(mut self, v: T) -> Self
4069 where
4070 T: std::convert::Into<wkt::ListValue>,
4071 {
4072 self.key = std::option::Option::Some(v.into());
4073 self
4074 }
4075
4076 /// Sets or clears the value of [key][crate::model::mutation::Send::key].
4077 pub fn set_or_clear_key<T>(mut self, v: std::option::Option<T>) -> Self
4078 where
4079 T: std::convert::Into<wkt::ListValue>,
4080 {
4081 self.key = v.map(|x| x.into());
4082 self
4083 }
4084
4085 /// Sets the value of [deliver_time][crate::model::mutation::Send::deliver_time].
4086 pub fn set_deliver_time<T>(mut self, v: T) -> Self
4087 where
4088 T: std::convert::Into<wkt::Timestamp>,
4089 {
4090 self.deliver_time = std::option::Option::Some(v.into());
4091 self
4092 }
4093
4094 /// Sets or clears the value of [deliver_time][crate::model::mutation::Send::deliver_time].
4095 pub fn set_or_clear_deliver_time<T>(mut self, v: std::option::Option<T>) -> Self
4096 where
4097 T: std::convert::Into<wkt::Timestamp>,
4098 {
4099 self.deliver_time = v.map(|x| x.into());
4100 self
4101 }
4102
4103 /// Sets the value of [payload][crate::model::mutation::Send::payload].
4104 pub fn set_payload<T>(mut self, v: T) -> Self
4105 where
4106 T: std::convert::Into<wkt::Value>,
4107 {
4108 self.payload = std::option::Option::Some(v.into());
4109 self
4110 }
4111
4112 /// Sets or clears the value of [payload][crate::model::mutation::Send::payload].
4113 pub fn set_or_clear_payload<T>(mut self, v: std::option::Option<T>) -> Self
4114 where
4115 T: std::convert::Into<wkt::Value>,
4116 {
4117 self.payload = v.map(|x| x.into());
4118 self
4119 }
4120 }
4121
4122 impl wkt::message::Message for Send {
4123 fn typename() -> &'static str {
4124 "type.googleapis.com/google.spanner.v1.Mutation.Send"
4125 }
4126 }
4127
4128 /// Arguments to [ack][google.spanner.v1.Mutation.ack] operations.
4129 ///
4130 /// [google.spanner.v1.Mutation.ack]: crate::model::Mutation::operation
4131 #[derive(Clone, Default, PartialEq)]
4132 #[non_exhaustive]
4133 pub struct Ack {
4134 /// Required. The queue where the message to be acked is stored.
4135 pub queue: std::string::String,
4136
4137 /// Required. The primary key of the message to be acked.
4138 pub key: std::option::Option<wkt::ListValue>,
4139
4140 /// By default, an attempt to ack a message that does not exist will fail
4141 /// with a `NOT_FOUND` error. With `ignore_not_found` set to true, the ack
4142 /// will succeed even if the message does not exist. This is useful for
4143 /// unconditionally acking a message, even if it is missing or has already
4144 /// been acked.
4145 pub ignore_not_found: bool,
4146
4147 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4148 }
4149
4150 impl Ack {
4151 /// Creates a new default instance.
4152 pub fn new() -> Self {
4153 std::default::Default::default()
4154 }
4155
4156 /// Sets the value of [queue][crate::model::mutation::Ack::queue].
4157 pub fn set_queue<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4158 self.queue = v.into();
4159 self
4160 }
4161
4162 /// Sets the value of [key][crate::model::mutation::Ack::key].
4163 pub fn set_key<T>(mut self, v: T) -> Self
4164 where
4165 T: std::convert::Into<wkt::ListValue>,
4166 {
4167 self.key = std::option::Option::Some(v.into());
4168 self
4169 }
4170
4171 /// Sets or clears the value of [key][crate::model::mutation::Ack::key].
4172 pub fn set_or_clear_key<T>(mut self, v: std::option::Option<T>) -> Self
4173 where
4174 T: std::convert::Into<wkt::ListValue>,
4175 {
4176 self.key = v.map(|x| x.into());
4177 self
4178 }
4179
4180 /// Sets the value of [ignore_not_found][crate::model::mutation::Ack::ignore_not_found].
4181 pub fn set_ignore_not_found<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4182 self.ignore_not_found = v.into();
4183 self
4184 }
4185 }
4186
4187 impl wkt::message::Message for Ack {
4188 fn typename() -> &'static str {
4189 "type.googleapis.com/google.spanner.v1.Mutation.Ack"
4190 }
4191 }
4192
4193 /// Required. The operation to perform.
4194 #[derive(Clone, Debug, PartialEq)]
4195 #[non_exhaustive]
4196 pub enum Operation {
4197 /// Insert new rows in a table. If any of the rows already exist,
4198 /// the write or transaction fails with error `ALREADY_EXISTS`.
4199 Insert(std::boxed::Box<crate::model::mutation::Write>),
4200 /// Update existing rows in a table. If any of the rows does not
4201 /// already exist, the transaction fails with error `NOT_FOUND`.
4202 Update(std::boxed::Box<crate::model::mutation::Write>),
4203 /// Like [insert][google.spanner.v1.Mutation.insert], except that if the row
4204 /// already exists, then its column values are overwritten with the ones
4205 /// provided. Any column values not explicitly written are preserved.
4206 ///
4207 /// When using
4208 /// [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as
4209 /// when using [insert][google.spanner.v1.Mutation.insert], all `NOT NULL`
4210 /// columns in the table must be given a value. This holds true even when the
4211 /// row already exists and will therefore actually be updated.
4212 ///
4213 /// [google.spanner.v1.Mutation.insert]: crate::model::Mutation::operation
4214 /// [google.spanner.v1.Mutation.insert_or_update]: crate::model::Mutation::operation
4215 InsertOrUpdate(std::boxed::Box<crate::model::mutation::Write>),
4216 /// Like [insert][google.spanner.v1.Mutation.insert], except that if the row
4217 /// already exists, it is deleted, and the column values provided are
4218 /// inserted instead. Unlike
4219 /// [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this
4220 /// means any values not explicitly written become `NULL`.
4221 ///
4222 /// In an interleaved table, if you create the child table with the
4223 /// `ON DELETE CASCADE` annotation, then replacing a parent row
4224 /// also deletes the child rows. Otherwise, you must delete the
4225 /// child rows before you replace the parent row.
4226 ///
4227 /// [google.spanner.v1.Mutation.insert]: crate::model::Mutation::operation
4228 /// [google.spanner.v1.Mutation.insert_or_update]: crate::model::Mutation::operation
4229 Replace(std::boxed::Box<crate::model::mutation::Write>),
4230 /// Delete rows from a table. Succeeds whether or not the named
4231 /// rows were present.
4232 Delete(std::boxed::Box<crate::model::mutation::Delete>),
4233 /// Send a message to a queue.
4234 Send(std::boxed::Box<crate::model::mutation::Send>),
4235 /// Ack a message from a queue.
4236 Ack(std::boxed::Box<crate::model::mutation::Ack>),
4237 }
4238
4239 impl Operation {
4240 /// Initializes the enum to the [Insert](Self::Insert) branch.
4241 pub fn from_insert(
4242 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4243 ) -> Self {
4244 Self::Insert(value.into())
4245 }
4246 /// Initializes the enum to the [Update](Self::Update) branch.
4247 pub fn from_update(
4248 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4249 ) -> Self {
4250 Self::Update(value.into())
4251 }
4252 /// Initializes the enum to the [InsertOrUpdate](Self::InsertOrUpdate) branch.
4253 pub fn from_insert_or_update(
4254 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4255 ) -> Self {
4256 Self::InsertOrUpdate(value.into())
4257 }
4258 /// Initializes the enum to the [Replace](Self::Replace) branch.
4259 pub fn from_replace(
4260 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4261 ) -> Self {
4262 Self::Replace(value.into())
4263 }
4264 /// Initializes the enum to the [Delete](Self::Delete) branch.
4265 pub fn from_delete(
4266 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Delete>>,
4267 ) -> Self {
4268 Self::Delete(value.into())
4269 }
4270 /// Initializes the enum to the [Send](Self::Send) branch.
4271 pub fn from_send(
4272 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Send>>,
4273 ) -> Self {
4274 Self::Send(value.into())
4275 }
4276 /// Initializes the enum to the [Ack](Self::Ack) branch.
4277 pub fn from_ack(
4278 value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Ack>>,
4279 ) -> Self {
4280 Self::Ack(value.into())
4281 }
4282 }
4283}
4284
4285/// Node information for nodes appearing in a
4286/// [QueryPlan.plan_nodes][google.spanner.v1.QueryPlan.plan_nodes].
4287///
4288/// [google.spanner.v1.QueryPlan.plan_nodes]: crate::model::QueryPlan::plan_nodes
4289#[derive(Clone, Default, PartialEq)]
4290#[non_exhaustive]
4291pub struct PlanNode {
4292 /// The `PlanNode`'s index in [node
4293 /// list][google.spanner.v1.QueryPlan.plan_nodes].
4294 ///
4295 /// [google.spanner.v1.QueryPlan.plan_nodes]: crate::model::QueryPlan::plan_nodes
4296 pub index: i32,
4297
4298 /// Used to determine the type of node. May be needed for visualizing
4299 /// different kinds of nodes differently. For example, If the node is a
4300 /// [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a
4301 /// condensed representation which can be used to directly embed a description
4302 /// of the node in its parent.
4303 ///
4304 /// [google.spanner.v1.PlanNode.Kind.SCALAR]: crate::model::plan_node::Kind::Scalar
4305 pub kind: crate::model::plan_node::Kind,
4306
4307 /// The display name for the node.
4308 pub display_name: std::string::String,
4309
4310 /// List of child node `index`es and their relationship to this parent.
4311 pub child_links: std::vec::Vec<crate::model::plan_node::ChildLink>,
4312
4313 /// Condensed representation for
4314 /// [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes.
4315 ///
4316 /// [google.spanner.v1.PlanNode.Kind.SCALAR]: crate::model::plan_node::Kind::Scalar
4317 pub short_representation: std::option::Option<crate::model::plan_node::ShortRepresentation>,
4318
4319 /// Attributes relevant to the node contained in a group of key-value pairs.
4320 /// For example, a Parameter Reference node could have the following
4321 /// information in its metadata:
4322 ///
4323 /// ```norust
4324 /// {
4325 /// "parameter_reference": "param1",
4326 /// "parameter_type": "array"
4327 /// }
4328 /// ```
4329 pub metadata: std::option::Option<wkt::Struct>,
4330
4331 /// The execution statistics associated with the node, contained in a group of
4332 /// key-value pairs. Only present if the plan was returned as a result of a
4333 /// profile query. For example, number of executions, number of rows/time per
4334 /// execution etc.
4335 pub execution_stats: std::option::Option<wkt::Struct>,
4336
4337 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4338}
4339
4340impl PlanNode {
4341 /// Creates a new default instance.
4342 pub fn new() -> Self {
4343 std::default::Default::default()
4344 }
4345
4346 /// Sets the value of [index][crate::model::PlanNode::index].
4347 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4348 self.index = v.into();
4349 self
4350 }
4351
4352 /// Sets the value of [kind][crate::model::PlanNode::kind].
4353 pub fn set_kind<T: std::convert::Into<crate::model::plan_node::Kind>>(mut self, v: T) -> Self {
4354 self.kind = v.into();
4355 self
4356 }
4357
4358 /// Sets the value of [display_name][crate::model::PlanNode::display_name].
4359 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4360 self.display_name = v.into();
4361 self
4362 }
4363
4364 /// Sets the value of [child_links][crate::model::PlanNode::child_links].
4365 pub fn set_child_links<T, V>(mut self, v: T) -> Self
4366 where
4367 T: std::iter::IntoIterator<Item = V>,
4368 V: std::convert::Into<crate::model::plan_node::ChildLink>,
4369 {
4370 use std::iter::Iterator;
4371 self.child_links = v.into_iter().map(|i| i.into()).collect();
4372 self
4373 }
4374
4375 /// Sets the value of [short_representation][crate::model::PlanNode::short_representation].
4376 pub fn set_short_representation<T>(mut self, v: T) -> Self
4377 where
4378 T: std::convert::Into<crate::model::plan_node::ShortRepresentation>,
4379 {
4380 self.short_representation = std::option::Option::Some(v.into());
4381 self
4382 }
4383
4384 /// Sets or clears the value of [short_representation][crate::model::PlanNode::short_representation].
4385 pub fn set_or_clear_short_representation<T>(mut self, v: std::option::Option<T>) -> Self
4386 where
4387 T: std::convert::Into<crate::model::plan_node::ShortRepresentation>,
4388 {
4389 self.short_representation = v.map(|x| x.into());
4390 self
4391 }
4392
4393 /// Sets the value of [metadata][crate::model::PlanNode::metadata].
4394 pub fn set_metadata<T>(mut self, v: T) -> Self
4395 where
4396 T: std::convert::Into<wkt::Struct>,
4397 {
4398 self.metadata = std::option::Option::Some(v.into());
4399 self
4400 }
4401
4402 /// Sets or clears the value of [metadata][crate::model::PlanNode::metadata].
4403 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
4404 where
4405 T: std::convert::Into<wkt::Struct>,
4406 {
4407 self.metadata = v.map(|x| x.into());
4408 self
4409 }
4410
4411 /// Sets the value of [execution_stats][crate::model::PlanNode::execution_stats].
4412 pub fn set_execution_stats<T>(mut self, v: T) -> Self
4413 where
4414 T: std::convert::Into<wkt::Struct>,
4415 {
4416 self.execution_stats = std::option::Option::Some(v.into());
4417 self
4418 }
4419
4420 /// Sets or clears the value of [execution_stats][crate::model::PlanNode::execution_stats].
4421 pub fn set_or_clear_execution_stats<T>(mut self, v: std::option::Option<T>) -> Self
4422 where
4423 T: std::convert::Into<wkt::Struct>,
4424 {
4425 self.execution_stats = v.map(|x| x.into());
4426 self
4427 }
4428}
4429
4430impl wkt::message::Message for PlanNode {
4431 fn typename() -> &'static str {
4432 "type.googleapis.com/google.spanner.v1.PlanNode"
4433 }
4434}
4435
4436/// Defines additional types related to [PlanNode].
4437pub mod plan_node {
4438 #[allow(unused_imports)]
4439 use super::*;
4440
4441 /// Metadata associated with a parent-child relationship appearing in a
4442 /// [PlanNode][google.spanner.v1.PlanNode].
4443 ///
4444 /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4445 #[derive(Clone, Default, PartialEq)]
4446 #[non_exhaustive]
4447 pub struct ChildLink {
4448 /// The node to which the link points.
4449 pub child_index: i32,
4450
4451 /// The type of the link. For example, in Hash Joins this could be used to
4452 /// distinguish between the build child and the probe child, or in the case
4453 /// of the child being an output variable, to represent the tag associated
4454 /// with the output variable.
4455 pub r#type: std::string::String,
4456
4457 /// Only present if the child node is
4458 /// [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds to an
4459 /// output variable of the parent node. The field carries the name of the
4460 /// output variable. For example, a `TableScan` operator that reads rows from
4461 /// a table will have child links to the `SCALAR` nodes representing the
4462 /// output variables created for each column that is read by the operator.
4463 /// The corresponding `variable` fields will be set to the variable names
4464 /// assigned to the columns.
4465 ///
4466 /// [google.spanner.v1.PlanNode.Kind.SCALAR]: crate::model::plan_node::Kind::Scalar
4467 pub variable: std::string::String,
4468
4469 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4470 }
4471
4472 impl ChildLink {
4473 /// Creates a new default instance.
4474 pub fn new() -> Self {
4475 std::default::Default::default()
4476 }
4477
4478 /// Sets the value of [child_index][crate::model::plan_node::ChildLink::child_index].
4479 pub fn set_child_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4480 self.child_index = v.into();
4481 self
4482 }
4483
4484 /// Sets the value of [r#type][crate::model::plan_node::ChildLink::type].
4485 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4486 self.r#type = v.into();
4487 self
4488 }
4489
4490 /// Sets the value of [variable][crate::model::plan_node::ChildLink::variable].
4491 pub fn set_variable<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4492 self.variable = v.into();
4493 self
4494 }
4495 }
4496
4497 impl wkt::message::Message for ChildLink {
4498 fn typename() -> &'static str {
4499 "type.googleapis.com/google.spanner.v1.PlanNode.ChildLink"
4500 }
4501 }
4502
4503 /// Condensed representation of a node and its subtree. Only present for
4504 /// `SCALAR` [PlanNode(s)][google.spanner.v1.PlanNode].
4505 ///
4506 /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4507 #[derive(Clone, Default, PartialEq)]
4508 #[non_exhaustive]
4509 pub struct ShortRepresentation {
4510 /// A string representation of the expression subtree rooted at this node.
4511 pub description: std::string::String,
4512
4513 /// A mapping of (subquery variable name) -> (subquery node id) for cases
4514 /// where the `description` string of this node references a `SCALAR`
4515 /// subquery contained in the expression subtree rooted at this node. The
4516 /// referenced `SCALAR` subquery may not necessarily be a direct child of
4517 /// this node.
4518 pub subqueries: std::collections::HashMap<std::string::String, i32>,
4519
4520 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4521 }
4522
4523 impl ShortRepresentation {
4524 /// Creates a new default instance.
4525 pub fn new() -> Self {
4526 std::default::Default::default()
4527 }
4528
4529 /// Sets the value of [description][crate::model::plan_node::ShortRepresentation::description].
4530 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4531 self.description = v.into();
4532 self
4533 }
4534
4535 /// Sets the value of [subqueries][crate::model::plan_node::ShortRepresentation::subqueries].
4536 pub fn set_subqueries<T, K, V>(mut self, v: T) -> Self
4537 where
4538 T: std::iter::IntoIterator<Item = (K, V)>,
4539 K: std::convert::Into<std::string::String>,
4540 V: std::convert::Into<i32>,
4541 {
4542 use std::iter::Iterator;
4543 self.subqueries = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4544 self
4545 }
4546 }
4547
4548 impl wkt::message::Message for ShortRepresentation {
4549 fn typename() -> &'static str {
4550 "type.googleapis.com/google.spanner.v1.PlanNode.ShortRepresentation"
4551 }
4552 }
4553
4554 /// The kind of [PlanNode][google.spanner.v1.PlanNode]. Distinguishes between
4555 /// the two different kinds of nodes that can appear in a query plan.
4556 ///
4557 /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4558 ///
4559 /// # Working with unknown values
4560 ///
4561 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4562 /// additional enum variants at any time. Adding new variants is not considered
4563 /// a breaking change. Applications should write their code in anticipation of:
4564 ///
4565 /// - New values appearing in future releases of the client library, **and**
4566 /// - New values received dynamically, without application changes.
4567 ///
4568 /// Please consult the [Working with enums] section in the user guide for some
4569 /// guidelines.
4570 ///
4571 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4572 #[derive(Clone, Debug, PartialEq)]
4573 #[non_exhaustive]
4574 pub enum Kind {
4575 /// Not specified.
4576 Unspecified,
4577 /// Denotes a Relational operator node in the expression tree. Relational
4578 /// operators represent iterative processing of rows during query execution.
4579 /// For example, a `TableScan` operation that reads rows from a table.
4580 Relational,
4581 /// Denotes a Scalar node in the expression tree. Scalar nodes represent
4582 /// non-iterable entities in the query plan. For example, constants or
4583 /// arithmetic operators appearing inside predicate expressions or references
4584 /// to column names.
4585 Scalar,
4586 /// If set, the enum was initialized with an unknown value.
4587 ///
4588 /// Applications can examine the value using [Kind::value] or
4589 /// [Kind::name].
4590 UnknownValue(kind::UnknownValue),
4591 }
4592
4593 #[doc(hidden)]
4594 pub mod kind {
4595 #[allow(unused_imports)]
4596 use super::*;
4597 #[derive(Clone, Debug, PartialEq)]
4598 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4599 }
4600
4601 impl Kind {
4602 /// Gets the enum value.
4603 ///
4604 /// Returns `None` if the enum contains an unknown value deserialized from
4605 /// the string representation of enums.
4606 pub fn value(&self) -> std::option::Option<i32> {
4607 match self {
4608 Self::Unspecified => std::option::Option::Some(0),
4609 Self::Relational => std::option::Option::Some(1),
4610 Self::Scalar => std::option::Option::Some(2),
4611 Self::UnknownValue(u) => u.0.value(),
4612 }
4613 }
4614
4615 /// Gets the enum value as a string.
4616 ///
4617 /// Returns `None` if the enum contains an unknown value deserialized from
4618 /// the integer representation of enums.
4619 pub fn name(&self) -> std::option::Option<&str> {
4620 match self {
4621 Self::Unspecified => std::option::Option::Some("KIND_UNSPECIFIED"),
4622 Self::Relational => std::option::Option::Some("RELATIONAL"),
4623 Self::Scalar => std::option::Option::Some("SCALAR"),
4624 Self::UnknownValue(u) => u.0.name(),
4625 }
4626 }
4627 }
4628
4629 impl std::default::Default for Kind {
4630 fn default() -> Self {
4631 use std::convert::From;
4632 Self::from(0)
4633 }
4634 }
4635
4636 impl std::fmt::Display for Kind {
4637 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4638 wkt::internal::display_enum(f, self.name(), self.value())
4639 }
4640 }
4641
4642 impl std::convert::From<i32> for Kind {
4643 fn from(value: i32) -> Self {
4644 match value {
4645 0 => Self::Unspecified,
4646 1 => Self::Relational,
4647 2 => Self::Scalar,
4648 _ => Self::UnknownValue(kind::UnknownValue(
4649 wkt::internal::UnknownEnumValue::Integer(value),
4650 )),
4651 }
4652 }
4653 }
4654
4655 impl std::convert::From<&str> for Kind {
4656 fn from(value: &str) -> Self {
4657 use std::string::ToString;
4658 match value {
4659 "KIND_UNSPECIFIED" => Self::Unspecified,
4660 "RELATIONAL" => Self::Relational,
4661 "SCALAR" => Self::Scalar,
4662 _ => Self::UnknownValue(kind::UnknownValue(
4663 wkt::internal::UnknownEnumValue::String(value.to_string()),
4664 )),
4665 }
4666 }
4667 }
4668
4669 impl serde::ser::Serialize for Kind {
4670 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4671 where
4672 S: serde::Serializer,
4673 {
4674 match self {
4675 Self::Unspecified => serializer.serialize_i32(0),
4676 Self::Relational => serializer.serialize_i32(1),
4677 Self::Scalar => serializer.serialize_i32(2),
4678 Self::UnknownValue(u) => u.0.serialize(serializer),
4679 }
4680 }
4681 }
4682
4683 impl<'de> serde::de::Deserialize<'de> for Kind {
4684 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4685 where
4686 D: serde::Deserializer<'de>,
4687 {
4688 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Kind>::new(
4689 ".google.spanner.v1.PlanNode.Kind",
4690 ))
4691 }
4692 }
4693}
4694
4695/// Output of query advisor analysis.
4696#[derive(Clone, Default, PartialEq)]
4697#[non_exhaustive]
4698pub struct QueryAdvisorResult {
4699 /// Optional. Index Recommendation for a query. This is an optional field and
4700 /// the recommendation will only be available when the recommendation
4701 /// guarantees significant improvement in query performance.
4702 pub index_advice: std::vec::Vec<crate::model::query_advisor_result::IndexAdvice>,
4703
4704 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4705}
4706
4707impl QueryAdvisorResult {
4708 /// Creates a new default instance.
4709 pub fn new() -> Self {
4710 std::default::Default::default()
4711 }
4712
4713 /// Sets the value of [index_advice][crate::model::QueryAdvisorResult::index_advice].
4714 pub fn set_index_advice<T, V>(mut self, v: T) -> Self
4715 where
4716 T: std::iter::IntoIterator<Item = V>,
4717 V: std::convert::Into<crate::model::query_advisor_result::IndexAdvice>,
4718 {
4719 use std::iter::Iterator;
4720 self.index_advice = v.into_iter().map(|i| i.into()).collect();
4721 self
4722 }
4723}
4724
4725impl wkt::message::Message for QueryAdvisorResult {
4726 fn typename() -> &'static str {
4727 "type.googleapis.com/google.spanner.v1.QueryAdvisorResult"
4728 }
4729}
4730
4731/// Defines additional types related to [QueryAdvisorResult].
4732pub mod query_advisor_result {
4733 #[allow(unused_imports)]
4734 use super::*;
4735
4736 /// Recommendation to add new indexes to run queries more efficiently.
4737 #[derive(Clone, Default, PartialEq)]
4738 #[non_exhaustive]
4739 pub struct IndexAdvice {
4740 /// Optional. DDL statements to add new indexes that will improve the query.
4741 pub ddl: std::vec::Vec<std::string::String>,
4742
4743 /// Optional. Estimated latency improvement factor. For example if the query
4744 /// currently takes 500 ms to run and the estimated latency with new indexes
4745 /// is 100 ms this field will be 5.
4746 pub improvement_factor: f64,
4747
4748 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4749 }
4750
4751 impl IndexAdvice {
4752 /// Creates a new default instance.
4753 pub fn new() -> Self {
4754 std::default::Default::default()
4755 }
4756
4757 /// Sets the value of [ddl][crate::model::query_advisor_result::IndexAdvice::ddl].
4758 pub fn set_ddl<T, V>(mut self, v: T) -> Self
4759 where
4760 T: std::iter::IntoIterator<Item = V>,
4761 V: std::convert::Into<std::string::String>,
4762 {
4763 use std::iter::Iterator;
4764 self.ddl = v.into_iter().map(|i| i.into()).collect();
4765 self
4766 }
4767
4768 /// Sets the value of [improvement_factor][crate::model::query_advisor_result::IndexAdvice::improvement_factor].
4769 pub fn set_improvement_factor<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4770 self.improvement_factor = v.into();
4771 self
4772 }
4773 }
4774
4775 impl wkt::message::Message for IndexAdvice {
4776 fn typename() -> &'static str {
4777 "type.googleapis.com/google.spanner.v1.QueryAdvisorResult.IndexAdvice"
4778 }
4779 }
4780}
4781
4782/// Contains an ordered list of nodes appearing in the query plan.
4783#[derive(Clone, Default, PartialEq)]
4784#[non_exhaustive]
4785pub struct QueryPlan {
4786 /// The nodes in the query plan. Plan nodes are returned in pre-order starting
4787 /// with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id`
4788 /// corresponds to its index in `plan_nodes`.
4789 ///
4790 /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4791 pub plan_nodes: std::vec::Vec<crate::model::PlanNode>,
4792
4793 /// Optional. The advise/recommendations for a query. Currently this field will
4794 /// be serving index recommendations for a query.
4795 pub query_advice: std::option::Option<crate::model::QueryAdvisorResult>,
4796
4797 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4798}
4799
4800impl QueryPlan {
4801 /// Creates a new default instance.
4802 pub fn new() -> Self {
4803 std::default::Default::default()
4804 }
4805
4806 /// Sets the value of [plan_nodes][crate::model::QueryPlan::plan_nodes].
4807 pub fn set_plan_nodes<T, V>(mut self, v: T) -> Self
4808 where
4809 T: std::iter::IntoIterator<Item = V>,
4810 V: std::convert::Into<crate::model::PlanNode>,
4811 {
4812 use std::iter::Iterator;
4813 self.plan_nodes = v.into_iter().map(|i| i.into()).collect();
4814 self
4815 }
4816
4817 /// Sets the value of [query_advice][crate::model::QueryPlan::query_advice].
4818 pub fn set_query_advice<T>(mut self, v: T) -> Self
4819 where
4820 T: std::convert::Into<crate::model::QueryAdvisorResult>,
4821 {
4822 self.query_advice = std::option::Option::Some(v.into());
4823 self
4824 }
4825
4826 /// Sets or clears the value of [query_advice][crate::model::QueryPlan::query_advice].
4827 pub fn set_or_clear_query_advice<T>(mut self, v: std::option::Option<T>) -> Self
4828 where
4829 T: std::convert::Into<crate::model::QueryAdvisorResult>,
4830 {
4831 self.query_advice = v.map(|x| x.into());
4832 self
4833 }
4834}
4835
4836impl wkt::message::Message for QueryPlan {
4837 fn typename() -> &'static str {
4838 "type.googleapis.com/google.spanner.v1.QueryPlan"
4839 }
4840}
4841
4842/// Results from [Read][google.spanner.v1.Spanner.Read] or
4843/// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
4844///
4845/// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
4846/// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
4847#[derive(Clone, Default, PartialEq)]
4848#[non_exhaustive]
4849pub struct ResultSet {
4850 /// Metadata about the result set, such as row type information.
4851 pub metadata: std::option::Option<crate::model::ResultSetMetadata>,
4852
4853 /// Each element in `rows` is a row whose format is defined by
4854 /// [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
4855 /// element in each row matches the ith field in
4856 /// [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
4857 /// are encoded based on type as described [here][google.spanner.v1.TypeCode].
4858 ///
4859 /// [google.spanner.v1.ResultSetMetadata.row_type]: crate::model::ResultSetMetadata::row_type
4860 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
4861 pub rows: std::vec::Vec<wkt::ListValue>,
4862
4863 /// Query plan and execution statistics for the SQL statement that
4864 /// produced this result set. These can be requested by setting
4865 /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
4866 /// DML statements always produce stats containing the number of rows
4867 /// modified, unless executed using the
4868 /// [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
4869 /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
4870 /// Other fields might or might not be populated, based on the
4871 /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
4872 ///
4873 /// [google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]: crate::model::execute_sql_request::QueryMode::Plan
4874 /// [google.spanner.v1.ExecuteSqlRequest.query_mode]: crate::model::ExecuteSqlRequest::query_mode
4875 pub stats: std::option::Option<crate::model::ResultSetStats>,
4876
4877 /// Optional. A precommit token is included if the read-write transaction is on
4878 /// a multiplexed session. Pass the precommit token with the highest sequence
4879 /// number from this transaction attempt to the
4880 /// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
4881 ///
4882 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
4883 pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
4884
4885 /// Optional. A cache update expresses a set of changes the client should
4886 /// incorporate into its location cache. The client should discard the changes
4887 /// if they are older than the data it already has. This data can be obtained
4888 /// in response to requests that included a `RoutingHint` field, but may also
4889 /// be obtained by explicit location-fetching RPCs which may be added in the
4890 /// future.
4891 pub cache_update: std::option::Option<crate::model::CacheUpdate>,
4892
4893 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4894}
4895
4896impl ResultSet {
4897 /// Creates a new default instance.
4898 pub fn new() -> Self {
4899 std::default::Default::default()
4900 }
4901
4902 /// Sets the value of [metadata][crate::model::ResultSet::metadata].
4903 pub fn set_metadata<T>(mut self, v: T) -> Self
4904 where
4905 T: std::convert::Into<crate::model::ResultSetMetadata>,
4906 {
4907 self.metadata = std::option::Option::Some(v.into());
4908 self
4909 }
4910
4911 /// Sets or clears the value of [metadata][crate::model::ResultSet::metadata].
4912 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
4913 where
4914 T: std::convert::Into<crate::model::ResultSetMetadata>,
4915 {
4916 self.metadata = v.map(|x| x.into());
4917 self
4918 }
4919
4920 /// Sets the value of [rows][crate::model::ResultSet::rows].
4921 pub fn set_rows<T, V>(mut self, v: T) -> Self
4922 where
4923 T: std::iter::IntoIterator<Item = V>,
4924 V: std::convert::Into<wkt::ListValue>,
4925 {
4926 use std::iter::Iterator;
4927 self.rows = v.into_iter().map(|i| i.into()).collect();
4928 self
4929 }
4930
4931 /// Sets the value of [stats][crate::model::ResultSet::stats].
4932 pub fn set_stats<T>(mut self, v: T) -> Self
4933 where
4934 T: std::convert::Into<crate::model::ResultSetStats>,
4935 {
4936 self.stats = std::option::Option::Some(v.into());
4937 self
4938 }
4939
4940 /// Sets or clears the value of [stats][crate::model::ResultSet::stats].
4941 pub fn set_or_clear_stats<T>(mut self, v: std::option::Option<T>) -> Self
4942 where
4943 T: std::convert::Into<crate::model::ResultSetStats>,
4944 {
4945 self.stats = v.map(|x| x.into());
4946 self
4947 }
4948
4949 /// Sets the value of [precommit_token][crate::model::ResultSet::precommit_token].
4950 pub fn set_precommit_token<T>(mut self, v: T) -> Self
4951 where
4952 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
4953 {
4954 self.precommit_token = std::option::Option::Some(v.into());
4955 self
4956 }
4957
4958 /// Sets or clears the value of [precommit_token][crate::model::ResultSet::precommit_token].
4959 pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
4960 where
4961 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
4962 {
4963 self.precommit_token = v.map(|x| x.into());
4964 self
4965 }
4966
4967 /// Sets the value of [cache_update][crate::model::ResultSet::cache_update].
4968 pub fn set_cache_update<T>(mut self, v: T) -> Self
4969 where
4970 T: std::convert::Into<crate::model::CacheUpdate>,
4971 {
4972 self.cache_update = std::option::Option::Some(v.into());
4973 self
4974 }
4975
4976 /// Sets or clears the value of [cache_update][crate::model::ResultSet::cache_update].
4977 pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
4978 where
4979 T: std::convert::Into<crate::model::CacheUpdate>,
4980 {
4981 self.cache_update = v.map(|x| x.into());
4982 self
4983 }
4984}
4985
4986impl wkt::message::Message for ResultSet {
4987 fn typename() -> &'static str {
4988 "type.googleapis.com/google.spanner.v1.ResultSet"
4989 }
4990}
4991
4992/// Partial results from a streaming read or SQL query. Streaming reads and
4993/// SQL queries better tolerate large result sets, large rows, and large
4994/// values, but are a little trickier to consume.
4995#[derive(Clone, Default, PartialEq)]
4996#[non_exhaustive]
4997pub struct PartialResultSet {
4998 /// Metadata about the result set, such as row type information.
4999 /// Only present in the first response.
5000 pub metadata: std::option::Option<crate::model::ResultSetMetadata>,
5001
5002 /// A streamed result set consists of a stream of values, which might
5003 /// be split into many `PartialResultSet` messages to accommodate
5004 /// large rows and/or large values. Every N complete values defines a
5005 /// row, where N is equal to the number of entries in
5006 /// [metadata.row_type.fields][google.spanner.v1.StructType.fields].
5007 ///
5008 /// Most values are encoded based on type as described
5009 /// [here][google.spanner.v1.TypeCode].
5010 ///
5011 /// It's possible that the last value in values is "chunked",
5012 /// meaning that the rest of the value is sent in subsequent
5013 /// `PartialResultSet`(s). This is denoted by the
5014 /// [chunked_value][google.spanner.v1.PartialResultSet.chunked_value] field.
5015 /// Two or more chunked values can be merged to form a complete value as
5016 /// follows:
5017 ///
5018 /// * `bool/number/null`: can't be chunked
5019 /// * `string`: concatenate the strings
5020 /// * `list`: concatenate the lists. If the last element in a list is a
5021 /// `string`, `list`, or `object`, merge it with the first element in
5022 /// the next list by applying these rules recursively.
5023 /// * `object`: concatenate the (field name, field value) pairs. If a
5024 /// field name is duplicated, then apply these rules recursively
5025 /// to merge the field values.
5026 ///
5027 /// Some examples of merging:
5028 ///
5029 /// ```norust
5030 /// Strings are concatenated.
5031 /// "foo", "bar" => "foobar"
5032 ///
5033 /// Lists of non-strings are concatenated.
5034 /// [2, 3], [4] => [2, 3, 4]
5035 ///
5036 /// Lists are concatenated, but the last and first elements are merged
5037 /// because they are strings.
5038 /// ["a", "b"], ["c", "d"] => ["a", "bc", "d"]
5039 ///
5040 /// Lists are concatenated, but the last and first elements are merged
5041 /// because they are lists. Recursively, the last and first elements
5042 /// of the inner lists are merged because they are strings.
5043 /// ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"]
5044 ///
5045 /// Non-overlapping object fields are combined.
5046 /// {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"}
5047 ///
5048 /// Overlapping object fields are merged.
5049 /// {"a": "1"}, {"a": "2"} => {"a": "12"}
5050 ///
5051 /// Examples of merging objects containing lists of strings.
5052 /// {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]}
5053 /// ```
5054 ///
5055 /// For a more complete example, suppose a streaming SQL query is
5056 /// yielding a result set whose rows contain a single string
5057 /// field. The following `PartialResultSet`s might be yielded:
5058 ///
5059 /// ```norust
5060 /// {
5061 /// "metadata": { ... }
5062 /// "values": ["Hello", "W"]
5063 /// "chunked_value": true
5064 /// "resume_token": "Af65..."
5065 /// }
5066 /// {
5067 /// "values": ["orl"]
5068 /// "chunked_value": true
5069 /// }
5070 /// {
5071 /// "values": ["d"]
5072 /// "resume_token": "Zx1B..."
5073 /// }
5074 /// ```
5075 ///
5076 /// This sequence of `PartialResultSet`s encodes two rows, one
5077 /// containing the field value `"Hello"`, and a second containing the
5078 /// field value `"World" = "W" + "orl" + "d"`.
5079 ///
5080 /// Not all `PartialResultSet`s contain a `resume_token`. Execution can only be
5081 /// resumed from a previously yielded `resume_token`. For the above sequence of
5082 /// `PartialResultSet`s, resuming the query with `"resume_token": "Af65..."`
5083 /// yields results from the `PartialResultSet` with value "orl".
5084 ///
5085 /// [google.spanner.v1.PartialResultSet.chunked_value]: crate::model::PartialResultSet::chunked_value
5086 /// [google.spanner.v1.StructType.fields]: crate::model::StructType::fields
5087 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
5088 pub values: std::vec::Vec<wkt::Value>,
5089
5090 /// If true, then the final value in
5091 /// [values][google.spanner.v1.PartialResultSet.values] is chunked, and must be
5092 /// combined with more values from subsequent `PartialResultSet`s to obtain a
5093 /// complete field value.
5094 ///
5095 /// [google.spanner.v1.PartialResultSet.values]: crate::model::PartialResultSet::values
5096 pub chunked_value: bool,
5097
5098 /// Streaming calls might be interrupted for a variety of reasons, such
5099 /// as TCP connection loss. If this occurs, the stream of results can
5100 /// be resumed by re-sending the original request and including
5101 /// `resume_token`. Note that executing any other transaction in the
5102 /// same session invalidates the token.
5103 pub resume_token: ::bytes::Bytes,
5104
5105 /// Query plan and execution statistics for the statement that produced this
5106 /// streaming result set. These can be requested by setting
5107 /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]
5108 /// and are sent only once with the last response in the stream. This field is
5109 /// also present in the last response for DML statements.
5110 ///
5111 /// [google.spanner.v1.ExecuteSqlRequest.query_mode]: crate::model::ExecuteSqlRequest::query_mode
5112 pub stats: std::option::Option<crate::model::ResultSetStats>,
5113
5114 /// Optional. A precommit token is included if the read-write transaction
5115 /// has multiplexed sessions enabled. Pass the precommit token with the highest
5116 /// sequence number from this transaction attempt to the
5117 /// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
5118 ///
5119 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
5120 pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
5121
5122 /// Optional. Indicates whether this is the last `PartialResultSet` in the
5123 /// stream. The server might optionally set this field. Clients shouldn't rely
5124 /// on this field being set in all cases.
5125 pub last: bool,
5126
5127 /// Optional. A cache update expresses a set of changes the client should
5128 /// incorporate into its location cache. The client should discard the changes
5129 /// if they are older than the data it already has. This data can be obtained
5130 /// in response to requests that included a `RoutingHint` field, but may also
5131 /// be obtained by explicit location-fetching RPCs which may be added in the
5132 /// future.
5133 pub cache_update: std::option::Option<crate::model::CacheUpdate>,
5134
5135 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5136}
5137
5138impl PartialResultSet {
5139 /// Creates a new default instance.
5140 pub fn new() -> Self {
5141 std::default::Default::default()
5142 }
5143
5144 /// Sets the value of [metadata][crate::model::PartialResultSet::metadata].
5145 pub fn set_metadata<T>(mut self, v: T) -> Self
5146 where
5147 T: std::convert::Into<crate::model::ResultSetMetadata>,
5148 {
5149 self.metadata = std::option::Option::Some(v.into());
5150 self
5151 }
5152
5153 /// Sets or clears the value of [metadata][crate::model::PartialResultSet::metadata].
5154 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
5155 where
5156 T: std::convert::Into<crate::model::ResultSetMetadata>,
5157 {
5158 self.metadata = v.map(|x| x.into());
5159 self
5160 }
5161
5162 /// Sets the value of [values][crate::model::PartialResultSet::values].
5163 pub fn set_values<T, V>(mut self, v: T) -> Self
5164 where
5165 T: std::iter::IntoIterator<Item = V>,
5166 V: std::convert::Into<wkt::Value>,
5167 {
5168 use std::iter::Iterator;
5169 self.values = v.into_iter().map(|i| i.into()).collect();
5170 self
5171 }
5172
5173 /// Sets the value of [chunked_value][crate::model::PartialResultSet::chunked_value].
5174 pub fn set_chunked_value<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5175 self.chunked_value = v.into();
5176 self
5177 }
5178
5179 /// Sets the value of [resume_token][crate::model::PartialResultSet::resume_token].
5180 pub fn set_resume_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
5181 self.resume_token = v.into();
5182 self
5183 }
5184
5185 /// Sets the value of [stats][crate::model::PartialResultSet::stats].
5186 pub fn set_stats<T>(mut self, v: T) -> Self
5187 where
5188 T: std::convert::Into<crate::model::ResultSetStats>,
5189 {
5190 self.stats = std::option::Option::Some(v.into());
5191 self
5192 }
5193
5194 /// Sets or clears the value of [stats][crate::model::PartialResultSet::stats].
5195 pub fn set_or_clear_stats<T>(mut self, v: std::option::Option<T>) -> Self
5196 where
5197 T: std::convert::Into<crate::model::ResultSetStats>,
5198 {
5199 self.stats = v.map(|x| x.into());
5200 self
5201 }
5202
5203 /// Sets the value of [precommit_token][crate::model::PartialResultSet::precommit_token].
5204 pub fn set_precommit_token<T>(mut self, v: T) -> Self
5205 where
5206 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
5207 {
5208 self.precommit_token = std::option::Option::Some(v.into());
5209 self
5210 }
5211
5212 /// Sets or clears the value of [precommit_token][crate::model::PartialResultSet::precommit_token].
5213 pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
5214 where
5215 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
5216 {
5217 self.precommit_token = v.map(|x| x.into());
5218 self
5219 }
5220
5221 /// Sets the value of [last][crate::model::PartialResultSet::last].
5222 pub fn set_last<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5223 self.last = v.into();
5224 self
5225 }
5226
5227 /// Sets the value of [cache_update][crate::model::PartialResultSet::cache_update].
5228 pub fn set_cache_update<T>(mut self, v: T) -> Self
5229 where
5230 T: std::convert::Into<crate::model::CacheUpdate>,
5231 {
5232 self.cache_update = std::option::Option::Some(v.into());
5233 self
5234 }
5235
5236 /// Sets or clears the value of [cache_update][crate::model::PartialResultSet::cache_update].
5237 pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
5238 where
5239 T: std::convert::Into<crate::model::CacheUpdate>,
5240 {
5241 self.cache_update = v.map(|x| x.into());
5242 self
5243 }
5244}
5245
5246impl wkt::message::Message for PartialResultSet {
5247 fn typename() -> &'static str {
5248 "type.googleapis.com/google.spanner.v1.PartialResultSet"
5249 }
5250}
5251
5252/// Metadata about a [ResultSet][google.spanner.v1.ResultSet] or
5253/// [PartialResultSet][google.spanner.v1.PartialResultSet].
5254///
5255/// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
5256/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
5257#[derive(Clone, Default, PartialEq)]
5258#[non_exhaustive]
5259pub struct ResultSetMetadata {
5260 /// Indicates the field names and types for the rows in the result
5261 /// set. For example, a SQL query like `"SELECT UserId, UserName FROM
5262 /// Users"` could return a `row_type` value like:
5263 ///
5264 /// ```norust
5265 /// "fields": [
5266 /// { "name": "UserId", "type": { "code": "INT64" } },
5267 /// { "name": "UserName", "type": { "code": "STRING" } },
5268 /// ]
5269 /// ```
5270 pub row_type: std::option::Option<crate::model::StructType>,
5271
5272 /// If the read or SQL query began a transaction as a side-effect, the
5273 /// information about the new transaction is yielded here.
5274 pub transaction: std::option::Option<crate::model::Transaction>,
5275
5276 /// A SQL query can be parameterized. In PLAN mode, these parameters can be
5277 /// undeclared. This indicates the field names and types for those undeclared
5278 /// parameters in the SQL query. For example, a SQL query like `"SELECT * FROM
5279 /// Users where UserId = @userId and UserName = @userName "` could return a
5280 /// `undeclared_parameters` value like:
5281 ///
5282 /// ```norust
5283 /// "fields": [
5284 /// { "name": "UserId", "type": { "code": "INT64" } },
5285 /// { "name": "UserName", "type": { "code": "STRING" } },
5286 /// ]
5287 /// ```
5288 pub undeclared_parameters: std::option::Option<crate::model::StructType>,
5289
5290 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5291}
5292
5293impl ResultSetMetadata {
5294 /// Creates a new default instance.
5295 pub fn new() -> Self {
5296 std::default::Default::default()
5297 }
5298
5299 /// Sets the value of [row_type][crate::model::ResultSetMetadata::row_type].
5300 pub fn set_row_type<T>(mut self, v: T) -> Self
5301 where
5302 T: std::convert::Into<crate::model::StructType>,
5303 {
5304 self.row_type = std::option::Option::Some(v.into());
5305 self
5306 }
5307
5308 /// Sets or clears the value of [row_type][crate::model::ResultSetMetadata::row_type].
5309 pub fn set_or_clear_row_type<T>(mut self, v: std::option::Option<T>) -> Self
5310 where
5311 T: std::convert::Into<crate::model::StructType>,
5312 {
5313 self.row_type = v.map(|x| x.into());
5314 self
5315 }
5316
5317 /// Sets the value of [transaction][crate::model::ResultSetMetadata::transaction].
5318 pub fn set_transaction<T>(mut self, v: T) -> Self
5319 where
5320 T: std::convert::Into<crate::model::Transaction>,
5321 {
5322 self.transaction = std::option::Option::Some(v.into());
5323 self
5324 }
5325
5326 /// Sets or clears the value of [transaction][crate::model::ResultSetMetadata::transaction].
5327 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
5328 where
5329 T: std::convert::Into<crate::model::Transaction>,
5330 {
5331 self.transaction = v.map(|x| x.into());
5332 self
5333 }
5334
5335 /// Sets the value of [undeclared_parameters][crate::model::ResultSetMetadata::undeclared_parameters].
5336 pub fn set_undeclared_parameters<T>(mut self, v: T) -> Self
5337 where
5338 T: std::convert::Into<crate::model::StructType>,
5339 {
5340 self.undeclared_parameters = std::option::Option::Some(v.into());
5341 self
5342 }
5343
5344 /// Sets or clears the value of [undeclared_parameters][crate::model::ResultSetMetadata::undeclared_parameters].
5345 pub fn set_or_clear_undeclared_parameters<T>(mut self, v: std::option::Option<T>) -> Self
5346 where
5347 T: std::convert::Into<crate::model::StructType>,
5348 {
5349 self.undeclared_parameters = v.map(|x| x.into());
5350 self
5351 }
5352}
5353
5354impl wkt::message::Message for ResultSetMetadata {
5355 fn typename() -> &'static str {
5356 "type.googleapis.com/google.spanner.v1.ResultSetMetadata"
5357 }
5358}
5359
5360/// Additional statistics about a [ResultSet][google.spanner.v1.ResultSet] or
5361/// [PartialResultSet][google.spanner.v1.PartialResultSet].
5362///
5363/// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
5364/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
5365#[derive(Clone, Default, PartialEq)]
5366#[non_exhaustive]
5367pub struct ResultSetStats {
5368 /// [QueryPlan][google.spanner.v1.QueryPlan] for the query associated with this
5369 /// result.
5370 ///
5371 /// [google.spanner.v1.QueryPlan]: crate::model::QueryPlan
5372 pub query_plan: std::option::Option<crate::model::QueryPlan>,
5373
5374 /// Aggregated statistics from the execution of the query. Only present when
5375 /// the query is profiled. For example, a query could return the statistics as
5376 /// follows:
5377 ///
5378 /// ```norust
5379 /// {
5380 /// "rows_returned": "3",
5381 /// "elapsed_time": "1.22 secs",
5382 /// "cpu_time": "1.19 secs"
5383 /// }
5384 /// ```
5385 pub query_stats: std::option::Option<wkt::Struct>,
5386
5387 /// The number of rows modified by the DML statement.
5388 pub row_count: std::option::Option<crate::model::result_set_stats::RowCount>,
5389
5390 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5391}
5392
5393impl ResultSetStats {
5394 /// Creates a new default instance.
5395 pub fn new() -> Self {
5396 std::default::Default::default()
5397 }
5398
5399 /// Sets the value of [query_plan][crate::model::ResultSetStats::query_plan].
5400 pub fn set_query_plan<T>(mut self, v: T) -> Self
5401 where
5402 T: std::convert::Into<crate::model::QueryPlan>,
5403 {
5404 self.query_plan = std::option::Option::Some(v.into());
5405 self
5406 }
5407
5408 /// Sets or clears the value of [query_plan][crate::model::ResultSetStats::query_plan].
5409 pub fn set_or_clear_query_plan<T>(mut self, v: std::option::Option<T>) -> Self
5410 where
5411 T: std::convert::Into<crate::model::QueryPlan>,
5412 {
5413 self.query_plan = v.map(|x| x.into());
5414 self
5415 }
5416
5417 /// Sets the value of [query_stats][crate::model::ResultSetStats::query_stats].
5418 pub fn set_query_stats<T>(mut self, v: T) -> Self
5419 where
5420 T: std::convert::Into<wkt::Struct>,
5421 {
5422 self.query_stats = std::option::Option::Some(v.into());
5423 self
5424 }
5425
5426 /// Sets or clears the value of [query_stats][crate::model::ResultSetStats::query_stats].
5427 pub fn set_or_clear_query_stats<T>(mut self, v: std::option::Option<T>) -> Self
5428 where
5429 T: std::convert::Into<wkt::Struct>,
5430 {
5431 self.query_stats = v.map(|x| x.into());
5432 self
5433 }
5434
5435 /// Sets the value of [row_count][crate::model::ResultSetStats::row_count].
5436 ///
5437 /// Note that all the setters affecting `row_count` are mutually
5438 /// exclusive.
5439 pub fn set_row_count<
5440 T: std::convert::Into<std::option::Option<crate::model::result_set_stats::RowCount>>,
5441 >(
5442 mut self,
5443 v: T,
5444 ) -> Self {
5445 self.row_count = v.into();
5446 self
5447 }
5448
5449 /// The value of [row_count][crate::model::ResultSetStats::row_count]
5450 /// if it holds a `RowCountExact`, `None` if the field is not set or
5451 /// holds a different branch.
5452 pub fn row_count_exact(&self) -> std::option::Option<&i64> {
5453 #[allow(unreachable_patterns)]
5454 self.row_count.as_ref().and_then(|v| match v {
5455 crate::model::result_set_stats::RowCount::RowCountExact(v) => {
5456 std::option::Option::Some(v)
5457 }
5458 _ => std::option::Option::None,
5459 })
5460 }
5461
5462 /// Sets the value of [row_count][crate::model::ResultSetStats::row_count]
5463 /// to hold a `RowCountExact`.
5464 ///
5465 /// Note that all the setters affecting `row_count` are
5466 /// mutually exclusive.
5467 pub fn set_row_count_exact<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5468 self.row_count = std::option::Option::Some(
5469 crate::model::result_set_stats::RowCount::RowCountExact(v.into()),
5470 );
5471 self
5472 }
5473
5474 /// The value of [row_count][crate::model::ResultSetStats::row_count]
5475 /// if it holds a `RowCountLowerBound`, `None` if the field is not set or
5476 /// holds a different branch.
5477 pub fn row_count_lower_bound(&self) -> std::option::Option<&i64> {
5478 #[allow(unreachable_patterns)]
5479 self.row_count.as_ref().and_then(|v| match v {
5480 crate::model::result_set_stats::RowCount::RowCountLowerBound(v) => {
5481 std::option::Option::Some(v)
5482 }
5483 _ => std::option::Option::None,
5484 })
5485 }
5486
5487 /// Sets the value of [row_count][crate::model::ResultSetStats::row_count]
5488 /// to hold a `RowCountLowerBound`.
5489 ///
5490 /// Note that all the setters affecting `row_count` are
5491 /// mutually exclusive.
5492 pub fn set_row_count_lower_bound<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5493 self.row_count = std::option::Option::Some(
5494 crate::model::result_set_stats::RowCount::RowCountLowerBound(v.into()),
5495 );
5496 self
5497 }
5498}
5499
5500impl wkt::message::Message for ResultSetStats {
5501 fn typename() -> &'static str {
5502 "type.googleapis.com/google.spanner.v1.ResultSetStats"
5503 }
5504}
5505
5506/// Defines additional types related to [ResultSetStats].
5507pub mod result_set_stats {
5508 #[allow(unused_imports)]
5509 use super::*;
5510
5511 /// The number of rows modified by the DML statement.
5512 #[derive(Clone, Debug, PartialEq)]
5513 #[non_exhaustive]
5514 pub enum RowCount {
5515 /// Standard DML returns an exact count of rows that were modified.
5516 RowCountExact(i64),
5517 /// Partitioned DML doesn't offer exactly-once semantics, so it
5518 /// returns a lower bound of the rows modified.
5519 RowCountLowerBound(i64),
5520 }
5521
5522 impl RowCount {
5523 /// Initializes the enum to the [RowCountExact](Self::RowCountExact) branch.
5524 pub fn from_row_count_exact(value: impl std::convert::Into<i64>) -> Self {
5525 Self::RowCountExact(value.into())
5526 }
5527 /// Initializes the enum to the [RowCountLowerBound](Self::RowCountLowerBound) branch.
5528 pub fn from_row_count_lower_bound(value: impl std::convert::Into<i64>) -> Self {
5529 Self::RowCountLowerBound(value.into())
5530 }
5531 }
5532}
5533
5534/// The request for [CreateSession][google.spanner.v1.Spanner.CreateSession].
5535///
5536/// [google.spanner.v1.Spanner.CreateSession]: crate::client::Spanner::create_session
5537#[derive(Clone, Default, PartialEq)]
5538#[non_exhaustive]
5539pub struct CreateSessionRequest {
5540 /// Required. The database in which the new session is created.
5541 pub database: std::string::String,
5542
5543 /// Required. The session to create.
5544 pub session: std::option::Option<crate::model::Session>,
5545
5546 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5547}
5548
5549impl CreateSessionRequest {
5550 /// Creates a new default instance.
5551 pub fn new() -> Self {
5552 std::default::Default::default()
5553 }
5554
5555 /// Sets the value of [database][crate::model::CreateSessionRequest::database].
5556 pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5557 self.database = v.into();
5558 self
5559 }
5560
5561 /// Sets the value of [session][crate::model::CreateSessionRequest::session].
5562 pub fn set_session<T>(mut self, v: T) -> Self
5563 where
5564 T: std::convert::Into<crate::model::Session>,
5565 {
5566 self.session = std::option::Option::Some(v.into());
5567 self
5568 }
5569
5570 /// Sets or clears the value of [session][crate::model::CreateSessionRequest::session].
5571 pub fn set_or_clear_session<T>(mut self, v: std::option::Option<T>) -> Self
5572 where
5573 T: std::convert::Into<crate::model::Session>,
5574 {
5575 self.session = v.map(|x| x.into());
5576 self
5577 }
5578}
5579
5580impl wkt::message::Message for CreateSessionRequest {
5581 fn typename() -> &'static str {
5582 "type.googleapis.com/google.spanner.v1.CreateSessionRequest"
5583 }
5584}
5585
5586/// The request for
5587/// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
5588///
5589/// [google.spanner.v1.Spanner.BatchCreateSessions]: crate::client::Spanner::batch_create_sessions
5590#[derive(Clone, Default, PartialEq)]
5591#[non_exhaustive]
5592pub struct BatchCreateSessionsRequest {
5593 /// Required. The database in which the new sessions are created.
5594 pub database: std::string::String,
5595
5596 /// Parameters to apply to each created session.
5597 pub session_template: std::option::Option<crate::model::Session>,
5598
5599 /// Required. The number of sessions to be created in this batch call. At least
5600 /// one session is created. The API can return fewer than the requested number
5601 /// of sessions. If a specific number of sessions are desired, the client can
5602 /// make additional calls to `BatchCreateSessions` (adjusting
5603 /// [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count]
5604 /// as necessary).
5605 ///
5606 /// [google.spanner.v1.BatchCreateSessionsRequest.session_count]: crate::model::BatchCreateSessionsRequest::session_count
5607 pub session_count: i32,
5608
5609 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5610}
5611
5612impl BatchCreateSessionsRequest {
5613 /// Creates a new default instance.
5614 pub fn new() -> Self {
5615 std::default::Default::default()
5616 }
5617
5618 /// Sets the value of [database][crate::model::BatchCreateSessionsRequest::database].
5619 pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5620 self.database = v.into();
5621 self
5622 }
5623
5624 /// Sets the value of [session_template][crate::model::BatchCreateSessionsRequest::session_template].
5625 pub fn set_session_template<T>(mut self, v: T) -> Self
5626 where
5627 T: std::convert::Into<crate::model::Session>,
5628 {
5629 self.session_template = std::option::Option::Some(v.into());
5630 self
5631 }
5632
5633 /// Sets or clears the value of [session_template][crate::model::BatchCreateSessionsRequest::session_template].
5634 pub fn set_or_clear_session_template<T>(mut self, v: std::option::Option<T>) -> Self
5635 where
5636 T: std::convert::Into<crate::model::Session>,
5637 {
5638 self.session_template = v.map(|x| x.into());
5639 self
5640 }
5641
5642 /// Sets the value of [session_count][crate::model::BatchCreateSessionsRequest::session_count].
5643 pub fn set_session_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5644 self.session_count = v.into();
5645 self
5646 }
5647}
5648
5649impl wkt::message::Message for BatchCreateSessionsRequest {
5650 fn typename() -> &'static str {
5651 "type.googleapis.com/google.spanner.v1.BatchCreateSessionsRequest"
5652 }
5653}
5654
5655/// The response for
5656/// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
5657///
5658/// [google.spanner.v1.Spanner.BatchCreateSessions]: crate::client::Spanner::batch_create_sessions
5659#[derive(Clone, Default, PartialEq)]
5660#[non_exhaustive]
5661pub struct BatchCreateSessionsResponse {
5662 /// The freshly created sessions.
5663 pub session: std::vec::Vec<crate::model::Session>,
5664
5665 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5666}
5667
5668impl BatchCreateSessionsResponse {
5669 /// Creates a new default instance.
5670 pub fn new() -> Self {
5671 std::default::Default::default()
5672 }
5673
5674 /// Sets the value of [session][crate::model::BatchCreateSessionsResponse::session].
5675 pub fn set_session<T, V>(mut self, v: T) -> Self
5676 where
5677 T: std::iter::IntoIterator<Item = V>,
5678 V: std::convert::Into<crate::model::Session>,
5679 {
5680 use std::iter::Iterator;
5681 self.session = v.into_iter().map(|i| i.into()).collect();
5682 self
5683 }
5684}
5685
5686impl wkt::message::Message for BatchCreateSessionsResponse {
5687 fn typename() -> &'static str {
5688 "type.googleapis.com/google.spanner.v1.BatchCreateSessionsResponse"
5689 }
5690}
5691
5692/// A session in the Cloud Spanner API.
5693#[derive(Clone, Default, PartialEq)]
5694#[non_exhaustive]
5695pub struct Session {
5696 /// Output only. The name of the session. This is always system-assigned.
5697 pub name: std::string::String,
5698
5699 /// The labels for the session.
5700 ///
5701 /// * Label keys must be between 1 and 63 characters long and must conform to
5702 /// the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.
5703 /// * Label values must be between 0 and 63 characters long and must conform
5704 /// to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
5705 /// * No more than 64 labels can be associated with a given session.
5706 ///
5707 /// See <https://goo.gl/xmQnxf> for more information on and examples of labels.
5708 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
5709
5710 /// Output only. The timestamp when the session is created.
5711 pub create_time: std::option::Option<wkt::Timestamp>,
5712
5713 /// Output only. The approximate timestamp when the session is last used. It's
5714 /// typically earlier than the actual last use time.
5715 pub approximate_last_use_time: std::option::Option<wkt::Timestamp>,
5716
5717 /// The database role which created this session.
5718 pub creator_role: std::string::String,
5719
5720 /// Optional. If `true`, specifies a multiplexed session. Use a multiplexed
5721 /// session for multiple, concurrent operations including any combination of
5722 /// read-only and read-write transactions. Use
5723 /// [`sessions.create`][google.spanner.v1.Spanner.CreateSession] to create
5724 /// multiplexed sessions. Don't use
5725 /// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions] to
5726 /// create a multiplexed session. You can't delete or list multiplexed
5727 /// sessions.
5728 ///
5729 /// [google.spanner.v1.Spanner.BatchCreateSessions]: crate::client::Spanner::batch_create_sessions
5730 /// [google.spanner.v1.Spanner.CreateSession]: crate::client::Spanner::create_session
5731 pub multiplexed: bool,
5732
5733 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5734}
5735
5736impl Session {
5737 /// Creates a new default instance.
5738 pub fn new() -> Self {
5739 std::default::Default::default()
5740 }
5741
5742 /// Sets the value of [name][crate::model::Session::name].
5743 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5744 self.name = v.into();
5745 self
5746 }
5747
5748 /// Sets the value of [labels][crate::model::Session::labels].
5749 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
5750 where
5751 T: std::iter::IntoIterator<Item = (K, V)>,
5752 K: std::convert::Into<std::string::String>,
5753 V: std::convert::Into<std::string::String>,
5754 {
5755 use std::iter::Iterator;
5756 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5757 self
5758 }
5759
5760 /// Sets the value of [create_time][crate::model::Session::create_time].
5761 pub fn set_create_time<T>(mut self, v: T) -> Self
5762 where
5763 T: std::convert::Into<wkt::Timestamp>,
5764 {
5765 self.create_time = std::option::Option::Some(v.into());
5766 self
5767 }
5768
5769 /// Sets or clears the value of [create_time][crate::model::Session::create_time].
5770 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
5771 where
5772 T: std::convert::Into<wkt::Timestamp>,
5773 {
5774 self.create_time = v.map(|x| x.into());
5775 self
5776 }
5777
5778 /// Sets the value of [approximate_last_use_time][crate::model::Session::approximate_last_use_time].
5779 pub fn set_approximate_last_use_time<T>(mut self, v: T) -> Self
5780 where
5781 T: std::convert::Into<wkt::Timestamp>,
5782 {
5783 self.approximate_last_use_time = std::option::Option::Some(v.into());
5784 self
5785 }
5786
5787 /// Sets or clears the value of [approximate_last_use_time][crate::model::Session::approximate_last_use_time].
5788 pub fn set_or_clear_approximate_last_use_time<T>(mut self, v: std::option::Option<T>) -> Self
5789 where
5790 T: std::convert::Into<wkt::Timestamp>,
5791 {
5792 self.approximate_last_use_time = v.map(|x| x.into());
5793 self
5794 }
5795
5796 /// Sets the value of [creator_role][crate::model::Session::creator_role].
5797 pub fn set_creator_role<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5798 self.creator_role = v.into();
5799 self
5800 }
5801
5802 /// Sets the value of [multiplexed][crate::model::Session::multiplexed].
5803 pub fn set_multiplexed<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5804 self.multiplexed = v.into();
5805 self
5806 }
5807}
5808
5809impl wkt::message::Message for Session {
5810 fn typename() -> &'static str {
5811 "type.googleapis.com/google.spanner.v1.Session"
5812 }
5813}
5814
5815/// The request for [GetSession][google.spanner.v1.Spanner.GetSession].
5816///
5817/// [google.spanner.v1.Spanner.GetSession]: crate::client::Spanner::get_session
5818#[derive(Clone, Default, PartialEq)]
5819#[non_exhaustive]
5820pub struct GetSessionRequest {
5821 /// Required. The name of the session to retrieve.
5822 pub name: std::string::String,
5823
5824 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5825}
5826
5827impl GetSessionRequest {
5828 /// Creates a new default instance.
5829 pub fn new() -> Self {
5830 std::default::Default::default()
5831 }
5832
5833 /// Sets the value of [name][crate::model::GetSessionRequest::name].
5834 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5835 self.name = v.into();
5836 self
5837 }
5838}
5839
5840impl wkt::message::Message for GetSessionRequest {
5841 fn typename() -> &'static str {
5842 "type.googleapis.com/google.spanner.v1.GetSessionRequest"
5843 }
5844}
5845
5846/// The request for [ListSessions][google.spanner.v1.Spanner.ListSessions].
5847///
5848/// [google.spanner.v1.Spanner.ListSessions]: crate::client::Spanner::list_sessions
5849#[derive(Clone, Default, PartialEq)]
5850#[non_exhaustive]
5851pub struct ListSessionsRequest {
5852 /// Required. The database in which to list sessions.
5853 pub database: std::string::String,
5854
5855 /// Number of sessions to be returned in the response. If 0 or less, defaults
5856 /// to the server's maximum allowed page size.
5857 pub page_size: i32,
5858
5859 /// If non-empty, `page_token` should contain a
5860 /// [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token]
5861 /// from a previous
5862 /// [ListSessionsResponse][google.spanner.v1.ListSessionsResponse].
5863 ///
5864 /// [google.spanner.v1.ListSessionsResponse]: crate::model::ListSessionsResponse
5865 /// [google.spanner.v1.ListSessionsResponse.next_page_token]: crate::model::ListSessionsResponse::next_page_token
5866 pub page_token: std::string::String,
5867
5868 /// An expression for filtering the results of the request. Filter rules are
5869 /// case insensitive. The fields eligible for filtering are:
5870 ///
5871 /// * `labels.key` where key is the name of a label
5872 ///
5873 /// Some examples of using filters are:
5874 ///
5875 /// * `labels.env:*` --> The session has the label "env".
5876 /// * `labels.env:dev` --> The session has the label "env" and the value of
5877 /// the label contains the string "dev".
5878 pub filter: std::string::String,
5879
5880 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5881}
5882
5883impl ListSessionsRequest {
5884 /// Creates a new default instance.
5885 pub fn new() -> Self {
5886 std::default::Default::default()
5887 }
5888
5889 /// Sets the value of [database][crate::model::ListSessionsRequest::database].
5890 pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5891 self.database = v.into();
5892 self
5893 }
5894
5895 /// Sets the value of [page_size][crate::model::ListSessionsRequest::page_size].
5896 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5897 self.page_size = v.into();
5898 self
5899 }
5900
5901 /// Sets the value of [page_token][crate::model::ListSessionsRequest::page_token].
5902 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5903 self.page_token = v.into();
5904 self
5905 }
5906
5907 /// Sets the value of [filter][crate::model::ListSessionsRequest::filter].
5908 pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5909 self.filter = v.into();
5910 self
5911 }
5912}
5913
5914impl wkt::message::Message for ListSessionsRequest {
5915 fn typename() -> &'static str {
5916 "type.googleapis.com/google.spanner.v1.ListSessionsRequest"
5917 }
5918}
5919
5920/// The response for [ListSessions][google.spanner.v1.Spanner.ListSessions].
5921///
5922/// [google.spanner.v1.Spanner.ListSessions]: crate::client::Spanner::list_sessions
5923#[derive(Clone, Default, PartialEq)]
5924#[non_exhaustive]
5925pub struct ListSessionsResponse {
5926 /// The list of requested sessions.
5927 pub sessions: std::vec::Vec<crate::model::Session>,
5928
5929 /// `next_page_token` can be sent in a subsequent
5930 /// [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more
5931 /// of the matching sessions.
5932 ///
5933 /// [google.spanner.v1.Spanner.ListSessions]: crate::client::Spanner::list_sessions
5934 pub next_page_token: std::string::String,
5935
5936 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5937}
5938
5939impl ListSessionsResponse {
5940 /// Creates a new default instance.
5941 pub fn new() -> Self {
5942 std::default::Default::default()
5943 }
5944
5945 /// Sets the value of [sessions][crate::model::ListSessionsResponse::sessions].
5946 pub fn set_sessions<T, V>(mut self, v: T) -> Self
5947 where
5948 T: std::iter::IntoIterator<Item = V>,
5949 V: std::convert::Into<crate::model::Session>,
5950 {
5951 use std::iter::Iterator;
5952 self.sessions = v.into_iter().map(|i| i.into()).collect();
5953 self
5954 }
5955
5956 /// Sets the value of [next_page_token][crate::model::ListSessionsResponse::next_page_token].
5957 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5958 self.next_page_token = v.into();
5959 self
5960 }
5961}
5962
5963impl wkt::message::Message for ListSessionsResponse {
5964 fn typename() -> &'static str {
5965 "type.googleapis.com/google.spanner.v1.ListSessionsResponse"
5966 }
5967}
5968
5969#[doc(hidden)]
5970impl google_cloud_gax::paginator::internal::PageableResponse for ListSessionsResponse {
5971 type PageItem = crate::model::Session;
5972
5973 fn items(self) -> std::vec::Vec<Self::PageItem> {
5974 self.sessions
5975 }
5976
5977 fn next_page_token(&self) -> std::string::String {
5978 use std::clone::Clone;
5979 self.next_page_token.clone()
5980 }
5981}
5982
5983/// The request for [DeleteSession][google.spanner.v1.Spanner.DeleteSession].
5984///
5985/// [google.spanner.v1.Spanner.DeleteSession]: crate::client::Spanner::delete_session
5986#[derive(Clone, Default, PartialEq)]
5987#[non_exhaustive]
5988pub struct DeleteSessionRequest {
5989 /// Required. The name of the session to delete.
5990 pub name: std::string::String,
5991
5992 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5993}
5994
5995impl DeleteSessionRequest {
5996 /// Creates a new default instance.
5997 pub fn new() -> Self {
5998 std::default::Default::default()
5999 }
6000
6001 /// Sets the value of [name][crate::model::DeleteSessionRequest::name].
6002 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6003 self.name = v.into();
6004 self
6005 }
6006}
6007
6008impl wkt::message::Message for DeleteSessionRequest {
6009 fn typename() -> &'static str {
6010 "type.googleapis.com/google.spanner.v1.DeleteSessionRequest"
6011 }
6012}
6013
6014/// Common request options for various APIs.
6015#[derive(Clone, Default, PartialEq)]
6016#[non_exhaustive]
6017pub struct RequestOptions {
6018 /// Priority for the request.
6019 pub priority: crate::model::request_options::Priority,
6020
6021 /// A per-request tag which can be applied to queries or reads, used for
6022 /// statistics collection.
6023 /// Both `request_tag` and `transaction_tag` can be specified for a read or
6024 /// query that belongs to a transaction.
6025 /// This field is ignored for requests where it's not applicable (for example,
6026 /// `CommitRequest`).
6027 /// Legal characters for `request_tag` values are all printable characters
6028 /// (ASCII 32 - 126) and the length of a request_tag is limited to 50
6029 /// characters. Values that exceed this limit are truncated.
6030 /// Any leading underscore (_) characters are removed from the string.
6031 pub request_tag: std::string::String,
6032
6033 /// A tag used for statistics collection about this transaction.
6034 /// Both `request_tag` and `transaction_tag` can be specified for a read or
6035 /// query that belongs to a transaction.
6036 /// To enable tagging on a transaction, `transaction_tag` must be set to the
6037 /// same value for all requests belonging to the same transaction, including
6038 /// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
6039 /// If this request doesn't belong to any transaction, `transaction_tag` is
6040 /// ignored.
6041 /// Legal characters for `transaction_tag` values are all printable characters
6042 /// (ASCII 32 - 126) and the length of a `transaction_tag` is limited to 50
6043 /// characters. Values that exceed this limit are truncated.
6044 /// Any leading underscore (_) characters are removed from the string.
6045 ///
6046 /// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
6047 pub transaction_tag: std::string::String,
6048
6049 /// Optional. Optional context that may be needed for some requests.
6050 pub client_context: std::option::Option<crate::model::request_options::ClientContext>,
6051
6052 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6053}
6054
6055impl RequestOptions {
6056 /// Creates a new default instance.
6057 pub fn new() -> Self {
6058 std::default::Default::default()
6059 }
6060
6061 /// Sets the value of [priority][crate::model::RequestOptions::priority].
6062 pub fn set_priority<T: std::convert::Into<crate::model::request_options::Priority>>(
6063 mut self,
6064 v: T,
6065 ) -> Self {
6066 self.priority = v.into();
6067 self
6068 }
6069
6070 /// Sets the value of [request_tag][crate::model::RequestOptions::request_tag].
6071 pub fn set_request_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6072 self.request_tag = v.into();
6073 self
6074 }
6075
6076 /// Sets the value of [transaction_tag][crate::model::RequestOptions::transaction_tag].
6077 pub fn set_transaction_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6078 self.transaction_tag = v.into();
6079 self
6080 }
6081
6082 /// Sets the value of [client_context][crate::model::RequestOptions::client_context].
6083 pub fn set_client_context<T>(mut self, v: T) -> Self
6084 where
6085 T: std::convert::Into<crate::model::request_options::ClientContext>,
6086 {
6087 self.client_context = std::option::Option::Some(v.into());
6088 self
6089 }
6090
6091 /// Sets or clears the value of [client_context][crate::model::RequestOptions::client_context].
6092 pub fn set_or_clear_client_context<T>(mut self, v: std::option::Option<T>) -> Self
6093 where
6094 T: std::convert::Into<crate::model::request_options::ClientContext>,
6095 {
6096 self.client_context = v.map(|x| x.into());
6097 self
6098 }
6099}
6100
6101impl wkt::message::Message for RequestOptions {
6102 fn typename() -> &'static str {
6103 "type.googleapis.com/google.spanner.v1.RequestOptions"
6104 }
6105}
6106
6107/// Defines additional types related to [RequestOptions].
6108pub mod request_options {
6109 #[allow(unused_imports)]
6110 use super::*;
6111
6112 /// Container for various pieces of client-owned context attached to a request.
6113 #[derive(Clone, Default, PartialEq)]
6114 #[non_exhaustive]
6115 pub struct ClientContext {
6116 /// Optional. Map of parameter name to value for this request. These values
6117 /// will be returned by any SECURE_CONTEXT() calls invoked by this request
6118 /// (e.g., by queries against Parameterized Secure Views).
6119 pub secure_context: std::collections::HashMap<std::string::String, wkt::Value>,
6120
6121 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6122 }
6123
6124 impl ClientContext {
6125 /// Creates a new default instance.
6126 pub fn new() -> Self {
6127 std::default::Default::default()
6128 }
6129
6130 /// Sets the value of [secure_context][crate::model::request_options::ClientContext::secure_context].
6131 pub fn set_secure_context<T, K, V>(mut self, v: T) -> Self
6132 where
6133 T: std::iter::IntoIterator<Item = (K, V)>,
6134 K: std::convert::Into<std::string::String>,
6135 V: std::convert::Into<wkt::Value>,
6136 {
6137 use std::iter::Iterator;
6138 self.secure_context = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6139 self
6140 }
6141 }
6142
6143 impl wkt::message::Message for ClientContext {
6144 fn typename() -> &'static str {
6145 "type.googleapis.com/google.spanner.v1.RequestOptions.ClientContext"
6146 }
6147 }
6148
6149 /// The relative priority for requests. Note that priority isn't applicable
6150 /// for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
6151 ///
6152 /// The priority acts as a hint to the Cloud Spanner scheduler and doesn't
6153 /// guarantee priority or order of execution. For example:
6154 ///
6155 /// * Some parts of a write operation always execute at `PRIORITY_HIGH`,
6156 /// regardless of the specified priority. This can cause you to see an
6157 /// increase in high priority workload even when executing a low priority
6158 /// request. This can also potentially cause a priority inversion where a
6159 /// lower priority request is fulfilled ahead of a higher priority
6160 /// request.
6161 /// * If a transaction contains multiple operations with different priorities,
6162 /// Cloud Spanner doesn't guarantee to process the higher priority
6163 /// operations first. There might be other constraints to satisfy, such as
6164 /// the order of operations.
6165 ///
6166 /// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
6167 ///
6168 /// # Working with unknown values
6169 ///
6170 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6171 /// additional enum variants at any time. Adding new variants is not considered
6172 /// a breaking change. Applications should write their code in anticipation of:
6173 ///
6174 /// - New values appearing in future releases of the client library, **and**
6175 /// - New values received dynamically, without application changes.
6176 ///
6177 /// Please consult the [Working with enums] section in the user guide for some
6178 /// guidelines.
6179 ///
6180 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6181 #[derive(Clone, Debug, PartialEq)]
6182 #[non_exhaustive]
6183 pub enum Priority {
6184 /// `PRIORITY_UNSPECIFIED` is equivalent to `PRIORITY_HIGH`.
6185 Unspecified,
6186 /// This specifies that the request is low priority.
6187 Low,
6188 /// This specifies that the request is medium priority.
6189 Medium,
6190 /// This specifies that the request is high priority.
6191 High,
6192 /// If set, the enum was initialized with an unknown value.
6193 ///
6194 /// Applications can examine the value using [Priority::value] or
6195 /// [Priority::name].
6196 UnknownValue(priority::UnknownValue),
6197 }
6198
6199 #[doc(hidden)]
6200 pub mod priority {
6201 #[allow(unused_imports)]
6202 use super::*;
6203 #[derive(Clone, Debug, PartialEq)]
6204 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6205 }
6206
6207 impl Priority {
6208 /// Gets the enum value.
6209 ///
6210 /// Returns `None` if the enum contains an unknown value deserialized from
6211 /// the string representation of enums.
6212 pub fn value(&self) -> std::option::Option<i32> {
6213 match self {
6214 Self::Unspecified => std::option::Option::Some(0),
6215 Self::Low => std::option::Option::Some(1),
6216 Self::Medium => std::option::Option::Some(2),
6217 Self::High => std::option::Option::Some(3),
6218 Self::UnknownValue(u) => u.0.value(),
6219 }
6220 }
6221
6222 /// Gets the enum value as a string.
6223 ///
6224 /// Returns `None` if the enum contains an unknown value deserialized from
6225 /// the integer representation of enums.
6226 pub fn name(&self) -> std::option::Option<&str> {
6227 match self {
6228 Self::Unspecified => std::option::Option::Some("PRIORITY_UNSPECIFIED"),
6229 Self::Low => std::option::Option::Some("PRIORITY_LOW"),
6230 Self::Medium => std::option::Option::Some("PRIORITY_MEDIUM"),
6231 Self::High => std::option::Option::Some("PRIORITY_HIGH"),
6232 Self::UnknownValue(u) => u.0.name(),
6233 }
6234 }
6235 }
6236
6237 impl std::default::Default for Priority {
6238 fn default() -> Self {
6239 use std::convert::From;
6240 Self::from(0)
6241 }
6242 }
6243
6244 impl std::fmt::Display for Priority {
6245 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6246 wkt::internal::display_enum(f, self.name(), self.value())
6247 }
6248 }
6249
6250 impl std::convert::From<i32> for Priority {
6251 fn from(value: i32) -> Self {
6252 match value {
6253 0 => Self::Unspecified,
6254 1 => Self::Low,
6255 2 => Self::Medium,
6256 3 => Self::High,
6257 _ => Self::UnknownValue(priority::UnknownValue(
6258 wkt::internal::UnknownEnumValue::Integer(value),
6259 )),
6260 }
6261 }
6262 }
6263
6264 impl std::convert::From<&str> for Priority {
6265 fn from(value: &str) -> Self {
6266 use std::string::ToString;
6267 match value {
6268 "PRIORITY_UNSPECIFIED" => Self::Unspecified,
6269 "PRIORITY_LOW" => Self::Low,
6270 "PRIORITY_MEDIUM" => Self::Medium,
6271 "PRIORITY_HIGH" => Self::High,
6272 _ => Self::UnknownValue(priority::UnknownValue(
6273 wkt::internal::UnknownEnumValue::String(value.to_string()),
6274 )),
6275 }
6276 }
6277 }
6278
6279 impl serde::ser::Serialize for Priority {
6280 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6281 where
6282 S: serde::Serializer,
6283 {
6284 match self {
6285 Self::Unspecified => serializer.serialize_i32(0),
6286 Self::Low => serializer.serialize_i32(1),
6287 Self::Medium => serializer.serialize_i32(2),
6288 Self::High => serializer.serialize_i32(3),
6289 Self::UnknownValue(u) => u.0.serialize(serializer),
6290 }
6291 }
6292 }
6293
6294 impl<'de> serde::de::Deserialize<'de> for Priority {
6295 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6296 where
6297 D: serde::Deserializer<'de>,
6298 {
6299 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Priority>::new(
6300 ".google.spanner.v1.RequestOptions.Priority",
6301 ))
6302 }
6303 }
6304}
6305
6306/// The `DirectedReadOptions` can be used to indicate which replicas or regions
6307/// should be used for non-transactional reads or queries.
6308///
6309/// `DirectedReadOptions` can only be specified for a read-only transaction,
6310/// otherwise the API returns an `INVALID_ARGUMENT` error.
6311#[derive(Clone, Default, PartialEq)]
6312#[non_exhaustive]
6313pub struct DirectedReadOptions {
6314 /// Required. At most one of either `include_replicas` or `exclude_replicas`
6315 /// should be present in the message.
6316 pub replicas: std::option::Option<crate::model::directed_read_options::Replicas>,
6317
6318 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6319}
6320
6321impl DirectedReadOptions {
6322 /// Creates a new default instance.
6323 pub fn new() -> Self {
6324 std::default::Default::default()
6325 }
6326
6327 /// Sets the value of [replicas][crate::model::DirectedReadOptions::replicas].
6328 ///
6329 /// Note that all the setters affecting `replicas` are mutually
6330 /// exclusive.
6331 pub fn set_replicas<
6332 T: std::convert::Into<std::option::Option<crate::model::directed_read_options::Replicas>>,
6333 >(
6334 mut self,
6335 v: T,
6336 ) -> Self {
6337 self.replicas = v.into();
6338 self
6339 }
6340
6341 /// The value of [replicas][crate::model::DirectedReadOptions::replicas]
6342 /// if it holds a `IncludeReplicas`, `None` if the field is not set or
6343 /// holds a different branch.
6344 pub fn include_replicas(
6345 &self,
6346 ) -> std::option::Option<&std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>>
6347 {
6348 #[allow(unreachable_patterns)]
6349 self.replicas.as_ref().and_then(|v| match v {
6350 crate::model::directed_read_options::Replicas::IncludeReplicas(v) => {
6351 std::option::Option::Some(v)
6352 }
6353 _ => std::option::Option::None,
6354 })
6355 }
6356
6357 /// Sets the value of [replicas][crate::model::DirectedReadOptions::replicas]
6358 /// to hold a `IncludeReplicas`.
6359 ///
6360 /// Note that all the setters affecting `replicas` are
6361 /// mutually exclusive.
6362 pub fn set_include_replicas<
6363 T: std::convert::Into<std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>>,
6364 >(
6365 mut self,
6366 v: T,
6367 ) -> Self {
6368 self.replicas = std::option::Option::Some(
6369 crate::model::directed_read_options::Replicas::IncludeReplicas(v.into()),
6370 );
6371 self
6372 }
6373
6374 /// The value of [replicas][crate::model::DirectedReadOptions::replicas]
6375 /// if it holds a `ExcludeReplicas`, `None` if the field is not set or
6376 /// holds a different branch.
6377 pub fn exclude_replicas(
6378 &self,
6379 ) -> std::option::Option<&std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>>
6380 {
6381 #[allow(unreachable_patterns)]
6382 self.replicas.as_ref().and_then(|v| match v {
6383 crate::model::directed_read_options::Replicas::ExcludeReplicas(v) => {
6384 std::option::Option::Some(v)
6385 }
6386 _ => std::option::Option::None,
6387 })
6388 }
6389
6390 /// Sets the value of [replicas][crate::model::DirectedReadOptions::replicas]
6391 /// to hold a `ExcludeReplicas`.
6392 ///
6393 /// Note that all the setters affecting `replicas` are
6394 /// mutually exclusive.
6395 pub fn set_exclude_replicas<
6396 T: std::convert::Into<std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>>,
6397 >(
6398 mut self,
6399 v: T,
6400 ) -> Self {
6401 self.replicas = std::option::Option::Some(
6402 crate::model::directed_read_options::Replicas::ExcludeReplicas(v.into()),
6403 );
6404 self
6405 }
6406}
6407
6408impl wkt::message::Message for DirectedReadOptions {
6409 fn typename() -> &'static str {
6410 "type.googleapis.com/google.spanner.v1.DirectedReadOptions"
6411 }
6412}
6413
6414/// Defines additional types related to [DirectedReadOptions].
6415pub mod directed_read_options {
6416 #[allow(unused_imports)]
6417 use super::*;
6418
6419 /// The directed read replica selector.
6420 /// Callers must provide one or more of the following fields for replica
6421 /// selection:
6422 ///
6423 /// * `location` - The location must be one of the regions within the
6424 /// multi-region configuration of your database.
6425 /// * `type` - The type of the replica.
6426 ///
6427 /// Some examples of using replica_selectors are:
6428 ///
6429 /// * `location:us-east1` --> The "us-east1" replica(s) of any available type
6430 /// is used to process the request.
6431 /// * `type:READ_ONLY` --> The "READ_ONLY" type replica(s) in the nearest
6432 /// available location are used to process the
6433 /// request.
6434 /// * `location:us-east1 type:READ_ONLY` --> The "READ_ONLY" type replica(s)
6435 /// in location "us-east1" is used to process
6436 /// the request.
6437 #[derive(Clone, Default, PartialEq)]
6438 #[non_exhaustive]
6439 pub struct ReplicaSelection {
6440 /// The location or region of the serving requests, for example, "us-east1".
6441 pub location: std::string::String,
6442
6443 /// The type of replica.
6444 pub r#type: crate::model::directed_read_options::replica_selection::Type,
6445
6446 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6447 }
6448
6449 impl ReplicaSelection {
6450 /// Creates a new default instance.
6451 pub fn new() -> Self {
6452 std::default::Default::default()
6453 }
6454
6455 /// Sets the value of [location][crate::model::directed_read_options::ReplicaSelection::location].
6456 pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6457 self.location = v.into();
6458 self
6459 }
6460
6461 /// Sets the value of [r#type][crate::model::directed_read_options::ReplicaSelection::type].
6462 pub fn set_type<
6463 T: std::convert::Into<crate::model::directed_read_options::replica_selection::Type>,
6464 >(
6465 mut self,
6466 v: T,
6467 ) -> Self {
6468 self.r#type = v.into();
6469 self
6470 }
6471 }
6472
6473 impl wkt::message::Message for ReplicaSelection {
6474 fn typename() -> &'static str {
6475 "type.googleapis.com/google.spanner.v1.DirectedReadOptions.ReplicaSelection"
6476 }
6477 }
6478
6479 /// Defines additional types related to [ReplicaSelection].
6480 pub mod replica_selection {
6481 #[allow(unused_imports)]
6482 use super::*;
6483
6484 /// Indicates the type of replica.
6485 ///
6486 /// # Working with unknown values
6487 ///
6488 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6489 /// additional enum variants at any time. Adding new variants is not considered
6490 /// a breaking change. Applications should write their code in anticipation of:
6491 ///
6492 /// - New values appearing in future releases of the client library, **and**
6493 /// - New values received dynamically, without application changes.
6494 ///
6495 /// Please consult the [Working with enums] section in the user guide for some
6496 /// guidelines.
6497 ///
6498 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6499 #[derive(Clone, Debug, PartialEq)]
6500 #[non_exhaustive]
6501 pub enum Type {
6502 /// Not specified.
6503 Unspecified,
6504 /// Read-write replicas support both reads and writes.
6505 ReadWrite,
6506 /// Read-only replicas only support reads (not writes).
6507 ReadOnly,
6508 /// If set, the enum was initialized with an unknown value.
6509 ///
6510 /// Applications can examine the value using [Type::value] or
6511 /// [Type::name].
6512 UnknownValue(r#type::UnknownValue),
6513 }
6514
6515 #[doc(hidden)]
6516 pub mod r#type {
6517 #[allow(unused_imports)]
6518 use super::*;
6519 #[derive(Clone, Debug, PartialEq)]
6520 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6521 }
6522
6523 impl Type {
6524 /// Gets the enum value.
6525 ///
6526 /// Returns `None` if the enum contains an unknown value deserialized from
6527 /// the string representation of enums.
6528 pub fn value(&self) -> std::option::Option<i32> {
6529 match self {
6530 Self::Unspecified => std::option::Option::Some(0),
6531 Self::ReadWrite => std::option::Option::Some(1),
6532 Self::ReadOnly => std::option::Option::Some(2),
6533 Self::UnknownValue(u) => u.0.value(),
6534 }
6535 }
6536
6537 /// Gets the enum value as a string.
6538 ///
6539 /// Returns `None` if the enum contains an unknown value deserialized from
6540 /// the integer representation of enums.
6541 pub fn name(&self) -> std::option::Option<&str> {
6542 match self {
6543 Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
6544 Self::ReadWrite => std::option::Option::Some("READ_WRITE"),
6545 Self::ReadOnly => std::option::Option::Some("READ_ONLY"),
6546 Self::UnknownValue(u) => u.0.name(),
6547 }
6548 }
6549 }
6550
6551 impl std::default::Default for Type {
6552 fn default() -> Self {
6553 use std::convert::From;
6554 Self::from(0)
6555 }
6556 }
6557
6558 impl std::fmt::Display for Type {
6559 fn fmt(
6560 &self,
6561 f: &mut std::fmt::Formatter<'_>,
6562 ) -> std::result::Result<(), std::fmt::Error> {
6563 wkt::internal::display_enum(f, self.name(), self.value())
6564 }
6565 }
6566
6567 impl std::convert::From<i32> for Type {
6568 fn from(value: i32) -> Self {
6569 match value {
6570 0 => Self::Unspecified,
6571 1 => Self::ReadWrite,
6572 2 => Self::ReadOnly,
6573 _ => Self::UnknownValue(r#type::UnknownValue(
6574 wkt::internal::UnknownEnumValue::Integer(value),
6575 )),
6576 }
6577 }
6578 }
6579
6580 impl std::convert::From<&str> for Type {
6581 fn from(value: &str) -> Self {
6582 use std::string::ToString;
6583 match value {
6584 "TYPE_UNSPECIFIED" => Self::Unspecified,
6585 "READ_WRITE" => Self::ReadWrite,
6586 "READ_ONLY" => Self::ReadOnly,
6587 _ => Self::UnknownValue(r#type::UnknownValue(
6588 wkt::internal::UnknownEnumValue::String(value.to_string()),
6589 )),
6590 }
6591 }
6592 }
6593
6594 impl serde::ser::Serialize for Type {
6595 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6596 where
6597 S: serde::Serializer,
6598 {
6599 match self {
6600 Self::Unspecified => serializer.serialize_i32(0),
6601 Self::ReadWrite => serializer.serialize_i32(1),
6602 Self::ReadOnly => serializer.serialize_i32(2),
6603 Self::UnknownValue(u) => u.0.serialize(serializer),
6604 }
6605 }
6606 }
6607
6608 impl<'de> serde::de::Deserialize<'de> for Type {
6609 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6610 where
6611 D: serde::Deserializer<'de>,
6612 {
6613 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
6614 ".google.spanner.v1.DirectedReadOptions.ReplicaSelection.Type",
6615 ))
6616 }
6617 }
6618 }
6619
6620 /// An `IncludeReplicas` contains a repeated set of `ReplicaSelection` which
6621 /// indicates the order in which replicas should be considered.
6622 #[derive(Clone, Default, PartialEq)]
6623 #[non_exhaustive]
6624 pub struct IncludeReplicas {
6625 /// The directed read replica selector.
6626 pub replica_selections:
6627 std::vec::Vec<crate::model::directed_read_options::ReplicaSelection>,
6628
6629 /// If `true`, Spanner doesn't route requests to a replica outside the
6630 /// <`include_replicas` list when all of the specified replicas are
6631 /// unavailable or unhealthy. Default value is `false`.
6632 pub auto_failover_disabled: bool,
6633
6634 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6635 }
6636
6637 impl IncludeReplicas {
6638 /// Creates a new default instance.
6639 pub fn new() -> Self {
6640 std::default::Default::default()
6641 }
6642
6643 /// Sets the value of [replica_selections][crate::model::directed_read_options::IncludeReplicas::replica_selections].
6644 pub fn set_replica_selections<T, V>(mut self, v: T) -> Self
6645 where
6646 T: std::iter::IntoIterator<Item = V>,
6647 V: std::convert::Into<crate::model::directed_read_options::ReplicaSelection>,
6648 {
6649 use std::iter::Iterator;
6650 self.replica_selections = v.into_iter().map(|i| i.into()).collect();
6651 self
6652 }
6653
6654 /// Sets the value of [auto_failover_disabled][crate::model::directed_read_options::IncludeReplicas::auto_failover_disabled].
6655 pub fn set_auto_failover_disabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6656 self.auto_failover_disabled = v.into();
6657 self
6658 }
6659 }
6660
6661 impl wkt::message::Message for IncludeReplicas {
6662 fn typename() -> &'static str {
6663 "type.googleapis.com/google.spanner.v1.DirectedReadOptions.IncludeReplicas"
6664 }
6665 }
6666
6667 /// An ExcludeReplicas contains a repeated set of ReplicaSelection that should
6668 /// be excluded from serving requests.
6669 #[derive(Clone, Default, PartialEq)]
6670 #[non_exhaustive]
6671 pub struct ExcludeReplicas {
6672 /// The directed read replica selector.
6673 pub replica_selections:
6674 std::vec::Vec<crate::model::directed_read_options::ReplicaSelection>,
6675
6676 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6677 }
6678
6679 impl ExcludeReplicas {
6680 /// Creates a new default instance.
6681 pub fn new() -> Self {
6682 std::default::Default::default()
6683 }
6684
6685 /// Sets the value of [replica_selections][crate::model::directed_read_options::ExcludeReplicas::replica_selections].
6686 pub fn set_replica_selections<T, V>(mut self, v: T) -> Self
6687 where
6688 T: std::iter::IntoIterator<Item = V>,
6689 V: std::convert::Into<crate::model::directed_read_options::ReplicaSelection>,
6690 {
6691 use std::iter::Iterator;
6692 self.replica_selections = v.into_iter().map(|i| i.into()).collect();
6693 self
6694 }
6695 }
6696
6697 impl wkt::message::Message for ExcludeReplicas {
6698 fn typename() -> &'static str {
6699 "type.googleapis.com/google.spanner.v1.DirectedReadOptions.ExcludeReplicas"
6700 }
6701 }
6702
6703 /// Required. At most one of either `include_replicas` or `exclude_replicas`
6704 /// should be present in the message.
6705 #[derive(Clone, Debug, PartialEq)]
6706 #[non_exhaustive]
6707 pub enum Replicas {
6708 /// `Include_replicas` indicates the order of replicas (as they appear in
6709 /// this list) to process the request. If `auto_failover_disabled` is set to
6710 /// `true` and all replicas are exhausted without finding a healthy replica,
6711 /// Spanner waits for a replica in the list to become available, requests
6712 /// might fail due to `DEADLINE_EXCEEDED` errors.
6713 IncludeReplicas(std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>),
6714 /// `Exclude_replicas` indicates that specified replicas should be excluded
6715 /// from serving requests. Spanner doesn't route requests to the replicas
6716 /// in this list.
6717 ExcludeReplicas(std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>),
6718 }
6719
6720 impl Replicas {
6721 /// Initializes the enum to the [IncludeReplicas](Self::IncludeReplicas) branch.
6722 pub fn from_include_replicas(
6723 value: impl std::convert::Into<
6724 std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>,
6725 >,
6726 ) -> Self {
6727 Self::IncludeReplicas(value.into())
6728 }
6729 /// Initializes the enum to the [ExcludeReplicas](Self::ExcludeReplicas) branch.
6730 pub fn from_exclude_replicas(
6731 value: impl std::convert::Into<
6732 std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>,
6733 >,
6734 ) -> Self {
6735 Self::ExcludeReplicas(value.into())
6736 }
6737 }
6738}
6739
6740/// The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
6741/// [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
6742///
6743/// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
6744#[derive(Clone, Default, PartialEq)]
6745#[non_exhaustive]
6746pub struct ExecuteSqlRequest {
6747 /// Required. The session in which the SQL query should be performed.
6748 pub session: std::string::String,
6749
6750 /// The transaction to use.
6751 ///
6752 /// For queries, if none is provided, the default is a temporary read-only
6753 /// transaction with strong concurrency.
6754 ///
6755 /// Standard DML statements require a read-write transaction. To protect
6756 /// against replays, single-use transactions are not supported. The caller
6757 /// must either supply an existing transaction ID or begin a new transaction.
6758 ///
6759 /// Partitioned DML requires an existing Partitioned DML transaction ID.
6760 pub transaction: std::option::Option<crate::model::TransactionSelector>,
6761
6762 /// Required. The SQL string.
6763 pub sql: std::string::String,
6764
6765 /// Parameter names and values that bind to placeholders in the SQL string.
6766 ///
6767 /// A parameter placeholder consists of the `@` character followed by the
6768 /// parameter name (for example, `@firstName`). Parameter names must conform
6769 /// to the naming requirements of identifiers as specified at
6770 /// <https://cloud.google.com/spanner/docs/lexical#identifiers>.
6771 ///
6772 /// Parameters can appear anywhere that a literal value is expected. The same
6773 /// parameter name can be used more than once, for example:
6774 ///
6775 /// `"WHERE id > @msg_id AND id < @msg_id + 100"`
6776 ///
6777 /// It's an error to execute a SQL statement with unbound parameters.
6778 pub params: std::option::Option<wkt::Struct>,
6779
6780 /// It isn't always possible for Cloud Spanner to infer the right SQL type
6781 /// from a JSON value. For example, values of type `BYTES` and values
6782 /// of type `STRING` both appear in
6783 /// [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings.
6784 ///
6785 /// In these cases, you can use `param_types` to specify the exact
6786 /// SQL type for some or all of the SQL statement parameters. See the
6787 /// definition of [Type][google.spanner.v1.Type] for more information
6788 /// about SQL types.
6789 ///
6790 /// [google.spanner.v1.ExecuteSqlRequest.params]: crate::model::ExecuteSqlRequest::params
6791 /// [google.spanner.v1.Type]: crate::model::Type
6792 pub param_types: std::collections::HashMap<std::string::String, crate::model::Type>,
6793
6794 /// If this request is resuming a previously interrupted SQL statement
6795 /// execution, `resume_token` should be copied from the last
6796 /// [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
6797 /// interruption. Doing this enables the new SQL statement execution to resume
6798 /// where the last one left off. The rest of the request parameters must
6799 /// exactly match the request that yielded this token.
6800 ///
6801 /// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
6802 pub resume_token: ::bytes::Bytes,
6803
6804 /// Used to control the amount of debugging information returned in
6805 /// [ResultSetStats][google.spanner.v1.ResultSetStats]. If
6806 /// [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is
6807 /// set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only
6808 /// be set to
6809 /// [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL].
6810 ///
6811 /// [google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]: crate::model::execute_sql_request::QueryMode::Normal
6812 /// [google.spanner.v1.ExecuteSqlRequest.partition_token]: crate::model::ExecuteSqlRequest::partition_token
6813 /// [google.spanner.v1.ExecuteSqlRequest.query_mode]: crate::model::ExecuteSqlRequest::query_mode
6814 /// [google.spanner.v1.ResultSetStats]: crate::model::ResultSetStats
6815 pub query_mode: crate::model::execute_sql_request::QueryMode,
6816
6817 /// If present, results are restricted to the specified partition
6818 /// previously created using `PartitionQuery`. There must be an exact
6819 /// match for the values of fields common to this message and the
6820 /// `PartitionQueryRequest` message used to create this `partition_token`.
6821 pub partition_token: ::bytes::Bytes,
6822
6823 /// A per-transaction sequence number used to identify this request. This field
6824 /// makes each request idempotent such that if the request is received multiple
6825 /// times, at most one succeeds.
6826 ///
6827 /// The sequence number must be monotonically increasing within the
6828 /// transaction. If a request arrives for the first time with an out-of-order
6829 /// sequence number, the transaction can be aborted. Replays of previously
6830 /// handled requests yield the same response as the first execution.
6831 ///
6832 /// Required for DML statements. Ignored for queries.
6833 pub seqno: i64,
6834
6835 /// Query optimizer configuration to use for the given query.
6836 pub query_options: std::option::Option<crate::model::execute_sql_request::QueryOptions>,
6837
6838 /// Common options for this request.
6839 pub request_options: std::option::Option<crate::model::RequestOptions>,
6840
6841 /// Directed read options for this request.
6842 pub directed_read_options: std::option::Option<crate::model::DirectedReadOptions>,
6843
6844 /// If this is for a partitioned query and this field is set to `true`, the
6845 /// request is executed with Spanner Data Boost independent compute resources.
6846 ///
6847 /// If the field is set to `true` but the request doesn't set
6848 /// `partition_token`, the API returns an `INVALID_ARGUMENT` error.
6849 pub data_boost_enabled: bool,
6850
6851 /// Optional. If set to `true`, this statement marks the end of the
6852 /// transaction. After this statement executes, you must commit or abort the
6853 /// transaction. Attempts to execute any other requests against this
6854 /// transaction (including reads and queries) are rejected.
6855 ///
6856 /// For DML statements, setting this option might cause some error reporting to
6857 /// be deferred until commit time (for example, validation of unique
6858 /// constraints). Given this, successful execution of a DML statement shouldn't
6859 /// be assumed until a subsequent `Commit` call completes successfully.
6860 pub last_statement: bool,
6861
6862 /// Optional. Makes the Spanner requests location-aware if present.
6863 ///
6864 /// It gives the server hints that can be used to route the request
6865 /// to an appropriate server, potentially significantly decreasing latency and
6866 /// improving throughput. To achieve improved performance, most fields must be
6867 /// filled in with accurate values.
6868 pub routing_hint: std::option::Option<crate::model::RoutingHint>,
6869
6870 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6871}
6872
6873impl ExecuteSqlRequest {
6874 /// Creates a new default instance.
6875 pub fn new() -> Self {
6876 std::default::Default::default()
6877 }
6878
6879 /// Sets the value of [session][crate::model::ExecuteSqlRequest::session].
6880 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6881 self.session = v.into();
6882 self
6883 }
6884
6885 /// Sets the value of [transaction][crate::model::ExecuteSqlRequest::transaction].
6886 pub fn set_transaction<T>(mut self, v: T) -> Self
6887 where
6888 T: std::convert::Into<crate::model::TransactionSelector>,
6889 {
6890 self.transaction = std::option::Option::Some(v.into());
6891 self
6892 }
6893
6894 /// Sets or clears the value of [transaction][crate::model::ExecuteSqlRequest::transaction].
6895 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
6896 where
6897 T: std::convert::Into<crate::model::TransactionSelector>,
6898 {
6899 self.transaction = v.map(|x| x.into());
6900 self
6901 }
6902
6903 /// Sets the value of [sql][crate::model::ExecuteSqlRequest::sql].
6904 pub fn set_sql<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6905 self.sql = v.into();
6906 self
6907 }
6908
6909 /// Sets the value of [params][crate::model::ExecuteSqlRequest::params].
6910 pub fn set_params<T>(mut self, v: T) -> Self
6911 where
6912 T: std::convert::Into<wkt::Struct>,
6913 {
6914 self.params = std::option::Option::Some(v.into());
6915 self
6916 }
6917
6918 /// Sets or clears the value of [params][crate::model::ExecuteSqlRequest::params].
6919 pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
6920 where
6921 T: std::convert::Into<wkt::Struct>,
6922 {
6923 self.params = v.map(|x| x.into());
6924 self
6925 }
6926
6927 /// Sets the value of [param_types][crate::model::ExecuteSqlRequest::param_types].
6928 pub fn set_param_types<T, K, V>(mut self, v: T) -> Self
6929 where
6930 T: std::iter::IntoIterator<Item = (K, V)>,
6931 K: std::convert::Into<std::string::String>,
6932 V: std::convert::Into<crate::model::Type>,
6933 {
6934 use std::iter::Iterator;
6935 self.param_types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6936 self
6937 }
6938
6939 /// Sets the value of [resume_token][crate::model::ExecuteSqlRequest::resume_token].
6940 pub fn set_resume_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
6941 self.resume_token = v.into();
6942 self
6943 }
6944
6945 /// Sets the value of [query_mode][crate::model::ExecuteSqlRequest::query_mode].
6946 pub fn set_query_mode<T: std::convert::Into<crate::model::execute_sql_request::QueryMode>>(
6947 mut self,
6948 v: T,
6949 ) -> Self {
6950 self.query_mode = v.into();
6951 self
6952 }
6953
6954 /// Sets the value of [partition_token][crate::model::ExecuteSqlRequest::partition_token].
6955 pub fn set_partition_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
6956 self.partition_token = v.into();
6957 self
6958 }
6959
6960 /// Sets the value of [seqno][crate::model::ExecuteSqlRequest::seqno].
6961 pub fn set_seqno<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6962 self.seqno = v.into();
6963 self
6964 }
6965
6966 /// Sets the value of [query_options][crate::model::ExecuteSqlRequest::query_options].
6967 pub fn set_query_options<T>(mut self, v: T) -> Self
6968 where
6969 T: std::convert::Into<crate::model::execute_sql_request::QueryOptions>,
6970 {
6971 self.query_options = std::option::Option::Some(v.into());
6972 self
6973 }
6974
6975 /// Sets or clears the value of [query_options][crate::model::ExecuteSqlRequest::query_options].
6976 pub fn set_or_clear_query_options<T>(mut self, v: std::option::Option<T>) -> Self
6977 where
6978 T: std::convert::Into<crate::model::execute_sql_request::QueryOptions>,
6979 {
6980 self.query_options = v.map(|x| x.into());
6981 self
6982 }
6983
6984 /// Sets the value of [request_options][crate::model::ExecuteSqlRequest::request_options].
6985 pub fn set_request_options<T>(mut self, v: T) -> Self
6986 where
6987 T: std::convert::Into<crate::model::RequestOptions>,
6988 {
6989 self.request_options = std::option::Option::Some(v.into());
6990 self
6991 }
6992
6993 /// Sets or clears the value of [request_options][crate::model::ExecuteSqlRequest::request_options].
6994 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
6995 where
6996 T: std::convert::Into<crate::model::RequestOptions>,
6997 {
6998 self.request_options = v.map(|x| x.into());
6999 self
7000 }
7001
7002 /// Sets the value of [directed_read_options][crate::model::ExecuteSqlRequest::directed_read_options].
7003 pub fn set_directed_read_options<T>(mut self, v: T) -> Self
7004 where
7005 T: std::convert::Into<crate::model::DirectedReadOptions>,
7006 {
7007 self.directed_read_options = std::option::Option::Some(v.into());
7008 self
7009 }
7010
7011 /// Sets or clears the value of [directed_read_options][crate::model::ExecuteSqlRequest::directed_read_options].
7012 pub fn set_or_clear_directed_read_options<T>(mut self, v: std::option::Option<T>) -> Self
7013 where
7014 T: std::convert::Into<crate::model::DirectedReadOptions>,
7015 {
7016 self.directed_read_options = v.map(|x| x.into());
7017 self
7018 }
7019
7020 /// Sets the value of [data_boost_enabled][crate::model::ExecuteSqlRequest::data_boost_enabled].
7021 pub fn set_data_boost_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7022 self.data_boost_enabled = v.into();
7023 self
7024 }
7025
7026 /// Sets the value of [last_statement][crate::model::ExecuteSqlRequest::last_statement].
7027 pub fn set_last_statement<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7028 self.last_statement = v.into();
7029 self
7030 }
7031
7032 /// Sets the value of [routing_hint][crate::model::ExecuteSqlRequest::routing_hint].
7033 pub fn set_routing_hint<T>(mut self, v: T) -> Self
7034 where
7035 T: std::convert::Into<crate::model::RoutingHint>,
7036 {
7037 self.routing_hint = std::option::Option::Some(v.into());
7038 self
7039 }
7040
7041 /// Sets or clears the value of [routing_hint][crate::model::ExecuteSqlRequest::routing_hint].
7042 pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
7043 where
7044 T: std::convert::Into<crate::model::RoutingHint>,
7045 {
7046 self.routing_hint = v.map(|x| x.into());
7047 self
7048 }
7049}
7050
7051impl wkt::message::Message for ExecuteSqlRequest {
7052 fn typename() -> &'static str {
7053 "type.googleapis.com/google.spanner.v1.ExecuteSqlRequest"
7054 }
7055}
7056
7057/// Defines additional types related to [ExecuteSqlRequest].
7058pub mod execute_sql_request {
7059 #[allow(unused_imports)]
7060 use super::*;
7061
7062 /// Query optimizer configuration.
7063 #[derive(Clone, Default, PartialEq)]
7064 #[non_exhaustive]
7065 pub struct QueryOptions {
7066 /// An option to control the selection of optimizer version.
7067 ///
7068 /// This parameter allows individual queries to pick different query
7069 /// optimizer versions.
7070 ///
7071 /// Specifying `latest` as a value instructs Cloud Spanner to use the
7072 /// latest supported query optimizer version. If not specified, Cloud Spanner
7073 /// uses the optimizer version set at the database level options. Any other
7074 /// positive integer (from the list of supported optimizer versions)
7075 /// overrides the default optimizer version for query execution.
7076 ///
7077 /// The list of supported optimizer versions can be queried from
7078 /// `SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS`.
7079 ///
7080 /// Executing a SQL statement with an invalid optimizer version fails with
7081 /// an `INVALID_ARGUMENT` error.
7082 ///
7083 /// See
7084 /// <https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer>
7085 /// for more information on managing the query optimizer.
7086 ///
7087 /// The `optimizer_version` statement hint has precedence over this setting.
7088 pub optimizer_version: std::string::String,
7089
7090 /// An option to control the selection of optimizer statistics package.
7091 ///
7092 /// This parameter allows individual queries to use a different query
7093 /// optimizer statistics package.
7094 ///
7095 /// Specifying `latest` as a value instructs Cloud Spanner to use the latest
7096 /// generated statistics package. If not specified, Cloud Spanner uses
7097 /// the statistics package set at the database level options, or the latest
7098 /// package if the database option isn't set.
7099 ///
7100 /// The statistics package requested by the query has to be exempt from
7101 /// garbage collection. This can be achieved with the following DDL
7102 /// statement:
7103 ///
7104 /// ```norust
7105 /// ALTER STATISTICS <package_name> SET OPTIONS (allow_gc=false)
7106 /// ```
7107 ///
7108 /// The list of available statistics packages can be queried from
7109 /// `INFORMATION_SCHEMA.SPANNER_STATISTICS`.
7110 ///
7111 /// Executing a SQL statement with an invalid optimizer statistics package
7112 /// or with a statistics package that allows garbage collection fails with
7113 /// an `INVALID_ARGUMENT` error.
7114 pub optimizer_statistics_package: std::string::String,
7115
7116 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7117 }
7118
7119 impl QueryOptions {
7120 /// Creates a new default instance.
7121 pub fn new() -> Self {
7122 std::default::Default::default()
7123 }
7124
7125 /// Sets the value of [optimizer_version][crate::model::execute_sql_request::QueryOptions::optimizer_version].
7126 pub fn set_optimizer_version<T: std::convert::Into<std::string::String>>(
7127 mut self,
7128 v: T,
7129 ) -> Self {
7130 self.optimizer_version = v.into();
7131 self
7132 }
7133
7134 /// Sets the value of [optimizer_statistics_package][crate::model::execute_sql_request::QueryOptions::optimizer_statistics_package].
7135 pub fn set_optimizer_statistics_package<T: std::convert::Into<std::string::String>>(
7136 mut self,
7137 v: T,
7138 ) -> Self {
7139 self.optimizer_statistics_package = v.into();
7140 self
7141 }
7142 }
7143
7144 impl wkt::message::Message for QueryOptions {
7145 fn typename() -> &'static str {
7146 "type.googleapis.com/google.spanner.v1.ExecuteSqlRequest.QueryOptions"
7147 }
7148 }
7149
7150 /// Mode in which the statement must be processed.
7151 ///
7152 /// # Working with unknown values
7153 ///
7154 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7155 /// additional enum variants at any time. Adding new variants is not considered
7156 /// a breaking change. Applications should write their code in anticipation of:
7157 ///
7158 /// - New values appearing in future releases of the client library, **and**
7159 /// - New values received dynamically, without application changes.
7160 ///
7161 /// Please consult the [Working with enums] section in the user guide for some
7162 /// guidelines.
7163 ///
7164 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
7165 #[derive(Clone, Debug, PartialEq)]
7166 #[non_exhaustive]
7167 pub enum QueryMode {
7168 /// The default mode. Only the statement results are returned.
7169 Normal,
7170 /// This mode returns only the query plan, without any results or
7171 /// execution statistics information.
7172 Plan,
7173 /// This mode returns the query plan, overall execution statistics,
7174 /// operator level execution statistics along with the results. This has a
7175 /// performance overhead compared to the other modes. It isn't recommended
7176 /// to use this mode for production traffic.
7177 Profile,
7178 /// This mode returns the overall (but not operator-level) execution
7179 /// statistics along with the results.
7180 WithStats,
7181 /// This mode returns the query plan, overall (but not operator-level)
7182 /// execution statistics along with the results.
7183 WithPlanAndStats,
7184 /// If set, the enum was initialized with an unknown value.
7185 ///
7186 /// Applications can examine the value using [QueryMode::value] or
7187 /// [QueryMode::name].
7188 UnknownValue(query_mode::UnknownValue),
7189 }
7190
7191 #[doc(hidden)]
7192 pub mod query_mode {
7193 #[allow(unused_imports)]
7194 use super::*;
7195 #[derive(Clone, Debug, PartialEq)]
7196 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7197 }
7198
7199 impl QueryMode {
7200 /// Gets the enum value.
7201 ///
7202 /// Returns `None` if the enum contains an unknown value deserialized from
7203 /// the string representation of enums.
7204 pub fn value(&self) -> std::option::Option<i32> {
7205 match self {
7206 Self::Normal => std::option::Option::Some(0),
7207 Self::Plan => std::option::Option::Some(1),
7208 Self::Profile => std::option::Option::Some(2),
7209 Self::WithStats => std::option::Option::Some(3),
7210 Self::WithPlanAndStats => std::option::Option::Some(4),
7211 Self::UnknownValue(u) => u.0.value(),
7212 }
7213 }
7214
7215 /// Gets the enum value as a string.
7216 ///
7217 /// Returns `None` if the enum contains an unknown value deserialized from
7218 /// the integer representation of enums.
7219 pub fn name(&self) -> std::option::Option<&str> {
7220 match self {
7221 Self::Normal => std::option::Option::Some("NORMAL"),
7222 Self::Plan => std::option::Option::Some("PLAN"),
7223 Self::Profile => std::option::Option::Some("PROFILE"),
7224 Self::WithStats => std::option::Option::Some("WITH_STATS"),
7225 Self::WithPlanAndStats => std::option::Option::Some("WITH_PLAN_AND_STATS"),
7226 Self::UnknownValue(u) => u.0.name(),
7227 }
7228 }
7229 }
7230
7231 impl std::default::Default for QueryMode {
7232 fn default() -> Self {
7233 use std::convert::From;
7234 Self::from(0)
7235 }
7236 }
7237
7238 impl std::fmt::Display for QueryMode {
7239 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7240 wkt::internal::display_enum(f, self.name(), self.value())
7241 }
7242 }
7243
7244 impl std::convert::From<i32> for QueryMode {
7245 fn from(value: i32) -> Self {
7246 match value {
7247 0 => Self::Normal,
7248 1 => Self::Plan,
7249 2 => Self::Profile,
7250 3 => Self::WithStats,
7251 4 => Self::WithPlanAndStats,
7252 _ => Self::UnknownValue(query_mode::UnknownValue(
7253 wkt::internal::UnknownEnumValue::Integer(value),
7254 )),
7255 }
7256 }
7257 }
7258
7259 impl std::convert::From<&str> for QueryMode {
7260 fn from(value: &str) -> Self {
7261 use std::string::ToString;
7262 match value {
7263 "NORMAL" => Self::Normal,
7264 "PLAN" => Self::Plan,
7265 "PROFILE" => Self::Profile,
7266 "WITH_STATS" => Self::WithStats,
7267 "WITH_PLAN_AND_STATS" => Self::WithPlanAndStats,
7268 _ => Self::UnknownValue(query_mode::UnknownValue(
7269 wkt::internal::UnknownEnumValue::String(value.to_string()),
7270 )),
7271 }
7272 }
7273 }
7274
7275 impl serde::ser::Serialize for QueryMode {
7276 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7277 where
7278 S: serde::Serializer,
7279 {
7280 match self {
7281 Self::Normal => serializer.serialize_i32(0),
7282 Self::Plan => serializer.serialize_i32(1),
7283 Self::Profile => serializer.serialize_i32(2),
7284 Self::WithStats => serializer.serialize_i32(3),
7285 Self::WithPlanAndStats => serializer.serialize_i32(4),
7286 Self::UnknownValue(u) => u.0.serialize(serializer),
7287 }
7288 }
7289 }
7290
7291 impl<'de> serde::de::Deserialize<'de> for QueryMode {
7292 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7293 where
7294 D: serde::Deserializer<'de>,
7295 {
7296 deserializer.deserialize_any(wkt::internal::EnumVisitor::<QueryMode>::new(
7297 ".google.spanner.v1.ExecuteSqlRequest.QueryMode",
7298 ))
7299 }
7300 }
7301}
7302
7303/// The request for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
7304///
7305/// [google.spanner.v1.Spanner.ExecuteBatchDml]: crate::client::Spanner::execute_batch_dml
7306#[derive(Clone, Default, PartialEq)]
7307#[non_exhaustive]
7308pub struct ExecuteBatchDmlRequest {
7309 /// Required. The session in which the DML statements should be performed.
7310 pub session: std::string::String,
7311
7312 /// Required. The transaction to use. Must be a read-write transaction.
7313 ///
7314 /// To protect against replays, single-use transactions are not supported. The
7315 /// caller must either supply an existing transaction ID or begin a new
7316 /// transaction.
7317 pub transaction: std::option::Option<crate::model::TransactionSelector>,
7318
7319 /// Required. The list of statements to execute in this batch. Statements are
7320 /// executed serially, such that the effects of statement `i` are visible to
7321 /// statement `i+1`. Each statement must be a DML statement. Execution stops at
7322 /// the first failed statement; the remaining statements are not executed.
7323 ///
7324 /// Callers must provide at least one statement.
7325 pub statements: std::vec::Vec<crate::model::execute_batch_dml_request::Statement>,
7326
7327 /// Required. A per-transaction sequence number used to identify this request.
7328 /// This field makes each request idempotent such that if the request is
7329 /// received multiple times, at most one succeeds.
7330 ///
7331 /// The sequence number must be monotonically increasing within the
7332 /// transaction. If a request arrives for the first time with an out-of-order
7333 /// sequence number, the transaction might be aborted. Replays of previously
7334 /// handled requests yield the same response as the first execution.
7335 pub seqno: i64,
7336
7337 /// Common options for this request.
7338 pub request_options: std::option::Option<crate::model::RequestOptions>,
7339
7340 /// Optional. If set to `true`, this request marks the end of the transaction.
7341 /// After these statements execute, you must commit or abort the transaction.
7342 /// Attempts to execute any other requests against this transaction
7343 /// (including reads and queries) are rejected.
7344 ///
7345 /// Setting this option might cause some error reporting to be deferred until
7346 /// commit time (for example, validation of unique constraints). Given this,
7347 /// successful execution of statements shouldn't be assumed until a subsequent
7348 /// `Commit` call completes successfully.
7349 pub last_statements: bool,
7350
7351 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7352}
7353
7354impl ExecuteBatchDmlRequest {
7355 /// Creates a new default instance.
7356 pub fn new() -> Self {
7357 std::default::Default::default()
7358 }
7359
7360 /// Sets the value of [session][crate::model::ExecuteBatchDmlRequest::session].
7361 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7362 self.session = v.into();
7363 self
7364 }
7365
7366 /// Sets the value of [transaction][crate::model::ExecuteBatchDmlRequest::transaction].
7367 pub fn set_transaction<T>(mut self, v: T) -> Self
7368 where
7369 T: std::convert::Into<crate::model::TransactionSelector>,
7370 {
7371 self.transaction = std::option::Option::Some(v.into());
7372 self
7373 }
7374
7375 /// Sets or clears the value of [transaction][crate::model::ExecuteBatchDmlRequest::transaction].
7376 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
7377 where
7378 T: std::convert::Into<crate::model::TransactionSelector>,
7379 {
7380 self.transaction = v.map(|x| x.into());
7381 self
7382 }
7383
7384 /// Sets the value of [statements][crate::model::ExecuteBatchDmlRequest::statements].
7385 pub fn set_statements<T, V>(mut self, v: T) -> Self
7386 where
7387 T: std::iter::IntoIterator<Item = V>,
7388 V: std::convert::Into<crate::model::execute_batch_dml_request::Statement>,
7389 {
7390 use std::iter::Iterator;
7391 self.statements = v.into_iter().map(|i| i.into()).collect();
7392 self
7393 }
7394
7395 /// Sets the value of [seqno][crate::model::ExecuteBatchDmlRequest::seqno].
7396 pub fn set_seqno<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7397 self.seqno = v.into();
7398 self
7399 }
7400
7401 /// Sets the value of [request_options][crate::model::ExecuteBatchDmlRequest::request_options].
7402 pub fn set_request_options<T>(mut self, v: T) -> Self
7403 where
7404 T: std::convert::Into<crate::model::RequestOptions>,
7405 {
7406 self.request_options = std::option::Option::Some(v.into());
7407 self
7408 }
7409
7410 /// Sets or clears the value of [request_options][crate::model::ExecuteBatchDmlRequest::request_options].
7411 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
7412 where
7413 T: std::convert::Into<crate::model::RequestOptions>,
7414 {
7415 self.request_options = v.map(|x| x.into());
7416 self
7417 }
7418
7419 /// Sets the value of [last_statements][crate::model::ExecuteBatchDmlRequest::last_statements].
7420 pub fn set_last_statements<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7421 self.last_statements = v.into();
7422 self
7423 }
7424}
7425
7426impl wkt::message::Message for ExecuteBatchDmlRequest {
7427 fn typename() -> &'static str {
7428 "type.googleapis.com/google.spanner.v1.ExecuteBatchDmlRequest"
7429 }
7430}
7431
7432/// Defines additional types related to [ExecuteBatchDmlRequest].
7433pub mod execute_batch_dml_request {
7434 #[allow(unused_imports)]
7435 use super::*;
7436
7437 /// A single DML statement.
7438 #[derive(Clone, Default, PartialEq)]
7439 #[non_exhaustive]
7440 pub struct Statement {
7441 /// Required. The DML string.
7442 pub sql: std::string::String,
7443
7444 /// Parameter names and values that bind to placeholders in the DML string.
7445 ///
7446 /// A parameter placeholder consists of the `@` character followed by the
7447 /// parameter name (for example, `@firstName`). Parameter names can contain
7448 /// letters, numbers, and underscores.
7449 ///
7450 /// Parameters can appear anywhere that a literal value is expected. The
7451 /// same parameter name can be used more than once, for example:
7452 ///
7453 /// `"WHERE id > @msg_id AND id < @msg_id + 100"`
7454 ///
7455 /// It's an error to execute a SQL statement with unbound parameters.
7456 pub params: std::option::Option<wkt::Struct>,
7457
7458 /// It isn't always possible for Cloud Spanner to infer the right SQL type
7459 /// from a JSON value. For example, values of type `BYTES` and values
7460 /// of type `STRING` both appear in
7461 /// [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as
7462 /// JSON strings.
7463 ///
7464 /// In these cases, `param_types` can be used to specify the exact
7465 /// SQL type for some or all of the SQL statement parameters. See the
7466 /// definition of [Type][google.spanner.v1.Type] for more information
7467 /// about SQL types.
7468 ///
7469 /// [google.spanner.v1.ExecuteBatchDmlRequest.Statement.params]: crate::model::execute_batch_dml_request::Statement::params
7470 /// [google.spanner.v1.Type]: crate::model::Type
7471 pub param_types: std::collections::HashMap<std::string::String, crate::model::Type>,
7472
7473 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7474 }
7475
7476 impl Statement {
7477 /// Creates a new default instance.
7478 pub fn new() -> Self {
7479 std::default::Default::default()
7480 }
7481
7482 /// Sets the value of [sql][crate::model::execute_batch_dml_request::Statement::sql].
7483 pub fn set_sql<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7484 self.sql = v.into();
7485 self
7486 }
7487
7488 /// Sets the value of [params][crate::model::execute_batch_dml_request::Statement::params].
7489 pub fn set_params<T>(mut self, v: T) -> Self
7490 where
7491 T: std::convert::Into<wkt::Struct>,
7492 {
7493 self.params = std::option::Option::Some(v.into());
7494 self
7495 }
7496
7497 /// Sets or clears the value of [params][crate::model::execute_batch_dml_request::Statement::params].
7498 pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
7499 where
7500 T: std::convert::Into<wkt::Struct>,
7501 {
7502 self.params = v.map(|x| x.into());
7503 self
7504 }
7505
7506 /// Sets the value of [param_types][crate::model::execute_batch_dml_request::Statement::param_types].
7507 pub fn set_param_types<T, K, V>(mut self, v: T) -> Self
7508 where
7509 T: std::iter::IntoIterator<Item = (K, V)>,
7510 K: std::convert::Into<std::string::String>,
7511 V: std::convert::Into<crate::model::Type>,
7512 {
7513 use std::iter::Iterator;
7514 self.param_types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7515 self
7516 }
7517 }
7518
7519 impl wkt::message::Message for Statement {
7520 fn typename() -> &'static str {
7521 "type.googleapis.com/google.spanner.v1.ExecuteBatchDmlRequest.Statement"
7522 }
7523 }
7524}
7525
7526/// The response for
7527/// [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
7528/// of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML
7529/// statement that has successfully executed, in the same order as the statements
7530/// in the request. If a statement fails, the status in the response body
7531/// identifies the cause of the failure.
7532///
7533/// To check for DML statements that failed, use the following approach:
7534///
7535/// 1. Check the status in the response message. The
7536/// [google.rpc.Code][google.rpc.Code] enum
7537/// value `OK` indicates that all statements were executed successfully.
7538/// 1. If the status was not `OK`, check the number of result sets in the
7539/// response. If the response contains `N`
7540/// [ResultSet][google.spanner.v1.ResultSet] messages, then statement `N+1` in
7541/// the request failed.
7542///
7543/// Example 1:
7544///
7545/// * Request: 5 DML statements, all executed successfully.
7546/// * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the
7547/// status `OK`.
7548///
7549/// Example 2:
7550///
7551/// * Request: 5 DML statements. The third statement has a syntax error.
7552/// * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax
7553/// error (`INVALID_ARGUMENT`)
7554/// status. The number of [ResultSet][google.spanner.v1.ResultSet] messages
7555/// indicates that the third statement failed, and the fourth and fifth
7556/// statements were not executed.
7557///
7558/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
7559/// [google.spanner.v1.Spanner.ExecuteBatchDml]: crate::client::Spanner::execute_batch_dml
7560#[derive(Clone, Default, PartialEq)]
7561#[non_exhaustive]
7562pub struct ExecuteBatchDmlResponse {
7563 /// One [ResultSet][google.spanner.v1.ResultSet] for each statement in the
7564 /// request that ran successfully, in the same order as the statements in the
7565 /// request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any
7566 /// rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each
7567 /// [ResultSet][google.spanner.v1.ResultSet] contain the number of rows
7568 /// modified by the statement.
7569 ///
7570 /// Only the first [ResultSet][google.spanner.v1.ResultSet] in the response
7571 /// contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata].
7572 ///
7573 /// [google.spanner.v1.ResultSet]: crate::model::ResultSet
7574 /// [google.spanner.v1.ResultSetMetadata]: crate::model::ResultSetMetadata
7575 /// [google.spanner.v1.ResultSetStats]: crate::model::ResultSetStats
7576 pub result_sets: std::vec::Vec<crate::model::ResultSet>,
7577
7578 /// If all DML statements are executed successfully, the status is `OK`.
7579 /// Otherwise, the error status of the first failed statement.
7580 pub status: std::option::Option<google_cloud_rpc::model::Status>,
7581
7582 /// Optional. A precommit token is included if the read-write transaction
7583 /// is on a multiplexed session. Pass the precommit token with the highest
7584 /// sequence number from this transaction attempt should be passed to the
7585 /// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
7586 ///
7587 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
7588 pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
7589
7590 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7591}
7592
7593impl ExecuteBatchDmlResponse {
7594 /// Creates a new default instance.
7595 pub fn new() -> Self {
7596 std::default::Default::default()
7597 }
7598
7599 /// Sets the value of [result_sets][crate::model::ExecuteBatchDmlResponse::result_sets].
7600 pub fn set_result_sets<T, V>(mut self, v: T) -> Self
7601 where
7602 T: std::iter::IntoIterator<Item = V>,
7603 V: std::convert::Into<crate::model::ResultSet>,
7604 {
7605 use std::iter::Iterator;
7606 self.result_sets = v.into_iter().map(|i| i.into()).collect();
7607 self
7608 }
7609
7610 /// Sets the value of [status][crate::model::ExecuteBatchDmlResponse::status].
7611 pub fn set_status<T>(mut self, v: T) -> Self
7612 where
7613 T: std::convert::Into<google_cloud_rpc::model::Status>,
7614 {
7615 self.status = std::option::Option::Some(v.into());
7616 self
7617 }
7618
7619 /// Sets or clears the value of [status][crate::model::ExecuteBatchDmlResponse::status].
7620 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
7621 where
7622 T: std::convert::Into<google_cloud_rpc::model::Status>,
7623 {
7624 self.status = v.map(|x| x.into());
7625 self
7626 }
7627
7628 /// Sets the value of [precommit_token][crate::model::ExecuteBatchDmlResponse::precommit_token].
7629 pub fn set_precommit_token<T>(mut self, v: T) -> Self
7630 where
7631 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
7632 {
7633 self.precommit_token = std::option::Option::Some(v.into());
7634 self
7635 }
7636
7637 /// Sets or clears the value of [precommit_token][crate::model::ExecuteBatchDmlResponse::precommit_token].
7638 pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
7639 where
7640 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
7641 {
7642 self.precommit_token = v.map(|x| x.into());
7643 self
7644 }
7645}
7646
7647impl wkt::message::Message for ExecuteBatchDmlResponse {
7648 fn typename() -> &'static str {
7649 "type.googleapis.com/google.spanner.v1.ExecuteBatchDmlResponse"
7650 }
7651}
7652
7653/// Options for a `PartitionQueryRequest` and `PartitionReadRequest`.
7654#[derive(Clone, Default, PartialEq)]
7655#[non_exhaustive]
7656pub struct PartitionOptions {
7657 /// **Note:** This hint is currently ignored by `PartitionQuery` and
7658 /// `PartitionRead` requests.
7659 ///
7660 /// The desired data size for each partition generated. The default for this
7661 /// option is currently 1 GiB. This is only a hint. The actual size of each
7662 /// partition can be smaller or larger than this size request.
7663 pub partition_size_bytes: i64,
7664
7665 /// **Note:** This hint is currently ignored by `PartitionQuery` and
7666 /// `PartitionRead` requests.
7667 ///
7668 /// The desired maximum number of partitions to return. For example, this
7669 /// might be set to the number of workers available. The default for this
7670 /// option is currently 10,000. The maximum value is currently 200,000. This
7671 /// is only a hint. The actual number of partitions returned can be smaller or
7672 /// larger than this maximum count request.
7673 pub max_partitions: i64,
7674
7675 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7676}
7677
7678impl PartitionOptions {
7679 /// Creates a new default instance.
7680 pub fn new() -> Self {
7681 std::default::Default::default()
7682 }
7683
7684 /// Sets the value of [partition_size_bytes][crate::model::PartitionOptions::partition_size_bytes].
7685 pub fn set_partition_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7686 self.partition_size_bytes = v.into();
7687 self
7688 }
7689
7690 /// Sets the value of [max_partitions][crate::model::PartitionOptions::max_partitions].
7691 pub fn set_max_partitions<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7692 self.max_partitions = v.into();
7693 self
7694 }
7695}
7696
7697impl wkt::message::Message for PartitionOptions {
7698 fn typename() -> &'static str {
7699 "type.googleapis.com/google.spanner.v1.PartitionOptions"
7700 }
7701}
7702
7703/// The request for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
7704///
7705/// [google.spanner.v1.Spanner.PartitionQuery]: crate::client::Spanner::partition_query
7706#[derive(Clone, Default, PartialEq)]
7707#[non_exhaustive]
7708pub struct PartitionQueryRequest {
7709 /// Required. The session used to create the partitions.
7710 pub session: std::string::String,
7711
7712 /// Read-only snapshot transactions are supported, read and write and
7713 /// single-use transactions are not.
7714 pub transaction: std::option::Option<crate::model::TransactionSelector>,
7715
7716 /// Required. The query request to generate partitions for. The request fails
7717 /// if the query isn't root partitionable. For a query to be root
7718 /// partitionable, it needs to satisfy a few conditions. For example, if the
7719 /// query execution plan contains a distributed union operator, then it must be
7720 /// the first operator in the plan. For more information about other
7721 /// conditions, see [Read data in
7722 /// parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel).
7723 ///
7724 /// The query request must not contain DML commands, such as `INSERT`,
7725 /// `UPDATE`, or `DELETE`. Use
7726 /// [`ExecuteStreamingSql`][google.spanner.v1.Spanner.ExecuteStreamingSql] with
7727 /// a `PartitionedDml` transaction for large, partition-friendly DML
7728 /// operations.
7729 pub sql: std::string::String,
7730
7731 /// Optional. Parameter names and values that bind to placeholders in the SQL
7732 /// string.
7733 ///
7734 /// A parameter placeholder consists of the `@` character followed by the
7735 /// parameter name (for example, `@firstName`). Parameter names can contain
7736 /// letters, numbers, and underscores.
7737 ///
7738 /// Parameters can appear anywhere that a literal value is expected. The same
7739 /// parameter name can be used more than once, for example:
7740 ///
7741 /// `"WHERE id > @msg_id AND id < @msg_id + 100"`
7742 ///
7743 /// It's an error to execute a SQL statement with unbound parameters.
7744 pub params: std::option::Option<wkt::Struct>,
7745
7746 /// Optional. It isn't always possible for Cloud Spanner to infer the right SQL
7747 /// type from a JSON value. For example, values of type `BYTES` and values of
7748 /// type `STRING` both appear in
7749 /// [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings.
7750 ///
7751 /// In these cases, `param_types` can be used to specify the exact
7752 /// SQL type for some or all of the SQL query parameters. See the
7753 /// definition of [Type][google.spanner.v1.Type] for more information
7754 /// about SQL types.
7755 ///
7756 /// [google.spanner.v1.PartitionQueryRequest.params]: crate::model::PartitionQueryRequest::params
7757 /// [google.spanner.v1.Type]: crate::model::Type
7758 pub param_types: std::collections::HashMap<std::string::String, crate::model::Type>,
7759
7760 /// Additional options that affect how many partitions are created.
7761 pub partition_options: std::option::Option<crate::model::PartitionOptions>,
7762
7763 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7764}
7765
7766impl PartitionQueryRequest {
7767 /// Creates a new default instance.
7768 pub fn new() -> Self {
7769 std::default::Default::default()
7770 }
7771
7772 /// Sets the value of [session][crate::model::PartitionQueryRequest::session].
7773 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7774 self.session = v.into();
7775 self
7776 }
7777
7778 /// Sets the value of [transaction][crate::model::PartitionQueryRequest::transaction].
7779 pub fn set_transaction<T>(mut self, v: T) -> Self
7780 where
7781 T: std::convert::Into<crate::model::TransactionSelector>,
7782 {
7783 self.transaction = std::option::Option::Some(v.into());
7784 self
7785 }
7786
7787 /// Sets or clears the value of [transaction][crate::model::PartitionQueryRequest::transaction].
7788 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
7789 where
7790 T: std::convert::Into<crate::model::TransactionSelector>,
7791 {
7792 self.transaction = v.map(|x| x.into());
7793 self
7794 }
7795
7796 /// Sets the value of [sql][crate::model::PartitionQueryRequest::sql].
7797 pub fn set_sql<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7798 self.sql = v.into();
7799 self
7800 }
7801
7802 /// Sets the value of [params][crate::model::PartitionQueryRequest::params].
7803 pub fn set_params<T>(mut self, v: T) -> Self
7804 where
7805 T: std::convert::Into<wkt::Struct>,
7806 {
7807 self.params = std::option::Option::Some(v.into());
7808 self
7809 }
7810
7811 /// Sets or clears the value of [params][crate::model::PartitionQueryRequest::params].
7812 pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
7813 where
7814 T: std::convert::Into<wkt::Struct>,
7815 {
7816 self.params = v.map(|x| x.into());
7817 self
7818 }
7819
7820 /// Sets the value of [param_types][crate::model::PartitionQueryRequest::param_types].
7821 pub fn set_param_types<T, K, V>(mut self, v: T) -> Self
7822 where
7823 T: std::iter::IntoIterator<Item = (K, V)>,
7824 K: std::convert::Into<std::string::String>,
7825 V: std::convert::Into<crate::model::Type>,
7826 {
7827 use std::iter::Iterator;
7828 self.param_types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7829 self
7830 }
7831
7832 /// Sets the value of [partition_options][crate::model::PartitionQueryRequest::partition_options].
7833 pub fn set_partition_options<T>(mut self, v: T) -> Self
7834 where
7835 T: std::convert::Into<crate::model::PartitionOptions>,
7836 {
7837 self.partition_options = std::option::Option::Some(v.into());
7838 self
7839 }
7840
7841 /// Sets or clears the value of [partition_options][crate::model::PartitionQueryRequest::partition_options].
7842 pub fn set_or_clear_partition_options<T>(mut self, v: std::option::Option<T>) -> Self
7843 where
7844 T: std::convert::Into<crate::model::PartitionOptions>,
7845 {
7846 self.partition_options = v.map(|x| x.into());
7847 self
7848 }
7849}
7850
7851impl wkt::message::Message for PartitionQueryRequest {
7852 fn typename() -> &'static str {
7853 "type.googleapis.com/google.spanner.v1.PartitionQueryRequest"
7854 }
7855}
7856
7857/// The request for [PartitionRead][google.spanner.v1.Spanner.PartitionRead]
7858///
7859/// [google.spanner.v1.Spanner.PartitionRead]: crate::client::Spanner::partition_read
7860#[derive(Clone, Default, PartialEq)]
7861#[non_exhaustive]
7862pub struct PartitionReadRequest {
7863 /// Required. The session used to create the partitions.
7864 pub session: std::string::String,
7865
7866 /// Read only snapshot transactions are supported, read/write and single use
7867 /// transactions are not.
7868 pub transaction: std::option::Option<crate::model::TransactionSelector>,
7869
7870 /// Required. The name of the table in the database to be read.
7871 pub table: std::string::String,
7872
7873 /// If non-empty, the name of an index on
7874 /// [table][google.spanner.v1.PartitionReadRequest.table]. This index is used
7875 /// instead of the table primary key when interpreting
7876 /// [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting
7877 /// result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set]
7878 /// for further information.
7879 ///
7880 /// [google.spanner.v1.PartitionReadRequest.key_set]: crate::model::PartitionReadRequest::key_set
7881 /// [google.spanner.v1.PartitionReadRequest.table]: crate::model::PartitionReadRequest::table
7882 pub index: std::string::String,
7883
7884 /// The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be
7885 /// returned for each row matching this request.
7886 ///
7887 /// [google.spanner.v1.PartitionReadRequest.table]: crate::model::PartitionReadRequest::table
7888 pub columns: std::vec::Vec<std::string::String>,
7889
7890 /// Required. `key_set` identifies the rows to be yielded. `key_set` names the
7891 /// primary keys of the rows in
7892 /// [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless
7893 /// [index][google.spanner.v1.PartitionReadRequest.index] is present. If
7894 /// [index][google.spanner.v1.PartitionReadRequest.index] is present, then
7895 /// [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names
7896 /// index keys in [index][google.spanner.v1.PartitionReadRequest.index].
7897 ///
7898 /// It isn't an error for the `key_set` to name rows that don't
7899 /// exist in the database. Read yields nothing for nonexistent rows.
7900 ///
7901 /// [google.spanner.v1.PartitionReadRequest.index]: crate::model::PartitionReadRequest::index
7902 /// [google.spanner.v1.PartitionReadRequest.key_set]: crate::model::PartitionReadRequest::key_set
7903 /// [google.spanner.v1.PartitionReadRequest.table]: crate::model::PartitionReadRequest::table
7904 pub key_set: std::option::Option<crate::model::KeySet>,
7905
7906 /// Additional options that affect how many partitions are created.
7907 pub partition_options: std::option::Option<crate::model::PartitionOptions>,
7908
7909 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7910}
7911
7912impl PartitionReadRequest {
7913 /// Creates a new default instance.
7914 pub fn new() -> Self {
7915 std::default::Default::default()
7916 }
7917
7918 /// Sets the value of [session][crate::model::PartitionReadRequest::session].
7919 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7920 self.session = v.into();
7921 self
7922 }
7923
7924 /// Sets the value of [transaction][crate::model::PartitionReadRequest::transaction].
7925 pub fn set_transaction<T>(mut self, v: T) -> Self
7926 where
7927 T: std::convert::Into<crate::model::TransactionSelector>,
7928 {
7929 self.transaction = std::option::Option::Some(v.into());
7930 self
7931 }
7932
7933 /// Sets or clears the value of [transaction][crate::model::PartitionReadRequest::transaction].
7934 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
7935 where
7936 T: std::convert::Into<crate::model::TransactionSelector>,
7937 {
7938 self.transaction = v.map(|x| x.into());
7939 self
7940 }
7941
7942 /// Sets the value of [table][crate::model::PartitionReadRequest::table].
7943 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7944 self.table = v.into();
7945 self
7946 }
7947
7948 /// Sets the value of [index][crate::model::PartitionReadRequest::index].
7949 pub fn set_index<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7950 self.index = v.into();
7951 self
7952 }
7953
7954 /// Sets the value of [columns][crate::model::PartitionReadRequest::columns].
7955 pub fn set_columns<T, V>(mut self, v: T) -> Self
7956 where
7957 T: std::iter::IntoIterator<Item = V>,
7958 V: std::convert::Into<std::string::String>,
7959 {
7960 use std::iter::Iterator;
7961 self.columns = v.into_iter().map(|i| i.into()).collect();
7962 self
7963 }
7964
7965 /// Sets the value of [key_set][crate::model::PartitionReadRequest::key_set].
7966 pub fn set_key_set<T>(mut self, v: T) -> Self
7967 where
7968 T: std::convert::Into<crate::model::KeySet>,
7969 {
7970 self.key_set = std::option::Option::Some(v.into());
7971 self
7972 }
7973
7974 /// Sets or clears the value of [key_set][crate::model::PartitionReadRequest::key_set].
7975 pub fn set_or_clear_key_set<T>(mut self, v: std::option::Option<T>) -> Self
7976 where
7977 T: std::convert::Into<crate::model::KeySet>,
7978 {
7979 self.key_set = v.map(|x| x.into());
7980 self
7981 }
7982
7983 /// Sets the value of [partition_options][crate::model::PartitionReadRequest::partition_options].
7984 pub fn set_partition_options<T>(mut self, v: T) -> Self
7985 where
7986 T: std::convert::Into<crate::model::PartitionOptions>,
7987 {
7988 self.partition_options = std::option::Option::Some(v.into());
7989 self
7990 }
7991
7992 /// Sets or clears the value of [partition_options][crate::model::PartitionReadRequest::partition_options].
7993 pub fn set_or_clear_partition_options<T>(mut self, v: std::option::Option<T>) -> Self
7994 where
7995 T: std::convert::Into<crate::model::PartitionOptions>,
7996 {
7997 self.partition_options = v.map(|x| x.into());
7998 self
7999 }
8000}
8001
8002impl wkt::message::Message for PartitionReadRequest {
8003 fn typename() -> &'static str {
8004 "type.googleapis.com/google.spanner.v1.PartitionReadRequest"
8005 }
8006}
8007
8008/// Information returned for each partition returned in a
8009/// PartitionResponse.
8010#[derive(Clone, Default, PartialEq)]
8011#[non_exhaustive]
8012pub struct Partition {
8013 /// This token can be passed to `Read`, `StreamingRead`, `ExecuteSql`, or
8014 /// `ExecuteStreamingSql` requests to restrict the results to those identified
8015 /// by this partition token.
8016 pub partition_token: ::bytes::Bytes,
8017
8018 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8019}
8020
8021impl Partition {
8022 /// Creates a new default instance.
8023 pub fn new() -> Self {
8024 std::default::Default::default()
8025 }
8026
8027 /// Sets the value of [partition_token][crate::model::Partition::partition_token].
8028 pub fn set_partition_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
8029 self.partition_token = v.into();
8030 self
8031 }
8032}
8033
8034impl wkt::message::Message for Partition {
8035 fn typename() -> &'static str {
8036 "type.googleapis.com/google.spanner.v1.Partition"
8037 }
8038}
8039
8040/// The response for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
8041/// or [PartitionRead][google.spanner.v1.Spanner.PartitionRead]
8042///
8043/// [google.spanner.v1.Spanner.PartitionQuery]: crate::client::Spanner::partition_query
8044/// [google.spanner.v1.Spanner.PartitionRead]: crate::client::Spanner::partition_read
8045#[derive(Clone, Default, PartialEq)]
8046#[non_exhaustive]
8047pub struct PartitionResponse {
8048 /// Partitions created by this request.
8049 pub partitions: std::vec::Vec<crate::model::Partition>,
8050
8051 /// Transaction created by this request.
8052 pub transaction: std::option::Option<crate::model::Transaction>,
8053
8054 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8055}
8056
8057impl PartitionResponse {
8058 /// Creates a new default instance.
8059 pub fn new() -> Self {
8060 std::default::Default::default()
8061 }
8062
8063 /// Sets the value of [partitions][crate::model::PartitionResponse::partitions].
8064 pub fn set_partitions<T, V>(mut self, v: T) -> Self
8065 where
8066 T: std::iter::IntoIterator<Item = V>,
8067 V: std::convert::Into<crate::model::Partition>,
8068 {
8069 use std::iter::Iterator;
8070 self.partitions = v.into_iter().map(|i| i.into()).collect();
8071 self
8072 }
8073
8074 /// Sets the value of [transaction][crate::model::PartitionResponse::transaction].
8075 pub fn set_transaction<T>(mut self, v: T) -> Self
8076 where
8077 T: std::convert::Into<crate::model::Transaction>,
8078 {
8079 self.transaction = std::option::Option::Some(v.into());
8080 self
8081 }
8082
8083 /// Sets or clears the value of [transaction][crate::model::PartitionResponse::transaction].
8084 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
8085 where
8086 T: std::convert::Into<crate::model::Transaction>,
8087 {
8088 self.transaction = v.map(|x| x.into());
8089 self
8090 }
8091}
8092
8093impl wkt::message::Message for PartitionResponse {
8094 fn typename() -> &'static str {
8095 "type.googleapis.com/google.spanner.v1.PartitionResponse"
8096 }
8097}
8098
8099/// The request for [Read][google.spanner.v1.Spanner.Read] and
8100/// [StreamingRead][google.spanner.v1.Spanner.StreamingRead].
8101///
8102/// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
8103#[derive(Clone, Default, PartialEq)]
8104#[non_exhaustive]
8105pub struct ReadRequest {
8106 /// Required. The session in which the read should be performed.
8107 pub session: std::string::String,
8108
8109 /// The transaction to use. If none is provided, the default is a
8110 /// temporary read-only transaction with strong concurrency.
8111 pub transaction: std::option::Option<crate::model::TransactionSelector>,
8112
8113 /// Required. The name of the table in the database to be read.
8114 pub table: std::string::String,
8115
8116 /// If non-empty, the name of an index on
8117 /// [table][google.spanner.v1.ReadRequest.table]. This index is used instead of
8118 /// the table primary key when interpreting
8119 /// [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows.
8120 /// See [key_set][google.spanner.v1.ReadRequest.key_set] for further
8121 /// information.
8122 ///
8123 /// [google.spanner.v1.ReadRequest.key_set]: crate::model::ReadRequest::key_set
8124 /// [google.spanner.v1.ReadRequest.table]: crate::model::ReadRequest::table
8125 pub index: std::string::String,
8126
8127 /// Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be
8128 /// returned for each row matching this request.
8129 ///
8130 /// [google.spanner.v1.ReadRequest.table]: crate::model::ReadRequest::table
8131 pub columns: std::vec::Vec<std::string::String>,
8132
8133 /// Required. `key_set` identifies the rows to be yielded. `key_set` names the
8134 /// primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to
8135 /// be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present.
8136 /// If [index][google.spanner.v1.ReadRequest.index] is present, then
8137 /// [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys
8138 /// in [index][google.spanner.v1.ReadRequest.index].
8139 ///
8140 /// If the [partition_token][google.spanner.v1.ReadRequest.partition_token]
8141 /// field is empty, rows are yielded in table primary key order (if
8142 /// [index][google.spanner.v1.ReadRequest.index] is empty) or index key order
8143 /// (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the
8144 /// [partition_token][google.spanner.v1.ReadRequest.partition_token] field
8145 /// isn't empty, rows are yielded in an unspecified order.
8146 ///
8147 /// It isn't an error for the `key_set` to name rows that don't
8148 /// exist in the database. Read yields nothing for nonexistent rows.
8149 ///
8150 /// [google.spanner.v1.ReadRequest.index]: crate::model::ReadRequest::index
8151 /// [google.spanner.v1.ReadRequest.key_set]: crate::model::ReadRequest::key_set
8152 /// [google.spanner.v1.ReadRequest.partition_token]: crate::model::ReadRequest::partition_token
8153 /// [google.spanner.v1.ReadRequest.table]: crate::model::ReadRequest::table
8154 pub key_set: std::option::Option<crate::model::KeySet>,
8155
8156 /// If greater than zero, only the first `limit` rows are yielded. If `limit`
8157 /// is zero, the default is no limit. A limit can't be specified if
8158 /// `partition_token` is set.
8159 pub limit: i64,
8160
8161 /// If this request is resuming a previously interrupted read,
8162 /// `resume_token` should be copied from the last
8163 /// [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
8164 /// interruption. Doing this enables the new read to resume where the last read
8165 /// left off. The rest of the request parameters must exactly match the request
8166 /// that yielded this token.
8167 ///
8168 /// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
8169 pub resume_token: ::bytes::Bytes,
8170
8171 /// If present, results are restricted to the specified partition
8172 /// previously created using `PartitionRead`. There must be an exact
8173 /// match for the values of fields common to this message and the
8174 /// PartitionReadRequest message used to create this partition_token.
8175 pub partition_token: ::bytes::Bytes,
8176
8177 /// Common options for this request.
8178 pub request_options: std::option::Option<crate::model::RequestOptions>,
8179
8180 /// Directed read options for this request.
8181 pub directed_read_options: std::option::Option<crate::model::DirectedReadOptions>,
8182
8183 /// If this is for a partitioned read and this field is set to `true`, the
8184 /// request is executed with Spanner Data Boost independent compute resources.
8185 ///
8186 /// If the field is set to `true` but the request doesn't set
8187 /// `partition_token`, the API returns an `INVALID_ARGUMENT` error.
8188 pub data_boost_enabled: bool,
8189
8190 /// Optional. Order for the returned rows.
8191 ///
8192 /// By default, Spanner returns result rows in primary key order except for
8193 /// PartitionRead requests. For applications that don't require rows to be
8194 /// returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting
8195 /// `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval,
8196 /// resulting in lower latencies in certain cases (for example, bulk point
8197 /// lookups).
8198 pub order_by: crate::model::read_request::OrderBy,
8199
8200 /// Optional. Lock Hint for the request, it can only be used with read-write
8201 /// transactions.
8202 pub lock_hint: crate::model::read_request::LockHint,
8203
8204 /// Optional. Makes the Spanner requests location-aware if present.
8205 ///
8206 /// It gives the server hints that can be used to route the request
8207 /// to an appropriate server, potentially significantly decreasing latency and
8208 /// improving throughput. To achieve improved performance, most fields must be
8209 /// filled in with accurate values.
8210 pub routing_hint: std::option::Option<crate::model::RoutingHint>,
8211
8212 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8213}
8214
8215impl ReadRequest {
8216 /// Creates a new default instance.
8217 pub fn new() -> Self {
8218 std::default::Default::default()
8219 }
8220
8221 /// Sets the value of [session][crate::model::ReadRequest::session].
8222 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8223 self.session = v.into();
8224 self
8225 }
8226
8227 /// Sets the value of [transaction][crate::model::ReadRequest::transaction].
8228 pub fn set_transaction<T>(mut self, v: T) -> Self
8229 where
8230 T: std::convert::Into<crate::model::TransactionSelector>,
8231 {
8232 self.transaction = std::option::Option::Some(v.into());
8233 self
8234 }
8235
8236 /// Sets or clears the value of [transaction][crate::model::ReadRequest::transaction].
8237 pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
8238 where
8239 T: std::convert::Into<crate::model::TransactionSelector>,
8240 {
8241 self.transaction = v.map(|x| x.into());
8242 self
8243 }
8244
8245 /// Sets the value of [table][crate::model::ReadRequest::table].
8246 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8247 self.table = v.into();
8248 self
8249 }
8250
8251 /// Sets the value of [index][crate::model::ReadRequest::index].
8252 pub fn set_index<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8253 self.index = v.into();
8254 self
8255 }
8256
8257 /// Sets the value of [columns][crate::model::ReadRequest::columns].
8258 pub fn set_columns<T, V>(mut self, v: T) -> Self
8259 where
8260 T: std::iter::IntoIterator<Item = V>,
8261 V: std::convert::Into<std::string::String>,
8262 {
8263 use std::iter::Iterator;
8264 self.columns = v.into_iter().map(|i| i.into()).collect();
8265 self
8266 }
8267
8268 /// Sets the value of [key_set][crate::model::ReadRequest::key_set].
8269 pub fn set_key_set<T>(mut self, v: T) -> Self
8270 where
8271 T: std::convert::Into<crate::model::KeySet>,
8272 {
8273 self.key_set = std::option::Option::Some(v.into());
8274 self
8275 }
8276
8277 /// Sets or clears the value of [key_set][crate::model::ReadRequest::key_set].
8278 pub fn set_or_clear_key_set<T>(mut self, v: std::option::Option<T>) -> Self
8279 where
8280 T: std::convert::Into<crate::model::KeySet>,
8281 {
8282 self.key_set = v.map(|x| x.into());
8283 self
8284 }
8285
8286 /// Sets the value of [limit][crate::model::ReadRequest::limit].
8287 pub fn set_limit<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
8288 self.limit = v.into();
8289 self
8290 }
8291
8292 /// Sets the value of [resume_token][crate::model::ReadRequest::resume_token].
8293 pub fn set_resume_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
8294 self.resume_token = v.into();
8295 self
8296 }
8297
8298 /// Sets the value of [partition_token][crate::model::ReadRequest::partition_token].
8299 pub fn set_partition_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
8300 self.partition_token = v.into();
8301 self
8302 }
8303
8304 /// Sets the value of [request_options][crate::model::ReadRequest::request_options].
8305 pub fn set_request_options<T>(mut self, v: T) -> Self
8306 where
8307 T: std::convert::Into<crate::model::RequestOptions>,
8308 {
8309 self.request_options = std::option::Option::Some(v.into());
8310 self
8311 }
8312
8313 /// Sets or clears the value of [request_options][crate::model::ReadRequest::request_options].
8314 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
8315 where
8316 T: std::convert::Into<crate::model::RequestOptions>,
8317 {
8318 self.request_options = v.map(|x| x.into());
8319 self
8320 }
8321
8322 /// Sets the value of [directed_read_options][crate::model::ReadRequest::directed_read_options].
8323 pub fn set_directed_read_options<T>(mut self, v: T) -> Self
8324 where
8325 T: std::convert::Into<crate::model::DirectedReadOptions>,
8326 {
8327 self.directed_read_options = std::option::Option::Some(v.into());
8328 self
8329 }
8330
8331 /// Sets or clears the value of [directed_read_options][crate::model::ReadRequest::directed_read_options].
8332 pub fn set_or_clear_directed_read_options<T>(mut self, v: std::option::Option<T>) -> Self
8333 where
8334 T: std::convert::Into<crate::model::DirectedReadOptions>,
8335 {
8336 self.directed_read_options = v.map(|x| x.into());
8337 self
8338 }
8339
8340 /// Sets the value of [data_boost_enabled][crate::model::ReadRequest::data_boost_enabled].
8341 pub fn set_data_boost_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8342 self.data_boost_enabled = v.into();
8343 self
8344 }
8345
8346 /// Sets the value of [order_by][crate::model::ReadRequest::order_by].
8347 pub fn set_order_by<T: std::convert::Into<crate::model::read_request::OrderBy>>(
8348 mut self,
8349 v: T,
8350 ) -> Self {
8351 self.order_by = v.into();
8352 self
8353 }
8354
8355 /// Sets the value of [lock_hint][crate::model::ReadRequest::lock_hint].
8356 pub fn set_lock_hint<T: std::convert::Into<crate::model::read_request::LockHint>>(
8357 mut self,
8358 v: T,
8359 ) -> Self {
8360 self.lock_hint = v.into();
8361 self
8362 }
8363
8364 /// Sets the value of [routing_hint][crate::model::ReadRequest::routing_hint].
8365 pub fn set_routing_hint<T>(mut self, v: T) -> Self
8366 where
8367 T: std::convert::Into<crate::model::RoutingHint>,
8368 {
8369 self.routing_hint = std::option::Option::Some(v.into());
8370 self
8371 }
8372
8373 /// Sets or clears the value of [routing_hint][crate::model::ReadRequest::routing_hint].
8374 pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
8375 where
8376 T: std::convert::Into<crate::model::RoutingHint>,
8377 {
8378 self.routing_hint = v.map(|x| x.into());
8379 self
8380 }
8381}
8382
8383impl wkt::message::Message for ReadRequest {
8384 fn typename() -> &'static str {
8385 "type.googleapis.com/google.spanner.v1.ReadRequest"
8386 }
8387}
8388
8389/// Defines additional types related to [ReadRequest].
8390pub mod read_request {
8391 #[allow(unused_imports)]
8392 use super::*;
8393
8394 /// An option to control the order in which rows are returned from a read.
8395 ///
8396 /// # Working with unknown values
8397 ///
8398 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8399 /// additional enum variants at any time. Adding new variants is not considered
8400 /// a breaking change. Applications should write their code in anticipation of:
8401 ///
8402 /// - New values appearing in future releases of the client library, **and**
8403 /// - New values received dynamically, without application changes.
8404 ///
8405 /// Please consult the [Working with enums] section in the user guide for some
8406 /// guidelines.
8407 ///
8408 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8409 #[derive(Clone, Debug, PartialEq)]
8410 #[non_exhaustive]
8411 pub enum OrderBy {
8412 /// Default value.
8413 ///
8414 /// `ORDER_BY_UNSPECIFIED` is equivalent to `ORDER_BY_PRIMARY_KEY`.
8415 Unspecified,
8416 /// Read rows are returned in primary key order.
8417 ///
8418 /// In the event that this option is used in conjunction with the
8419 /// `partition_token` field, the API returns an `INVALID_ARGUMENT` error.
8420 PrimaryKey,
8421 /// Read rows are returned in any order.
8422 NoOrder,
8423 /// If set, the enum was initialized with an unknown value.
8424 ///
8425 /// Applications can examine the value using [OrderBy::value] or
8426 /// [OrderBy::name].
8427 UnknownValue(order_by::UnknownValue),
8428 }
8429
8430 #[doc(hidden)]
8431 pub mod order_by {
8432 #[allow(unused_imports)]
8433 use super::*;
8434 #[derive(Clone, Debug, PartialEq)]
8435 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8436 }
8437
8438 impl OrderBy {
8439 /// Gets the enum value.
8440 ///
8441 /// Returns `None` if the enum contains an unknown value deserialized from
8442 /// the string representation of enums.
8443 pub fn value(&self) -> std::option::Option<i32> {
8444 match self {
8445 Self::Unspecified => std::option::Option::Some(0),
8446 Self::PrimaryKey => std::option::Option::Some(1),
8447 Self::NoOrder => std::option::Option::Some(2),
8448 Self::UnknownValue(u) => u.0.value(),
8449 }
8450 }
8451
8452 /// Gets the enum value as a string.
8453 ///
8454 /// Returns `None` if the enum contains an unknown value deserialized from
8455 /// the integer representation of enums.
8456 pub fn name(&self) -> std::option::Option<&str> {
8457 match self {
8458 Self::Unspecified => std::option::Option::Some("ORDER_BY_UNSPECIFIED"),
8459 Self::PrimaryKey => std::option::Option::Some("ORDER_BY_PRIMARY_KEY"),
8460 Self::NoOrder => std::option::Option::Some("ORDER_BY_NO_ORDER"),
8461 Self::UnknownValue(u) => u.0.name(),
8462 }
8463 }
8464 }
8465
8466 impl std::default::Default for OrderBy {
8467 fn default() -> Self {
8468 use std::convert::From;
8469 Self::from(0)
8470 }
8471 }
8472
8473 impl std::fmt::Display for OrderBy {
8474 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8475 wkt::internal::display_enum(f, self.name(), self.value())
8476 }
8477 }
8478
8479 impl std::convert::From<i32> for OrderBy {
8480 fn from(value: i32) -> Self {
8481 match value {
8482 0 => Self::Unspecified,
8483 1 => Self::PrimaryKey,
8484 2 => Self::NoOrder,
8485 _ => Self::UnknownValue(order_by::UnknownValue(
8486 wkt::internal::UnknownEnumValue::Integer(value),
8487 )),
8488 }
8489 }
8490 }
8491
8492 impl std::convert::From<&str> for OrderBy {
8493 fn from(value: &str) -> Self {
8494 use std::string::ToString;
8495 match value {
8496 "ORDER_BY_UNSPECIFIED" => Self::Unspecified,
8497 "ORDER_BY_PRIMARY_KEY" => Self::PrimaryKey,
8498 "ORDER_BY_NO_ORDER" => Self::NoOrder,
8499 _ => Self::UnknownValue(order_by::UnknownValue(
8500 wkt::internal::UnknownEnumValue::String(value.to_string()),
8501 )),
8502 }
8503 }
8504 }
8505
8506 impl serde::ser::Serialize for OrderBy {
8507 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8508 where
8509 S: serde::Serializer,
8510 {
8511 match self {
8512 Self::Unspecified => serializer.serialize_i32(0),
8513 Self::PrimaryKey => serializer.serialize_i32(1),
8514 Self::NoOrder => serializer.serialize_i32(2),
8515 Self::UnknownValue(u) => u.0.serialize(serializer),
8516 }
8517 }
8518 }
8519
8520 impl<'de> serde::de::Deserialize<'de> for OrderBy {
8521 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8522 where
8523 D: serde::Deserializer<'de>,
8524 {
8525 deserializer.deserialize_any(wkt::internal::EnumVisitor::<OrderBy>::new(
8526 ".google.spanner.v1.ReadRequest.OrderBy",
8527 ))
8528 }
8529 }
8530
8531 /// A lock hint mechanism for reads done within a transaction.
8532 ///
8533 /// # Working with unknown values
8534 ///
8535 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8536 /// additional enum variants at any time. Adding new variants is not considered
8537 /// a breaking change. Applications should write their code in anticipation of:
8538 ///
8539 /// - New values appearing in future releases of the client library, **and**
8540 /// - New values received dynamically, without application changes.
8541 ///
8542 /// Please consult the [Working with enums] section in the user guide for some
8543 /// guidelines.
8544 ///
8545 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8546 #[derive(Clone, Debug, PartialEq)]
8547 #[non_exhaustive]
8548 pub enum LockHint {
8549 /// Default value.
8550 ///
8551 /// `LOCK_HINT_UNSPECIFIED` is equivalent to `LOCK_HINT_SHARED`.
8552 Unspecified,
8553 /// Acquire shared locks.
8554 ///
8555 /// By default when you perform a read as part of a read-write transaction,
8556 /// Spanner acquires shared read locks, which allows other reads to still
8557 /// access the data until your transaction is ready to commit. When your
8558 /// transaction is committing and writes are being applied, the transaction
8559 /// attempts to upgrade to an exclusive lock for any data you are writing.
8560 /// For more information about locks, see [Lock
8561 /// modes](https://cloud.google.com/spanner/docs/introspection/lock-statistics#explain-lock-modes).
8562 Shared,
8563 /// Acquire exclusive locks.
8564 ///
8565 /// Requesting exclusive locks is beneficial if you observe high write
8566 /// contention, which means you notice that multiple transactions are
8567 /// concurrently trying to read and write to the same data, resulting in a
8568 /// large number of aborts. This problem occurs when two transactions
8569 /// initially acquire shared locks and then both try to upgrade to exclusive
8570 /// locks at the same time. In this situation both transactions are waiting
8571 /// for the other to give up their lock, resulting in a deadlocked situation.
8572 /// Spanner is able to detect this occurring and force one of the
8573 /// transactions to abort. However, this is a slow and expensive operation
8574 /// and results in lower performance. In this case it makes sense to acquire
8575 /// exclusive locks at the start of the transaction because then when
8576 /// multiple transactions try to act on the same data, they automatically get
8577 /// serialized. Each transaction waits its turn to acquire the lock and
8578 /// avoids getting into deadlock situations.
8579 ///
8580 /// Because the exclusive lock hint is just a hint, it shouldn't be
8581 /// considered equivalent to a mutex. In other words, you shouldn't use
8582 /// Spanner exclusive locks as a mutual exclusion mechanism for the execution
8583 /// of code outside of Spanner.
8584 ///
8585 /// **Note:** Request exclusive locks judiciously because they block others
8586 /// from reading that data for the entire transaction, rather than just when
8587 /// the writes are being performed. Unless you observe high write contention,
8588 /// you should use the default of shared read locks so you don't prematurely
8589 /// block other clients from reading the data that you're writing to.
8590 Exclusive,
8591 /// If set, the enum was initialized with an unknown value.
8592 ///
8593 /// Applications can examine the value using [LockHint::value] or
8594 /// [LockHint::name].
8595 UnknownValue(lock_hint::UnknownValue),
8596 }
8597
8598 #[doc(hidden)]
8599 pub mod lock_hint {
8600 #[allow(unused_imports)]
8601 use super::*;
8602 #[derive(Clone, Debug, PartialEq)]
8603 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8604 }
8605
8606 impl LockHint {
8607 /// Gets the enum value.
8608 ///
8609 /// Returns `None` if the enum contains an unknown value deserialized from
8610 /// the string representation of enums.
8611 pub fn value(&self) -> std::option::Option<i32> {
8612 match self {
8613 Self::Unspecified => std::option::Option::Some(0),
8614 Self::Shared => std::option::Option::Some(1),
8615 Self::Exclusive => std::option::Option::Some(2),
8616 Self::UnknownValue(u) => u.0.value(),
8617 }
8618 }
8619
8620 /// Gets the enum value as a string.
8621 ///
8622 /// Returns `None` if the enum contains an unknown value deserialized from
8623 /// the integer representation of enums.
8624 pub fn name(&self) -> std::option::Option<&str> {
8625 match self {
8626 Self::Unspecified => std::option::Option::Some("LOCK_HINT_UNSPECIFIED"),
8627 Self::Shared => std::option::Option::Some("LOCK_HINT_SHARED"),
8628 Self::Exclusive => std::option::Option::Some("LOCK_HINT_EXCLUSIVE"),
8629 Self::UnknownValue(u) => u.0.name(),
8630 }
8631 }
8632 }
8633
8634 impl std::default::Default for LockHint {
8635 fn default() -> Self {
8636 use std::convert::From;
8637 Self::from(0)
8638 }
8639 }
8640
8641 impl std::fmt::Display for LockHint {
8642 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8643 wkt::internal::display_enum(f, self.name(), self.value())
8644 }
8645 }
8646
8647 impl std::convert::From<i32> for LockHint {
8648 fn from(value: i32) -> Self {
8649 match value {
8650 0 => Self::Unspecified,
8651 1 => Self::Shared,
8652 2 => Self::Exclusive,
8653 _ => Self::UnknownValue(lock_hint::UnknownValue(
8654 wkt::internal::UnknownEnumValue::Integer(value),
8655 )),
8656 }
8657 }
8658 }
8659
8660 impl std::convert::From<&str> for LockHint {
8661 fn from(value: &str) -> Self {
8662 use std::string::ToString;
8663 match value {
8664 "LOCK_HINT_UNSPECIFIED" => Self::Unspecified,
8665 "LOCK_HINT_SHARED" => Self::Shared,
8666 "LOCK_HINT_EXCLUSIVE" => Self::Exclusive,
8667 _ => Self::UnknownValue(lock_hint::UnknownValue(
8668 wkt::internal::UnknownEnumValue::String(value.to_string()),
8669 )),
8670 }
8671 }
8672 }
8673
8674 impl serde::ser::Serialize for LockHint {
8675 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8676 where
8677 S: serde::Serializer,
8678 {
8679 match self {
8680 Self::Unspecified => serializer.serialize_i32(0),
8681 Self::Shared => serializer.serialize_i32(1),
8682 Self::Exclusive => serializer.serialize_i32(2),
8683 Self::UnknownValue(u) => u.0.serialize(serializer),
8684 }
8685 }
8686 }
8687
8688 impl<'de> serde::de::Deserialize<'de> for LockHint {
8689 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8690 where
8691 D: serde::Deserializer<'de>,
8692 {
8693 deserializer.deserialize_any(wkt::internal::EnumVisitor::<LockHint>::new(
8694 ".google.spanner.v1.ReadRequest.LockHint",
8695 ))
8696 }
8697 }
8698}
8699
8700/// The request for
8701/// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
8702///
8703/// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
8704#[derive(Clone, Default, PartialEq)]
8705#[non_exhaustive]
8706pub struct BeginTransactionRequest {
8707 /// Required. The session in which the transaction runs.
8708 pub session: std::string::String,
8709
8710 /// Required. Options for the new transaction.
8711 pub options: std::option::Option<crate::model::TransactionOptions>,
8712
8713 /// Common options for this request.
8714 /// Priority is ignored for this request. Setting the priority in this
8715 /// `request_options` struct doesn't do anything. To set the priority for a
8716 /// transaction, set it on the reads and writes that are part of this
8717 /// transaction instead.
8718 pub request_options: std::option::Option<crate::model::RequestOptions>,
8719
8720 /// Optional. Required for read-write transactions on a multiplexed session
8721 /// that commit mutations but don't perform any reads or queries. You must
8722 /// randomly select one of the mutations from the mutation set and send it as a
8723 /// part of this request.
8724 pub mutation_key: std::option::Option<crate::model::Mutation>,
8725
8726 /// Optional. Makes the Spanner requests location-aware if present.
8727 ///
8728 /// It gives the server hints that can be used to route the request
8729 /// to an appropriate server, potentially significantly decreasing latency and
8730 /// improving throughput. To achieve improved performance, most fields must be
8731 /// filled in with accurate values.
8732 pub routing_hint: std::option::Option<crate::model::RoutingHint>,
8733
8734 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8735}
8736
8737impl BeginTransactionRequest {
8738 /// Creates a new default instance.
8739 pub fn new() -> Self {
8740 std::default::Default::default()
8741 }
8742
8743 /// Sets the value of [session][crate::model::BeginTransactionRequest::session].
8744 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8745 self.session = v.into();
8746 self
8747 }
8748
8749 /// Sets the value of [options][crate::model::BeginTransactionRequest::options].
8750 pub fn set_options<T>(mut self, v: T) -> Self
8751 where
8752 T: std::convert::Into<crate::model::TransactionOptions>,
8753 {
8754 self.options = std::option::Option::Some(v.into());
8755 self
8756 }
8757
8758 /// Sets or clears the value of [options][crate::model::BeginTransactionRequest::options].
8759 pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
8760 where
8761 T: std::convert::Into<crate::model::TransactionOptions>,
8762 {
8763 self.options = v.map(|x| x.into());
8764 self
8765 }
8766
8767 /// Sets the value of [request_options][crate::model::BeginTransactionRequest::request_options].
8768 pub fn set_request_options<T>(mut self, v: T) -> Self
8769 where
8770 T: std::convert::Into<crate::model::RequestOptions>,
8771 {
8772 self.request_options = std::option::Option::Some(v.into());
8773 self
8774 }
8775
8776 /// Sets or clears the value of [request_options][crate::model::BeginTransactionRequest::request_options].
8777 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
8778 where
8779 T: std::convert::Into<crate::model::RequestOptions>,
8780 {
8781 self.request_options = v.map(|x| x.into());
8782 self
8783 }
8784
8785 /// Sets the value of [mutation_key][crate::model::BeginTransactionRequest::mutation_key].
8786 pub fn set_mutation_key<T>(mut self, v: T) -> Self
8787 where
8788 T: std::convert::Into<crate::model::Mutation>,
8789 {
8790 self.mutation_key = std::option::Option::Some(v.into());
8791 self
8792 }
8793
8794 /// Sets or clears the value of [mutation_key][crate::model::BeginTransactionRequest::mutation_key].
8795 pub fn set_or_clear_mutation_key<T>(mut self, v: std::option::Option<T>) -> Self
8796 where
8797 T: std::convert::Into<crate::model::Mutation>,
8798 {
8799 self.mutation_key = v.map(|x| x.into());
8800 self
8801 }
8802
8803 /// Sets the value of [routing_hint][crate::model::BeginTransactionRequest::routing_hint].
8804 pub fn set_routing_hint<T>(mut self, v: T) -> Self
8805 where
8806 T: std::convert::Into<crate::model::RoutingHint>,
8807 {
8808 self.routing_hint = std::option::Option::Some(v.into());
8809 self
8810 }
8811
8812 /// Sets or clears the value of [routing_hint][crate::model::BeginTransactionRequest::routing_hint].
8813 pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
8814 where
8815 T: std::convert::Into<crate::model::RoutingHint>,
8816 {
8817 self.routing_hint = v.map(|x| x.into());
8818 self
8819 }
8820}
8821
8822impl wkt::message::Message for BeginTransactionRequest {
8823 fn typename() -> &'static str {
8824 "type.googleapis.com/google.spanner.v1.BeginTransactionRequest"
8825 }
8826}
8827
8828/// The request for [Commit][google.spanner.v1.Spanner.Commit].
8829///
8830/// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
8831#[derive(Clone, Default, PartialEq)]
8832#[non_exhaustive]
8833pub struct CommitRequest {
8834 /// Required. The session in which the transaction to be committed is running.
8835 pub session: std::string::String,
8836
8837 /// The mutations to be executed when this transaction commits. All
8838 /// mutations are applied atomically, in the order they appear in
8839 /// this list.
8840 pub mutations: std::vec::Vec<crate::model::Mutation>,
8841
8842 /// If `true`, then statistics related to the transaction is included in
8843 /// the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats].
8844 /// Default value is `false`.
8845 ///
8846 /// [google.spanner.v1.CommitResponse.commit_stats]: crate::model::CommitResponse::commit_stats
8847 pub return_commit_stats: bool,
8848
8849 /// Optional. The amount of latency this request is configured to incur in
8850 /// order to improve throughput. If this field isn't set, Spanner assumes
8851 /// requests are relatively latency sensitive and automatically determines an
8852 /// appropriate delay time. You can specify a commit delay value between 0 and
8853 /// 500 ms.
8854 pub max_commit_delay: std::option::Option<wkt::Duration>,
8855
8856 /// Common options for this request.
8857 pub request_options: std::option::Option<crate::model::RequestOptions>,
8858
8859 /// Optional. If the read-write transaction was executed on a multiplexed
8860 /// session, then you must include the precommit token with the highest
8861 /// sequence number received in this transaction attempt. Failing to do so
8862 /// results in a `FailedPrecondition` error.
8863 pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
8864
8865 /// Optional. Makes the Spanner requests location-aware if present.
8866 ///
8867 /// It gives the server hints that can be used to route the request
8868 /// to an appropriate server, potentially significantly decreasing latency and
8869 /// improving throughput. To achieve improved performance, most fields must be
8870 /// filled in with accurate values.
8871 pub routing_hint: std::option::Option<crate::model::RoutingHint>,
8872
8873 /// Required. The transaction in which to commit.
8874 pub transaction: std::option::Option<crate::model::commit_request::Transaction>,
8875
8876 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8877}
8878
8879impl CommitRequest {
8880 /// Creates a new default instance.
8881 pub fn new() -> Self {
8882 std::default::Default::default()
8883 }
8884
8885 /// Sets the value of [session][crate::model::CommitRequest::session].
8886 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8887 self.session = v.into();
8888 self
8889 }
8890
8891 /// Sets the value of [mutations][crate::model::CommitRequest::mutations].
8892 pub fn set_mutations<T, V>(mut self, v: T) -> Self
8893 where
8894 T: std::iter::IntoIterator<Item = V>,
8895 V: std::convert::Into<crate::model::Mutation>,
8896 {
8897 use std::iter::Iterator;
8898 self.mutations = v.into_iter().map(|i| i.into()).collect();
8899 self
8900 }
8901
8902 /// Sets the value of [return_commit_stats][crate::model::CommitRequest::return_commit_stats].
8903 pub fn set_return_commit_stats<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8904 self.return_commit_stats = v.into();
8905 self
8906 }
8907
8908 /// Sets the value of [max_commit_delay][crate::model::CommitRequest::max_commit_delay].
8909 pub fn set_max_commit_delay<T>(mut self, v: T) -> Self
8910 where
8911 T: std::convert::Into<wkt::Duration>,
8912 {
8913 self.max_commit_delay = std::option::Option::Some(v.into());
8914 self
8915 }
8916
8917 /// Sets or clears the value of [max_commit_delay][crate::model::CommitRequest::max_commit_delay].
8918 pub fn set_or_clear_max_commit_delay<T>(mut self, v: std::option::Option<T>) -> Self
8919 where
8920 T: std::convert::Into<wkt::Duration>,
8921 {
8922 self.max_commit_delay = v.map(|x| x.into());
8923 self
8924 }
8925
8926 /// Sets the value of [request_options][crate::model::CommitRequest::request_options].
8927 pub fn set_request_options<T>(mut self, v: T) -> Self
8928 where
8929 T: std::convert::Into<crate::model::RequestOptions>,
8930 {
8931 self.request_options = std::option::Option::Some(v.into());
8932 self
8933 }
8934
8935 /// Sets or clears the value of [request_options][crate::model::CommitRequest::request_options].
8936 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
8937 where
8938 T: std::convert::Into<crate::model::RequestOptions>,
8939 {
8940 self.request_options = v.map(|x| x.into());
8941 self
8942 }
8943
8944 /// Sets the value of [precommit_token][crate::model::CommitRequest::precommit_token].
8945 pub fn set_precommit_token<T>(mut self, v: T) -> Self
8946 where
8947 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
8948 {
8949 self.precommit_token = std::option::Option::Some(v.into());
8950 self
8951 }
8952
8953 /// Sets or clears the value of [precommit_token][crate::model::CommitRequest::precommit_token].
8954 pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
8955 where
8956 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
8957 {
8958 self.precommit_token = v.map(|x| x.into());
8959 self
8960 }
8961
8962 /// Sets the value of [routing_hint][crate::model::CommitRequest::routing_hint].
8963 pub fn set_routing_hint<T>(mut self, v: T) -> Self
8964 where
8965 T: std::convert::Into<crate::model::RoutingHint>,
8966 {
8967 self.routing_hint = std::option::Option::Some(v.into());
8968 self
8969 }
8970
8971 /// Sets or clears the value of [routing_hint][crate::model::CommitRequest::routing_hint].
8972 pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
8973 where
8974 T: std::convert::Into<crate::model::RoutingHint>,
8975 {
8976 self.routing_hint = v.map(|x| x.into());
8977 self
8978 }
8979
8980 /// Sets the value of [transaction][crate::model::CommitRequest::transaction].
8981 ///
8982 /// Note that all the setters affecting `transaction` are mutually
8983 /// exclusive.
8984 pub fn set_transaction<
8985 T: std::convert::Into<std::option::Option<crate::model::commit_request::Transaction>>,
8986 >(
8987 mut self,
8988 v: T,
8989 ) -> Self {
8990 self.transaction = v.into();
8991 self
8992 }
8993
8994 /// The value of [transaction][crate::model::CommitRequest::transaction]
8995 /// if it holds a `TransactionId`, `None` if the field is not set or
8996 /// holds a different branch.
8997 pub fn transaction_id(&self) -> std::option::Option<&::bytes::Bytes> {
8998 #[allow(unreachable_patterns)]
8999 self.transaction.as_ref().and_then(|v| match v {
9000 crate::model::commit_request::Transaction::TransactionId(v) => {
9001 std::option::Option::Some(v)
9002 }
9003 _ => std::option::Option::None,
9004 })
9005 }
9006
9007 /// Sets the value of [transaction][crate::model::CommitRequest::transaction]
9008 /// to hold a `TransactionId`.
9009 ///
9010 /// Note that all the setters affecting `transaction` are
9011 /// mutually exclusive.
9012 pub fn set_transaction_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
9013 self.transaction = std::option::Option::Some(
9014 crate::model::commit_request::Transaction::TransactionId(v.into()),
9015 );
9016 self
9017 }
9018
9019 /// The value of [transaction][crate::model::CommitRequest::transaction]
9020 /// if it holds a `SingleUseTransaction`, `None` if the field is not set or
9021 /// holds a different branch.
9022 pub fn single_use_transaction(
9023 &self,
9024 ) -> std::option::Option<&std::boxed::Box<crate::model::TransactionOptions>> {
9025 #[allow(unreachable_patterns)]
9026 self.transaction.as_ref().and_then(|v| match v {
9027 crate::model::commit_request::Transaction::SingleUseTransaction(v) => {
9028 std::option::Option::Some(v)
9029 }
9030 _ => std::option::Option::None,
9031 })
9032 }
9033
9034 /// Sets the value of [transaction][crate::model::CommitRequest::transaction]
9035 /// to hold a `SingleUseTransaction`.
9036 ///
9037 /// Note that all the setters affecting `transaction` are
9038 /// mutually exclusive.
9039 pub fn set_single_use_transaction<
9040 T: std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
9041 >(
9042 mut self,
9043 v: T,
9044 ) -> Self {
9045 self.transaction = std::option::Option::Some(
9046 crate::model::commit_request::Transaction::SingleUseTransaction(v.into()),
9047 );
9048 self
9049 }
9050}
9051
9052impl wkt::message::Message for CommitRequest {
9053 fn typename() -> &'static str {
9054 "type.googleapis.com/google.spanner.v1.CommitRequest"
9055 }
9056}
9057
9058/// Defines additional types related to [CommitRequest].
9059pub mod commit_request {
9060 #[allow(unused_imports)]
9061 use super::*;
9062
9063 /// Required. The transaction in which to commit.
9064 #[derive(Clone, Debug, PartialEq)]
9065 #[non_exhaustive]
9066 pub enum Transaction {
9067 /// Commit a previously-started transaction.
9068 TransactionId(::bytes::Bytes),
9069 /// Execute mutations in a temporary transaction. Note that unlike
9070 /// commit of a previously-started transaction, commit with a
9071 /// temporary transaction is non-idempotent. That is, if the
9072 /// `CommitRequest` is sent to Cloud Spanner more than once (for
9073 /// instance, due to retries in the application, or in the
9074 /// transport library), it's possible that the mutations are
9075 /// executed more than once. If this is undesirable, use
9076 /// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and
9077 /// [Commit][google.spanner.v1.Spanner.Commit] instead.
9078 ///
9079 /// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
9080 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
9081 SingleUseTransaction(std::boxed::Box<crate::model::TransactionOptions>),
9082 }
9083
9084 impl Transaction {
9085 /// Initializes the enum to the [TransactionId](Self::TransactionId) branch.
9086 pub fn from_transaction_id(value: impl std::convert::Into<::bytes::Bytes>) -> Self {
9087 Self::TransactionId(value.into())
9088 }
9089 /// Initializes the enum to the [SingleUseTransaction](Self::SingleUseTransaction) branch.
9090 pub fn from_single_use_transaction(
9091 value: impl std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
9092 ) -> Self {
9093 Self::SingleUseTransaction(value.into())
9094 }
9095 }
9096}
9097
9098/// The request for [Rollback][google.spanner.v1.Spanner.Rollback].
9099///
9100/// [google.spanner.v1.Spanner.Rollback]: crate::client::Spanner::rollback
9101#[derive(Clone, Default, PartialEq)]
9102#[non_exhaustive]
9103pub struct RollbackRequest {
9104 /// Required. The session in which the transaction to roll back is running.
9105 pub session: std::string::String,
9106
9107 /// Required. The transaction to roll back.
9108 pub transaction_id: ::bytes::Bytes,
9109
9110 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9111}
9112
9113impl RollbackRequest {
9114 /// Creates a new default instance.
9115 pub fn new() -> Self {
9116 std::default::Default::default()
9117 }
9118
9119 /// Sets the value of [session][crate::model::RollbackRequest::session].
9120 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9121 self.session = v.into();
9122 self
9123 }
9124
9125 /// Sets the value of [transaction_id][crate::model::RollbackRequest::transaction_id].
9126 pub fn set_transaction_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
9127 self.transaction_id = v.into();
9128 self
9129 }
9130}
9131
9132impl wkt::message::Message for RollbackRequest {
9133 fn typename() -> &'static str {
9134 "type.googleapis.com/google.spanner.v1.RollbackRequest"
9135 }
9136}
9137
9138/// The request for [BatchWrite][google.spanner.v1.Spanner.BatchWrite].
9139#[derive(Clone, Default, PartialEq)]
9140#[non_exhaustive]
9141pub struct BatchWriteRequest {
9142 /// Required. The session in which the batch request is to be run.
9143 pub session: std::string::String,
9144
9145 /// Common options for this request.
9146 pub request_options: std::option::Option<crate::model::RequestOptions>,
9147
9148 /// Required. The groups of mutations to be applied.
9149 pub mutation_groups: std::vec::Vec<crate::model::batch_write_request::MutationGroup>,
9150
9151 /// Optional. If you don't set the `exclude_txn_from_change_streams` option or
9152 /// if it's set to `false`, then any change streams monitoring columns modified
9153 /// by transactions will capture the updates made within that transaction.
9154 pub exclude_txn_from_change_streams: bool,
9155
9156 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9157}
9158
9159impl BatchWriteRequest {
9160 /// Creates a new default instance.
9161 pub fn new() -> Self {
9162 std::default::Default::default()
9163 }
9164
9165 /// Sets the value of [session][crate::model::BatchWriteRequest::session].
9166 pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9167 self.session = v.into();
9168 self
9169 }
9170
9171 /// Sets the value of [request_options][crate::model::BatchWriteRequest::request_options].
9172 pub fn set_request_options<T>(mut self, v: T) -> Self
9173 where
9174 T: std::convert::Into<crate::model::RequestOptions>,
9175 {
9176 self.request_options = std::option::Option::Some(v.into());
9177 self
9178 }
9179
9180 /// Sets or clears the value of [request_options][crate::model::BatchWriteRequest::request_options].
9181 pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
9182 where
9183 T: std::convert::Into<crate::model::RequestOptions>,
9184 {
9185 self.request_options = v.map(|x| x.into());
9186 self
9187 }
9188
9189 /// Sets the value of [mutation_groups][crate::model::BatchWriteRequest::mutation_groups].
9190 pub fn set_mutation_groups<T, V>(mut self, v: T) -> Self
9191 where
9192 T: std::iter::IntoIterator<Item = V>,
9193 V: std::convert::Into<crate::model::batch_write_request::MutationGroup>,
9194 {
9195 use std::iter::Iterator;
9196 self.mutation_groups = v.into_iter().map(|i| i.into()).collect();
9197 self
9198 }
9199
9200 /// Sets the value of [exclude_txn_from_change_streams][crate::model::BatchWriteRequest::exclude_txn_from_change_streams].
9201 pub fn set_exclude_txn_from_change_streams<T: std::convert::Into<bool>>(
9202 mut self,
9203 v: T,
9204 ) -> Self {
9205 self.exclude_txn_from_change_streams = v.into();
9206 self
9207 }
9208}
9209
9210impl wkt::message::Message for BatchWriteRequest {
9211 fn typename() -> &'static str {
9212 "type.googleapis.com/google.spanner.v1.BatchWriteRequest"
9213 }
9214}
9215
9216/// Defines additional types related to [BatchWriteRequest].
9217pub mod batch_write_request {
9218 #[allow(unused_imports)]
9219 use super::*;
9220
9221 /// A group of mutations to be committed together. Related mutations should be
9222 /// placed in a group. For example, two mutations inserting rows with the same
9223 /// primary key prefix in both parent and child tables are related.
9224 #[derive(Clone, Default, PartialEq)]
9225 #[non_exhaustive]
9226 pub struct MutationGroup {
9227 /// Required. The mutations in this group.
9228 pub mutations: std::vec::Vec<crate::model::Mutation>,
9229
9230 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9231 }
9232
9233 impl MutationGroup {
9234 /// Creates a new default instance.
9235 pub fn new() -> Self {
9236 std::default::Default::default()
9237 }
9238
9239 /// Sets the value of [mutations][crate::model::batch_write_request::MutationGroup::mutations].
9240 pub fn set_mutations<T, V>(mut self, v: T) -> Self
9241 where
9242 T: std::iter::IntoIterator<Item = V>,
9243 V: std::convert::Into<crate::model::Mutation>,
9244 {
9245 use std::iter::Iterator;
9246 self.mutations = v.into_iter().map(|i| i.into()).collect();
9247 self
9248 }
9249 }
9250
9251 impl wkt::message::Message for MutationGroup {
9252 fn typename() -> &'static str {
9253 "type.googleapis.com/google.spanner.v1.BatchWriteRequest.MutationGroup"
9254 }
9255 }
9256}
9257
9258/// The result of applying a batch of mutations.
9259#[derive(Clone, Default, PartialEq)]
9260#[non_exhaustive]
9261pub struct BatchWriteResponse {
9262 /// The mutation groups applied in this batch. The values index into the
9263 /// `mutation_groups` field in the corresponding `BatchWriteRequest`.
9264 pub indexes: std::vec::Vec<i32>,
9265
9266 /// An `OK` status indicates success. Any other status indicates a failure.
9267 pub status: std::option::Option<google_cloud_rpc::model::Status>,
9268
9269 /// The commit timestamp of the transaction that applied this batch.
9270 /// Present if status is OK and the mutation groups were applied, absent
9271 /// otherwise.
9272 ///
9273 /// For mutation groups with conditions, a status=OK and missing
9274 /// commit_timestamp means that the mutation groups were not applied due to the
9275 /// condition not being satisfied after evaluation.
9276 pub commit_timestamp: std::option::Option<wkt::Timestamp>,
9277
9278 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9279}
9280
9281impl BatchWriteResponse {
9282 /// Creates a new default instance.
9283 pub fn new() -> Self {
9284 std::default::Default::default()
9285 }
9286
9287 /// Sets the value of [indexes][crate::model::BatchWriteResponse::indexes].
9288 pub fn set_indexes<T, V>(mut self, v: T) -> Self
9289 where
9290 T: std::iter::IntoIterator<Item = V>,
9291 V: std::convert::Into<i32>,
9292 {
9293 use std::iter::Iterator;
9294 self.indexes = v.into_iter().map(|i| i.into()).collect();
9295 self
9296 }
9297
9298 /// Sets the value of [status][crate::model::BatchWriteResponse::status].
9299 pub fn set_status<T>(mut self, v: T) -> Self
9300 where
9301 T: std::convert::Into<google_cloud_rpc::model::Status>,
9302 {
9303 self.status = std::option::Option::Some(v.into());
9304 self
9305 }
9306
9307 /// Sets or clears the value of [status][crate::model::BatchWriteResponse::status].
9308 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
9309 where
9310 T: std::convert::Into<google_cloud_rpc::model::Status>,
9311 {
9312 self.status = v.map(|x| x.into());
9313 self
9314 }
9315
9316 /// Sets the value of [commit_timestamp][crate::model::BatchWriteResponse::commit_timestamp].
9317 pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
9318 where
9319 T: std::convert::Into<wkt::Timestamp>,
9320 {
9321 self.commit_timestamp = std::option::Option::Some(v.into());
9322 self
9323 }
9324
9325 /// Sets or clears the value of [commit_timestamp][crate::model::BatchWriteResponse::commit_timestamp].
9326 pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
9327 where
9328 T: std::convert::Into<wkt::Timestamp>,
9329 {
9330 self.commit_timestamp = v.map(|x| x.into());
9331 self
9332 }
9333}
9334
9335impl wkt::message::Message for BatchWriteResponse {
9336 fn typename() -> &'static str {
9337 "type.googleapis.com/google.spanner.v1.BatchWriteResponse"
9338 }
9339}
9340
9341/// The request for
9342/// [FetchCacheUpdate][google.spanner.v1.Spanner.FetchCacheUpdate].
9343#[derive(Clone, Default, PartialEq)]
9344#[non_exhaustive]
9345pub struct FetchCacheUpdateRequest {
9346 /// Required. The database for which to retrieve the cache update.
9347 pub database: std::string::String,
9348
9349 /// Optional. The maximum number of key recipes to return in the response.
9350 /// If not set, a default limit of 100 will be used.
9351 pub max_recipe_count: i32,
9352
9353 /// Optional. The maximum number of ranges to return in the response.
9354 /// If not set, a default limit of 10000 will be used.
9355 pub max_range_count: i32,
9356
9357 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9358}
9359
9360impl FetchCacheUpdateRequest {
9361 /// Creates a new default instance.
9362 pub fn new() -> Self {
9363 std::default::Default::default()
9364 }
9365
9366 /// Sets the value of [database][crate::model::FetchCacheUpdateRequest::database].
9367 pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9368 self.database = v.into();
9369 self
9370 }
9371
9372 /// Sets the value of [max_recipe_count][crate::model::FetchCacheUpdateRequest::max_recipe_count].
9373 pub fn set_max_recipe_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9374 self.max_recipe_count = v.into();
9375 self
9376 }
9377
9378 /// Sets the value of [max_range_count][crate::model::FetchCacheUpdateRequest::max_range_count].
9379 pub fn set_max_range_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9380 self.max_range_count = v.into();
9381 self
9382 }
9383}
9384
9385impl wkt::message::Message for FetchCacheUpdateRequest {
9386 fn typename() -> &'static str {
9387 "type.googleapis.com/google.spanner.v1.FetchCacheUpdateRequest"
9388 }
9389}
9390
9391/// Options to use for transactions.
9392#[derive(Clone, Default, PartialEq)]
9393#[non_exhaustive]
9394pub struct TransactionOptions {
9395 /// When `exclude_txn_from_change_streams` is set to `true`, it prevents read
9396 /// or write transactions from being tracked in change streams.
9397 ///
9398 /// * If the DDL option `allow_txn_exclusion` is set to `true`, then the
9399 /// updates
9400 /// made within this transaction aren't recorded in the change stream.
9401 ///
9402 /// * If you don't set the DDL option `allow_txn_exclusion` or if it's
9403 /// set to `false`, then the updates made within this transaction are
9404 /// recorded in the change stream.
9405 ///
9406 ///
9407 /// When `exclude_txn_from_change_streams` is set to `false` or not set,
9408 /// modifications from this transaction are recorded in all change streams
9409 /// that are tracking columns modified by these transactions.
9410 ///
9411 /// The `exclude_txn_from_change_streams` option can only be specified
9412 /// for read-write or partitioned DML transactions, otherwise the API returns
9413 /// an `INVALID_ARGUMENT` error.
9414 pub exclude_txn_from_change_streams: bool,
9415
9416 /// Isolation level for the transaction.
9417 pub isolation_level: crate::model::transaction_options::IsolationLevel,
9418
9419 /// Required. The type of transaction.
9420 pub mode: std::option::Option<crate::model::transaction_options::Mode>,
9421
9422 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9423}
9424
9425impl TransactionOptions {
9426 /// Creates a new default instance.
9427 pub fn new() -> Self {
9428 std::default::Default::default()
9429 }
9430
9431 /// Sets the value of [exclude_txn_from_change_streams][crate::model::TransactionOptions::exclude_txn_from_change_streams].
9432 pub fn set_exclude_txn_from_change_streams<T: std::convert::Into<bool>>(
9433 mut self,
9434 v: T,
9435 ) -> Self {
9436 self.exclude_txn_from_change_streams = v.into();
9437 self
9438 }
9439
9440 /// Sets the value of [isolation_level][crate::model::TransactionOptions::isolation_level].
9441 pub fn set_isolation_level<
9442 T: std::convert::Into<crate::model::transaction_options::IsolationLevel>,
9443 >(
9444 mut self,
9445 v: T,
9446 ) -> Self {
9447 self.isolation_level = v.into();
9448 self
9449 }
9450
9451 /// Sets the value of [mode][crate::model::TransactionOptions::mode].
9452 ///
9453 /// Note that all the setters affecting `mode` are mutually
9454 /// exclusive.
9455 pub fn set_mode<
9456 T: std::convert::Into<std::option::Option<crate::model::transaction_options::Mode>>,
9457 >(
9458 mut self,
9459 v: T,
9460 ) -> Self {
9461 self.mode = v.into();
9462 self
9463 }
9464
9465 /// The value of [mode][crate::model::TransactionOptions::mode]
9466 /// if it holds a `ReadWrite`, `None` if the field is not set or
9467 /// holds a different branch.
9468 pub fn read_write(
9469 &self,
9470 ) -> std::option::Option<&std::boxed::Box<crate::model::transaction_options::ReadWrite>> {
9471 #[allow(unreachable_patterns)]
9472 self.mode.as_ref().and_then(|v| match v {
9473 crate::model::transaction_options::Mode::ReadWrite(v) => std::option::Option::Some(v),
9474 _ => std::option::Option::None,
9475 })
9476 }
9477
9478 /// Sets the value of [mode][crate::model::TransactionOptions::mode]
9479 /// to hold a `ReadWrite`.
9480 ///
9481 /// Note that all the setters affecting `mode` are
9482 /// mutually exclusive.
9483 pub fn set_read_write<
9484 T: std::convert::Into<std::boxed::Box<crate::model::transaction_options::ReadWrite>>,
9485 >(
9486 mut self,
9487 v: T,
9488 ) -> Self {
9489 self.mode =
9490 std::option::Option::Some(crate::model::transaction_options::Mode::ReadWrite(v.into()));
9491 self
9492 }
9493
9494 /// The value of [mode][crate::model::TransactionOptions::mode]
9495 /// if it holds a `PartitionedDml`, `None` if the field is not set or
9496 /// holds a different branch.
9497 pub fn partitioned_dml(
9498 &self,
9499 ) -> std::option::Option<&std::boxed::Box<crate::model::transaction_options::PartitionedDml>>
9500 {
9501 #[allow(unreachable_patterns)]
9502 self.mode.as_ref().and_then(|v| match v {
9503 crate::model::transaction_options::Mode::PartitionedDml(v) => {
9504 std::option::Option::Some(v)
9505 }
9506 _ => std::option::Option::None,
9507 })
9508 }
9509
9510 /// Sets the value of [mode][crate::model::TransactionOptions::mode]
9511 /// to hold a `PartitionedDml`.
9512 ///
9513 /// Note that all the setters affecting `mode` are
9514 /// mutually exclusive.
9515 pub fn set_partitioned_dml<
9516 T: std::convert::Into<std::boxed::Box<crate::model::transaction_options::PartitionedDml>>,
9517 >(
9518 mut self,
9519 v: T,
9520 ) -> Self {
9521 self.mode = std::option::Option::Some(
9522 crate::model::transaction_options::Mode::PartitionedDml(v.into()),
9523 );
9524 self
9525 }
9526
9527 /// The value of [mode][crate::model::TransactionOptions::mode]
9528 /// if it holds a `ReadOnly`, `None` if the field is not set or
9529 /// holds a different branch.
9530 pub fn read_only(
9531 &self,
9532 ) -> std::option::Option<&std::boxed::Box<crate::model::transaction_options::ReadOnly>> {
9533 #[allow(unreachable_patterns)]
9534 self.mode.as_ref().and_then(|v| match v {
9535 crate::model::transaction_options::Mode::ReadOnly(v) => std::option::Option::Some(v),
9536 _ => std::option::Option::None,
9537 })
9538 }
9539
9540 /// Sets the value of [mode][crate::model::TransactionOptions::mode]
9541 /// to hold a `ReadOnly`.
9542 ///
9543 /// Note that all the setters affecting `mode` are
9544 /// mutually exclusive.
9545 pub fn set_read_only<
9546 T: std::convert::Into<std::boxed::Box<crate::model::transaction_options::ReadOnly>>,
9547 >(
9548 mut self,
9549 v: T,
9550 ) -> Self {
9551 self.mode =
9552 std::option::Option::Some(crate::model::transaction_options::Mode::ReadOnly(v.into()));
9553 self
9554 }
9555}
9556
9557impl wkt::message::Message for TransactionOptions {
9558 fn typename() -> &'static str {
9559 "type.googleapis.com/google.spanner.v1.TransactionOptions"
9560 }
9561}
9562
9563/// Defines additional types related to [TransactionOptions].
9564pub mod transaction_options {
9565 #[allow(unused_imports)]
9566 use super::*;
9567
9568 /// Message type to initiate a read-write transaction. Currently this
9569 /// transaction type has no options.
9570 #[derive(Clone, Default, PartialEq)]
9571 #[non_exhaustive]
9572 pub struct ReadWrite {
9573 /// Read lock mode for the transaction.
9574 pub read_lock_mode: crate::model::transaction_options::read_write::ReadLockMode,
9575
9576 /// Optional. Clients should pass the transaction ID of the previous
9577 /// transaction attempt that was aborted if this transaction is being
9578 /// executed on a multiplexed session.
9579 pub multiplexed_session_previous_transaction_id: ::bytes::Bytes,
9580
9581 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9582 }
9583
9584 impl ReadWrite {
9585 /// Creates a new default instance.
9586 pub fn new() -> Self {
9587 std::default::Default::default()
9588 }
9589
9590 /// Sets the value of [read_lock_mode][crate::model::transaction_options::ReadWrite::read_lock_mode].
9591 pub fn set_read_lock_mode<
9592 T: std::convert::Into<crate::model::transaction_options::read_write::ReadLockMode>,
9593 >(
9594 mut self,
9595 v: T,
9596 ) -> Self {
9597 self.read_lock_mode = v.into();
9598 self
9599 }
9600
9601 /// Sets the value of [multiplexed_session_previous_transaction_id][crate::model::transaction_options::ReadWrite::multiplexed_session_previous_transaction_id].
9602 pub fn set_multiplexed_session_previous_transaction_id<
9603 T: std::convert::Into<::bytes::Bytes>,
9604 >(
9605 mut self,
9606 v: T,
9607 ) -> Self {
9608 self.multiplexed_session_previous_transaction_id = v.into();
9609 self
9610 }
9611 }
9612
9613 impl wkt::message::Message for ReadWrite {
9614 fn typename() -> &'static str {
9615 "type.googleapis.com/google.spanner.v1.TransactionOptions.ReadWrite"
9616 }
9617 }
9618
9619 /// Defines additional types related to [ReadWrite].
9620 pub mod read_write {
9621 #[allow(unused_imports)]
9622 use super::*;
9623
9624 /// `ReadLockMode` is used to set the read lock mode for read-write
9625 /// transactions.
9626 ///
9627 /// # Working with unknown values
9628 ///
9629 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
9630 /// additional enum variants at any time. Adding new variants is not considered
9631 /// a breaking change. Applications should write their code in anticipation of:
9632 ///
9633 /// - New values appearing in future releases of the client library, **and**
9634 /// - New values received dynamically, without application changes.
9635 ///
9636 /// Please consult the [Working with enums] section in the user guide for some
9637 /// guidelines.
9638 ///
9639 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
9640 #[derive(Clone, Debug, PartialEq)]
9641 #[non_exhaustive]
9642 pub enum ReadLockMode {
9643 /// Default value.
9644 ///
9645 /// * If isolation level is
9646 /// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE],
9647 /// locking semantics default to `PESSIMISTIC`.
9648 /// * If isolation level is
9649 /// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ],
9650 /// locking semantics default to `OPTIMISTIC`.
9651 /// * See
9652 /// [Concurrency
9653 /// control](https://cloud.google.com/spanner/docs/concurrency-control)
9654 /// for more details.
9655 ///
9656 /// [google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]: crate::model::transaction_options::IsolationLevel::RepeatableRead
9657 /// [google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]: crate::model::transaction_options::IsolationLevel::Serializable
9658 Unspecified,
9659 /// Pessimistic lock mode.
9660 ///
9661 /// Lock acquisition behavior depends on the isolation level in use. In
9662 /// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]
9663 /// isolation, reads and writes acquire necessary locks during transaction
9664 /// statement execution. In
9665 /// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]
9666 /// isolation, reads that explicitly request to be locked and writes
9667 /// acquire locks.
9668 /// See
9669 /// [Concurrency
9670 /// control](https://cloud.google.com/spanner/docs/concurrency-control) for
9671 /// details on the types of locks acquired at each transaction step.
9672 ///
9673 /// [google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]: crate::model::transaction_options::IsolationLevel::RepeatableRead
9674 /// [google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]: crate::model::transaction_options::IsolationLevel::Serializable
9675 Pessimistic,
9676 /// Optimistic lock mode.
9677 ///
9678 /// Lock acquisition behavior depends on the isolation level in use. In
9679 /// both
9680 /// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]
9681 /// and
9682 /// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]
9683 /// isolation, reads and writes do not acquire locks during transaction
9684 /// statement execution.
9685 /// See
9686 /// [Concurrency
9687 /// control](https://cloud.google.com/spanner/docs/concurrency-control) for
9688 /// details on how the guarantees of each isolation level are provided at
9689 /// commit time.
9690 ///
9691 /// [google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]: crate::model::transaction_options::IsolationLevel::RepeatableRead
9692 /// [google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]: crate::model::transaction_options::IsolationLevel::Serializable
9693 Optimistic,
9694 /// If set, the enum was initialized with an unknown value.
9695 ///
9696 /// Applications can examine the value using [ReadLockMode::value] or
9697 /// [ReadLockMode::name].
9698 UnknownValue(read_lock_mode::UnknownValue),
9699 }
9700
9701 #[doc(hidden)]
9702 pub mod read_lock_mode {
9703 #[allow(unused_imports)]
9704 use super::*;
9705 #[derive(Clone, Debug, PartialEq)]
9706 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
9707 }
9708
9709 impl ReadLockMode {
9710 /// Gets the enum value.
9711 ///
9712 /// Returns `None` if the enum contains an unknown value deserialized from
9713 /// the string representation of enums.
9714 pub fn value(&self) -> std::option::Option<i32> {
9715 match self {
9716 Self::Unspecified => std::option::Option::Some(0),
9717 Self::Pessimistic => std::option::Option::Some(1),
9718 Self::Optimistic => std::option::Option::Some(2),
9719 Self::UnknownValue(u) => u.0.value(),
9720 }
9721 }
9722
9723 /// Gets the enum value as a string.
9724 ///
9725 /// Returns `None` if the enum contains an unknown value deserialized from
9726 /// the integer representation of enums.
9727 pub fn name(&self) -> std::option::Option<&str> {
9728 match self {
9729 Self::Unspecified => std::option::Option::Some("READ_LOCK_MODE_UNSPECIFIED"),
9730 Self::Pessimistic => std::option::Option::Some("PESSIMISTIC"),
9731 Self::Optimistic => std::option::Option::Some("OPTIMISTIC"),
9732 Self::UnknownValue(u) => u.0.name(),
9733 }
9734 }
9735 }
9736
9737 impl std::default::Default for ReadLockMode {
9738 fn default() -> Self {
9739 use std::convert::From;
9740 Self::from(0)
9741 }
9742 }
9743
9744 impl std::fmt::Display for ReadLockMode {
9745 fn fmt(
9746 &self,
9747 f: &mut std::fmt::Formatter<'_>,
9748 ) -> std::result::Result<(), std::fmt::Error> {
9749 wkt::internal::display_enum(f, self.name(), self.value())
9750 }
9751 }
9752
9753 impl std::convert::From<i32> for ReadLockMode {
9754 fn from(value: i32) -> Self {
9755 match value {
9756 0 => Self::Unspecified,
9757 1 => Self::Pessimistic,
9758 2 => Self::Optimistic,
9759 _ => Self::UnknownValue(read_lock_mode::UnknownValue(
9760 wkt::internal::UnknownEnumValue::Integer(value),
9761 )),
9762 }
9763 }
9764 }
9765
9766 impl std::convert::From<&str> for ReadLockMode {
9767 fn from(value: &str) -> Self {
9768 use std::string::ToString;
9769 match value {
9770 "READ_LOCK_MODE_UNSPECIFIED" => Self::Unspecified,
9771 "PESSIMISTIC" => Self::Pessimistic,
9772 "OPTIMISTIC" => Self::Optimistic,
9773 _ => Self::UnknownValue(read_lock_mode::UnknownValue(
9774 wkt::internal::UnknownEnumValue::String(value.to_string()),
9775 )),
9776 }
9777 }
9778 }
9779
9780 impl serde::ser::Serialize for ReadLockMode {
9781 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9782 where
9783 S: serde::Serializer,
9784 {
9785 match self {
9786 Self::Unspecified => serializer.serialize_i32(0),
9787 Self::Pessimistic => serializer.serialize_i32(1),
9788 Self::Optimistic => serializer.serialize_i32(2),
9789 Self::UnknownValue(u) => u.0.serialize(serializer),
9790 }
9791 }
9792 }
9793
9794 impl<'de> serde::de::Deserialize<'de> for ReadLockMode {
9795 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9796 where
9797 D: serde::Deserializer<'de>,
9798 {
9799 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ReadLockMode>::new(
9800 ".google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode",
9801 ))
9802 }
9803 }
9804 }
9805
9806 /// Message type to initiate a Partitioned DML transaction.
9807 #[derive(Clone, Default, PartialEq)]
9808 #[non_exhaustive]
9809 pub struct PartitionedDml {
9810 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9811 }
9812
9813 impl PartitionedDml {
9814 /// Creates a new default instance.
9815 pub fn new() -> Self {
9816 std::default::Default::default()
9817 }
9818 }
9819
9820 impl wkt::message::Message for PartitionedDml {
9821 fn typename() -> &'static str {
9822 "type.googleapis.com/google.spanner.v1.TransactionOptions.PartitionedDml"
9823 }
9824 }
9825
9826 /// Message type to initiate a read-only transaction.
9827 #[derive(Clone, Default, PartialEq)]
9828 #[non_exhaustive]
9829 pub struct ReadOnly {
9830 /// If true, the Cloud Spanner-selected read timestamp is included in
9831 /// the [Transaction][google.spanner.v1.Transaction] message that describes
9832 /// the transaction.
9833 ///
9834 /// [google.spanner.v1.Transaction]: crate::model::Transaction
9835 pub return_read_timestamp: bool,
9836
9837 /// How to choose the timestamp for the read-only transaction.
9838 pub timestamp_bound:
9839 std::option::Option<crate::model::transaction_options::read_only::TimestampBound>,
9840
9841 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9842 }
9843
9844 impl ReadOnly {
9845 /// Creates a new default instance.
9846 pub fn new() -> Self {
9847 std::default::Default::default()
9848 }
9849
9850 /// Sets the value of [return_read_timestamp][crate::model::transaction_options::ReadOnly::return_read_timestamp].
9851 pub fn set_return_read_timestamp<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9852 self.return_read_timestamp = v.into();
9853 self
9854 }
9855
9856 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound].
9857 ///
9858 /// Note that all the setters affecting `timestamp_bound` are mutually
9859 /// exclusive.
9860 pub fn set_timestamp_bound<
9861 T: std::convert::Into<
9862 std::option::Option<
9863 crate::model::transaction_options::read_only::TimestampBound,
9864 >,
9865 >,
9866 >(
9867 mut self,
9868 v: T,
9869 ) -> Self {
9870 self.timestamp_bound = v.into();
9871 self
9872 }
9873
9874 /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9875 /// if it holds a `Strong`, `None` if the field is not set or
9876 /// holds a different branch.
9877 pub fn strong(&self) -> std::option::Option<&bool> {
9878 #[allow(unreachable_patterns)]
9879 self.timestamp_bound.as_ref().and_then(|v| match v {
9880 crate::model::transaction_options::read_only::TimestampBound::Strong(v) => {
9881 std::option::Option::Some(v)
9882 }
9883 _ => std::option::Option::None,
9884 })
9885 }
9886
9887 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9888 /// to hold a `Strong`.
9889 ///
9890 /// Note that all the setters affecting `timestamp_bound` are
9891 /// mutually exclusive.
9892 pub fn set_strong<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9893 self.timestamp_bound = std::option::Option::Some(
9894 crate::model::transaction_options::read_only::TimestampBound::Strong(v.into()),
9895 );
9896 self
9897 }
9898
9899 /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9900 /// if it holds a `MinReadTimestamp`, `None` if the field is not set or
9901 /// holds a different branch.
9902 pub fn min_read_timestamp(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
9903 #[allow(unreachable_patterns)]
9904 self.timestamp_bound.as_ref().and_then(|v| match v {
9905 crate::model::transaction_options::read_only::TimestampBound::MinReadTimestamp(
9906 v,
9907 ) => std::option::Option::Some(v),
9908 _ => std::option::Option::None,
9909 })
9910 }
9911
9912 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9913 /// to hold a `MinReadTimestamp`.
9914 ///
9915 /// Note that all the setters affecting `timestamp_bound` are
9916 /// mutually exclusive.
9917 pub fn set_min_read_timestamp<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
9918 mut self,
9919 v: T,
9920 ) -> Self {
9921 self.timestamp_bound = std::option::Option::Some(
9922 crate::model::transaction_options::read_only::TimestampBound::MinReadTimestamp(
9923 v.into(),
9924 ),
9925 );
9926 self
9927 }
9928
9929 /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9930 /// if it holds a `MaxStaleness`, `None` if the field is not set or
9931 /// holds a different branch.
9932 pub fn max_staleness(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
9933 #[allow(unreachable_patterns)]
9934 self.timestamp_bound.as_ref().and_then(|v| match v {
9935 crate::model::transaction_options::read_only::TimestampBound::MaxStaleness(v) => {
9936 std::option::Option::Some(v)
9937 }
9938 _ => std::option::Option::None,
9939 })
9940 }
9941
9942 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9943 /// to hold a `MaxStaleness`.
9944 ///
9945 /// Note that all the setters affecting `timestamp_bound` are
9946 /// mutually exclusive.
9947 pub fn set_max_staleness<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
9948 mut self,
9949 v: T,
9950 ) -> Self {
9951 self.timestamp_bound = std::option::Option::Some(
9952 crate::model::transaction_options::read_only::TimestampBound::MaxStaleness(
9953 v.into(),
9954 ),
9955 );
9956 self
9957 }
9958
9959 /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9960 /// if it holds a `ReadTimestamp`, `None` if the field is not set or
9961 /// holds a different branch.
9962 pub fn read_timestamp(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
9963 #[allow(unreachable_patterns)]
9964 self.timestamp_bound.as_ref().and_then(|v| match v {
9965 crate::model::transaction_options::read_only::TimestampBound::ReadTimestamp(v) => {
9966 std::option::Option::Some(v)
9967 }
9968 _ => std::option::Option::None,
9969 })
9970 }
9971
9972 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9973 /// to hold a `ReadTimestamp`.
9974 ///
9975 /// Note that all the setters affecting `timestamp_bound` are
9976 /// mutually exclusive.
9977 pub fn set_read_timestamp<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
9978 mut self,
9979 v: T,
9980 ) -> Self {
9981 self.timestamp_bound = std::option::Option::Some(
9982 crate::model::transaction_options::read_only::TimestampBound::ReadTimestamp(
9983 v.into(),
9984 ),
9985 );
9986 self
9987 }
9988
9989 /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9990 /// if it holds a `ExactStaleness`, `None` if the field is not set or
9991 /// holds a different branch.
9992 pub fn exact_staleness(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
9993 #[allow(unreachable_patterns)]
9994 self.timestamp_bound.as_ref().and_then(|v| match v {
9995 crate::model::transaction_options::read_only::TimestampBound::ExactStaleness(v) => {
9996 std::option::Option::Some(v)
9997 }
9998 _ => std::option::Option::None,
9999 })
10000 }
10001
10002 /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
10003 /// to hold a `ExactStaleness`.
10004 ///
10005 /// Note that all the setters affecting `timestamp_bound` are
10006 /// mutually exclusive.
10007 pub fn set_exact_staleness<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
10008 mut self,
10009 v: T,
10010 ) -> Self {
10011 self.timestamp_bound = std::option::Option::Some(
10012 crate::model::transaction_options::read_only::TimestampBound::ExactStaleness(
10013 v.into(),
10014 ),
10015 );
10016 self
10017 }
10018 }
10019
10020 impl wkt::message::Message for ReadOnly {
10021 fn typename() -> &'static str {
10022 "type.googleapis.com/google.spanner.v1.TransactionOptions.ReadOnly"
10023 }
10024 }
10025
10026 /// Defines additional types related to [ReadOnly].
10027 pub mod read_only {
10028 #[allow(unused_imports)]
10029 use super::*;
10030
10031 /// How to choose the timestamp for the read-only transaction.
10032 #[derive(Clone, Debug, PartialEq)]
10033 #[non_exhaustive]
10034 pub enum TimestampBound {
10035 /// Read at a timestamp where all previously committed transactions
10036 /// are visible.
10037 Strong(bool),
10038 /// Executes all reads at a timestamp >= `min_read_timestamp`.
10039 ///
10040 /// This is useful for requesting fresher data than some previous
10041 /// read, or data that is fresh enough to observe the effects of some
10042 /// previously committed transaction whose timestamp is known.
10043 ///
10044 /// Note that this option can only be used in single-use transactions.
10045 ///
10046 /// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
10047 /// Example: `"2014-10-02T15:01:23.045123456Z"`.
10048 MinReadTimestamp(std::boxed::Box<wkt::Timestamp>),
10049 /// Read data at a timestamp >= `NOW - max_staleness`
10050 /// seconds. Guarantees that all writes that have committed more
10051 /// than the specified number of seconds ago are visible. Because
10052 /// Cloud Spanner chooses the exact timestamp, this mode works even if
10053 /// the client's local clock is substantially skewed from Cloud Spanner
10054 /// commit timestamps.
10055 ///
10056 /// Useful for reading the freshest data available at a nearby
10057 /// replica, while bounding the possible staleness if the local
10058 /// replica has fallen behind.
10059 ///
10060 /// Note that this option can only be used in single-use
10061 /// transactions.
10062 MaxStaleness(std::boxed::Box<wkt::Duration>),
10063 /// Executes all reads at the given timestamp. Unlike other modes,
10064 /// reads at a specific timestamp are repeatable; the same read at
10065 /// the same timestamp always returns the same data. If the
10066 /// timestamp is in the future, the read is blocked until the
10067 /// specified timestamp, modulo the read's deadline.
10068 ///
10069 /// Useful for large scale consistent reads such as mapreduces, or
10070 /// for coordinating many reads against a consistent snapshot of the
10071 /// data.
10072 ///
10073 /// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
10074 /// Example: `"2014-10-02T15:01:23.045123456Z"`.
10075 ReadTimestamp(std::boxed::Box<wkt::Timestamp>),
10076 /// Executes all reads at a timestamp that is `exact_staleness`
10077 /// old. The timestamp is chosen soon after the read is started.
10078 ///
10079 /// Guarantees that all writes that have committed more than the
10080 /// specified number of seconds ago are visible. Because Cloud Spanner
10081 /// chooses the exact timestamp, this mode works even if the client's
10082 /// local clock is substantially skewed from Cloud Spanner commit
10083 /// timestamps.
10084 ///
10085 /// Useful for reading at nearby replicas without the distributed
10086 /// timestamp negotiation overhead of `max_staleness`.
10087 ExactStaleness(std::boxed::Box<wkt::Duration>),
10088 }
10089
10090 impl TimestampBound {
10091 /// Initializes the enum to the [Strong](Self::Strong) branch.
10092 pub fn from_strong(value: impl std::convert::Into<bool>) -> Self {
10093 Self::Strong(value.into())
10094 }
10095 /// Initializes the enum to the [MinReadTimestamp](Self::MinReadTimestamp) branch.
10096 pub fn from_min_read_timestamp(
10097 value: impl std::convert::Into<std::boxed::Box<wkt::Timestamp>>,
10098 ) -> Self {
10099 Self::MinReadTimestamp(value.into())
10100 }
10101 /// Initializes the enum to the [MaxStaleness](Self::MaxStaleness) branch.
10102 pub fn from_max_staleness(
10103 value: impl std::convert::Into<std::boxed::Box<wkt::Duration>>,
10104 ) -> Self {
10105 Self::MaxStaleness(value.into())
10106 }
10107 /// Initializes the enum to the [ReadTimestamp](Self::ReadTimestamp) branch.
10108 pub fn from_read_timestamp(
10109 value: impl std::convert::Into<std::boxed::Box<wkt::Timestamp>>,
10110 ) -> Self {
10111 Self::ReadTimestamp(value.into())
10112 }
10113 /// Initializes the enum to the [ExactStaleness](Self::ExactStaleness) branch.
10114 pub fn from_exact_staleness(
10115 value: impl std::convert::Into<std::boxed::Box<wkt::Duration>>,
10116 ) -> Self {
10117 Self::ExactStaleness(value.into())
10118 }
10119 }
10120 }
10121
10122 /// `IsolationLevel` is used when setting the [isolation
10123 /// level](https://cloud.google.com/spanner/docs/isolation-levels) for a
10124 /// transaction.
10125 ///
10126 /// # Working with unknown values
10127 ///
10128 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10129 /// additional enum variants at any time. Adding new variants is not considered
10130 /// a breaking change. Applications should write their code in anticipation of:
10131 ///
10132 /// - New values appearing in future releases of the client library, **and**
10133 /// - New values received dynamically, without application changes.
10134 ///
10135 /// Please consult the [Working with enums] section in the user guide for some
10136 /// guidelines.
10137 ///
10138 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10139 #[derive(Clone, Debug, PartialEq)]
10140 #[non_exhaustive]
10141 pub enum IsolationLevel {
10142 /// Default value.
10143 ///
10144 /// If the value is not specified, the `SERIALIZABLE` isolation level is
10145 /// used.
10146 Unspecified,
10147 /// All transactions appear as if they executed in a serial order, even if
10148 /// some of the reads, writes, and other operations of distinct transactions
10149 /// actually occurred in parallel. Spanner assigns commit timestamps that
10150 /// reflect the order of committed transactions to implement this property.
10151 /// Spanner offers a stronger guarantee than serializability called external
10152 /// consistency. For more information, see
10153 /// [TrueTime and external
10154 /// consistency](https://cloud.google.com/spanner/docs/true-time-external-consistency#serializability).
10155 Serializable,
10156 /// All reads performed during the transaction observe a consistent snapshot
10157 /// of the database, and the transaction is only successfully committed in
10158 /// the absence of conflicts between its updates and any concurrent updates
10159 /// that have occurred since that snapshot. Consequently, in contrast to
10160 /// `SERIALIZABLE` transactions, only write-write conflicts are detected in
10161 /// snapshot transactions.
10162 ///
10163 /// This isolation level does not support read-only and partitioned DML
10164 /// transactions.
10165 ///
10166 /// When `REPEATABLE_READ` is specified on a read-write transaction, the
10167 /// locking semantics default to `OPTIMISTIC`.
10168 RepeatableRead,
10169 /// If set, the enum was initialized with an unknown value.
10170 ///
10171 /// Applications can examine the value using [IsolationLevel::value] or
10172 /// [IsolationLevel::name].
10173 UnknownValue(isolation_level::UnknownValue),
10174 }
10175
10176 #[doc(hidden)]
10177 pub mod isolation_level {
10178 #[allow(unused_imports)]
10179 use super::*;
10180 #[derive(Clone, Debug, PartialEq)]
10181 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10182 }
10183
10184 impl IsolationLevel {
10185 /// Gets the enum value.
10186 ///
10187 /// Returns `None` if the enum contains an unknown value deserialized from
10188 /// the string representation of enums.
10189 pub fn value(&self) -> std::option::Option<i32> {
10190 match self {
10191 Self::Unspecified => std::option::Option::Some(0),
10192 Self::Serializable => std::option::Option::Some(1),
10193 Self::RepeatableRead => std::option::Option::Some(2),
10194 Self::UnknownValue(u) => u.0.value(),
10195 }
10196 }
10197
10198 /// Gets the enum value as a string.
10199 ///
10200 /// Returns `None` if the enum contains an unknown value deserialized from
10201 /// the integer representation of enums.
10202 pub fn name(&self) -> std::option::Option<&str> {
10203 match self {
10204 Self::Unspecified => std::option::Option::Some("ISOLATION_LEVEL_UNSPECIFIED"),
10205 Self::Serializable => std::option::Option::Some("SERIALIZABLE"),
10206 Self::RepeatableRead => std::option::Option::Some("REPEATABLE_READ"),
10207 Self::UnknownValue(u) => u.0.name(),
10208 }
10209 }
10210 }
10211
10212 impl std::default::Default for IsolationLevel {
10213 fn default() -> Self {
10214 use std::convert::From;
10215 Self::from(0)
10216 }
10217 }
10218
10219 impl std::fmt::Display for IsolationLevel {
10220 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
10221 wkt::internal::display_enum(f, self.name(), self.value())
10222 }
10223 }
10224
10225 impl std::convert::From<i32> for IsolationLevel {
10226 fn from(value: i32) -> Self {
10227 match value {
10228 0 => Self::Unspecified,
10229 1 => Self::Serializable,
10230 2 => Self::RepeatableRead,
10231 _ => Self::UnknownValue(isolation_level::UnknownValue(
10232 wkt::internal::UnknownEnumValue::Integer(value),
10233 )),
10234 }
10235 }
10236 }
10237
10238 impl std::convert::From<&str> for IsolationLevel {
10239 fn from(value: &str) -> Self {
10240 use std::string::ToString;
10241 match value {
10242 "ISOLATION_LEVEL_UNSPECIFIED" => Self::Unspecified,
10243 "SERIALIZABLE" => Self::Serializable,
10244 "REPEATABLE_READ" => Self::RepeatableRead,
10245 _ => Self::UnknownValue(isolation_level::UnknownValue(
10246 wkt::internal::UnknownEnumValue::String(value.to_string()),
10247 )),
10248 }
10249 }
10250 }
10251
10252 impl serde::ser::Serialize for IsolationLevel {
10253 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10254 where
10255 S: serde::Serializer,
10256 {
10257 match self {
10258 Self::Unspecified => serializer.serialize_i32(0),
10259 Self::Serializable => serializer.serialize_i32(1),
10260 Self::RepeatableRead => serializer.serialize_i32(2),
10261 Self::UnknownValue(u) => u.0.serialize(serializer),
10262 }
10263 }
10264 }
10265
10266 impl<'de> serde::de::Deserialize<'de> for IsolationLevel {
10267 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10268 where
10269 D: serde::Deserializer<'de>,
10270 {
10271 deserializer.deserialize_any(wkt::internal::EnumVisitor::<IsolationLevel>::new(
10272 ".google.spanner.v1.TransactionOptions.IsolationLevel",
10273 ))
10274 }
10275 }
10276
10277 /// Required. The type of transaction.
10278 #[derive(Clone, Debug, PartialEq)]
10279 #[non_exhaustive]
10280 pub enum Mode {
10281 /// Transaction may write.
10282 ///
10283 /// Authorization to begin a read-write transaction requires
10284 /// `spanner.databases.beginOrRollbackReadWriteTransaction` permission
10285 /// on the `session` resource.
10286 ReadWrite(std::boxed::Box<crate::model::transaction_options::ReadWrite>),
10287 /// Partitioned DML transaction.
10288 ///
10289 /// Authorization to begin a Partitioned DML transaction requires
10290 /// `spanner.databases.beginPartitionedDmlTransaction` permission
10291 /// on the `session` resource.
10292 PartitionedDml(std::boxed::Box<crate::model::transaction_options::PartitionedDml>),
10293 /// Transaction does not write.
10294 ///
10295 /// Authorization to begin a read-only transaction requires
10296 /// `spanner.databases.beginReadOnlyTransaction` permission
10297 /// on the `session` resource.
10298 ReadOnly(std::boxed::Box<crate::model::transaction_options::ReadOnly>),
10299 }
10300
10301 impl Mode {
10302 /// Initializes the enum to the [ReadWrite](Self::ReadWrite) branch.
10303 pub fn from_read_write(
10304 value: impl std::convert::Into<
10305 std::boxed::Box<crate::model::transaction_options::ReadWrite>,
10306 >,
10307 ) -> Self {
10308 Self::ReadWrite(value.into())
10309 }
10310 /// Initializes the enum to the [PartitionedDml](Self::PartitionedDml) branch.
10311 pub fn from_partitioned_dml(
10312 value: impl std::convert::Into<
10313 std::boxed::Box<crate::model::transaction_options::PartitionedDml>,
10314 >,
10315 ) -> Self {
10316 Self::PartitionedDml(value.into())
10317 }
10318 /// Initializes the enum to the [ReadOnly](Self::ReadOnly) branch.
10319 pub fn from_read_only(
10320 value: impl std::convert::Into<std::boxed::Box<crate::model::transaction_options::ReadOnly>>,
10321 ) -> Self {
10322 Self::ReadOnly(value.into())
10323 }
10324 }
10325}
10326
10327/// A transaction.
10328#[derive(Clone, Default, PartialEq)]
10329#[non_exhaustive]
10330pub struct Transaction {
10331 /// `id` may be used to identify the transaction in subsequent
10332 /// [Read][google.spanner.v1.Spanner.Read],
10333 /// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql],
10334 /// [Commit][google.spanner.v1.Spanner.Commit], or
10335 /// [Rollback][google.spanner.v1.Spanner.Rollback] calls.
10336 ///
10337 /// Single-use read-only transactions do not have IDs, because
10338 /// single-use transactions do not support multiple requests.
10339 ///
10340 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
10341 /// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
10342 /// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
10343 /// [google.spanner.v1.Spanner.Rollback]: crate::client::Spanner::rollback
10344 pub id: ::bytes::Bytes,
10345
10346 /// For snapshot read-only transactions, the read timestamp chosen
10347 /// for the transaction. Not returned by default: see
10348 /// [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp].
10349 ///
10350 /// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
10351 /// Example: `"2014-10-02T15:01:23.045123456Z"`.
10352 ///
10353 /// [google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp]: crate::model::transaction_options::ReadOnly::return_read_timestamp
10354 pub read_timestamp: std::option::Option<wkt::Timestamp>,
10355
10356 /// A precommit token is included in the response of a BeginTransaction
10357 /// request if the read-write transaction is on a multiplexed session and
10358 /// a mutation_key was specified in the
10359 /// [BeginTransaction][google.spanner.v1.BeginTransactionRequest].
10360 /// The precommit token with the highest sequence number from this transaction
10361 /// attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit]
10362 /// request for this transaction.
10363 ///
10364 /// [google.spanner.v1.BeginTransactionRequest]: crate::model::BeginTransactionRequest
10365 /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
10366 pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
10367
10368 /// Optional. A cache update expresses a set of changes the client should
10369 /// incorporate into its location cache. The client should discard the changes
10370 /// if they are older than the data it already has. This data can be obtained
10371 /// in response to requests that included a `RoutingHint` field, but may also
10372 /// be obtained by explicit location-fetching RPCs which may be added in the
10373 /// future.
10374 pub cache_update: std::option::Option<crate::model::CacheUpdate>,
10375
10376 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10377}
10378
10379impl Transaction {
10380 /// Creates a new default instance.
10381 pub fn new() -> Self {
10382 std::default::Default::default()
10383 }
10384
10385 /// Sets the value of [id][crate::model::Transaction::id].
10386 pub fn set_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
10387 self.id = v.into();
10388 self
10389 }
10390
10391 /// Sets the value of [read_timestamp][crate::model::Transaction::read_timestamp].
10392 pub fn set_read_timestamp<T>(mut self, v: T) -> Self
10393 where
10394 T: std::convert::Into<wkt::Timestamp>,
10395 {
10396 self.read_timestamp = std::option::Option::Some(v.into());
10397 self
10398 }
10399
10400 /// Sets or clears the value of [read_timestamp][crate::model::Transaction::read_timestamp].
10401 pub fn set_or_clear_read_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
10402 where
10403 T: std::convert::Into<wkt::Timestamp>,
10404 {
10405 self.read_timestamp = v.map(|x| x.into());
10406 self
10407 }
10408
10409 /// Sets the value of [precommit_token][crate::model::Transaction::precommit_token].
10410 pub fn set_precommit_token<T>(mut self, v: T) -> Self
10411 where
10412 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
10413 {
10414 self.precommit_token = std::option::Option::Some(v.into());
10415 self
10416 }
10417
10418 /// Sets or clears the value of [precommit_token][crate::model::Transaction::precommit_token].
10419 pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
10420 where
10421 T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
10422 {
10423 self.precommit_token = v.map(|x| x.into());
10424 self
10425 }
10426
10427 /// Sets the value of [cache_update][crate::model::Transaction::cache_update].
10428 pub fn set_cache_update<T>(mut self, v: T) -> Self
10429 where
10430 T: std::convert::Into<crate::model::CacheUpdate>,
10431 {
10432 self.cache_update = std::option::Option::Some(v.into());
10433 self
10434 }
10435
10436 /// Sets or clears the value of [cache_update][crate::model::Transaction::cache_update].
10437 pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
10438 where
10439 T: std::convert::Into<crate::model::CacheUpdate>,
10440 {
10441 self.cache_update = v.map(|x| x.into());
10442 self
10443 }
10444}
10445
10446impl wkt::message::Message for Transaction {
10447 fn typename() -> &'static str {
10448 "type.googleapis.com/google.spanner.v1.Transaction"
10449 }
10450}
10451
10452/// This message is used to select the transaction in which a
10453/// [Read][google.spanner.v1.Spanner.Read] or
10454/// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs.
10455///
10456/// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more
10457/// information about transactions.
10458///
10459/// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
10460/// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
10461/// [google.spanner.v1.TransactionOptions]: crate::model::TransactionOptions
10462#[derive(Clone, Default, PartialEq)]
10463#[non_exhaustive]
10464pub struct TransactionSelector {
10465 /// If no fields are set, the default is a single use transaction
10466 /// with strong concurrency.
10467 pub selector: std::option::Option<crate::model::transaction_selector::Selector>,
10468
10469 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10470}
10471
10472impl TransactionSelector {
10473 /// Creates a new default instance.
10474 pub fn new() -> Self {
10475 std::default::Default::default()
10476 }
10477
10478 /// Sets the value of [selector][crate::model::TransactionSelector::selector].
10479 ///
10480 /// Note that all the setters affecting `selector` are mutually
10481 /// exclusive.
10482 pub fn set_selector<
10483 T: std::convert::Into<std::option::Option<crate::model::transaction_selector::Selector>>,
10484 >(
10485 mut self,
10486 v: T,
10487 ) -> Self {
10488 self.selector = v.into();
10489 self
10490 }
10491
10492 /// The value of [selector][crate::model::TransactionSelector::selector]
10493 /// if it holds a `SingleUse`, `None` if the field is not set or
10494 /// holds a different branch.
10495 pub fn single_use(
10496 &self,
10497 ) -> std::option::Option<&std::boxed::Box<crate::model::TransactionOptions>> {
10498 #[allow(unreachable_patterns)]
10499 self.selector.as_ref().and_then(|v| match v {
10500 crate::model::transaction_selector::Selector::SingleUse(v) => {
10501 std::option::Option::Some(v)
10502 }
10503 _ => std::option::Option::None,
10504 })
10505 }
10506
10507 /// Sets the value of [selector][crate::model::TransactionSelector::selector]
10508 /// to hold a `SingleUse`.
10509 ///
10510 /// Note that all the setters affecting `selector` are
10511 /// mutually exclusive.
10512 pub fn set_single_use<
10513 T: std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
10514 >(
10515 mut self,
10516 v: T,
10517 ) -> Self {
10518 self.selector = std::option::Option::Some(
10519 crate::model::transaction_selector::Selector::SingleUse(v.into()),
10520 );
10521 self
10522 }
10523
10524 /// The value of [selector][crate::model::TransactionSelector::selector]
10525 /// if it holds a `Id`, `None` if the field is not set or
10526 /// holds a different branch.
10527 pub fn id(&self) -> std::option::Option<&::bytes::Bytes> {
10528 #[allow(unreachable_patterns)]
10529 self.selector.as_ref().and_then(|v| match v {
10530 crate::model::transaction_selector::Selector::Id(v) => std::option::Option::Some(v),
10531 _ => std::option::Option::None,
10532 })
10533 }
10534
10535 /// Sets the value of [selector][crate::model::TransactionSelector::selector]
10536 /// to hold a `Id`.
10537 ///
10538 /// Note that all the setters affecting `selector` are
10539 /// mutually exclusive.
10540 pub fn set_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
10541 self.selector =
10542 std::option::Option::Some(crate::model::transaction_selector::Selector::Id(v.into()));
10543 self
10544 }
10545
10546 /// The value of [selector][crate::model::TransactionSelector::selector]
10547 /// if it holds a `Begin`, `None` if the field is not set or
10548 /// holds a different branch.
10549 pub fn begin(&self) -> std::option::Option<&std::boxed::Box<crate::model::TransactionOptions>> {
10550 #[allow(unreachable_patterns)]
10551 self.selector.as_ref().and_then(|v| match v {
10552 crate::model::transaction_selector::Selector::Begin(v) => std::option::Option::Some(v),
10553 _ => std::option::Option::None,
10554 })
10555 }
10556
10557 /// Sets the value of [selector][crate::model::TransactionSelector::selector]
10558 /// to hold a `Begin`.
10559 ///
10560 /// Note that all the setters affecting `selector` are
10561 /// mutually exclusive.
10562 pub fn set_begin<T: std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>>(
10563 mut self,
10564 v: T,
10565 ) -> Self {
10566 self.selector = std::option::Option::Some(
10567 crate::model::transaction_selector::Selector::Begin(v.into()),
10568 );
10569 self
10570 }
10571}
10572
10573impl wkt::message::Message for TransactionSelector {
10574 fn typename() -> &'static str {
10575 "type.googleapis.com/google.spanner.v1.TransactionSelector"
10576 }
10577}
10578
10579/// Defines additional types related to [TransactionSelector].
10580pub mod transaction_selector {
10581 #[allow(unused_imports)]
10582 use super::*;
10583
10584 /// If no fields are set, the default is a single use transaction
10585 /// with strong concurrency.
10586 #[derive(Clone, Debug, PartialEq)]
10587 #[non_exhaustive]
10588 pub enum Selector {
10589 /// Execute the read or SQL query in a temporary transaction.
10590 /// This is the most efficient way to execute a transaction that
10591 /// consists of a single SQL query.
10592 SingleUse(std::boxed::Box<crate::model::TransactionOptions>),
10593 /// Execute the read or SQL query in a previously-started transaction.
10594 Id(::bytes::Bytes),
10595 /// Begin a new transaction and execute this read or SQL query in
10596 /// it. The transaction ID of the new transaction is returned in
10597 /// [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction],
10598 /// which is a [Transaction][google.spanner.v1.Transaction].
10599 ///
10600 /// [google.spanner.v1.ResultSetMetadata.transaction]: crate::model::ResultSetMetadata::transaction
10601 /// [google.spanner.v1.Transaction]: crate::model::Transaction
10602 Begin(std::boxed::Box<crate::model::TransactionOptions>),
10603 }
10604
10605 impl Selector {
10606 /// Initializes the enum to the [SingleUse](Self::SingleUse) branch.
10607 pub fn from_single_use(
10608 value: impl std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
10609 ) -> Self {
10610 Self::SingleUse(value.into())
10611 }
10612 /// Initializes the enum to the [Id](Self::Id) branch.
10613 pub fn from_id(value: impl std::convert::Into<::bytes::Bytes>) -> Self {
10614 Self::Id(value.into())
10615 }
10616 /// Initializes the enum to the [Begin](Self::Begin) branch.
10617 pub fn from_begin(
10618 value: impl std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
10619 ) -> Self {
10620 Self::Begin(value.into())
10621 }
10622 }
10623}
10624
10625/// When a read-write transaction is executed on a multiplexed session,
10626/// this precommit token is sent back to the client
10627/// as a part of the [Transaction][google.spanner.v1.Transaction] message in the
10628/// [BeginTransaction][google.spanner.v1.BeginTransactionRequest] response and
10629/// also as a part of the [ResultSet][google.spanner.v1.ResultSet] and
10630/// [PartialResultSet][google.spanner.v1.PartialResultSet] responses.
10631///
10632/// [google.spanner.v1.BeginTransactionRequest]: crate::model::BeginTransactionRequest
10633/// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
10634/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
10635/// [google.spanner.v1.Transaction]: crate::model::Transaction
10636#[derive(Clone, Default, PartialEq)]
10637#[non_exhaustive]
10638pub struct MultiplexedSessionPrecommitToken {
10639 /// Opaque precommit token.
10640 pub precommit_token: ::bytes::Bytes,
10641
10642 /// An incrementing seq number is generated on every precommit token
10643 /// that is returned. Clients should remember the precommit token with the
10644 /// highest sequence number from the current transaction attempt.
10645 pub seq_num: i32,
10646
10647 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10648}
10649
10650impl MultiplexedSessionPrecommitToken {
10651 /// Creates a new default instance.
10652 pub fn new() -> Self {
10653 std::default::Default::default()
10654 }
10655
10656 /// Sets the value of [precommit_token][crate::model::MultiplexedSessionPrecommitToken::precommit_token].
10657 pub fn set_precommit_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
10658 self.precommit_token = v.into();
10659 self
10660 }
10661
10662 /// Sets the value of [seq_num][crate::model::MultiplexedSessionPrecommitToken::seq_num].
10663 pub fn set_seq_num<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10664 self.seq_num = v.into();
10665 self
10666 }
10667}
10668
10669impl wkt::message::Message for MultiplexedSessionPrecommitToken {
10670 fn typename() -> &'static str {
10671 "type.googleapis.com/google.spanner.v1.MultiplexedSessionPrecommitToken"
10672 }
10673}
10674
10675/// `Type` indicates the type of a Cloud Spanner value, as might be stored in a
10676/// table cell or returned from an SQL query.
10677#[derive(Clone, Default, PartialEq)]
10678#[non_exhaustive]
10679pub struct Type {
10680 /// Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
10681 ///
10682 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
10683 pub code: crate::model::TypeCode,
10684
10685 /// If [code][google.spanner.v1.Type.code] ==
10686 /// [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the
10687 /// type of the array elements.
10688 ///
10689 /// [google.spanner.v1.Type.code]: crate::model::Type::code
10690 /// [google.spanner.v1.TypeCode.ARRAY]: crate::model::TypeCode::Array
10691 pub array_element_type: std::option::Option<std::boxed::Box<crate::model::Type>>,
10692
10693 /// If [code][google.spanner.v1.Type.code] ==
10694 /// [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides
10695 /// type information for the struct's fields.
10696 ///
10697 /// [google.spanner.v1.Type.code]: crate::model::Type::code
10698 /// [google.spanner.v1.TypeCode.STRUCT]: crate::model::TypeCode::Struct
10699 pub struct_type: std::option::Option<std::boxed::Box<crate::model::StructType>>,
10700
10701 /// The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that
10702 /// disambiguates SQL type that Spanner will use to represent values of this
10703 /// type during query processing. This is necessary for some type codes because
10704 /// a single [TypeCode][google.spanner.v1.TypeCode] can be mapped to different
10705 /// SQL types depending on the SQL dialect.
10706 /// [type_annotation][google.spanner.v1.Type.type_annotation] typically is not
10707 /// needed to process the content of a value (it doesn't affect serialization)
10708 /// and clients can ignore it on the read path.
10709 ///
10710 /// [google.spanner.v1.Type.type_annotation]: crate::model::Type::type_annotation
10711 /// [google.spanner.v1.TypeAnnotationCode]: crate::model::TypeAnnotationCode
10712 /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
10713 pub type_annotation: crate::model::TypeAnnotationCode,
10714
10715 /// If [code][google.spanner.v1.Type.code] ==
10716 /// [PROTO][google.spanner.v1.TypeCode.PROTO] or
10717 /// [code][google.spanner.v1.Type.code] ==
10718 /// [ENUM][google.spanner.v1.TypeCode.ENUM], then `proto_type_fqn` is the fully
10719 /// qualified name of the proto type representing the proto/enum definition.
10720 ///
10721 /// [google.spanner.v1.Type.code]: crate::model::Type::code
10722 /// [google.spanner.v1.TypeCode.ENUM]: crate::model::TypeCode::Enum
10723 /// [google.spanner.v1.TypeCode.PROTO]: crate::model::TypeCode::Proto
10724 pub proto_type_fqn: std::string::String,
10725
10726 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10727}
10728
10729impl Type {
10730 /// Creates a new default instance.
10731 pub fn new() -> Self {
10732 std::default::Default::default()
10733 }
10734
10735 /// Sets the value of [code][crate::model::Type::code].
10736 pub fn set_code<T: std::convert::Into<crate::model::TypeCode>>(mut self, v: T) -> Self {
10737 self.code = v.into();
10738 self
10739 }
10740
10741 /// Sets the value of [array_element_type][crate::model::Type::array_element_type].
10742 pub fn set_array_element_type<T>(mut self, v: T) -> Self
10743 where
10744 T: std::convert::Into<crate::model::Type>,
10745 {
10746 self.array_element_type = std::option::Option::Some(std::boxed::Box::new(v.into()));
10747 self
10748 }
10749
10750 /// Sets or clears the value of [array_element_type][crate::model::Type::array_element_type].
10751 pub fn set_or_clear_array_element_type<T>(mut self, v: std::option::Option<T>) -> Self
10752 where
10753 T: std::convert::Into<crate::model::Type>,
10754 {
10755 self.array_element_type = v.map(|x| std::boxed::Box::new(x.into()));
10756 self
10757 }
10758
10759 /// Sets the value of [struct_type][crate::model::Type::struct_type].
10760 pub fn set_struct_type<T>(mut self, v: T) -> Self
10761 where
10762 T: std::convert::Into<crate::model::StructType>,
10763 {
10764 self.struct_type = std::option::Option::Some(std::boxed::Box::new(v.into()));
10765 self
10766 }
10767
10768 /// Sets or clears the value of [struct_type][crate::model::Type::struct_type].
10769 pub fn set_or_clear_struct_type<T>(mut self, v: std::option::Option<T>) -> Self
10770 where
10771 T: std::convert::Into<crate::model::StructType>,
10772 {
10773 self.struct_type = v.map(|x| std::boxed::Box::new(x.into()));
10774 self
10775 }
10776
10777 /// Sets the value of [type_annotation][crate::model::Type::type_annotation].
10778 pub fn set_type_annotation<T: std::convert::Into<crate::model::TypeAnnotationCode>>(
10779 mut self,
10780 v: T,
10781 ) -> Self {
10782 self.type_annotation = v.into();
10783 self
10784 }
10785
10786 /// Sets the value of [proto_type_fqn][crate::model::Type::proto_type_fqn].
10787 pub fn set_proto_type_fqn<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10788 self.proto_type_fqn = v.into();
10789 self
10790 }
10791}
10792
10793impl wkt::message::Message for Type {
10794 fn typename() -> &'static str {
10795 "type.googleapis.com/google.spanner.v1.Type"
10796 }
10797}
10798
10799/// `StructType` defines the fields of a
10800/// [STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
10801///
10802/// [google.spanner.v1.TypeCode.STRUCT]: crate::model::TypeCode::Struct
10803#[derive(Clone, Default, PartialEq)]
10804#[non_exhaustive]
10805pub struct StructType {
10806 /// The list of fields that make up this struct. Order is
10807 /// significant, because values of this struct type are represented as
10808 /// lists, where the order of field values matches the order of
10809 /// fields in the [StructType][google.spanner.v1.StructType]. In turn, the
10810 /// order of fields matches the order of columns in a read request, or the
10811 /// order of fields in the `SELECT` clause of a query.
10812 ///
10813 /// [google.spanner.v1.StructType]: crate::model::StructType
10814 pub fields: std::vec::Vec<crate::model::struct_type::Field>,
10815
10816 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10817}
10818
10819impl StructType {
10820 /// Creates a new default instance.
10821 pub fn new() -> Self {
10822 std::default::Default::default()
10823 }
10824
10825 /// Sets the value of [fields][crate::model::StructType::fields].
10826 pub fn set_fields<T, V>(mut self, v: T) -> Self
10827 where
10828 T: std::iter::IntoIterator<Item = V>,
10829 V: std::convert::Into<crate::model::struct_type::Field>,
10830 {
10831 use std::iter::Iterator;
10832 self.fields = v.into_iter().map(|i| i.into()).collect();
10833 self
10834 }
10835}
10836
10837impl wkt::message::Message for StructType {
10838 fn typename() -> &'static str {
10839 "type.googleapis.com/google.spanner.v1.StructType"
10840 }
10841}
10842
10843/// Defines additional types related to [StructType].
10844pub mod struct_type {
10845 #[allow(unused_imports)]
10846 use super::*;
10847
10848 /// Message representing a single field of a struct.
10849 #[derive(Clone, Default, PartialEq)]
10850 #[non_exhaustive]
10851 pub struct Field {
10852 /// The name of the field. For reads, this is the column name. For
10853 /// SQL queries, it is the column alias (e.g., `"Word"` in the
10854 /// query `"SELECT 'hello' AS Word"`), or the column name (e.g.,
10855 /// `"ColName"` in the query `"SELECT ColName FROM Table"`). Some
10856 /// columns might have an empty name (e.g., `"SELECT
10857 /// UPPER(ColName)"`). Note that a query result can contain
10858 /// multiple fields with the same name.
10859 pub name: std::string::String,
10860
10861 /// The type of the field.
10862 pub r#type: std::option::Option<std::boxed::Box<crate::model::Type>>,
10863
10864 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10865 }
10866
10867 impl Field {
10868 /// Creates a new default instance.
10869 pub fn new() -> Self {
10870 std::default::Default::default()
10871 }
10872
10873 /// Sets the value of [name][crate::model::struct_type::Field::name].
10874 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10875 self.name = v.into();
10876 self
10877 }
10878
10879 /// Sets the value of [r#type][crate::model::struct_type::Field::type].
10880 pub fn set_type<T>(mut self, v: T) -> Self
10881 where
10882 T: std::convert::Into<crate::model::Type>,
10883 {
10884 self.r#type = std::option::Option::Some(std::boxed::Box::new(v.into()));
10885 self
10886 }
10887
10888 /// Sets or clears the value of [r#type][crate::model::struct_type::Field::type].
10889 pub fn set_or_clear_type<T>(mut self, v: std::option::Option<T>) -> Self
10890 where
10891 T: std::convert::Into<crate::model::Type>,
10892 {
10893 self.r#type = v.map(|x| std::boxed::Box::new(x.into()));
10894 self
10895 }
10896 }
10897
10898 impl wkt::message::Message for Field {
10899 fn typename() -> &'static str {
10900 "type.googleapis.com/google.spanner.v1.StructType.Field"
10901 }
10902 }
10903}
10904
10905/// `TypeCode` is used as part of [Type][google.spanner.v1.Type] to
10906/// indicate the type of a Cloud Spanner value.
10907///
10908/// Each legal value of a type can be encoded to or decoded from a JSON
10909/// value, using the encodings described below. All Cloud Spanner values can
10910/// be `null`, regardless of type; `null`s are always encoded as a JSON
10911/// `null`.
10912///
10913/// [google.spanner.v1.Type]: crate::model::Type
10914///
10915/// # Working with unknown values
10916///
10917/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10918/// additional enum variants at any time. Adding new variants is not considered
10919/// a breaking change. Applications should write their code in anticipation of:
10920///
10921/// - New values appearing in future releases of the client library, **and**
10922/// - New values received dynamically, without application changes.
10923///
10924/// Please consult the [Working with enums] section in the user guide for some
10925/// guidelines.
10926///
10927/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10928#[derive(Clone, Debug, PartialEq)]
10929#[non_exhaustive]
10930pub enum TypeCode {
10931 /// Not specified.
10932 Unspecified,
10933 /// Encoded as JSON `true` or `false`.
10934 Bool,
10935 /// Encoded as `string`, in decimal format.
10936 Int64,
10937 /// Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or
10938 /// `"-Infinity"`.
10939 Float64,
10940 /// Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or
10941 /// `"-Infinity"`.
10942 Float32,
10943 /// Encoded as `string` in RFC 3339 timestamp format. The time zone
10944 /// must be present, and must be `"Z"`.
10945 ///
10946 /// If the schema has the column option
10947 /// `allow_commit_timestamp=true`, the placeholder string
10948 /// `"spanner.commit_timestamp()"` can be used to instruct the system
10949 /// to insert the commit timestamp associated with the transaction
10950 /// commit.
10951 Timestamp,
10952 /// Encoded as `string` in RFC 3339 date format.
10953 Date,
10954 /// Encoded as `string`.
10955 String,
10956 /// Encoded as a base64-encoded `string`, as described in RFC 4648,
10957 /// section 4.
10958 Bytes,
10959 /// Encoded as `list`, where the list elements are represented
10960 /// according to
10961 /// [array_element_type][google.spanner.v1.Type.array_element_type].
10962 ///
10963 /// [google.spanner.v1.Type.array_element_type]: crate::model::Type::array_element_type
10964 Array,
10965 /// Encoded as `list`, where list element `i` is represented according
10966 /// to [struct_type.fields[i]][google.spanner.v1.StructType.fields].
10967 ///
10968 /// [google.spanner.v1.StructType.fields]: crate::model::StructType::fields
10969 Struct,
10970 /// Encoded as `string`, in decimal format or scientific notation format.
10971 /// Decimal format:
10972 /// `[+-]Digits[.[Digits]]` or
10973 /// `[+-][Digits].Digits`
10974 ///
10975 /// Scientific notation:
10976 /// `[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
10977 /// `[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
10978 /// (ExponentIndicator is `"e"` or `"E"`)
10979 Numeric,
10980 /// Encoded as a JSON-formatted `string` as described in RFC 7159. The
10981 /// following rules are applied when parsing JSON input:
10982 ///
10983 /// - Whitespace characters are not preserved.
10984 /// - If a JSON object has duplicate keys, only the first key is preserved.
10985 /// - Members of a JSON object are not guaranteed to have their order
10986 /// preserved.
10987 /// - JSON array elements will have their order preserved.
10988 Json,
10989 /// Encoded as a base64-encoded `string`, as described in RFC 4648,
10990 /// section 4.
10991 Proto,
10992 /// Encoded as `string`, in decimal format.
10993 Enum,
10994 /// Encoded as `string`, in `ISO8601` duration format -
10995 /// `P[n]Y[n]M[n]DT[n]H[n]M[n[.fraction]]S`
10996 /// where `n` is an integer.
10997 /// For example, `P1Y2M3DT4H5M6.5S` represents time duration of 1 year, 2
10998 /// months, 3 days, 4 hours, 5 minutes, and 6.5 seconds.
10999 Interval,
11000 /// Encoded as `string`, in lower-case hexa-decimal format, as described
11001 /// in RFC 9562, section 4.
11002 Uuid,
11003 /// If set, the enum was initialized with an unknown value.
11004 ///
11005 /// Applications can examine the value using [TypeCode::value] or
11006 /// [TypeCode::name].
11007 UnknownValue(type_code::UnknownValue),
11008}
11009
11010#[doc(hidden)]
11011pub mod type_code {
11012 #[allow(unused_imports)]
11013 use super::*;
11014 #[derive(Clone, Debug, PartialEq)]
11015 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11016}
11017
11018impl TypeCode {
11019 /// Gets the enum value.
11020 ///
11021 /// Returns `None` if the enum contains an unknown value deserialized from
11022 /// the string representation of enums.
11023 pub fn value(&self) -> std::option::Option<i32> {
11024 match self {
11025 Self::Unspecified => std::option::Option::Some(0),
11026 Self::Bool => std::option::Option::Some(1),
11027 Self::Int64 => std::option::Option::Some(2),
11028 Self::Float64 => std::option::Option::Some(3),
11029 Self::Float32 => std::option::Option::Some(15),
11030 Self::Timestamp => std::option::Option::Some(4),
11031 Self::Date => std::option::Option::Some(5),
11032 Self::String => std::option::Option::Some(6),
11033 Self::Bytes => std::option::Option::Some(7),
11034 Self::Array => std::option::Option::Some(8),
11035 Self::Struct => std::option::Option::Some(9),
11036 Self::Numeric => std::option::Option::Some(10),
11037 Self::Json => std::option::Option::Some(11),
11038 Self::Proto => std::option::Option::Some(13),
11039 Self::Enum => std::option::Option::Some(14),
11040 Self::Interval => std::option::Option::Some(16),
11041 Self::Uuid => std::option::Option::Some(17),
11042 Self::UnknownValue(u) => u.0.value(),
11043 }
11044 }
11045
11046 /// Gets the enum value as a string.
11047 ///
11048 /// Returns `None` if the enum contains an unknown value deserialized from
11049 /// the integer representation of enums.
11050 pub fn name(&self) -> std::option::Option<&str> {
11051 match self {
11052 Self::Unspecified => std::option::Option::Some("TYPE_CODE_UNSPECIFIED"),
11053 Self::Bool => std::option::Option::Some("BOOL"),
11054 Self::Int64 => std::option::Option::Some("INT64"),
11055 Self::Float64 => std::option::Option::Some("FLOAT64"),
11056 Self::Float32 => std::option::Option::Some("FLOAT32"),
11057 Self::Timestamp => std::option::Option::Some("TIMESTAMP"),
11058 Self::Date => std::option::Option::Some("DATE"),
11059 Self::String => std::option::Option::Some("STRING"),
11060 Self::Bytes => std::option::Option::Some("BYTES"),
11061 Self::Array => std::option::Option::Some("ARRAY"),
11062 Self::Struct => std::option::Option::Some("STRUCT"),
11063 Self::Numeric => std::option::Option::Some("NUMERIC"),
11064 Self::Json => std::option::Option::Some("JSON"),
11065 Self::Proto => std::option::Option::Some("PROTO"),
11066 Self::Enum => std::option::Option::Some("ENUM"),
11067 Self::Interval => std::option::Option::Some("INTERVAL"),
11068 Self::Uuid => std::option::Option::Some("UUID"),
11069 Self::UnknownValue(u) => u.0.name(),
11070 }
11071 }
11072}
11073
11074impl std::default::Default for TypeCode {
11075 fn default() -> Self {
11076 use std::convert::From;
11077 Self::from(0)
11078 }
11079}
11080
11081impl std::fmt::Display for TypeCode {
11082 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11083 wkt::internal::display_enum(f, self.name(), self.value())
11084 }
11085}
11086
11087impl std::convert::From<i32> for TypeCode {
11088 fn from(value: i32) -> Self {
11089 match value {
11090 0 => Self::Unspecified,
11091 1 => Self::Bool,
11092 2 => Self::Int64,
11093 3 => Self::Float64,
11094 4 => Self::Timestamp,
11095 5 => Self::Date,
11096 6 => Self::String,
11097 7 => Self::Bytes,
11098 8 => Self::Array,
11099 9 => Self::Struct,
11100 10 => Self::Numeric,
11101 11 => Self::Json,
11102 13 => Self::Proto,
11103 14 => Self::Enum,
11104 15 => Self::Float32,
11105 16 => Self::Interval,
11106 17 => Self::Uuid,
11107 _ => Self::UnknownValue(type_code::UnknownValue(
11108 wkt::internal::UnknownEnumValue::Integer(value),
11109 )),
11110 }
11111 }
11112}
11113
11114impl std::convert::From<&str> for TypeCode {
11115 fn from(value: &str) -> Self {
11116 use std::string::ToString;
11117 match value {
11118 "TYPE_CODE_UNSPECIFIED" => Self::Unspecified,
11119 "BOOL" => Self::Bool,
11120 "INT64" => Self::Int64,
11121 "FLOAT64" => Self::Float64,
11122 "FLOAT32" => Self::Float32,
11123 "TIMESTAMP" => Self::Timestamp,
11124 "DATE" => Self::Date,
11125 "STRING" => Self::String,
11126 "BYTES" => Self::Bytes,
11127 "ARRAY" => Self::Array,
11128 "STRUCT" => Self::Struct,
11129 "NUMERIC" => Self::Numeric,
11130 "JSON" => Self::Json,
11131 "PROTO" => Self::Proto,
11132 "ENUM" => Self::Enum,
11133 "INTERVAL" => Self::Interval,
11134 "UUID" => Self::Uuid,
11135 _ => Self::UnknownValue(type_code::UnknownValue(
11136 wkt::internal::UnknownEnumValue::String(value.to_string()),
11137 )),
11138 }
11139 }
11140}
11141
11142impl serde::ser::Serialize for TypeCode {
11143 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11144 where
11145 S: serde::Serializer,
11146 {
11147 match self {
11148 Self::Unspecified => serializer.serialize_i32(0),
11149 Self::Bool => serializer.serialize_i32(1),
11150 Self::Int64 => serializer.serialize_i32(2),
11151 Self::Float64 => serializer.serialize_i32(3),
11152 Self::Float32 => serializer.serialize_i32(15),
11153 Self::Timestamp => serializer.serialize_i32(4),
11154 Self::Date => serializer.serialize_i32(5),
11155 Self::String => serializer.serialize_i32(6),
11156 Self::Bytes => serializer.serialize_i32(7),
11157 Self::Array => serializer.serialize_i32(8),
11158 Self::Struct => serializer.serialize_i32(9),
11159 Self::Numeric => serializer.serialize_i32(10),
11160 Self::Json => serializer.serialize_i32(11),
11161 Self::Proto => serializer.serialize_i32(13),
11162 Self::Enum => serializer.serialize_i32(14),
11163 Self::Interval => serializer.serialize_i32(16),
11164 Self::Uuid => serializer.serialize_i32(17),
11165 Self::UnknownValue(u) => u.0.serialize(serializer),
11166 }
11167 }
11168}
11169
11170impl<'de> serde::de::Deserialize<'de> for TypeCode {
11171 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11172 where
11173 D: serde::Deserializer<'de>,
11174 {
11175 deserializer.deserialize_any(wkt::internal::EnumVisitor::<TypeCode>::new(
11176 ".google.spanner.v1.TypeCode",
11177 ))
11178 }
11179}
11180
11181/// `TypeAnnotationCode` is used as a part of [Type][google.spanner.v1.Type] to
11182/// disambiguate SQL types that should be used for a given Cloud Spanner value.
11183/// Disambiguation is needed because the same Cloud Spanner type can be mapped to
11184/// different SQL types depending on SQL dialect. TypeAnnotationCode doesn't
11185/// affect the way value is serialized.
11186///
11187/// [google.spanner.v1.Type]: crate::model::Type
11188///
11189/// # Working with unknown values
11190///
11191/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11192/// additional enum variants at any time. Adding new variants is not considered
11193/// a breaking change. Applications should write their code in anticipation of:
11194///
11195/// - New values appearing in future releases of the client library, **and**
11196/// - New values received dynamically, without application changes.
11197///
11198/// Please consult the [Working with enums] section in the user guide for some
11199/// guidelines.
11200///
11201/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
11202#[derive(Clone, Debug, PartialEq)]
11203#[non_exhaustive]
11204pub enum TypeAnnotationCode {
11205 /// Not specified.
11206 Unspecified,
11207 /// PostgreSQL compatible NUMERIC type. This annotation needs to be applied to
11208 /// [Type][google.spanner.v1.Type] instances having
11209 /// [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] type code to specify that
11210 /// values of this type should be treated as PostgreSQL NUMERIC values.
11211 /// Currently this annotation is always needed for
11212 /// [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] when a client interacts with
11213 /// PostgreSQL-enabled Spanner databases.
11214 ///
11215 /// [google.spanner.v1.Type]: crate::model::Type
11216 /// [google.spanner.v1.TypeCode.NUMERIC]: crate::model::TypeCode::Numeric
11217 PgNumeric,
11218 /// PostgreSQL compatible JSONB type. This annotation needs to be applied to
11219 /// [Type][google.spanner.v1.Type] instances having
11220 /// [JSON][google.spanner.v1.TypeCode.JSON] type code to specify that values of
11221 /// this type should be treated as PostgreSQL JSONB values. Currently this
11222 /// annotation is always needed for [JSON][google.spanner.v1.TypeCode.JSON]
11223 /// when a client interacts with PostgreSQL-enabled Spanner databases.
11224 ///
11225 /// [google.spanner.v1.Type]: crate::model::Type
11226 /// [google.spanner.v1.TypeCode.JSON]: crate::model::TypeCode::Json
11227 PgJsonb,
11228 /// PostgreSQL compatible OID type. This annotation can be used by a client
11229 /// interacting with PostgreSQL-enabled Spanner database to specify that a
11230 /// value should be treated using the semantics of the OID type.
11231 PgOid,
11232 /// If set, the enum was initialized with an unknown value.
11233 ///
11234 /// Applications can examine the value using [TypeAnnotationCode::value] or
11235 /// [TypeAnnotationCode::name].
11236 UnknownValue(type_annotation_code::UnknownValue),
11237}
11238
11239#[doc(hidden)]
11240pub mod type_annotation_code {
11241 #[allow(unused_imports)]
11242 use super::*;
11243 #[derive(Clone, Debug, PartialEq)]
11244 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11245}
11246
11247impl TypeAnnotationCode {
11248 /// Gets the enum value.
11249 ///
11250 /// Returns `None` if the enum contains an unknown value deserialized from
11251 /// the string representation of enums.
11252 pub fn value(&self) -> std::option::Option<i32> {
11253 match self {
11254 Self::Unspecified => std::option::Option::Some(0),
11255 Self::PgNumeric => std::option::Option::Some(2),
11256 Self::PgJsonb => std::option::Option::Some(3),
11257 Self::PgOid => std::option::Option::Some(4),
11258 Self::UnknownValue(u) => u.0.value(),
11259 }
11260 }
11261
11262 /// Gets the enum value as a string.
11263 ///
11264 /// Returns `None` if the enum contains an unknown value deserialized from
11265 /// the integer representation of enums.
11266 pub fn name(&self) -> std::option::Option<&str> {
11267 match self {
11268 Self::Unspecified => std::option::Option::Some("TYPE_ANNOTATION_CODE_UNSPECIFIED"),
11269 Self::PgNumeric => std::option::Option::Some("PG_NUMERIC"),
11270 Self::PgJsonb => std::option::Option::Some("PG_JSONB"),
11271 Self::PgOid => std::option::Option::Some("PG_OID"),
11272 Self::UnknownValue(u) => u.0.name(),
11273 }
11274 }
11275}
11276
11277impl std::default::Default for TypeAnnotationCode {
11278 fn default() -> Self {
11279 use std::convert::From;
11280 Self::from(0)
11281 }
11282}
11283
11284impl std::fmt::Display for TypeAnnotationCode {
11285 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11286 wkt::internal::display_enum(f, self.name(), self.value())
11287 }
11288}
11289
11290impl std::convert::From<i32> for TypeAnnotationCode {
11291 fn from(value: i32) -> Self {
11292 match value {
11293 0 => Self::Unspecified,
11294 2 => Self::PgNumeric,
11295 3 => Self::PgJsonb,
11296 4 => Self::PgOid,
11297 _ => Self::UnknownValue(type_annotation_code::UnknownValue(
11298 wkt::internal::UnknownEnumValue::Integer(value),
11299 )),
11300 }
11301 }
11302}
11303
11304impl std::convert::From<&str> for TypeAnnotationCode {
11305 fn from(value: &str) -> Self {
11306 use std::string::ToString;
11307 match value {
11308 "TYPE_ANNOTATION_CODE_UNSPECIFIED" => Self::Unspecified,
11309 "PG_NUMERIC" => Self::PgNumeric,
11310 "PG_JSONB" => Self::PgJsonb,
11311 "PG_OID" => Self::PgOid,
11312 _ => Self::UnknownValue(type_annotation_code::UnknownValue(
11313 wkt::internal::UnknownEnumValue::String(value.to_string()),
11314 )),
11315 }
11316 }
11317}
11318
11319impl serde::ser::Serialize for TypeAnnotationCode {
11320 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11321 where
11322 S: serde::Serializer,
11323 {
11324 match self {
11325 Self::Unspecified => serializer.serialize_i32(0),
11326 Self::PgNumeric => serializer.serialize_i32(2),
11327 Self::PgJsonb => serializer.serialize_i32(3),
11328 Self::PgOid => serializer.serialize_i32(4),
11329 Self::UnknownValue(u) => u.0.serialize(serializer),
11330 }
11331 }
11332}
11333
11334impl<'de> serde::de::Deserialize<'de> for TypeAnnotationCode {
11335 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11336 where
11337 D: serde::Deserializer<'de>,
11338 {
11339 deserializer.deserialize_any(wkt::internal::EnumVisitor::<TypeAnnotationCode>::new(
11340 ".google.spanner.v1.TypeAnnotationCode",
11341 ))
11342 }
11343}