1use pact_models::prelude::OptionalBody;
2use pact_models::content_types::ContentTypeHint;
3
4#[allow(clippy::derive_partial_eq_without_eq)]
11#[derive(Clone, PartialEq, ::prost::Message)]
12pub struct InitPluginRequest {
13 #[prost(string, tag = "1")]
15 pub implementation: ::prost::alloc::string::String,
16 #[prost(string, tag = "2")]
18 pub version: ::prost::alloc::string::String,
19}
20#[allow(clippy::derive_partial_eq_without_eq)]
23#[derive(Clone, PartialEq, ::prost::Message)]
24pub struct CatalogueEntry {
25 #[prost(enumeration = "catalogue_entry::EntryType", tag = "1")]
27 pub r#type: i32,
28 #[prost(string, tag = "2")]
30 pub key: ::prost::alloc::string::String,
31 #[prost(map = "string, string", tag = "3")]
34 pub values: ::std::collections::HashMap<
35 ::prost::alloc::string::String,
36 ::prost::alloc::string::String,
37 >,
38}
39pub 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 ContentMatcher = 0,
56 ContentGenerator = 1,
58 Transport = 2,
60 Matcher = 3,
62 Interaction = 4,
64 }
65 impl EntryType {
66 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 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#[allow(clippy::derive_partial_eq_without_eq)]
94#[derive(Clone, PartialEq, ::prost::Message)]
95pub struct InitPluginResponse {
96 #[prost(message, repeated, tag = "1")]
98 pub catalogue: ::prost::alloc::vec::Vec<CatalogueEntry>,
99}
100#[allow(clippy::derive_partial_eq_without_eq)]
102#[derive(Clone, PartialEq, ::prost::Message)]
103pub struct Catalogue {
104 #[prost(message, repeated, tag = "1")]
106 pub catalogue: ::prost::alloc::vec::Vec<CatalogueEntry>,
107}
108#[allow(clippy::derive_partial_eq_without_eq)]
110#[derive(Clone, PartialEq, ::prost::Message)]
111pub struct Body {
112 #[prost(string, tag = "1")]
114 pub content_type: ::prost::alloc::string::String,
115 #[prost(message, optional, tag = "2")]
117 pub content: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
118 #[prost(enumeration = "body::ContentTypeHint", tag = "3")]
121 pub content_type_hint: i32,
122}
123pub mod body {
125 #[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 Default = 0,
141 Text = 1,
143 Binary = 2,
145 }
146 impl ContentTypeHint {
147 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 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#[allow(clippy::derive_partial_eq_without_eq)]
171#[derive(Clone, PartialEq, ::prost::Message)]
172pub struct CompareContentsRequest {
173 #[prost(message, optional, tag = "1")]
175 pub expected: ::core::option::Option<Body>,
176 #[prost(message, optional, tag = "2")]
178 pub actual: ::core::option::Option<Body>,
179 #[prost(bool, tag = "3")]
182 pub allow_unexpected_keys: bool,
183 #[prost(map = "string, message", tag = "4")]
185 pub rules: ::std::collections::HashMap<
186 ::prost::alloc::string::String,
187 MatchingRules,
188 >,
189 #[prost(message, optional, tag = "5")]
191 pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
192}
193#[allow(clippy::derive_partial_eq_without_eq)]
195#[derive(Clone, PartialEq, ::prost::Message)]
196pub struct ContentTypeMismatch {
197 #[prost(string, tag = "1")]
199 pub expected: ::prost::alloc::string::String,
200 #[prost(string, tag = "2")]
202 pub actual: ::prost::alloc::string::String,
203}
204#[allow(clippy::derive_partial_eq_without_eq)]
206#[derive(Clone, PartialEq, ::prost::Message)]
207pub struct ContentMismatch {
208 #[prost(message, optional, tag = "1")]
210 pub expected: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
211 #[prost(message, optional, tag = "2")]
213 pub actual: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
214 #[prost(string, tag = "3")]
216 pub mismatch: ::prost::alloc::string::String,
217 #[prost(string, tag = "4")]
219 pub path: ::prost::alloc::string::String,
220 #[prost(string, tag = "5")]
222 pub diff: ::prost::alloc::string::String,
223 #[prost(string, tag = "6")]
225 pub mismatch_type: ::prost::alloc::string::String,
226}
227#[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#[allow(clippy::derive_partial_eq_without_eq)]
236#[derive(Clone, PartialEq, ::prost::Message)]
237pub struct CompareContentsResponse {
238 #[prost(string, tag = "1")]
241 pub error: ::prost::alloc::string::String,
242 #[prost(message, optional, tag = "2")]
244 pub type_mismatch: ::core::option::Option<ContentTypeMismatch>,
245 #[prost(map = "string, message", tag = "3")]
247 pub results: ::std::collections::HashMap<
248 ::prost::alloc::string::String,
249 ContentMismatches,
250 >,
251}
252#[allow(clippy::derive_partial_eq_without_eq)]
254#[derive(Clone, PartialEq, ::prost::Message)]
255pub struct ConfigureInteractionRequest {
256 #[prost(string, tag = "1")]
258 pub content_type: ::prost::alloc::string::String,
259 #[prost(message, optional, tag = "2")]
261 pub contents_config: ::core::option::Option<::prost_types::Struct>,
262}
263#[allow(clippy::derive_partial_eq_without_eq)]
265#[derive(Clone, PartialEq, ::prost::Message)]
266pub struct MatchingRule {
267 #[prost(string, tag = "1")]
269 pub r#type: ::prost::alloc::string::String,
270 #[prost(message, optional, tag = "2")]
272 pub values: ::core::option::Option<::prost_types::Struct>,
273}
274#[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#[allow(clippy::derive_partial_eq_without_eq)]
283#[derive(Clone, PartialEq, ::prost::Message)]
284pub struct Generator {
285 #[prost(string, tag = "1")]
287 pub r#type: ::prost::alloc::string::String,
288 #[prost(message, optional, tag = "2")]
290 pub values: ::core::option::Option<::prost_types::Struct>,
291}
292#[allow(clippy::derive_partial_eq_without_eq)]
294#[derive(Clone, PartialEq, ::prost::Message)]
295pub struct PluginConfiguration {
296 #[prost(message, optional, tag = "1")]
298 pub interaction_configuration: ::core::option::Option<::prost_types::Struct>,
299 #[prost(message, optional, tag = "2")]
301 pub pact_configuration: ::core::option::Option<::prost_types::Struct>,
302}
303#[allow(clippy::derive_partial_eq_without_eq)]
305#[derive(Clone, PartialEq, ::prost::Message)]
306pub struct InteractionResponse {
307 #[prost(message, optional, tag = "1")]
309 pub contents: ::core::option::Option<Body>,
310 #[prost(map = "string, message", tag = "2")]
312 pub rules: ::std::collections::HashMap<
313 ::prost::alloc::string::String,
314 MatchingRules,
315 >,
316 #[prost(map = "string, message", tag = "3")]
318 pub generators: ::std::collections::HashMap<
319 ::prost::alloc::string::String,
320 Generator,
321 >,
322 #[prost(message, optional, tag = "4")]
324 pub message_metadata: ::core::option::Option<::prost_types::Struct>,
325 #[prost(message, optional, tag = "5")]
327 pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
328 #[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 #[prost(string, tag = "8")]
336 pub part_name: ::prost::alloc::string::String,
337 #[prost(map = "string, message", tag = "9")]
339 pub metadata_rules: ::std::collections::HashMap<
340 ::prost::alloc::string::String,
341 MatchingRules,
342 >,
343 #[prost(map = "string, message", tag = "10")]
345 pub metadata_generators: ::std::collections::HashMap<
346 ::prost::alloc::string::String,
347 Generator,
348 >,
349}
350pub mod interaction_response {
352 #[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 = 0,
368 Html = 1,
370 }
371 impl MarkupType {
372 pub fn as_str_name(&self) -> &'static str {
377 match self {
378 MarkupType::CommonMark => "COMMON_MARK",
379 MarkupType::Html => "HTML",
380 }
381 }
382 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#[allow(clippy::derive_partial_eq_without_eq)]
394#[derive(Clone, PartialEq, ::prost::Message)]
395pub struct ConfigureInteractionResponse {
396 #[prost(string, tag = "1")]
398 pub error: ::prost::alloc::string::String,
399 #[prost(message, repeated, tag = "2")]
401 pub interaction: ::prost::alloc::vec::Vec<InteractionResponse>,
402 #[prost(message, optional, tag = "3")]
404 pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
405}
406#[allow(clippy::derive_partial_eq_without_eq)]
408#[derive(Clone, PartialEq, ::prost::Message)]
409pub struct GenerateContentRequest {
410 #[prost(message, optional, tag = "1")]
412 pub contents: ::core::option::Option<Body>,
413 #[prost(map = "string, message", tag = "2")]
415 pub generators: ::std::collections::HashMap<
416 ::prost::alloc::string::String,
417 Generator,
418 >,
419 #[prost(message, optional, tag = "3")]
421 pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
422 #[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}
430pub mod generate_content_request {
432 #[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 Consumer = 1,
449 Provider = 2,
451 }
452 impl TestMode {
453 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 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 #[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 pub fn as_str_name(&self) -> &'static str {
497 match self {
498 ContentFor::Request => "Request",
499 ContentFor::Response => "Response",
500 }
501 }
502 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#[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#[allow(clippy::derive_partial_eq_without_eq)]
521#[derive(Clone, PartialEq, ::prost::Message)]
522pub struct StartMockServerRequest {
523 #[prost(string, tag = "1")]
525 pub host_interface: ::prost::alloc::string::String,
526 #[prost(uint32, tag = "2")]
528 pub port: u32,
529 #[prost(bool, tag = "3")]
531 pub tls: bool,
532 #[prost(string, tag = "4")]
534 pub pact: ::prost::alloc::string::String,
535 #[prost(message, optional, tag = "5")]
537 pub test_context: ::core::option::Option<::prost_types::Struct>,
538}
539#[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}
546pub mod start_mock_server_response {
548 #[allow(clippy::derive_partial_eq_without_eq)]
549 #[derive(Clone, PartialEq, ::prost::Oneof)]
550 pub enum Response {
551 #[prost(string, tag = "1")]
553 Error(::prost::alloc::string::String),
554 #[prost(message, tag = "2")]
556 Details(super::MockServerDetails),
557 }
558}
559#[allow(clippy::derive_partial_eq_without_eq)]
561#[derive(Clone, PartialEq, ::prost::Message)]
562pub struct MockServerDetails {
563 #[prost(string, tag = "1")]
565 pub key: ::prost::alloc::string::String,
566 #[prost(uint32, tag = "2")]
568 pub port: u32,
569 #[prost(string, tag = "3")]
571 pub address: ::prost::alloc::string::String,
572}
573#[allow(clippy::derive_partial_eq_without_eq)]
576#[derive(Clone, PartialEq, ::prost::Message)]
577pub struct ShutdownMockServerRequest {
578 #[prost(string, tag = "1")]
580 pub server_key: ::prost::alloc::string::String,
581}
582#[allow(clippy::derive_partial_eq_without_eq)]
584#[derive(Clone, PartialEq, ::prost::Message)]
585pub struct MockServerRequest {
586 #[prost(string, tag = "1")]
588 pub server_key: ::prost::alloc::string::String,
589}
590#[allow(clippy::derive_partial_eq_without_eq)]
592#[derive(Clone, PartialEq, ::prost::Message)]
593pub struct MockServerResult {
594 #[prost(string, tag = "1")]
596 pub path: ::prost::alloc::string::String,
597 #[prost(string, tag = "2")]
599 pub error: ::prost::alloc::string::String,
600 #[prost(message, repeated, tag = "3")]
602 pub mismatches: ::prost::alloc::vec::Vec<ContentMismatch>,
603}
604#[allow(clippy::derive_partial_eq_without_eq)]
607#[derive(Clone, PartialEq, ::prost::Message)]
608pub struct ShutdownMockServerResponse {
609 #[prost(bool, tag = "1")]
611 pub ok: bool,
612 #[prost(message, repeated, tag = "2")]
614 pub results: ::prost::alloc::vec::Vec<MockServerResult>,
615}
616#[allow(clippy::derive_partial_eq_without_eq)]
618#[derive(Clone, PartialEq, ::prost::Message)]
619pub struct MockServerResults {
620 #[prost(bool, tag = "1")]
622 pub ok: bool,
623 #[prost(message, repeated, tag = "2")]
625 pub results: ::prost::alloc::vec::Vec<MockServerResult>,
626}
627#[allow(clippy::derive_partial_eq_without_eq)]
629#[derive(Clone, PartialEq, ::prost::Message)]
630pub struct VerificationPreparationRequest {
631 #[prost(string, tag = "1")]
633 pub pact: ::prost::alloc::string::String,
634 #[prost(string, tag = "2")]
636 pub interaction_key: ::prost::alloc::string::String,
637 #[prost(message, optional, tag = "3")]
639 pub config: ::core::option::Option<::prost_types::Struct>,
640}
641#[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}
648pub 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#[allow(clippy::derive_partial_eq_without_eq)]
661#[derive(Clone, PartialEq, ::prost::Message)]
662pub struct InteractionData {
663 #[prost(message, optional, tag = "1")]
665 pub body: ::core::option::Option<Body>,
666 #[prost(map = "string, message", tag = "2")]
668 pub metadata: ::std::collections::HashMap<
669 ::prost::alloc::string::String,
670 MetadataValue,
671 >,
672}
673#[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}
680pub mod verification_preparation_response {
682 #[allow(clippy::derive_partial_eq_without_eq)]
683 #[derive(Clone, PartialEq, ::prost::Oneof)]
684 pub enum Response {
685 #[prost(string, tag = "1")]
687 Error(::prost::alloc::string::String),
688 #[prost(message, tag = "2")]
690 InteractionData(super::InteractionData),
691 }
692}
693#[allow(clippy::derive_partial_eq_without_eq)]
695#[derive(Clone, PartialEq, ::prost::Message)]
696pub struct VerifyInteractionRequest {
697 #[prost(message, optional, tag = "1")]
699 pub interaction_data: ::core::option::Option<InteractionData>,
700 #[prost(message, optional, tag = "2")]
702 pub config: ::core::option::Option<::prost_types::Struct>,
703 #[prost(string, tag = "3")]
705 pub pact: ::prost::alloc::string::String,
706 #[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}
716pub 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#[allow(clippy::derive_partial_eq_without_eq)]
729#[derive(Clone, PartialEq, ::prost::Message)]
730pub struct VerificationResult {
731 #[prost(bool, tag = "1")]
733 pub success: bool,
734 #[prost(message, optional, tag = "2")]
736 pub response_data: ::core::option::Option<InteractionData>,
737 #[prost(message, repeated, tag = "3")]
739 pub mismatches: ::prost::alloc::vec::Vec<VerificationResultItem>,
740 #[prost(string, repeated, tag = "4")]
742 pub output: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
743}
744#[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}
751pub mod verify_interaction_response {
753 #[allow(clippy::derive_partial_eq_without_eq)]
754 #[derive(Clone, PartialEq, ::prost::Oneof)]
755 pub enum Response {
756 #[prost(string, tag = "1")]
758 Error(::prost::alloc::string::String),
759 #[prost(message, tag = "2")]
760 Result(super::VerificationResult),
761 }
762}
763pub 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 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 #[must_use]
822 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
823 self.inner = self.inner.send_compressed(encoding);
824 self
825 }
826 #[must_use]
828 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
829 self.inner = self.inner.accept_compressed(encoding);
830 self
831 }
832 #[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 #[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 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 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 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 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 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 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 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 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 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 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}
1122pub mod pact_plugin_server {
1124 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
1125 use tonic::codegen::*;
1126 #[async_trait]
1128 pub trait PactPlugin: Send + Sync + 'static {
1129 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 async fn update_catalogue(
1139 &self,
1140 request: tonic::Request<super::Catalogue>,
1141 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
1142 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 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 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 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 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 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 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 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 #[must_use]
1241 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
1242 self.accept_compression_encodings.enable(encoding);
1243 self
1244 }
1245 #[must_use]
1247 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
1248 self.send_compression_encodings.enable(encoding);
1249 self
1250 }
1251 #[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 #[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
1779impl 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}