google-cloud-pubsub 0.33.2

Google Cloud Client Libraries for Rust - Pub/Sub
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

mod debug;
mod deserialize;
mod serialize;

/// A message that is published by publishers and consumed by subscribers. The
/// message must contain either a non-empty data field or at least one attribute.
/// Note that client libraries represent this object differently
/// depending on the language. See the corresponding [client library
/// documentation](https://cloud.google.com/pubsub/docs/reference/libraries) for
/// more information. See [quotas and limits]
/// (<https://cloud.google.com/pubsub/quotas>) for more information about message
/// limits.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PubsubMessage {
    /// Optional. The message data field. If this field is empty, the message must
    /// contain at least one attribute.
    pub data: ::bytes::Bytes,

    /// Optional. Attributes for this message. If this field is empty, the message
    /// must contain non-empty data. This can be used to filter messages on the
    /// subscription.
    pub attributes: std::collections::HashMap<std::string::String, std::string::String>,

    /// ID of this message, assigned by the server when the message is published.
    /// Guaranteed to be unique within the topic. This value may be read by a
    /// subscriber that receives a `PubsubMessage` via a `Pull` call or a push
    /// delivery. It must not be populated by the publisher in a `Publish` call.
    pub message_id: std::string::String,

    /// The time at which the message was published, populated by the server when
    /// it receives the `Publish` call. It must not be populated by the
    /// publisher in a `Publish` call.
    pub publish_time: std::option::Option<wkt::Timestamp>,

    /// Optional. If non-empty, identifies related messages for which publish order
    /// should be respected. If a `Subscription` has `enable_message_ordering` set
    /// to `true`, messages published with the same non-empty `ordering_key` value
    /// will be delivered to subscribers in the order in which they are received by
    /// the Pub/Sub system. All `PubsubMessage`s published in a given
    /// `PublishRequest` must specify the same `ordering_key` value. For more
    /// information, see [ordering
    /// messages](https://cloud.google.com/pubsub/docs/ordering).
    pub ordering_key: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PubsubMessage {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [data][crate::model::PubsubMessage::data].
    pub fn set_data<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
        self.data = v.into();
        self
    }

    /// Sets the value of [attributes][crate::model::PubsubMessage::attributes].
    pub fn set_attributes<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.attributes = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [message_id][crate::model::PubsubMessage::message_id].
    pub fn set_message_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.message_id = v.into();
        self
    }

    /// Sets the value of [publish_time][crate::model::PubsubMessage::publish_time].
    pub fn set_publish_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.publish_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [publish_time][crate::model::PubsubMessage::publish_time].
    pub fn set_or_clear_publish_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.publish_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [ordering_key][crate::model::PubsubMessage::ordering_key].
    pub fn set_ordering_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.ordering_key = v.into();
        self
    }
}

impl wkt::message::Message for PubsubMessage {
    fn typename() -> &'static str {
        "type.googleapis.com/google.pubsub.v1.PubsubMessage"
    }
}

/// Request for the Publish method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PublishRequest {
    /// Required. The messages in the request will be published on this topic.
    /// Format is `projects/{project}/topics/{topic}`.
    pub topic: std::string::String,

    /// Required. The messages to publish.
    pub messages: std::vec::Vec<crate::model::PubsubMessage>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PublishRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [topic][crate::model::PublishRequest::topic].
    pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.topic = v.into();
        self
    }

    /// Sets the value of [messages][crate::model::PublishRequest::messages].
    pub fn set_messages<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::PubsubMessage>,
    {
        use std::iter::Iterator;
        self.messages = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for PublishRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.pubsub.v1.PublishRequest"
    }
}

/// Response for the `Publish` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PublishResponse {
    /// Optional. The server-assigned ID of each published message, in the same
    /// order as the messages in the request. IDs are guaranteed to be unique
    /// within the topic.
    pub message_ids: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PublishResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [message_ids][crate::model::PublishResponse::message_ids].
    pub fn set_message_ids<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.message_ids = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for PublishResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.pubsub.v1.PublishResponse"
    }
}

