envoy-types 0.7.3

Collection of protobuf types and other assets to work with the Envoy Proxy through Rust gRPC services.
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
// This file is @generated by prost-build.
/// Main message for a rate limit request. The rate limit service is designed to be fully generic
/// in the sense that it can operate on arbitrary hierarchical key/value pairs. The loaded
/// configuration will parse the request and find the most specific limit to apply. In addition,
/// a RateLimitRequest can contain multiple "descriptors" to limit on. When multiple descriptors
/// are provided, the server will limit on *ALL* of them and return an OVER_LIMIT response if any
/// of them are over limit. This enables more complex application level rate limiting scenarios
/// if desired.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RateLimitRequest {
    /// All rate limit requests must specify a domain. This enables the configuration to be per
    /// application without fear of overlap. E.g., "envoy".
    #[prost(string, tag = "1")]
    pub domain: ::prost::alloc::string::String,
    /// All rate limit requests must specify at least one RateLimitDescriptor. Each descriptor is
    /// processed by the service (see below). If any of the descriptors are over limit, the entire
    /// request is considered to be over limit.
    #[prost(message, repeated, tag = "2")]
    pub descriptors: ::prost::alloc::vec::Vec<
        super::super::super::extensions::common::ratelimit::v3::RateLimitDescriptor,
    >,
    /// Rate limit requests can optionally specify the number of hits a request adds to the matched
    /// limit. If the value is not set in the message, a request increases the matched limit by 1.
    /// This value can be overridden by setting filter state value `envoy.ratelimit.hits_addend`
    /// to the desired number. Invalid number (\< 0) or number will be ignored.
    #[prost(uint32, tag = "3")]
    pub hits_addend: u32,
}
impl ::prost::Name for RateLimitRequest {
    const NAME: &'static str = "RateLimitRequest";
    const PACKAGE: &'static str = "envoy.service.ratelimit.v3";
    fn full_name() -> ::prost::alloc::string::String {
        "envoy.service.ratelimit.v3.RateLimitRequest".into()
    }
    fn type_url() -> ::prost::alloc::string::String {
        "type.googleapis.com/envoy.service.ratelimit.v3.RateLimitRequest".into()
    }
}
/// A response from a ShouldRateLimit call.
/// \[\#next-free-field: 8\]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RateLimitResponse {
    /// The overall response code which takes into account all of the descriptors that were passed
    /// in the RateLimitRequest message.
    #[prost(enumeration = "rate_limit_response::Code", tag = "1")]
    pub overall_code: i32,
    /// A list of DescriptorStatus messages which matches the length of the descriptor list passed
    /// in the RateLimitRequest. This can be used by the caller to determine which individual
    /// descriptors failed and/or what the currently configured limits are for all of them.
    #[prost(message, repeated, tag = "2")]
    pub statuses: ::prost::alloc::vec::Vec<rate_limit_response::DescriptorStatus>,
    /// A list of headers to add to the response
    #[prost(message, repeated, tag = "3")]
    pub response_headers_to_add: ::prost::alloc::vec::Vec<
        super::super::super::config::core::v3::HeaderValue,
    >,
    /// A list of headers to add to the request when forwarded
    #[prost(message, repeated, tag = "4")]
    pub request_headers_to_add: ::prost::alloc::vec::Vec<
        super::super::super::config::core::v3::HeaderValue,
    >,
    /// A response body to send to the downstream client when the response code is not OK.
    #[prost(bytes = "vec", tag = "5")]
    pub raw_body: ::prost::alloc::vec::Vec<u8>,
    /// Optional response metadata that will be emitted as dynamic metadata to be consumed by the next
    /// filter. This metadata lives in a namespace specified by the canonical name of extension filter
    /// that requires it:
    ///
    /// * :ref:`envoy.filters.http.ratelimit <config_http_filters_ratelimit_dynamic_metadata>` for HTTP filter.
    /// * :ref:`envoy.filters.network.ratelimit <config_network_filters_ratelimit_dynamic_metadata>` for network filter.
    /// * :ref:`envoy.filters.thrift.rate_limit <config_thrift_filters_rate_limit_dynamic_metadata>` for Thrift filter.
    #[prost(message, optional, tag = "6")]
    pub dynamic_metadata: ::core::option::Option<
        super::super::super::super::google::protobuf::Struct,
    >,
    /// Quota is available for a request if its entire descriptor set has cached quota available.
    /// This is a union of all descriptors in the descriptor set. Clients can use the quota for future matches if and only if the descriptor set matches what was sent in the request that originated this response.
    ///
    ///
    /// If quota is available, a RLS request will not be made and the quota will be reduced by 1.
    /// If quota is not available (i.e., a cached entry doesn't exist for a RLS descriptor set), a RLS request will be triggered.
    /// If the server did not provide a quota, such as the quota message is empty then the request admission is determined by the
    /// : ref:`overall_code <envoy_v3_api_field_service.ratelimit.v3.RateLimitResponse.overall_code>`.
    ///
    ///
    /// If there is not sufficient quota and the cached entry exists for a RLS descriptor set is out-of-quota but not expired,
    /// the request will be treated as OVER_LIMIT.
    /// \[\#not-implemented-hide:\]
    #[prost(message, optional, tag = "7")]
    pub quota: ::core::option::Option<rate_limit_response::Quota>,
}
/// Nested message and enum types in `RateLimitResponse`.
pub mod rate_limit_response {
    /// Defines an actual rate limit in terms of requests per unit of time and the unit itself.
    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
    pub struct RateLimit {
        /// A name or description of this limit.
        #[prost(string, tag = "3")]
        pub name: ::prost::alloc::string::String,
        /// The number of requests per unit of time.
        #[prost(uint32, tag = "1")]
        pub requests_per_unit: u32,
        /// The unit of time.
        #[prost(enumeration = "rate_limit::Unit", tag = "2")]
        pub unit: i32,
    }
    /// Nested message and enum types in `RateLimit`.
    pub mod rate_limit {
        /// Identifies the unit of of time for rate limit.
        /// \[\#comment: replace by envoy/type/v3/ratelimit_unit.proto in v4\]
        #[derive(
            Clone,
            Copy,
            Debug,
            PartialEq,
            Eq,
            Hash,
            PartialOrd,
            Ord,
            ::prost::Enumeration
        )]
        #[repr(i32)]
        pub enum Unit {
            /// The time unit is not known.
            Unknown = 0,
            /// The time unit representing a second.
            Second = 1,
            /// The time unit representing a minute.
            Minute = 2,
            /// The time unit representing an hour.
            Hour = 3,
            /// The time unit representing a day.
            Day = 4,
            /// The time unit representing a week.
            Week = 7,
            /// The time unit representing a month.
            Month = 5,
            /// The time unit representing a year.
            Year = 6,
        }
        impl Unit {
            /// String value of the enum field names used in the ProtoBuf definition.
            ///
            /// The values are not transformed in any way and thus are considered stable
            /// (if the ProtoBuf definition does not change) and safe for programmatic use.
            pub fn as_str_name(&self) -> &'static str {
                match self {
                    Self::Unknown => "UNKNOWN",
                    Self::Second => "SECOND",
                    Self::Minute => "MINUTE",
                    Self::Hour => "HOUR",
                    Self::Day => "DAY",
                    Self::Week => "WEEK",
                    Self::Month => "MONTH",
                    Self::Year => "YEAR",
                }
            }
            /// Creates an enum from field names used in the ProtoBuf definition.
            pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
                match value {
                    "UNKNOWN" => Some(Self::Unknown),
                    "SECOND" => Some(Self::Second),
                    "MINUTE" => Some(Self::Minute),
                    "HOUR" => Some(Self::Hour),
                    "DAY" => Some(Self::Day),
                    "WEEK" => Some(Self::Week),
                    "MONTH" => Some(Self::Month),
                    "YEAR" => Some(Self::Year),
                    _ => None,
                }
            }
        }
    }
    impl ::prost::Name for RateLimit {
        const NAME: &'static str = "RateLimit";
        const PACKAGE: &'static str = "envoy.service.ratelimit.v3";
        fn full_name() -> ::prost::alloc::string::String {
            "envoy.service.ratelimit.v3.RateLimitResponse.RateLimit".into()
        }
        fn type_url() -> ::prost::alloc::string::String {
            "type.googleapis.com/envoy.service.ratelimit.v3.RateLimitResponse.RateLimit"
                .into()
        }
    }
    /// Cacheable quota for responses.
    /// Quota can be granted at different levels: either for each individual descriptor or for the whole descriptor set.
    /// This is a certain number of requests over a period of time.
    /// The client may cache this result and apply the effective RateLimitResponse to future matching
    /// requests without querying rate limit service.
    ///
    /// When quota expires due to timeout, a new RLS request will also be made.
    /// The implementation may choose to preemptively query the rate limit server for more quota on or
    /// before expiration or before the available quota runs out.
    /// \[\#not-implemented-hide:\]
    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
    pub struct Quota {
        /// Number of matching requests granted in quota. Must be 1 or more.
        #[prost(uint32, tag = "1")]
        pub requests: u32,
        /// The unique id that is associated with each Quota either at individual descriptor level or whole descriptor set level.
        ///
        /// For a matching policy with boolean logic, for example, match: "request.headers\['environment'\] == 'staging' || request.headers\['environment'\] == 'dev'"),
        /// the request_headers action produces a distinct list of descriptors for each possible value of the ‘environment’ header even though the granted quota is same.
        /// Thus, the client will use this id information (returned from RLS server) to correctly correlate the multiple descriptors/descriptor sets that have been granted with same quota (i.e., share the same quota among multiple descriptors or descriptor sets.)
        ///
        /// If id is empty, this id field will be ignored. If quota for the same id changes (e.g. due to configuration update), the old quota will be overridden by the new one. Shared quotas referenced by ID will still adhere to expiration after `valid_until`.
        #[prost(string, tag = "3")]
        pub id: ::prost::alloc::string::String,
        #[prost(oneof = "quota::ExpirationSpecifier", tags = "2")]
        pub expiration_specifier: ::core::option::Option<quota::ExpirationSpecifier>,
    }
    /// Nested message and enum types in `Quota`.
    pub mod quota {
        #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Oneof)]
        pub enum ExpirationSpecifier {
            /// Point in time at which the quota expires.
            #[prost(message, tag = "2")]
            ValidUntil(
                super::super::super::super::super::super::google::protobuf::Timestamp,
            ),
        }
    }
    impl ::prost::Name for Quota {
        const NAME: &'static str = "Quota";
        const PACKAGE: &'static str = "envoy.service.ratelimit.v3";
        fn full_name() -> ::prost::alloc::string::String {
            "envoy.service.ratelimit.v3.RateLimitResponse.Quota".into()
        }
        fn type_url() -> ::prost::alloc::string::String {
            "type.googleapis.com/envoy.service.ratelimit.v3.RateLimitResponse.Quota"
                .into()
        }
    }
    /// \[\#next-free-field: 6\]
    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
    pub struct DescriptorStatus {
        /// The response code for an individual descriptor.
        #[prost(enumeration = "Code", tag = "1")]
        pub code: i32,
        /// The current limit as configured by the server. Useful for debugging, etc.
        #[prost(message, optional, tag = "2")]
        pub current_limit: ::core::option::Option<RateLimit>,
        /// The limit remaining in the current time unit.
        #[prost(uint32, tag = "3")]
        pub limit_remaining: u32,
        /// Duration until reset of the current limit window.
        #[prost(message, optional, tag = "4")]
        pub duration_until_reset: ::core::option::Option<
            super::super::super::super::super::google::protobuf::Duration,
        >,
        /// Quota is available for a request if its descriptor set has cached quota available for all
        /// descriptors.
        /// This is for each individual descriptor in the descriptor set. The client will perform matches for each individual descriptor against available per-descriptor quota.
        ///
        /// If quota is available, a RLS request will not be made and the quota will be reduced by 1 for
        /// all matching descriptors.
        ///
        /// If there is not sufficient quota, there are three cases:
        ///
        /// 1. A cached entry exists for a RLS descriptor that is out-of-quota, but not expired.
        ///    In this case, the request will be treated as OVER_LIMIT.
        /// 1.
        ///    Some RLS descriptors have a cached entry that has valid quota but some RLS descriptors
        ///    have no cached entry. This will trigger a new RLS request.
        ///    When the result is returned, a single unit will be consumed from the quota for all
        ///    matching descriptors.
        ///    If the server did not provide a quota, such as the quota message is empty for some of
        ///    the descriptors, then the request admission is determined by the
        ///    : ref:`overall_code <envoy_v3_api_field_service.ratelimit.v3.RateLimitResponse.overall_code>`.
        ///
        ///
        /// 1.
        ///    All RLS descriptors lack a cached entry, this will trigger a new RLS request,
        ///    When the result is returned, a single unit will be consumed from the quota for all
        ///    matching descriptors.
        ///    If the server did not provide a quota, such as the quota message is empty for some of
        ///    the descriptors, then the request admission is determined by the
        ///    : ref:`overall_code <envoy_v3_api_field_service.ratelimit.v3.RateLimitResponse.overall_code>`.
        ///      \[\#not-implemented-hide:\]
        ///
        #[prost(message, optional, tag = "5")]
        pub quota: ::core::option::Option<Quota>,
    }
    impl ::prost::Name for DescriptorStatus {
        const NAME: &'static str = "DescriptorStatus";
        const PACKAGE: &'static str = "envoy.service.ratelimit.v3";
        fn full_name() -> ::prost::alloc::string::String {
            "envoy.service.ratelimit.v3.RateLimitResponse.DescriptorStatus".into()
        }
        fn type_url() -> ::prost::alloc::string::String {
            "type.googleapis.com/envoy.service.ratelimit.v3.RateLimitResponse.DescriptorStatus"
                .into()
        }
    }
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Code {
        /// The response code is not known.
        Unknown = 0,
        /// The response code to notify that the number of requests are under limit.
        Ok = 1,
        /// The response code to notify that the number of requests are over limit.
        OverLimit = 2,
    }
    impl Code {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Unknown => "UNKNOWN",
                Self::Ok => "OK",
                Self::OverLimit => "OVER_LIMIT",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "UNKNOWN" => Some(Self::Unknown),
                "OK" => Some(Self::Ok),
                "OVER_LIMIT" => Some(Self::OverLimit),
                _ => None,
            }
        }
    }
}
impl ::prost::Name for RateLimitResponse {
    const NAME: &'static str = "RateLimitResponse";
    const PACKAGE: &'static str = "envoy.service.ratelimit.v3";
    fn full_name() -> ::prost::alloc::string::String {
        "envoy.service.ratelimit.v3.RateLimitResponse".into()
    }
    fn type_url() -> ::prost::alloc::string::String {
        "type.googleapis.com/envoy.service.ratelimit.v3.RateLimitResponse".into()
    }
}
/// Generated client implementations.
pub mod rate_limit_service_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    #[derive(Debug, Clone)]
    pub struct RateLimitServiceClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl RateLimitServiceClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> RateLimitServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> RateLimitServiceClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            RateLimitServiceClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// Determine whether rate limiting should take place.
        pub async fn should_rate_limit(
            &mut self,
            request: impl tonic::IntoRequest<super::RateLimitRequest>,
        ) -> std::result::Result<
            tonic::Response<super::RateLimitResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/envoy.service.ratelimit.v3.RateLimitService/ShouldRateLimit",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "envoy.service.ratelimit.v3.RateLimitService",
                        "ShouldRateLimit",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}
