pact_plugin_driver/
proto.rs

1use pact_models::prelude::OptionalBody;
2use pact_models::content_types::ContentTypeHint;
3
4// Build with PACT_PLUGIN_BUILD_PROTOBUFS set, then include the following
5// tonic::include_proto!("io.pact.plugin");
6
7// ------------------ Generated --------------------------//
8// This file is @generated by prost-build.
9/// Request to verify the plugin has loaded OK
10#[allow(clippy::derive_partial_eq_without_eq)]
11#[derive(Clone, PartialEq, ::prost::Message)]
12pub struct InitPluginRequest {
13  /// Implementation calling the plugin
14  #[prost(string, tag = "1")]
15  pub implementation: ::prost::alloc::string::String,
16  /// Version of the implementation
17  #[prost(string, tag = "2")]
18  pub version: ::prost::alloc::string::String,
19}
20/// Entry to be added to the core catalogue. Each entry describes one of the features the plugin provides.
21/// Entries will be stored in the catalogue under the key "plugin/$name/$type/$key".
22#[allow(clippy::derive_partial_eq_without_eq)]
23#[derive(Clone, PartialEq, ::prost::Message)]
24pub struct CatalogueEntry {
25  /// Entry type
26  #[prost(enumeration = "catalogue_entry::EntryType", tag = "1")]
27  pub r#type: i32,
28  /// Entry key
29  #[prost(string, tag = "2")]
30  pub key: ::prost::alloc::string::String,
31  /// Associated data required for the entry. For CONTENT_MATCHER and CONTENT_GENERATOR types, a "content-types"
32  /// value (separated by semi-colons) is required for all the content types the plugin supports.
33  #[prost(map = "string, string", tag = "3")]
34  pub values: ::std::collections::HashMap<
35    ::prost::alloc::string::String,
36    ::prost::alloc::string::String,
37  >,
38}
39/// Nested message and enum types in `CatalogueEntry`.
40pub mod catalogue_entry {
41  #[derive(
42    Clone,
43    Copy,
44    Debug,
45    PartialEq,
46    Eq,
47    Hash,
48    PartialOrd,
49    Ord,
50    ::prost::Enumeration
51  )]
52  #[repr(i32)]
53  pub enum EntryType {
54    /// Matcher for contents of messages, requests or response bodies
55    ContentMatcher = 0,
56    /// Generator for contents of messages, requests or response bodies
57    ContentGenerator = 1,
58    /// Transport for a network protocol
59    Transport = 2,
60    /// Matching rule for content field/values
61    Matcher = 3,
62    /// Type of interaction
63    Interaction = 4,
64  }
65  impl EntryType {
66    /// String value of the enum field names used in the ProtoBuf definition.
67    ///
68    /// The values are not transformed in any way and thus are considered stable
69    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
70    pub fn as_str_name(&self) -> &'static str {
71      match self {
72        EntryType::ContentMatcher => "CONTENT_MATCHER",
73        EntryType::ContentGenerator => "CONTENT_GENERATOR",
74        EntryType::Transport => "TRANSPORT",
75        EntryType::Matcher => "MATCHER",
76        EntryType::Interaction => "INTERACTION",
77      }
78    }
79    /// Creates an enum from field names used in the ProtoBuf definition.
80    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
81      match value {
82        "CONTENT_MATCHER" => Some(Self::ContentMatcher),
83        "CONTENT_GENERATOR" => Some(Self::ContentGenerator),
84        "TRANSPORT" => Some(Self::Transport),
85        "MATCHER" => Some(Self::Matcher),
86        "INTERACTION" => Some(Self::Interaction),
87        _ => None,
88      }
89    }
90  }
91}
92/// Response to init plugin, providing the catalogue entries the plugin provides
93#[allow(clippy::derive_partial_eq_without_eq)]
94#[derive(Clone, PartialEq, ::prost::Message)]
95pub struct InitPluginResponse {
96  /// List of entries the plugin supports
97  #[prost(message, repeated, tag = "1")]
98  pub catalogue: ::prost::alloc::vec::Vec<CatalogueEntry>,
99}
100/// Catalogue of Core Pact + Plugin features
101#[allow(clippy::derive_partial_eq_without_eq)]
102#[derive(Clone, PartialEq, ::prost::Message)]
103pub struct Catalogue {
104  /// List of entries from the core catalogue
105  #[prost(message, repeated, tag = "1")]
106  pub catalogue: ::prost::alloc::vec::Vec<CatalogueEntry>,
107}
108/// Message representing a request, response or message body
109#[allow(clippy::derive_partial_eq_without_eq)]
110#[derive(Clone, PartialEq, ::prost::Message)]
111pub struct Body {
112  /// The content type of the body in MIME format (i.e. application/json)
113  #[prost(string, tag = "1")]
114  pub content_type: ::prost::alloc::string::String,
115  /// Bytes of the actual content
116  #[prost(message, optional, tag = "2")]
117  pub content: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
118  /// Content type override to apply (if required). If omitted, the default rules of the Pact implementation
119  /// will be used
120  #[prost(enumeration = "body::ContentTypeHint", tag = "3")]
121  pub content_type_hint: i32,
122}
123/// Nested message and enum types in `Body`.
124pub mod body {
125  /// Enum of content type override. This is a hint on how the content type should be treated.
126  #[derive(
127    Clone,
128    Copy,
129    Debug,
130    PartialEq,
131    Eq,
132    Hash,
133    PartialOrd,
134    Ord,
135    ::prost::Enumeration
136  )]
137  #[repr(i32)]
138  pub enum ContentTypeHint {
139    /// Determine the form of the content using the default rules of the Pact implementation
140    Default = 0,
141    /// Contents must always be treated as a text form
142    Text = 1,
143    /// Contents must always be treated as a binary form
144    Binary = 2,
145  }
146  impl ContentTypeHint {
147    /// String value of the enum field names used in the ProtoBuf definition.
148    ///
149    /// The values are not transformed in any way and thus are considered stable
150    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
151    pub fn as_str_name(&self) -> &'static str {
152      match self {
153        ContentTypeHint::Default => "DEFAULT",
154        ContentTypeHint::Text => "TEXT",
155        ContentTypeHint::Binary => "BINARY",
156      }
157    }
158    /// Creates an enum from field names used in the ProtoBuf definition.
159    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
160      match value {
161        "DEFAULT" => Some(Self::Default),
162        "TEXT" => Some(Self::Text),
163        "BINARY" => Some(Self::Binary),
164        _ => None,
165      }
166    }
167  }
168}
169/// Request to preform a comparison on an actual body given the expected one
170#[allow(clippy::derive_partial_eq_without_eq)]
171#[derive(Clone, PartialEq, ::prost::Message)]
172pub struct CompareContentsRequest {
173  /// Expected body from the Pact interaction
174  #[prost(message, optional, tag = "1")]
175  pub expected: ::core::option::Option<Body>,
176  /// Actual received body
177  #[prost(message, optional, tag = "2")]
178  pub actual: ::core::option::Option<Body>,
179  /// If unexpected keys or attributes should be allowed. Setting this to false results in additional keys or fields
180  /// will cause a mismatch
181  #[prost(bool, tag = "3")]
182  pub allow_unexpected_keys: bool,
183  /// Map of expressions to matching rules. The expressions follow the documented Pact matching rule expressions
184  #[prost(map = "string, message", tag = "4")]
185  pub rules: ::std::collections::HashMap<
186    ::prost::alloc::string::String,
187    MatchingRules,
188  >,
189  /// Additional data added to the Pact/Interaction by the plugin
190  #[prost(message, optional, tag = "5")]
191  pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
192}
193/// Indicates that there was a mismatch with the content type
194#[allow(clippy::derive_partial_eq_without_eq)]
195#[derive(Clone, PartialEq, ::prost::Message)]
196pub struct ContentTypeMismatch {
197  /// Expected content type (MIME format)
198  #[prost(string, tag = "1")]
199  pub expected: ::prost::alloc::string::String,
200  /// Actual content type received (MIME format)
201  #[prost(string, tag = "2")]
202  pub actual: ::prost::alloc::string::String,
203}
204/// A mismatch for an particular item of content
205#[allow(clippy::derive_partial_eq_without_eq)]
206#[derive(Clone, PartialEq, ::prost::Message)]
207pub struct ContentMismatch {
208  /// Expected data bytes
209  #[prost(message, optional, tag = "1")]
210  pub expected: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
211  /// Actual data bytes
212  #[prost(message, optional, tag = "2")]
213  pub actual: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
214  /// Description of the mismatch
215  #[prost(string, tag = "3")]
216  pub mismatch: ::prost::alloc::string::String,
217  /// Path to the item that was matched. This is the value as per the documented Pact matching rule expressions.
218  #[prost(string, tag = "4")]
219  pub path: ::prost::alloc::string::String,
220  /// Optional diff of the contents
221  #[prost(string, tag = "5")]
222  pub diff: ::prost::alloc::string::String,
223  /// Part of the interaction that the mismatch is for: body, headers, metadata, etc.
224  #[prost(string, tag = "6")]
225  pub mismatch_type: ::prost::alloc::string::String,
226}
227/// List of content mismatches
228#[allow(clippy::derive_partial_eq_without_eq)]
229#[derive(Clone, PartialEq, ::prost::Message)]
230pub struct ContentMismatches {
231  #[prost(message, repeated, tag = "1")]
232  pub mismatches: ::prost::alloc::vec::Vec<ContentMismatch>,
233}
234/// Response to the CompareContentsRequest with the results of the comparison
235#[allow(clippy::derive_partial_eq_without_eq)]
236#[derive(Clone, PartialEq, ::prost::Message)]
237pub struct CompareContentsResponse {
238  /// Error message if an error occurred. If this field is set, the remaining fields will be ignored and the
239  /// verification marked as failed
240  #[prost(string, tag = "1")]
241  pub error: ::prost::alloc::string::String,
242  /// There was a mismatch with the types of content. If this is set, the results may not be set.
243  #[prost(message, optional, tag = "2")]
244  pub type_mismatch: ::core::option::Option<ContentTypeMismatch>,
245  /// Results of the match, keyed by matching rule expression
246  #[prost(map = "string, message", tag = "3")]
247  pub results: ::std::collections::HashMap<
248    ::prost::alloc::string::String,
249    ContentMismatches,
250  >,
251}
252/// Request to configure/setup an interaction so that it can be verified later
253#[allow(clippy::derive_partial_eq_without_eq)]
254#[derive(Clone, PartialEq, ::prost::Message)]
255pub struct ConfigureInteractionRequest {
256  /// Content type of the interaction (MIME format)
257  #[prost(string, tag = "1")]
258  pub content_type: ::prost::alloc::string::String,
259  /// This is data specified by the user in the consumer test
260  #[prost(message, optional, tag = "2")]
261  pub contents_config: ::core::option::Option<::prost_types::Struct>,
262}
263/// Represents a matching rule
264#[allow(clippy::derive_partial_eq_without_eq)]
265#[derive(Clone, PartialEq, ::prost::Message)]
266pub struct MatchingRule {
267  /// Type of the matching rule
268  #[prost(string, tag = "1")]
269  pub r#type: ::prost::alloc::string::String,
270  /// Associated data for the matching rule
271  #[prost(message, optional, tag = "2")]
272  pub values: ::core::option::Option<::prost_types::Struct>,
273}
274/// List of matching rules
275#[allow(clippy::derive_partial_eq_without_eq)]
276#[derive(Clone, PartialEq, ::prost::Message)]
277pub struct MatchingRules {
278  #[prost(message, repeated, tag = "1")]
279  pub rule: ::prost::alloc::vec::Vec<MatchingRule>,
280}
281/// Example generator
282#[allow(clippy::derive_partial_eq_without_eq)]
283#[derive(Clone, PartialEq, ::prost::Message)]
284pub struct Generator {
285  /// Type of generator
286  #[prost(string, tag = "1")]
287  pub r#type: ::prost::alloc::string::String,
288  /// Associated data for the generator
289  #[prost(message, optional, tag = "2")]
290  pub values: ::core::option::Option<::prost_types::Struct>,
291}
292/// Plugin configuration added to the pact file by the ConfigureInteraction step
293#[allow(clippy::derive_partial_eq_without_eq)]
294#[derive(Clone, PartialEq, ::prost::Message)]
295pub struct PluginConfiguration {
296  /// Data to be persisted against the interaction
297  #[prost(message, optional, tag = "1")]
298  pub interaction_configuration: ::core::option::Option<::prost_types::Struct>,
299  /// Data to be persisted in the Pact file metadata (Global data)
300  #[prost(message, optional, tag = "2")]
301  pub pact_configuration: ::core::option::Option<::prost_types::Struct>,
302}
303/// Response to the configure/setup an interaction request
304#[allow(clippy::derive_partial_eq_without_eq)]
305#[derive(Clone, PartialEq, ::prost::Message)]
306pub struct InteractionResponse {
307  /// Contents for the interaction
308  #[prost(message, optional, tag = "1")]
309  pub contents: ::core::option::Option<Body>,
310  /// All matching rules to apply
311  #[prost(map = "string, message", tag = "2")]
312  pub rules: ::std::collections::HashMap<
313    ::prost::alloc::string::String,
314    MatchingRules,
315  >,
316  /// Generators to apply
317  #[prost(map = "string, message", tag = "3")]
318  pub generators: ::std::collections::HashMap<
319    ::prost::alloc::string::String,
320    Generator,
321  >,
322  /// For message interactions, any metadata to be applied
323  #[prost(message, optional, tag = "4")]
324  pub message_metadata: ::core::option::Option<::prost_types::Struct>,
325  /// Plugin specific data to be persisted in the pact file
326  #[prost(message, optional, tag = "5")]
327  pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
328  /// Markdown/HTML formatted text representation of the interaction
329  #[prost(string, tag = "6")]
330  pub interaction_markup: ::prost::alloc::string::String,
331  #[prost(enumeration = "interaction_response::MarkupType", tag = "7")]
332  pub interaction_markup_type: i32,
333  /// Description of what part this interaction belongs to (in the case of there being more than one, for instance,
334  /// request/response messages)
335  #[prost(string, tag = "8")]
336  pub part_name: ::prost::alloc::string::String,
337  /// All matching rules to apply to any message metadata
338  #[prost(map = "string, message", tag = "9")]
339  pub metadata_rules: ::std::collections::HashMap<
340    ::prost::alloc::string::String,
341    MatchingRules,
342  >,
343  /// Generators to apply to any message metadata
344  #[prost(map = "string, message", tag = "10")]
345  pub metadata_generators: ::std::collections::HashMap<
346    ::prost::alloc::string::String,
347    Generator,
348  >,
349}
350/// Nested message and enum types in `InteractionResponse`.
351pub mod interaction_response {
352  /// Type of markup used
353  #[derive(
354    Clone,
355    Copy,
356    Debug,
357    PartialEq,
358    Eq,
359    Hash,
360    PartialOrd,
361    Ord,
362    ::prost::Enumeration
363  )]
364  #[repr(i32)]
365  pub enum MarkupType {
366    /// CommonMark format
367    CommonMark = 0,
368    /// HTML format
369    Html = 1,
370  }
371  impl MarkupType {
372    /// String value of the enum field names used in the ProtoBuf definition.
373    ///
374    /// The values are not transformed in any way and thus are considered stable
375    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
376    pub fn as_str_name(&self) -> &'static str {
377      match self {
378        MarkupType::CommonMark => "COMMON_MARK",
379        MarkupType::Html => "HTML",
380      }
381    }
382    /// Creates an enum from field names used in the ProtoBuf definition.
383    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
384      match value {
385        "COMMON_MARK" => Some(Self::CommonMark),
386        "HTML" => Some(Self::Html),
387        _ => None,
388      }
389    }
390  }
391}
392/// Response to the configure/setup an interaction request
393#[allow(clippy::derive_partial_eq_without_eq)]
394#[derive(Clone, PartialEq, ::prost::Message)]
395pub struct ConfigureInteractionResponse {
396  /// If an error occurred. In this case, the other fields will be ignored/not set
397  #[prost(string, tag = "1")]
398  pub error: ::prost::alloc::string::String,
399  /// The actual response if no error occurred.
400  #[prost(message, repeated, tag = "2")]
401  pub interaction: ::prost::alloc::vec::Vec<InteractionResponse>,
402  /// Plugin specific data to be persisted in the pact file
403  #[prost(message, optional, tag = "3")]
404  pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
405}
406/// Request to generate the contents using any defined generators
407#[allow(clippy::derive_partial_eq_without_eq)]
408#[derive(Clone, PartialEq, ::prost::Message)]
409pub struct GenerateContentRequest {
410  /// Original contents
411  #[prost(message, optional, tag = "1")]
412  pub contents: ::core::option::Option<Body>,
413  /// Generators to apply
414  #[prost(map = "string, message", tag = "2")]
415  pub generators: ::std::collections::HashMap<
416    ::prost::alloc::string::String,
417    Generator,
418  >,
419  /// Additional data added to the Pact/Interaction by the plugin
420  #[prost(message, optional, tag = "3")]
421  pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
422  /// Context data provided by the test framework
423  #[prost(message, optional, tag = "4")]
424  pub test_context: ::core::option::Option<::prost_types::Struct>,
425  #[prost(enumeration = "generate_content_request::TestMode", tag = "5")]
426  pub test_mode: i32,
427  #[prost(enumeration = "generate_content_request::ContentFor", tag = "6")]
428  pub content_for: i32,
429}
430/// Nested message and enum types in `GenerateContentRequest`.
431pub mod generate_content_request {
432  /// The mode of the generation, if running from a consumer test or during provider verification
433  #[derive(
434    Clone,
435    Copy,
436    Debug,
437    PartialEq,
438    Eq,
439    Hash,
440    PartialOrd,
441    Ord,
442    ::prost::Enumeration
443  )]
444  #[repr(i32)]
445  pub enum TestMode {
446    Unknown = 0,
447    /// Running on the consumer side
448    Consumer = 1,
449    /// Running on the provider side
450    Provider = 2,
451  }
452  impl TestMode {
453    /// String value of the enum field names used in the ProtoBuf definition.
454    ///
455    /// The values are not transformed in any way and thus are considered stable
456    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
457    pub fn as_str_name(&self) -> &'static str {
458      match self {
459        TestMode::Unknown => "Unknown",
460        TestMode::Consumer => "Consumer",
461        TestMode::Provider => "Provider",
462      }
463    }
464    /// Creates an enum from field names used in the ProtoBuf definition.
465    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
466      match value {
467        "Unknown" => Some(Self::Unknown),
468        "Consumer" => Some(Self::Consumer),
469        "Provider" => Some(Self::Provider),
470        _ => None,
471      }
472    }
473  }
474  /// Which part the content is for
475  #[derive(
476    Clone,
477    Copy,
478    Debug,
479    PartialEq,
480    Eq,
481    Hash,
482    PartialOrd,
483    Ord,
484    ::prost::Enumeration
485  )]
486  #[repr(i32)]
487  pub enum ContentFor {
488    Request = 0,
489    Response = 1,
490  }
491  impl ContentFor {
492    /// String value of the enum field names used in the ProtoBuf definition.
493    ///
494    /// The values are not transformed in any way and thus are considered stable
495    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
496    pub fn as_str_name(&self) -> &'static str {
497      match self {
498        ContentFor::Request => "Request",
499        ContentFor::Response => "Response",
500      }
501    }
502    /// Creates an enum from field names used in the ProtoBuf definition.
503    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
504      match value {
505        "Request" => Some(Self::Request),
506        "Response" => Some(Self::Response),
507        _ => None,
508      }
509    }
510  }
511}
512/// Generated body/message response
513#[allow(clippy::derive_partial_eq_without_eq)]
514#[derive(Clone, PartialEq, ::prost::Message)]
515pub struct GenerateContentResponse {
516  #[prost(message, optional, tag = "1")]
517  pub contents: ::core::option::Option<Body>,
518}
519/// Request to start a mock server
520#[allow(clippy::derive_partial_eq_without_eq)]
521#[derive(Clone, PartialEq, ::prost::Message)]
522pub struct StartMockServerRequest {
523  /// Interface to bind to. Will default to the loopback adapter
524  #[prost(string, tag = "1")]
525  pub host_interface: ::prost::alloc::string::String,
526  /// Port to bind to. Default (or a value of 0) get the OS to open a random port
527  #[prost(uint32, tag = "2")]
528  pub port: u32,
529  /// If TLS should be used (if supported by the mock server)
530  #[prost(bool, tag = "3")]
531  pub tls: bool,
532  /// Pact as JSON to use for the mock server behaviour
533  #[prost(string, tag = "4")]
534  pub pact: ::prost::alloc::string::String,
535  /// Context data provided by the test framework
536  #[prost(message, optional, tag = "5")]
537  pub test_context: ::core::option::Option<::prost_types::Struct>,
538}
539/// Response to the start mock server request
540#[allow(clippy::derive_partial_eq_without_eq)]
541#[derive(Clone, PartialEq, ::prost::Message)]
542pub struct StartMockServerResponse {
543  #[prost(oneof = "start_mock_server_response::Response", tags = "1, 2")]
544  pub response: ::core::option::Option<start_mock_server_response::Response>,
545}
546/// Nested message and enum types in `StartMockServerResponse`.
547pub mod start_mock_server_response {
548  #[allow(clippy::derive_partial_eq_without_eq)]
549  #[derive(Clone, PartialEq, ::prost::Oneof)]
550  pub enum Response {
551    /// If an error occurred
552    #[prost(string, tag = "1")]
553    Error(::prost::alloc::string::String),
554    /// Mock server details
555    #[prost(message, tag = "2")]
556    Details(super::MockServerDetails),
557  }
558}
559/// Details on a running mock server
560#[allow(clippy::derive_partial_eq_without_eq)]
561#[derive(Clone, PartialEq, ::prost::Message)]
562pub struct MockServerDetails {
563  /// Mock server unique ID
564  #[prost(string, tag = "1")]
565  pub key: ::prost::alloc::string::String,
566  /// Port the mock server is running on
567  #[prost(uint32, tag = "2")]
568  pub port: u32,
569  /// IP address the mock server is bound to. Probably an IP6 address, but may be IP4
570  #[prost(string, tag = "3")]
571  pub address: ::prost::alloc::string::String,
572}
573/// Request to shut down a running mock server
574/// TODO: replace this with MockServerRequest in the next major version
575#[allow(clippy::derive_partial_eq_without_eq)]
576#[derive(Clone, PartialEq, ::prost::Message)]
577pub struct ShutdownMockServerRequest {
578  /// The server ID to shutdown
579  #[prost(string, tag = "1")]
580  pub server_key: ::prost::alloc::string::String,
581}
582/// Request for a running mock server by ID
583#[allow(clippy::derive_partial_eq_without_eq)]
584#[derive(Clone, PartialEq, ::prost::Message)]
585pub struct MockServerRequest {
586  /// The server ID to shutdown
587  #[prost(string, tag = "1")]
588  pub server_key: ::prost::alloc::string::String,
589}
590/// Result of a request that the mock server received
591#[allow(clippy::derive_partial_eq_without_eq)]
592#[derive(Clone, PartialEq, ::prost::Message)]
593pub struct MockServerResult {
594  /// service + method that was requested
595  #[prost(string, tag = "1")]
596  pub path: ::prost::alloc::string::String,
597  /// If an error occurred trying to handle the request
598  #[prost(string, tag = "2")]
599  pub error: ::prost::alloc::string::String,
600  /// Any mismatches that occurred
601  #[prost(message, repeated, tag = "3")]
602  pub mismatches: ::prost::alloc::vec::Vec<ContentMismatch>,
603}
604/// Response to the shut down mock server request
605/// TODO: replace this with MockServerResults in the next major version
606#[allow(clippy::derive_partial_eq_without_eq)]
607#[derive(Clone, PartialEq, ::prost::Message)]
608pub struct ShutdownMockServerResponse {
609  /// If the mock status is all ok
610  #[prost(bool, tag = "1")]
611  pub ok: bool,
612  /// The results of the test run, will contain an entry for each request received by the mock server
613  #[prost(message, repeated, tag = "2")]
614  pub results: ::prost::alloc::vec::Vec<MockServerResult>,
615}
616/// Matching results of the mock server.
617#[allow(clippy::derive_partial_eq_without_eq)]
618#[derive(Clone, PartialEq, ::prost::Message)]
619pub struct MockServerResults {
620  /// If the mock status is all ok
621  #[prost(bool, tag = "1")]
622  pub ok: bool,
623  /// The results of the test run, will contain an entry for each request received by the mock server
624  #[prost(message, repeated, tag = "2")]
625  pub results: ::prost::alloc::vec::Vec<MockServerResult>,
626}
627/// Request to prepare an interaction for verification
628#[allow(clippy::derive_partial_eq_without_eq)]
629#[derive(Clone, PartialEq, ::prost::Message)]
630pub struct VerificationPreparationRequest {
631  /// Pact as JSON to use for the verification
632  #[prost(string, tag = "1")]
633  pub pact: ::prost::alloc::string::String,
634  /// Interaction key for the interaction from the Pact that is being verified
635  #[prost(string, tag = "2")]
636  pub interaction_key: ::prost::alloc::string::String,
637  /// Any data supplied by the user to verify the interaction
638  #[prost(message, optional, tag = "3")]
639  pub config: ::core::option::Option<::prost_types::Struct>,
640}
641/// Request metadata value. Will either be a JSON-like value, or binary data
642#[allow(clippy::derive_partial_eq_without_eq)]
643#[derive(Clone, PartialEq, ::prost::Message)]
644pub struct MetadataValue {
645  #[prost(oneof = "metadata_value::Value", tags = "1, 2")]
646  pub value: ::core::option::Option<metadata_value::Value>,
647}
648/// Nested message and enum types in `MetadataValue`.
649pub mod metadata_value {
650  #[allow(clippy::derive_partial_eq_without_eq)]
651  #[derive(Clone, PartialEq, ::prost::Oneof)]
652  pub enum Value {
653    #[prost(message, tag = "1")]
654    NonBinaryValue(::prost_types::Value),
655    #[prost(bytes, tag = "2")]
656    BinaryValue(::prost::alloc::vec::Vec<u8>),
657  }
658}
659/// Interaction request data to be sent or received for verification
660#[allow(clippy::derive_partial_eq_without_eq)]
661#[derive(Clone, PartialEq, ::prost::Message)]
662pub struct InteractionData {
663  /// Request/Response body as bytes
664  #[prost(message, optional, tag = "1")]
665  pub body: ::core::option::Option<Body>,
666  /// Metadata associated with the request/response
667  #[prost(map = "string, message", tag = "2")]
668  pub metadata: ::std::collections::HashMap<
669    ::prost::alloc::string::String,
670    MetadataValue,
671  >,
672}
673/// Response for the prepare an interaction for verification request
674#[allow(clippy::derive_partial_eq_without_eq)]
675#[derive(Clone, PartialEq, ::prost::Message)]
676pub struct VerificationPreparationResponse {
677  #[prost(oneof = "verification_preparation_response::Response", tags = "1, 2")]
678  pub response: ::core::option::Option<verification_preparation_response::Response>,
679}
680/// Nested message and enum types in `VerificationPreparationResponse`.
681pub mod verification_preparation_response {
682  #[allow(clippy::derive_partial_eq_without_eq)]
683  #[derive(Clone, PartialEq, ::prost::Oneof)]
684  pub enum Response {
685    /// If an error occurred
686    #[prost(string, tag = "1")]
687    Error(::prost::alloc::string::String),
688    /// Interaction data required to construct any request
689    #[prost(message, tag = "2")]
690    InteractionData(super::InteractionData),
691  }
692}
693/// Request data to verify an interaction
694#[allow(clippy::derive_partial_eq_without_eq)]
695#[derive(Clone, PartialEq, ::prost::Message)]
696pub struct VerifyInteractionRequest {
697  /// Interaction data required to construct the request
698  #[prost(message, optional, tag = "1")]
699  pub interaction_data: ::core::option::Option<InteractionData>,
700  /// Any data supplied by the user to verify the interaction
701  #[prost(message, optional, tag = "2")]
702  pub config: ::core::option::Option<::prost_types::Struct>,
703  /// Pact as JSON to use for the verification
704  #[prost(string, tag = "3")]
705  pub pact: ::prost::alloc::string::String,
706  /// Interaction key for the interaction from the Pact that is being verified
707  #[prost(string, tag = "4")]
708  pub interaction_key: ::prost::alloc::string::String,
709}
710#[allow(clippy::derive_partial_eq_without_eq)]
711#[derive(Clone, PartialEq, ::prost::Message)]
712pub struct VerificationResultItem {
713  #[prost(oneof = "verification_result_item::Result", tags = "1, 2")]
714  pub result: ::core::option::Option<verification_result_item::Result>,
715}
716/// Nested message and enum types in `VerificationResultItem`.
717pub mod verification_result_item {
718  #[allow(clippy::derive_partial_eq_without_eq)]
719  #[derive(Clone, PartialEq, ::prost::Oneof)]
720  pub enum Result {
721    #[prost(string, tag = "1")]
722    Error(::prost::alloc::string::String),
723    #[prost(message, tag = "2")]
724    Mismatch(super::ContentMismatch),
725  }
726}
727/// Result of running the verification
728#[allow(clippy::derive_partial_eq_without_eq)]
729#[derive(Clone, PartialEq, ::prost::Message)]
730pub struct VerificationResult {
731  /// Was the verification successful?
732  #[prost(bool, tag = "1")]
733  pub success: bool,
734  /// Interaction data retrieved from the provider (optional)
735  #[prost(message, optional, tag = "2")]
736  pub response_data: ::core::option::Option<InteractionData>,
737  /// Any mismatches that occurred
738  #[prost(message, repeated, tag = "3")]
739  pub mismatches: ::prost::alloc::vec::Vec<VerificationResultItem>,
740  /// Output for the verification to display to the user
741  #[prost(string, repeated, tag = "4")]
742  pub output: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
743}
744/// Result of running the verification
745#[allow(clippy::derive_partial_eq_without_eq)]
746#[derive(Clone, PartialEq, ::prost::Message)]
747pub struct VerifyInteractionResponse {
748  #[prost(oneof = "verify_interaction_response::Response", tags = "1, 2")]
749  pub response: ::core::option::Option<verify_interaction_response::Response>,
750}
751/// Nested message and enum types in `VerifyInteractionResponse`.
752pub mod verify_interaction_response {
753  #[allow(clippy::derive_partial_eq_without_eq)]
754  #[derive(Clone, PartialEq, ::prost::Oneof)]
755  pub enum Response {
756    /// If an error occurred trying to run the verification
757    #[prost(string, tag = "1")]
758    Error(::prost::alloc::string::String),
759    #[prost(message, tag = "2")]
760    Result(super::VerificationResult),
761  }
762}
763/// Generated client implementations.
764pub mod pact_plugin_client {
765  #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
766  use tonic::codegen::*;
767  use tonic::codegen::http::Uri;
768  #[derive(Debug, Clone)]
769  pub struct PactPluginClient<T> {
770    inner: tonic::client::Grpc<T>,
771  }
772  impl PactPluginClient<tonic::transport::Channel> {
773    /// Attempt to create a new client by connecting to a given endpoint.
774    pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
775      where
776        D: TryInto<tonic::transport::Endpoint>,
777        D::Error: Into<StdError>,
778    {
779      let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
780      Ok(Self::new(conn))
781    }
782  }
783  impl<T> PactPluginClient<T>
784    where
785      T: tonic::client::GrpcService<tonic::body::BoxBody>,
786      T::Error: Into<StdError>,
787      T::ResponseBody: Body<Data = Bytes> + Send + 'static,
788      <T::ResponseBody as Body>::Error: Into<StdError> + Send,
789  {
790    pub fn new(inner: T) -> Self {
791      let inner = tonic::client::Grpc::new(inner);
792      Self { inner }
793    }
794    pub fn with_origin(inner: T, origin: Uri) -> Self {
795      let inner = tonic::client::Grpc::with_origin(inner, origin);
796      Self { inner }
797    }
798    pub fn with_interceptor<F>(
799      inner: T,
800      interceptor: F,
801    ) -> PactPluginClient<InterceptedService<T, F>>
802      where
803        F: tonic::service::Interceptor,
804        T::ResponseBody: Default,
805        T: tonic::codegen::Service<
806          http::Request<tonic::body::BoxBody>,
807          Response = http::Response<
808            <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
809          >,
810        >,
811        <T as tonic::codegen::Service<
812          http::Request<tonic::body::BoxBody>,
813        >>::Error: Into<StdError> + Send + Sync,
814    {
815      PactPluginClient::new(InterceptedService::new(inner, interceptor))
816    }
817    /// Compress requests with the given encoding.
818    ///
819    /// This requires the server to support it otherwise it might respond with an
820    /// error.
821    #[must_use]
822    pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
823      self.inner = self.inner.send_compressed(encoding);
824      self
825    }
826    /// Enable decompressing responses.
827    #[must_use]
828    pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
829      self.inner = self.inner.accept_compressed(encoding);
830      self
831    }
832    /// Limits the maximum size of a decoded message.
833    ///
834    /// Default: `4MB`
835    #[must_use]
836    pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
837      self.inner = self.inner.max_decoding_message_size(limit);
838      self
839    }
840    /// Limits the maximum size of an encoded message.
841    ///
842    /// Default: `usize::MAX`
843    #[must_use]
844    pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
845      self.inner = self.inner.max_encoding_message_size(limit);
846      self
847    }
848    /// Check that the plugin loaded OK. Returns the catalogue entries describing what the plugin provides
849    pub async fn init_plugin(
850      &mut self,
851      request: impl tonic::IntoRequest<super::InitPluginRequest>,
852    ) -> std::result::Result<
853      tonic::Response<super::InitPluginResponse>,
854      tonic::Status,
855    > {
856      self.inner
857        .ready()
858        .await
859        .map_err(|e| {
860          tonic::Status::new(
861            tonic::Code::Unknown,
862            format!("Service was not ready: {}", e.into()),
863          )
864        })?;
865      let codec = tonic::codec::ProstCodec::default();
866      let path = http::uri::PathAndQuery::from_static(
867        "/io.pact.plugin.PactPlugin/InitPlugin",
868      );
869      let mut req = request.into_request();
870      req.extensions_mut()
871        .insert(GrpcMethod::new("io.pact.plugin.PactPlugin", "InitPlugin"));
872      self.inner.unary(req, path, codec).await
873    }
874    /// Updated catalogue. This will be sent when the core catalogue has been updated (probably by a plugin loading).
875    pub async fn update_catalogue(
876      &mut self,
877      request: impl tonic::IntoRequest<super::Catalogue>,
878    ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
879      self.inner
880        .ready()
881        .await
882        .map_err(|e| {
883          tonic::Status::new(
884            tonic::Code::Unknown,
885            format!("Service was not ready: {}", e.into()),
886          )
887        })?;
888      let codec = tonic::codec::ProstCodec::default();
889      let path = http::uri::PathAndQuery::from_static(
890        "/io.pact.plugin.PactPlugin/UpdateCatalogue",
891      );
892      let mut req = request.into_request();
893      req.extensions_mut()
894        .insert(GrpcMethod::new("io.pact.plugin.PactPlugin", "UpdateCatalogue"));
895      self.inner.unary(req, path, codec).await
896    }
897    /// Request to perform a comparison of some contents (matching request)
898    pub async fn compare_contents(
899      &mut self,
900      request: impl tonic::IntoRequest<super::CompareContentsRequest>,
901    ) -> std::result::Result<
902      tonic::Response<super::CompareContentsResponse>,
903      tonic::Status,
904    > {
905      self.inner
906        .ready()
907        .await
908        .map_err(|e| {
909          tonic::Status::new(
910            tonic::Code::Unknown,
911            format!("Service was not ready: {}", e.into()),
912          )
913        })?;
914      let codec = tonic::codec::ProstCodec::default();
915      let path = http::uri::PathAndQuery::from_static(
916        "/io.pact.plugin.PactPlugin/CompareContents",
917      );
918      let mut req = request.into_request();
919      req.extensions_mut()
920        .insert(GrpcMethod::new("io.pact.plugin.PactPlugin", "CompareContents"));
921      self.inner.unary(req, path, codec).await
922    }
923    /// Request to configure/setup the interaction for later verification. Data returned will be persisted in the pact file.
924    pub async fn configure_interaction(
925      &mut self,
926      request: impl tonic::IntoRequest<super::ConfigureInteractionRequest>,
927    ) -> std::result::Result<
928      tonic::Response<super::ConfigureInteractionResponse>,
929      tonic::Status,
930    > {
931      self.inner
932        .ready()
933        .await
934        .map_err(|e| {
935          tonic::Status::new(
936            tonic::Code::Unknown,
937            format!("Service was not ready: {}", e.into()),
938          )
939        })?;
940      let codec = tonic::codec::ProstCodec::default();
941      let path = http::uri::PathAndQuery::from_static(
942        "/io.pact.plugin.PactPlugin/ConfigureInteraction",
943      );
944      let mut req = request.into_request();
945      req.extensions_mut()
946        .insert(
947          GrpcMethod::new("io.pact.plugin.PactPlugin", "ConfigureInteraction"),
948        );
949      self.inner.unary(req, path, codec).await
950    }
951    /// Request to generate the content using any defined generators
952    pub async fn generate_content(
953      &mut self,
954      request: impl tonic::IntoRequest<super::GenerateContentRequest>,
955    ) -> std::result::Result<
956      tonic::Response<super::GenerateContentResponse>,
957      tonic::Status,
958    > {
959      self.inner
960        .ready()
961        .await
962        .map_err(|e| {
963          tonic::Status::new(
964            tonic::Code::Unknown,
965            format!("Service was not ready: {}", e.into()),
966          )
967        })?;
968      let codec = tonic::codec::ProstCodec::default();
969      let path = http::uri::PathAndQuery::from_static(
970        "/io.pact.plugin.PactPlugin/GenerateContent",
971      );
972      let mut req = request.into_request();
973      req.extensions_mut()
974        .insert(GrpcMethod::new("io.pact.plugin.PactPlugin", "GenerateContent"));
975      self.inner.unary(req, path, codec).await
976    }
977    /// Start a mock server
978    pub async fn start_mock_server(
979      &mut self,
980      request: impl tonic::IntoRequest<super::StartMockServerRequest>,
981    ) -> std::result::Result<
982      tonic::Response<super::StartMockServerResponse>,
983      tonic::Status,
984    > {
985      self.inner
986        .ready()
987        .await
988        .map_err(|e| {
989          tonic::Status::new(
990            tonic::Code::Unknown,
991            format!("Service was not ready: {}", e.into()),
992          )
993        })?;
994      let codec = tonic::codec::ProstCodec::default();
995      let path = http::uri::PathAndQuery::from_static(
996        "/io.pact.plugin.PactPlugin/StartMockServer",
997      );
998      let mut req = request.into_request();
999      req.extensions_mut()
1000        .insert(GrpcMethod::new("io.pact.plugin.PactPlugin", "StartMockServer"));
1001      self.inner.unary(req, path, codec).await
1002    }
1003    /// Shutdown a running mock server
1004    /// TODO: Replace the message types with MockServerRequest and MockServerResults in the next major version
1005    pub async fn shutdown_mock_server(
1006      &mut self,
1007      request: impl tonic::IntoRequest<super::ShutdownMockServerRequest>,
1008    ) -> std::result::Result<
1009      tonic::Response<super::ShutdownMockServerResponse>,
1010      tonic::Status,
1011    > {
1012      self.inner
1013        .ready()
1014        .await
1015        .map_err(|e| {
1016          tonic::Status::new(
1017            tonic::Code::Unknown,
1018            format!("Service was not ready: {}", e.into()),
1019          )
1020        })?;
1021      let codec = tonic::codec::ProstCodec::default();
1022      let path = http::uri::PathAndQuery::from_static(
1023        "/io.pact.plugin.PactPlugin/ShutdownMockServer",
1024      );
1025      let mut req = request.into_request();
1026      req.extensions_mut()
1027        .insert(
1028          GrpcMethod::new("io.pact.plugin.PactPlugin", "ShutdownMockServer"),
1029        );
1030      self.inner.unary(req, path, codec).await
1031    }
1032    /// Get the matching results from a running mock server
1033    pub async fn get_mock_server_results(
1034      &mut self,
1035      request: impl tonic::IntoRequest<super::MockServerRequest>,
1036    ) -> std::result::Result<
1037      tonic::Response<super::MockServerResults>,
1038      tonic::Status,
1039    > {
1040      self.inner
1041        .ready()
1042        .await
1043        .map_err(|e| {
1044          tonic::Status::new(
1045            tonic::Code::Unknown,
1046            format!("Service was not ready: {}", e.into()),
1047          )
1048        })?;
1049      let codec = tonic::codec::ProstCodec::default();
1050      let path = http::uri::PathAndQuery::from_static(
1051        "/io.pact.plugin.PactPlugin/GetMockServerResults",
1052      );
1053      let mut req = request.into_request();
1054      req.extensions_mut()
1055        .insert(
1056          GrpcMethod::new("io.pact.plugin.PactPlugin", "GetMockServerResults"),
1057        );
1058      self.inner.unary(req, path, codec).await
1059    }
1060    /// Prepare an interaction for verification. This should return any data required to construct any request
1061    /// so that it can be amended before the verification is run
1062    pub async fn prepare_interaction_for_verification(
1063      &mut self,
1064      request: impl tonic::IntoRequest<super::VerificationPreparationRequest>,
1065    ) -> std::result::Result<
1066      tonic::Response<super::VerificationPreparationResponse>,
1067      tonic::Status,
1068    > {
1069      self.inner
1070        .ready()
1071        .await
1072        .map_err(|e| {
1073          tonic::Status::new(
1074            tonic::Code::Unknown,
1075            format!("Service was not ready: {}", e.into()),
1076          )
1077        })?;
1078      let codec = tonic::codec::ProstCodec::default();
1079      let path = http::uri::PathAndQuery::from_static(
1080        "/io.pact.plugin.PactPlugin/PrepareInteractionForVerification",
1081      );
1082      let mut req = request.into_request();
1083      req.extensions_mut()
1084        .insert(
1085          GrpcMethod::new(
1086            "io.pact.plugin.PactPlugin",
1087            "PrepareInteractionForVerification",
1088          ),
1089        );
1090      self.inner.unary(req, path, codec).await
1091    }
1092    /// Execute the verification for the interaction.
1093    pub async fn verify_interaction(
1094      &mut self,
1095      request: impl tonic::IntoRequest<super::VerifyInteractionRequest>,
1096    ) -> std::result::Result<
1097      tonic::Response<super::VerifyInteractionResponse>,
1098      tonic::Status,
1099    > {
1100      self.inner
1101        .ready()
1102        .await
1103        .map_err(|e| {
1104          tonic::Status::new(
1105            tonic::Code::Unknown,
1106            format!("Service was not ready: {}", e.into()),
1107          )
1108        })?;
1109      let codec = tonic::codec::ProstCodec::default();
1110      let path = http::uri::PathAndQuery::from_static(
1111        "/io.pact.plugin.PactPlugin/VerifyInteraction",
1112      );
1113      let mut req = request.into_request();
1114      req.extensions_mut()
1115        .insert(
1116          GrpcMethod::new("io.pact.plugin.PactPlugin", "VerifyInteraction"),
1117        );
1118      self.inner.unary(req, path, codec).await
1119    }
1120  }
1121}
1122/// Generated server implementations.
1123pub mod pact_plugin_server {
1124  #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
1125  use tonic::codegen::*;
1126  /// Generated trait containing gRPC methods that should be implemented for use with PactPluginServer.
1127  #[async_trait]
1128  pub trait PactPlugin: Send + Sync + 'static {
1129    /// Check that the plugin loaded OK. Returns the catalogue entries describing what the plugin provides
1130    async fn init_plugin(
1131      &self,
1132      request: tonic::Request<super::InitPluginRequest>,
1133    ) -> std::result::Result<
1134      tonic::Response<super::InitPluginResponse>,
1135      tonic::Status,
1136    >;
1137    /// Updated catalogue. This will be sent when the core catalogue has been updated (probably by a plugin loading).
1138    async fn update_catalogue(
1139      &self,
1140      request: tonic::Request<super::Catalogue>,
1141    ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
1142    /// Request to perform a comparison of some contents (matching request)
1143    async fn compare_contents(
1144      &self,
1145      request: tonic::Request<super::CompareContentsRequest>,
1146    ) -> std::result::Result<
1147      tonic::Response<super::CompareContentsResponse>,
1148      tonic::Status,
1149    >;
1150    /// Request to configure/setup the interaction for later verification. Data returned will be persisted in the pact file.
1151    async fn configure_interaction(
1152      &self,
1153      request: tonic::Request<super::ConfigureInteractionRequest>,
1154    ) -> std::result::Result<
1155      tonic::Response<super::ConfigureInteractionResponse>,
1156      tonic::Status,
1157    >;
1158    /// Request to generate the content using any defined generators
1159    async fn generate_content(
1160      &self,
1161      request: tonic::Request<super::GenerateContentRequest>,
1162    ) -> std::result::Result<
1163      tonic::Response<super::GenerateContentResponse>,
1164      tonic::Status,
1165    >;
1166    /// Start a mock server
1167    async fn start_mock_server(
1168      &self,
1169      request: tonic::Request<super::StartMockServerRequest>,
1170    ) -> std::result::Result<
1171      tonic::Response<super::StartMockServerResponse>,
1172      tonic::Status,
1173    >;
1174    /// Shutdown a running mock server
1175    /// TODO: Replace the message types with MockServerRequest and MockServerResults in the next major version
1176    async fn shutdown_mock_server(
1177      &self,
1178      request: tonic::Request<super::ShutdownMockServerRequest>,
1179    ) -> std::result::Result<
1180      tonic::Response<super::ShutdownMockServerResponse>,
1181      tonic::Status,
1182    >;
1183    /// Get the matching results from a running mock server
1184    async fn get_mock_server_results(
1185      &self,
1186      request: tonic::Request<super::MockServerRequest>,
1187    ) -> std::result::Result<
1188      tonic::Response<super::MockServerResults>,
1189      tonic::Status,
1190    >;
1191    /// Prepare an interaction for verification. This should return any data required to construct any request
1192    /// so that it can be amended before the verification is run
1193    async fn prepare_interaction_for_verification(
1194      &self,
1195      request: tonic::Request<super::VerificationPreparationRequest>,
1196    ) -> std::result::Result<
1197      tonic::Response<super::VerificationPreparationResponse>,
1198      tonic::Status,
1199    >;
1200    /// Execute the verification for the interaction.
1201    async fn verify_interaction(
1202      &self,
1203      request: tonic::Request<super::VerifyInteractionRequest>,
1204    ) -> std::result::Result<
1205      tonic::Response<super::VerifyInteractionResponse>,
1206      tonic::Status,
1207    >;
1208  }
1209  #[derive(Debug)]
1210  pub struct PactPluginServer<T: PactPlugin> {
1211    inner: Arc<T>,
1212    accept_compression_encodings: EnabledCompressionEncodings,
1213    send_compression_encodings: EnabledCompressionEncodings,
1214    max_decoding_message_size: Option<usize>,
1215    max_encoding_message_size: Option<usize>,
1216  }
1217  impl<T: PactPlugin> PactPluginServer<T> {
1218    pub fn new(inner: T) -> Self {
1219      Self::from_arc(Arc::new(inner))
1220    }
1221    pub fn from_arc(inner: Arc<T>) -> Self {
1222      Self {
1223        inner,
1224        accept_compression_encodings: Default::default(),
1225        send_compression_encodings: Default::default(),
1226        max_decoding_message_size: None,
1227        max_encoding_message_size: None,
1228      }
1229    }
1230    pub fn with_interceptor<F>(
1231      inner: T,
1232      interceptor: F,
1233    ) -> InterceptedService<Self, F>
1234      where
1235        F: tonic::service::Interceptor,
1236    {
1237      InterceptedService::new(Self::new(inner), interceptor)
1238    }
1239    /// Enable decompressing requests with the given encoding.
1240    #[must_use]
1241    pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
1242      self.accept_compression_encodings.enable(encoding);
1243      self
1244    }
1245    /// Compress responses with the given encoding, if the client supports it.
1246    #[must_use]
1247    pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
1248      self.send_compression_encodings.enable(encoding);
1249      self
1250    }
1251    /// Limits the maximum size of a decoded message.
1252    ///
1253    /// Default: `4MB`
1254    #[must_use]
1255    pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
1256      self.max_decoding_message_size = Some(limit);
1257      self
1258    }
1259    /// Limits the maximum size of an encoded message.
1260    ///
1261    /// Default: `usize::MAX`
1262    #[must_use]
1263    pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
1264      self.max_encoding_message_size = Some(limit);
1265      self
1266    }
1267  }
1268  impl<T, B> tonic::codegen::Service<http::Request<B>> for PactPluginServer<T>
1269    where
1270      T: PactPlugin,
1271      B: Body + Send + 'static,
1272      B::Error: Into<StdError> + Send + 'static,
1273  {
1274    type Response = http::Response<tonic::body::BoxBody>;
1275    type Error = std::convert::Infallible;
1276    type Future = BoxFuture<Self::Response, Self::Error>;
1277    fn poll_ready(
1278      &mut self,
1279      _cx: &mut Context<'_>,
1280    ) -> Poll<std::result::Result<(), Self::Error>> {
1281      Poll::Ready(Ok(()))
1282    }
1283    fn call(&mut self, req: http::Request<B>) -> Self::Future {
1284      match req.uri().path() {
1285        "/io.pact.plugin.PactPlugin/InitPlugin" => {
1286          #[allow(non_camel_case_types)]
1287          struct InitPluginSvc<T: PactPlugin>(pub Arc<T>);
1288          impl<
1289            T: PactPlugin,
1290          > tonic::server::UnaryService<super::InitPluginRequest>
1291          for InitPluginSvc<T> {
1292            type Response = super::InitPluginResponse;
1293            type Future = BoxFuture<
1294              tonic::Response<Self::Response>,
1295              tonic::Status,
1296            >;
1297            fn call(
1298              &mut self,
1299              request: tonic::Request<super::InitPluginRequest>,
1300            ) -> Self::Future {
1301              let inner = Arc::clone(&self.0);
1302              let fut = async move {
1303                <T as PactPlugin>::init_plugin(&inner, request).await
1304              };
1305              Box::pin(fut)
1306            }
1307          }
1308          let accept_compression_encodings = self.accept_compression_encodings;
1309          let send_compression_encodings = self.send_compression_encodings;
1310          let max_decoding_message_size = self.max_decoding_message_size;
1311          let max_encoding_message_size = self.max_encoding_message_size;
1312          let inner = self.inner.clone();
1313          let fut = async move {
1314            let method = InitPluginSvc(inner);
1315            let codec = tonic::codec::ProstCodec::default();
1316            let mut grpc = tonic::server::Grpc::new(codec)
1317              .apply_compression_config(
1318                accept_compression_encodings,
1319                send_compression_encodings,
1320              )
1321              .apply_max_message_size_config(
1322                max_decoding_message_size,
1323                max_encoding_message_size,
1324              );
1325            let res = grpc.unary(method, req).await;
1326            Ok(res)
1327          };
1328          Box::pin(fut)
1329        }
1330        "/io.pact.plugin.PactPlugin/UpdateCatalogue" => {
1331          #[allow(non_camel_case_types)]
1332          struct UpdateCatalogueSvc<T: PactPlugin>(pub Arc<T>);
1333          impl<T: PactPlugin> tonic::server::UnaryService<super::Catalogue>
1334          for UpdateCatalogueSvc<T> {
1335            type Response = ();
1336            type Future = BoxFuture<
1337              tonic::Response<Self::Response>,
1338              tonic::Status,
1339            >;
1340            fn call(
1341              &mut self,
1342              request: tonic::Request<super::Catalogue>,
1343            ) -> Self::Future {
1344              let inner = Arc::clone(&self.0);
1345              let fut = async move {
1346                <T as PactPlugin>::update_catalogue(&inner, request).await
1347              };
1348              Box::pin(fut)
1349            }
1350          }
1351          let accept_compression_encodings = self.accept_compression_encodings;
1352          let send_compression_encodings = self.send_compression_encodings;
1353          let max_decoding_message_size = self.max_decoding_message_size;
1354          let max_encoding_message_size = self.max_encoding_message_size;
1355          let inner = self.inner.clone();
1356          let fut = async move {
1357            let method = UpdateCatalogueSvc(inner);
1358            let codec = tonic::codec::ProstCodec::default();
1359            let mut grpc = tonic::server::Grpc::new(codec)
1360              .apply_compression_config(
1361                accept_compression_encodings,
1362                send_compression_encodings,
1363              )
1364              .apply_max_message_size_config(
1365                max_decoding_message_size,
1366                max_encoding_message_size,
1367              );
1368            let res = grpc.unary(method, req).await;
1369            Ok(res)
1370          };
1371          Box::pin(fut)
1372        }
1373        "/io.pact.plugin.PactPlugin/CompareContents" => {
1374          #[allow(non_camel_case_types)]
1375          struct CompareContentsSvc<T: PactPlugin>(pub Arc<T>);
1376          impl<
1377            T: PactPlugin,
1378          > tonic::server::UnaryService<super::CompareContentsRequest>
1379          for CompareContentsSvc<T> {
1380            type Response = super::CompareContentsResponse;
1381            type Future = BoxFuture<
1382              tonic::Response<Self::Response>,
1383              tonic::Status,
1384            >;
1385            fn call(
1386              &mut self,
1387              request: tonic::Request<super::CompareContentsRequest>,
1388            ) -> Self::Future {
1389              let inner = Arc::clone(&self.0);
1390              let fut = async move {
1391                <T as PactPlugin>::compare_contents(&inner, request).await
1392              };
1393              Box::pin(fut)
1394            }
1395          }
1396          let accept_compression_encodings = self.accept_compression_encodings;
1397          let send_compression_encodings = self.send_compression_encodings;
1398          let max_decoding_message_size = self.max_decoding_message_size;
1399          let max_encoding_message_size = self.max_encoding_message_size;
1400          let inner = self.inner.clone();
1401          let fut = async move {
1402            let method = CompareContentsSvc(inner);
1403            let codec = tonic::codec::ProstCodec::default();
1404            let mut grpc = tonic::server::Grpc::new(codec)
1405              .apply_compression_config(
1406                accept_compression_encodings,
1407                send_compression_encodings,
1408              )
1409              .apply_max_message_size_config(
1410                max_decoding_message_size,
1411                max_encoding_message_size,
1412              );
1413            let res = grpc.unary(method, req).await;
1414            Ok(res)
1415          };
1416          Box::pin(fut)
1417        }
1418        "/io.pact.plugin.PactPlugin/ConfigureInteraction" => {
1419          #[allow(non_camel_case_types)]
1420          struct ConfigureInteractionSvc<T: PactPlugin>(pub Arc<T>);
1421          impl<
1422            T: PactPlugin,
1423          > tonic::server::UnaryService<super::ConfigureInteractionRequest>
1424          for ConfigureInteractionSvc<T> {
1425            type Response = super::ConfigureInteractionResponse;
1426            type Future = BoxFuture<
1427              tonic::Response<Self::Response>,
1428              tonic::Status,
1429            >;
1430            fn call(
1431              &mut self,
1432              request: tonic::Request<super::ConfigureInteractionRequest>,
1433            ) -> Self::Future {
1434              let inner = Arc::clone(&self.0);
1435              let fut = async move {
1436                <T as PactPlugin>::configure_interaction(&inner, request)
1437                  .await
1438              };
1439              Box::pin(fut)
1440            }
1441          }
1442          let accept_compression_encodings = self.accept_compression_encodings;
1443          let send_compression_encodings = self.send_compression_encodings;
1444          let max_decoding_message_size = self.max_decoding_message_size;
1445          let max_encoding_message_size = self.max_encoding_message_size;
1446          let inner = self.inner.clone();
1447          let fut = async move {
1448            let method = ConfigureInteractionSvc(inner);
1449            let codec = tonic::codec::ProstCodec::default();
1450            let mut grpc = tonic::server::Grpc::new(codec)
1451              .apply_compression_config(
1452                accept_compression_encodings,
1453                send_compression_encodings,
1454              )
1455              .apply_max_message_size_config(
1456                max_decoding_message_size,
1457                max_encoding_message_size,
1458              );
1459            let res = grpc.unary(method, req).await;
1460            Ok(res)
1461          };
1462          Box::pin(fut)
1463        }
1464        "/io.pact.plugin.PactPlugin/GenerateContent" => {
1465          #[allow(non_camel_case_types)]
1466          struct GenerateContentSvc<T: PactPlugin>(pub Arc<T>);
1467          impl<
1468            T: PactPlugin,
1469          > tonic::server::UnaryService<super::GenerateContentRequest>
1470          for GenerateContentSvc<T> {
1471            type Response = super::GenerateContentResponse;
1472            type Future = BoxFuture<
1473              tonic::Response<Self::Response>,
1474              tonic::Status,
1475            >;
1476            fn call(
1477              &mut self,
1478              request: tonic::Request<super::GenerateContentRequest>,
1479            ) -> Self::Future {
1480              let inner = Arc::clone(&self.0);
1481              let fut = async move {
1482                <T as PactPlugin>::generate_content(&inner, request).await
1483              };
1484              Box::pin(fut)
1485            }
1486          }
1487          let accept_compression_encodings = self.accept_compression_encodings;
1488          let send_compression_encodings = self.send_compression_encodings;
1489          let max_decoding_message_size = self.max_decoding_message_size;
1490          let max_encoding_message_size = self.max_encoding_message_size;
1491          let inner = self.inner.clone();
1492          let fut = async move {
1493            let method = GenerateContentSvc(inner);
1494            let codec = tonic::codec::ProstCodec::default();
1495            let mut grpc = tonic::server::Grpc::new(codec)
1496              .apply_compression_config(
1497                accept_compression_encodings,
1498                send_compression_encodings,
1499              )
1500              .apply_max_message_size_config(
1501                max_decoding_message_size,
1502                max_encoding_message_size,
1503              );
1504            let res = grpc.unary(method, req).await;
1505            Ok(res)
1506          };
1507          Box::pin(fut)
1508        }
1509        "/io.pact.plugin.PactPlugin/StartMockServer" => {
1510          #[allow(non_camel_case_types)]
1511          struct StartMockServerSvc<T: PactPlugin>(pub Arc<T>);
1512          impl<
1513            T: PactPlugin,
1514          > tonic::server::UnaryService<super::StartMockServerRequest>
1515          for StartMockServerSvc<T> {
1516            type Response = super::StartMockServerResponse;
1517            type Future = BoxFuture<
1518              tonic::Response<Self::Response>,
1519              tonic::Status,
1520            >;
1521            fn call(
1522              &mut self,
1523              request: tonic::Request<super::StartMockServerRequest>,
1524            ) -> Self::Future {
1525              let inner = Arc::clone(&self.0);
1526              let fut = async move {
1527                <T as PactPlugin>::start_mock_server(&inner, request).await
1528              };
1529              Box::pin(fut)
1530            }
1531          }
1532          let accept_compression_encodings = self.accept_compression_encodings;
1533          let send_compression_encodings = self.send_compression_encodings;
1534          let max_decoding_message_size = self.max_decoding_message_size;
1535          let max_encoding_message_size = self.max_encoding_message_size;
1536          let inner = self.inner.clone();
1537          let fut = async move {
1538            let method = StartMockServerSvc(inner);
1539            let codec = tonic::codec::ProstCodec::default();
1540            let mut grpc = tonic::server::Grpc::new(codec)
1541              .apply_compression_config(
1542                accept_compression_encodings,
1543                send_compression_encodings,
1544              )
1545              .apply_max_message_size_config(
1546                max_decoding_message_size,
1547                max_encoding_message_size,
1548              );
1549            let res = grpc.unary(method, req).await;
1550            Ok(res)
1551          };
1552          Box::pin(fut)
1553        }
1554        "/io.pact.plugin.PactPlugin/ShutdownMockServer" => {
1555          #[allow(non_camel_case_types)]
1556          struct ShutdownMockServerSvc<T: PactPlugin>(pub Arc<T>);
1557          impl<
1558            T: PactPlugin,
1559          > tonic::server::UnaryService<super::ShutdownMockServerRequest>
1560          for ShutdownMockServerSvc<T> {
1561            type Response = super::ShutdownMockServerResponse;
1562            type Future = BoxFuture<
1563              tonic::Response<Self::Response>,
1564              tonic::Status,
1565            >;
1566            fn call(
1567              &mut self,
1568              request: tonic::Request<super::ShutdownMockServerRequest>,
1569            ) -> Self::Future {
1570              let inner = Arc::clone(&self.0);
1571              let fut = async move {
1572                <T as PactPlugin>::shutdown_mock_server(&inner, request)
1573                  .await
1574              };
1575              Box::pin(fut)
1576            }
1577          }
1578          let accept_compression_encodings = self.accept_compression_encodings;
1579          let send_compression_encodings = self.send_compression_encodings;
1580          let max_decoding_message_size = self.max_decoding_message_size;
1581          let max_encoding_message_size = self.max_encoding_message_size;
1582          let inner = self.inner.clone();
1583          let fut = async move {
1584            let method = ShutdownMockServerSvc(inner);
1585            let codec = tonic::codec::ProstCodec::default();
1586            let mut grpc = tonic::server::Grpc::new(codec)
1587              .apply_compression_config(
1588                accept_compression_encodings,
1589                send_compression_encodings,
1590              )
1591              .apply_max_message_size_config(
1592                max_decoding_message_size,
1593                max_encoding_message_size,
1594              );
1595            let res = grpc.unary(method, req).await;
1596            Ok(res)
1597          };
1598          Box::pin(fut)
1599        }
1600        "/io.pact.plugin.PactPlugin/GetMockServerResults" => {
1601          #[allow(non_camel_case_types)]
1602          struct GetMockServerResultsSvc<T: PactPlugin>(pub Arc<T>);
1603          impl<
1604            T: PactPlugin,
1605          > tonic::server::UnaryService<super::MockServerRequest>
1606          for GetMockServerResultsSvc<T> {
1607            type Response = super::MockServerResults;
1608            type Future = BoxFuture<
1609              tonic::Response<Self::Response>,
1610              tonic::Status,
1611            >;
1612            fn call(
1613              &mut self,
1614              request: tonic::Request<super::MockServerRequest>,
1615            ) -> Self::Future {
1616              let inner = Arc::clone(&self.0);
1617              let fut = async move {
1618                <T as PactPlugin>::get_mock_server_results(&inner, request)
1619                  .await
1620              };
1621              Box::pin(fut)
1622            }
1623          }
1624          let accept_compression_encodings = self.accept_compression_encodings;
1625          let send_compression_encodings = self.send_compression_encodings;
1626          let max_decoding_message_size = self.max_decoding_message_size;
1627          let max_encoding_message_size = self.max_encoding_message_size;
1628          let inner = self.inner.clone();
1629          let fut = async move {
1630            let method = GetMockServerResultsSvc(inner);
1631            let codec = tonic::codec::ProstCodec::default();
1632            let mut grpc = tonic::server::Grpc::new(codec)
1633              .apply_compression_config(
1634                accept_compression_encodings,
1635                send_compression_encodings,
1636              )
1637              .apply_max_message_size_config(
1638                max_decoding_message_size,
1639                max_encoding_message_size,
1640              );
1641            let res = grpc.unary(method, req).await;
1642            Ok(res)
1643          };
1644          Box::pin(fut)
1645        }
1646        "/io.pact.plugin.PactPlugin/PrepareInteractionForVerification" => {
1647          #[allow(non_camel_case_types)]
1648          struct PrepareInteractionForVerificationSvc<T: PactPlugin>(
1649            pub Arc<T>,
1650          );
1651          impl<
1652            T: PactPlugin,
1653          > tonic::server::UnaryService<super::VerificationPreparationRequest>
1654          for PrepareInteractionForVerificationSvc<T> {
1655            type Response = super::VerificationPreparationResponse;
1656            type Future = BoxFuture<
1657              tonic::Response<Self::Response>,
1658              tonic::Status,
1659            >;
1660            fn call(
1661              &mut self,
1662              request: tonic::Request<
1663                super::VerificationPreparationRequest,
1664              >,
1665            ) -> Self::Future {
1666              let inner = Arc::clone(&self.0);
1667              let fut = async move {
1668                <T as PactPlugin>::prepare_interaction_for_verification(
1669                  &inner,
1670                  request,
1671                )
1672                  .await
1673              };
1674              Box::pin(fut)
1675            }
1676          }
1677          let accept_compression_encodings = self.accept_compression_encodings;
1678          let send_compression_encodings = self.send_compression_encodings;
1679          let max_decoding_message_size = self.max_decoding_message_size;
1680          let max_encoding_message_size = self.max_encoding_message_size;
1681          let inner = self.inner.clone();
1682          let fut = async move {
1683            let method = PrepareInteractionForVerificationSvc(inner);
1684            let codec = tonic::codec::ProstCodec::default();
1685            let mut grpc = tonic::server::Grpc::new(codec)
1686              .apply_compression_config(
1687                accept_compression_encodings,
1688                send_compression_encodings,
1689              )
1690              .apply_max_message_size_config(
1691                max_decoding_message_size,
1692                max_encoding_message_size,
1693              );
1694            let res = grpc.unary(method, req).await;
1695            Ok(res)
1696          };
1697          Box::pin(fut)
1698        }
1699        "/io.pact.plugin.PactPlugin/VerifyInteraction" => {
1700          #[allow(non_camel_case_types)]
1701          struct VerifyInteractionSvc<T: PactPlugin>(pub Arc<T>);
1702          impl<
1703            T: PactPlugin,
1704          > tonic::server::UnaryService<super::VerifyInteractionRequest>
1705          for VerifyInteractionSvc<T> {
1706            type Response = super::VerifyInteractionResponse;
1707            type Future = BoxFuture<
1708              tonic::Response<Self::Response>,
1709              tonic::Status,
1710            >;
1711            fn call(
1712              &mut self,
1713              request: tonic::Request<super::VerifyInteractionRequest>,
1714            ) -> Self::Future {
1715              let inner = Arc::clone(&self.0);
1716              let fut = async move {
1717                <T as PactPlugin>::verify_interaction(&inner, request).await
1718              };
1719              Box::pin(fut)
1720            }
1721          }
1722          let accept_compression_encodings = self.accept_compression_encodings;
1723          let send_compression_encodings = self.send_compression_encodings;
1724          let max_decoding_message_size = self.max_decoding_message_size;
1725          let max_encoding_message_size = self.max_encoding_message_size;
1726          let inner = self.inner.clone();
1727          let fut = async move {
1728            let method = VerifyInteractionSvc(inner);
1729            let codec = tonic::codec::ProstCodec::default();
1730            let mut grpc = tonic::server::Grpc::new(codec)
1731              .apply_compression_config(
1732                accept_compression_encodings,
1733                send_compression_encodings,
1734              )
1735              .apply_max_message_size_config(
1736                max_decoding_message_size,
1737                max_encoding_message_size,
1738              );
1739            let res = grpc.unary(method, req).await;
1740            Ok(res)
1741          };
1742          Box::pin(fut)
1743        }
1744        _ => {
1745          Box::pin(async move {
1746            Ok(
1747              http::Response::builder()
1748                .status(200)
1749                .header("grpc-status", tonic::Code::Unimplemented as i32)
1750                .header(
1751                  http::header::CONTENT_TYPE,
1752                  tonic::metadata::GRPC_CONTENT_TYPE,
1753                )
1754                .body(empty_body())
1755                .unwrap(),
1756            )
1757          })
1758        }
1759      }
1760    }
1761  }
1762  impl<T: PactPlugin> Clone for PactPluginServer<T> {
1763    fn clone(&self) -> Self {
1764      let inner = self.inner.clone();
1765      Self {
1766        inner,
1767        accept_compression_encodings: self.accept_compression_encodings,
1768        send_compression_encodings: self.send_compression_encodings,
1769        max_decoding_message_size: self.max_decoding_message_size,
1770        max_encoding_message_size: self.max_encoding_message_size,
1771      }
1772    }
1773  }
1774  impl<T: PactPlugin> tonic::server::NamedService for PactPluginServer<T> {
1775    const NAME: &'static str = "io.pact.plugin.PactPlugin";
1776  }
1777}
1778
1779// ------------------ Generated --------------------------//
1780
1781impl From<&OptionalBody> for Body {
1782  fn from(body: &OptionalBody) -> Self {
1783    match body {
1784      OptionalBody::Present(bytes, ct, ct_hint) => Body {
1785        content_type: ct.as_ref().map(|ct| ct.to_string()).unwrap_or_default(),
1786        content: Some(bytes.to_vec()),
1787        content_type_hint: match ct_hint {
1788          Some(ct_hint) => match ct_hint {
1789            ContentTypeHint::BINARY => body::ContentTypeHint::Binary as i32,
1790            ContentTypeHint::TEXT => body::ContentTypeHint::Text as i32,
1791            ContentTypeHint::DEFAULT => body::ContentTypeHint::Default as i32
1792          }
1793          None => body::ContentTypeHint::Default as i32
1794        }
1795      },
1796      _ => Body {
1797        content_type: "".to_string(),
1798        content: None,
1799        content_type_hint: body::ContentTypeHint::Default as i32
1800      }
1801    }
1802  }
1803}