/// A message and its corresponding acknowledgment ID.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReceivedMessage {
    /// Optional. This ID can be used to acknowledge the received message.
    pub ack_id: std::string::String,

    /// Optional. The message.
    pub message: std::option::Option<crate::model::PubsubMessage>,

    /// Optional. The approximate number of times that Pub/Sub has attempted to
    /// deliver the associated message to a subscriber.
    ///
    /// More precisely, this is 1 + (number of NACKs) +
    /// (number of ack_deadline exceeds) for this message.
    ///
    /// A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
    /// exceeds event is whenever a message is not acknowledged within
    /// ack_deadline. Note that ack_deadline is initially
    /// Subscription.ackDeadlineSeconds, but may get extended automatically by
    /// the client library.
    ///
    /// Upon the first delivery of a given message, `delivery_attempt` will have a
    /// value of 1. The value is calculated at best effort and is approximate.
    ///
    /// If a DeadLetterPolicy is not set on the subscription, this will be 0.
    pub delivery_attempt: i32,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ReceivedMessage {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [ack_id][crate::model::ReceivedMessage::ack_id].
    pub fn set_ack_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.ack_id = v.into();
        self
    }

    /// Sets the value of [message][crate::model::ReceivedMessage::message].
    pub fn set_message<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::PubsubMessage>,
    {
        self.message = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [message][crate::model::ReceivedMessage::message].
    pub fn set_or_clear_message<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::PubsubMessage>,
    {
        self.message = v.map(|x| x.into());
        self
    }

    /// Sets the value of [delivery_attempt][crate::model::ReceivedMessage::delivery_attempt].
    pub fn set_delivery_attempt<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.delivery_attempt = v.into();
        self
    }
}

impl wkt::message::Message for ReceivedMessage {
    fn typename() -> &'static str {
        "type.googleapis.com/google.pubsub.v1.ReceivedMessage"
    }
}

/// Request for the ModifyAckDeadline method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ModifyAckDeadlineRequest {
    /// Required. The name of the subscription.
    /// Format is `projects/{project}/subscriptions/{sub}`.
    pub subscription: std::string::String,

    /// Required. List of acknowledgment IDs.
    pub ack_ids: std::vec::Vec<std::string::String>,

    /// Required. The new ack deadline with respect to the time this request was
    /// sent to the Pub/Sub system. For example, if the value is 10, the new ack
    /// deadline will expire 10 seconds after the `ModifyAckDeadline` call was
    /// made. Specifying zero might immediately make the message available for
    /// delivery to another subscriber client. This typically results in an
    /// increase in the rate of message redeliveries (that is, duplicates).
    /// The minimum deadline you can specify is 0 seconds.
    /// The maximum deadline you can specify in a single request is 600 seconds
    /// (10 minutes).
    pub ack_deadline_seconds: i32,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ModifyAckDeadlineRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [subscription][crate::model::ModifyAckDeadlineRequest::subscription].
    pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.subscription = v.into();
        self
    }

    /// Sets the value of [ack_ids][crate::model::ModifyAckDeadlineRequest::ack_ids].
    pub fn set_ack_ids<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.ack_ids = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [ack_deadline_seconds][crate::model::ModifyAckDeadlineRequest::ack_deadline_seconds].
    pub fn set_ack_deadline_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.ack_deadline_seconds = v.into();
        self
    }
}

impl wkt::message::Message for ModifyAckDeadlineRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.pubsub.v1.ModifyAckDeadlineRequest"
    }
}

/// Request for the Acknowledge method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AcknowledgeRequest {
    /// Required. The subscription whose message is being acknowledged.
    /// Format is `projects/{project}/subscriptions/{sub}`.
    pub subscription: std::string::String,

    /// Required. The acknowledgment ID for the messages being acknowledged that
    /// was returned by the Pub/Sub system in the `Pull` response. Must not be
    /// empty.
    pub ack_ids: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AcknowledgeRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [subscription][crate::model::AcknowledgeRequest::subscription].
    pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.subscription = v.into();
        self
    }

    /// Sets the value of [ack_ids][crate::model::AcknowledgeRequest::ack_ids].
    pub fn set_ack_ids<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.ack_ids = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for AcknowledgeRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.pubsub.v1.AcknowledgeRequest"
    }
}