/// Generated server implementations.
pub mod rate_limit_service_server {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    /// Generated trait containing gRPC methods that should be implemented for use with RateLimitServiceServer.
    #[async_trait]
    pub trait RateLimitService: std::marker::Send + std::marker::Sync + 'static {
        /// Determine whether rate limiting should take place.
        async fn should_rate_limit(
            &self,
            request: tonic::Request<super::RateLimitRequest>,
        ) -> std::result::Result<
            tonic::Response<super::RateLimitResponse>,
            tonic::Status,
        >;
    }
    #[derive(Debug)]
    pub struct RateLimitServiceServer<T> {
        inner: Arc<T>,
        accept_compression_encodings: EnabledCompressionEncodings,
        send_compression_encodings: EnabledCompressionEncodings,
        max_decoding_message_size: Option<usize>,
        max_encoding_message_size: Option<usize>,
    }
    impl<T> RateLimitServiceServer<T> {
        pub fn new(inner: T) -> Self {
            Self::from_arc(Arc::new(inner))
        }
        pub fn from_arc(inner: Arc<T>) -> Self {
            Self {
                inner,
                accept_compression_encodings: Default::default(),
                send_compression_encodings: Default::default(),
                max_decoding_message_size: None,
                max_encoding_message_size: None,
            }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> InterceptedService<Self, F>
        where
            F: tonic::service::Interceptor,
        {
            InterceptedService::new(Self::new(inner), interceptor)
        }
        /// Enable decompressing requests with the given encoding.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.accept_compression_encodings.enable(encoding);
            self
        }
        /// Compress responses with the given encoding, if the client supports it.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.send_compression_encodings.enable(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.max_decoding_message_size = Some(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.max_encoding_message_size = Some(limit);
            self
        }
    }
    impl<T, B> tonic::codegen::Service<http::Request<B>> for RateLimitServiceServer<T>
    where
        T: RateLimitService,
        B: Body + std::marker::Send + 'static,
        B::Error: Into<StdError> + std::marker::Send + 'static,
    {
        type Response = http::Response<tonic::body::Body>;
        type Error = std::convert::Infallible;
        type Future = BoxFuture<Self::Response, Self::Error>;
        fn poll_ready(
            &mut self,
            _cx: &mut Context<'_>,
        ) -> Poll<std::result::Result<(), Self::Error>> {
            Poll::Ready(Ok(()))
        }
        fn call(&mut self, req: http::Request<B>) -> Self::Future {
            match req.uri().path() {
                "/envoy.service.ratelimit.v3.RateLimitService/ShouldRateLimit" => {
                    #[allow(non_camel_case_types)]
                    struct ShouldRateLimitSvc<T: RateLimitService>(pub Arc<T>);
                    impl<
                        T: RateLimitService,
                    > tonic::server::UnaryService<super::RateLimitRequest>
                    for ShouldRateLimitSvc<T> {
                        type Response = super::RateLimitResponse;
                        type Future = BoxFuture<
                            tonic::Response<Self::Response>,
                            tonic::Status,
                        >;
                        fn call(
                            &mut self,
                            request: tonic::Request<super::RateLimitRequest>,
                        ) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as RateLimitService>::should_rate_limit(&inner, request)
                                    .await
                            };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = ShouldRateLimitSvc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.unary(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }
                _ => {
                    Box::pin(async move {
                        let mut response = http::Response::new(
                            tonic::body::Body::default(),
                        );
                        let headers = response.headers_mut();
                        headers
                            .insert(
                                tonic::Status::GRPC_STATUS,
                                (tonic::Code::Unimplemented as i32).into(),
                            );
                        headers
                            .insert(
                                http::header::CONTENT_TYPE,
                                tonic::metadata::GRPC_CONTENT_TYPE,
                            );
                        Ok(response)
                    })
                }
            }
        }
    }
    impl<T> Clone for RateLimitServiceServer<T> {
        fn clone(&self) -> Self {
            let inner = self.inner.clone();
            Self {
                inner,
                accept_compression_encodings: self.accept_compression_encodings,
                send_compression_encodings: self.send_compression_encodings,
                max_decoding_message_size: self.max_decoding_message_size,
                max_encoding_message_size: self.max_encoding_message_size,
            }
        }
    }
    /// Generated gRPC service name
    pub const SERVICE_NAME: &str = "envoy.service.ratelimit.v3.RateLimitService";
    impl<T> tonic::server::NamedService for RateLimitServiceServer<T> {
        const NAME: &'static str = SERVICE_NAME;
    }
}