/// Request for the `StreamingPull` streaming RPC method. This request is used to
/// establish the initial stream as well as to stream acknowledgments and ack
/// deadline modifications from the client to the server.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct StreamingPullRequest {
    /// Required. The subscription for which to initialize the new stream. This
    /// must be provided in the first request on the stream, and must not be set in
    /// subsequent requests from client to server.
    /// Format is `projects/{project}/subscriptions/{sub}`.
    pub subscription: std::string::String,

    /// Optional. List of acknowledgment IDs for acknowledging previously received
    /// messages (received on this stream or a different stream). If an ack ID has
    /// expired, the corresponding message may be redelivered later. Acknowledging
    /// a message more than once will not result in an error. If the acknowledgment
    /// ID is malformed, the stream will be aborted with status `INVALID_ARGUMENT`.
    pub ack_ids: std::vec::Vec<std::string::String>,

    /// Optional. The list of new ack deadlines for the IDs listed in
    /// `modify_deadline_ack_ids`. The size of this list must be the same as the
    /// size of `modify_deadline_ack_ids`. If it differs the stream will be aborted
    /// with `INVALID_ARGUMENT`. Each element in this list is applied to the
    /// element in the same position in `modify_deadline_ack_ids`. The new ack
    /// deadline is with respect to the time this request was sent to the Pub/Sub
    /// system. Must be >= 0. For example, if the value is 10, the new ack deadline
    /// will expire 10 seconds after this request is received. If the value is 0,
    /// the message is immediately made available for another streaming or
    /// non-streaming pull request. If the value is < 0 (an error), the stream will
    /// be aborted with status `INVALID_ARGUMENT`.
    pub modify_deadline_seconds: std::vec::Vec<i32>,

    /// Optional. List of acknowledgment IDs whose deadline will be modified based
    /// on the corresponding element in `modify_deadline_seconds`. This field can
    /// be used to indicate that more time is needed to process a message by the
    /// subscriber, or to make the message available for redelivery if the
    /// processing was interrupted.
    pub modify_deadline_ack_ids: std::vec::Vec<std::string::String>,

    /// Required. The ack deadline to use for the stream. This must be provided in
    /// the first request on the stream, but it can also be updated on subsequent
    /// requests from client to server. The minimum deadline you can specify is 10
    /// seconds. The maximum deadline you can specify is 600 seconds (10 minutes).
    pub stream_ack_deadline_seconds: i32,

    /// Optional. A unique identifier that is used to distinguish client instances
    /// from each other. Only needs to be provided on the initial request. When a
    /// stream disconnects and reconnects for the same stream, the client_id should
    /// be set to the same value so that state associated with the old stream can
    /// be transferred to the new stream. The same client_id should not be used for
    /// different client instances.
    pub client_id: std::string::String,

    /// Optional. Flow control settings for the maximum number of outstanding
    /// messages. When there are `max_outstanding_messages` currently sent to the
    /// streaming pull client that have not yet been acked or nacked, the server
    /// stops sending more messages. The sending of messages resumes once the
    /// number of outstanding messages is less than this value. If the value is
    /// <= 0, there is no limit to the number of outstanding messages. This
    /// property can only be set on the initial StreamingPullRequest. If it is set
    /// on a subsequent request, the stream will be aborted with status
    /// `INVALID_ARGUMENT`.
    pub max_outstanding_messages: i64,

    /// Optional. Flow control settings for the maximum number of outstanding
    /// bytes. When there are `max_outstanding_bytes` or more worth of messages
    /// currently sent to the streaming pull client that have not yet been acked or
    /// nacked, the server will stop sending more messages. The sending of messages
    /// resumes once the number of outstanding bytes is less than this value. If
    /// the value is <= 0, there is no limit to the number of outstanding bytes.
    /// This property can only be set on the initial StreamingPullRequest. If it is
    /// set on a subsequent request, the stream will be aborted with status
    /// `INVALID_ARGUMENT`.
    pub max_outstanding_bytes: i64,

    /// Optional. The protocol version used by the client. This property can only
    /// be set on the initial StreamingPullRequest. If it is set on a subsequent
    /// request, the stream will be aborted with status `INVALID_ARGUMENT`.
    pub protocol_version: i64,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl StreamingPullRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [subscription][crate::model::StreamingPullRequest::subscription].
    pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.subscription = v.into();
        self
    }

    /// Sets the value of [ack_ids][crate::model::StreamingPullRequest::ack_ids].
    pub fn set_ack_ids<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.ack_ids = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [modify_deadline_seconds][crate::model::StreamingPullRequest::modify_deadline_seconds].
    pub fn set_modify_deadline_seconds<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<i32>,
    {
        use std::iter::Iterator;
        self.modify_deadline_seconds = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [modify_deadline_ack_ids][crate::model::StreamingPullRequest::modify_deadline_ack_ids].
    pub fn set_modify_deadline_ack_ids<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.modify_deadline_ack_ids = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [stream_ack_deadline_seconds][crate::model::StreamingPullRequest::stream_ack_deadline_seconds].
    pub fn set_stream_ack_deadline_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.stream_ack_deadline_seconds = v.into();
        self
    }

    /// Sets the value of [client_id][crate::model::StreamingPullRequest::client_id].
    pub fn set_client_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.client_id = v.into();
        self
    }

    /// Sets the value of [max_outstanding_messages][crate::model::StreamingPullRequest::max_outstanding_messages].
    pub fn set_max_outstanding_messages<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.max_outstanding_messages = v.into();
        self
    }

    /// Sets the value of [max_outstanding_bytes][crate::model::StreamingPullRequest::max_outstanding_bytes].
    pub fn set_max_outstanding_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.max_outstanding_bytes = v.into();
        self
    }

    /// Sets the value of [protocol_version][crate::model::StreamingPullRequest::protocol_version].
    pub fn set_protocol_version<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.protocol_version = v.into();
        self
    }
}

impl wkt::message::Message for StreamingPullRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.pubsub.v1.StreamingPullRequest"
    }
}

/// Response for the `StreamingPull` method. This response is used to stream
/// messages from the server to the client.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct StreamingPullResponse {
    /// Optional. Received Pub/Sub messages.
    pub received_messages: std::vec::Vec<crate::model::ReceivedMessage>,

    /// Optional. This field will only be set if `enable_exactly_once_delivery` is
    /// set to `true` and is not guaranteed to be populated.
    pub acknowledge_confirmation:
        std::option::Option<crate::model::streaming_pull_response::AcknowledgeConfirmation>,

    /// Optional. This field will only be set if `enable_exactly_once_delivery` is
    /// set to `true` and is not guaranteed to be populated.
    pub modify_ack_deadline_confirmation:
        std::option::Option<crate::model::streaming_pull_response::ModifyAckDeadlineConfirmation>,

    /// Optional. Properties associated with this subscription.
    pub subscription_properties:
        std::option::Option<crate::model::streaming_pull_response::SubscriptionProperties>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl StreamingPullResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [received_messages][crate::model::StreamingPullResponse::received_messages].
    pub fn set_received_messages<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ReceivedMessage>,
    {
        use std::iter::Iterator;
        self.received_messages = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [acknowledge_confirmation][crate::model::StreamingPullResponse::acknowledge_confirmation].
    pub fn set_acknowledge_confirmation<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::streaming_pull_response::AcknowledgeConfirmation>,
    {
        self.acknowledge_confirmation = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [acknowledge_confirmation][crate::model::StreamingPullResponse::acknowledge_confirmation].
    pub fn set_or_clear_acknowledge_confirmation<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::streaming_pull_response::AcknowledgeConfirmation>,
    {
        self.acknowledge_confirmation = v.map(|x| x.into());
        self
    }

    /// Sets the value of [modify_ack_deadline_confirmation][crate::model::StreamingPullResponse::modify_ack_deadline_confirmation].
    pub fn set_modify_ack_deadline_confirmation<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::streaming_pull_response::ModifyAckDeadlineConfirmation>,
    {
        self.modify_ack_deadline_confirmation = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [modify_ack_deadline_confirmation][crate::model::StreamingPullResponse::modify_ack_deadline_confirmation].
    pub fn set_or_clear_modify_ack_deadline_confirmation<T>(
        mut self,
        v: std::option::Option<T>,
    ) -> Self
    where
        T: std::convert::Into<crate::model::streaming_pull_response::ModifyAckDeadlineConfirmation>,
    {
        self.modify_ack_deadline_confirmation = v.map(|x| x.into());
        self
    }

    /// Sets the value of [subscription_properties][crate::model::StreamingPullResponse::subscription_properties].
    pub fn set_subscription_properties<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::streaming_pull_response::SubscriptionProperties>,
    {
        self.subscription_properties = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [subscription_properties][crate::model::StreamingPullResponse::subscription_properties].
    pub fn set_or_clear_subscription_properties<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::streaming_pull_response::SubscriptionProperties>,
    {
        self.subscription_properties = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for StreamingPullResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.pubsub.v1.StreamingPullResponse"
    }
}

/// Defines additional types related to [StreamingPullResponse].
pub mod streaming_pull_response {
    #[allow(unused_imports)]
    use super::*;

    /// Acknowledgment IDs sent in one or more previous requests to acknowledge a
    /// previously received message.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct AcknowledgeConfirmation {
        /// Optional. Successfully processed acknowledgment IDs.
        pub ack_ids: std::vec::Vec<std::string::String>,

        /// Optional. List of acknowledgment IDs that were malformed or whose
        /// acknowledgment deadline has expired.
        pub invalid_ack_ids: std::vec::Vec<std::string::String>,

        /// Optional. List of acknowledgment IDs that were out of order.
        pub unordered_ack_ids: std::vec::Vec<std::string::String>,

        /// Optional. List of acknowledgment IDs that failed processing with
        /// temporary issues.
        pub temporary_failed_ack_ids: std::vec::Vec<std::string::String>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl AcknowledgeConfirmation {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [ack_ids][crate::model::streaming_pull_response::AcknowledgeConfirmation::ack_ids].
        pub fn set_ack_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.ack_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [invalid_ack_ids][crate::model::streaming_pull_response::AcknowledgeConfirmation::invalid_ack_ids].
        pub fn set_invalid_ack_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.invalid_ack_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [unordered_ack_ids][crate::model::streaming_pull_response::AcknowledgeConfirmation::unordered_ack_ids].
        pub fn set_unordered_ack_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.unordered_ack_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [temporary_failed_ack_ids][crate::model::streaming_pull_response::AcknowledgeConfirmation::temporary_failed_ack_ids].
        pub fn set_temporary_failed_ack_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.temporary_failed_ack_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for AcknowledgeConfirmation {
        fn typename() -> &'static str {
            "type.googleapis.com/google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation"
        }
    }

    /// Acknowledgment IDs sent in one or more previous requests to modify the
    /// deadline for a specific message.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct ModifyAckDeadlineConfirmation {
        /// Optional. Successfully processed acknowledgment IDs.
        pub ack_ids: std::vec::Vec<std::string::String>,

        /// Optional. List of acknowledgment IDs that were malformed or whose
        /// acknowledgment deadline has expired.
        pub invalid_ack_ids: std::vec::Vec<std::string::String>,

        /// Optional. List of acknowledgment IDs that failed processing with
        /// temporary issues.
        pub temporary_failed_ack_ids: std::vec::Vec<std::string::String>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl ModifyAckDeadlineConfirmation {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [ack_ids][crate::model::streaming_pull_response::ModifyAckDeadlineConfirmation::ack_ids].
        pub fn set_ack_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.ack_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [invalid_ack_ids][crate::model::streaming_pull_response::ModifyAckDeadlineConfirmation::invalid_ack_ids].
        pub fn set_invalid_ack_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.invalid_ack_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [temporary_failed_ack_ids][crate::model::streaming_pull_response::ModifyAckDeadlineConfirmation::temporary_failed_ack_ids].
        pub fn set_temporary_failed_ack_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.temporary_failed_ack_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for ModifyAckDeadlineConfirmation {
        fn typename() -> &'static str {
            "type.googleapis.com/google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation"
        }
    }

    /// Subscription properties sent as part of the response.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct SubscriptionProperties {
        /// Optional. True iff exactly once delivery is enabled for this
        /// subscription.
        pub exactly_once_delivery_enabled: bool,

        /// Optional. True iff message ordering is enabled for this subscription.
        pub message_ordering_enabled: bool,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl SubscriptionProperties {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [exactly_once_delivery_enabled][crate::model::streaming_pull_response::SubscriptionProperties::exactly_once_delivery_enabled].
        pub fn set_exactly_once_delivery_enabled<T: std::convert::Into<bool>>(
            mut self,
            v: T,
        ) -> Self {
            self.exactly_once_delivery_enabled = v.into();
            self
        }

        /// Sets the value of [message_ordering_enabled][crate::model::streaming_pull_response::SubscriptionProperties::message_ordering_enabled].
        pub fn set_message_ordering_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
            self.message_ordering_enabled = v.into();
            self
        }
    }

    impl wkt::message::Message for SubscriptionProperties {
        fn typename() -> &'static str {
            "type.googleapis.com/google.pubsub.v1.StreamingPullResponse.SubscriptionProperties"
        }
    }
}