@pact-foundation/pact-core 13.13.2 → 13.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/bin/pact-broker.js +3 -3
- package/bin/pact-broker.js.map +1 -1
- package/bin/pact-message.js +3 -3
- package/bin/pact-message.js.map +1 -1
- package/bin/pact-mock-service.js +2 -2
- package/bin/pact-mock-service.js.map +1 -1
- package/bin/pact-provider-verifier.js +3 -3
- package/bin/pact-provider-verifier.js.map +1 -1
- package/bin/pact-stub-service.js +3 -3
- package/bin/pact-stub-service.js.map +1 -1
- package/bin/pact.js +3 -3
- package/bin/pact.js.map +1 -1
- package/bin/pactflow.js +3 -3
- package/bin/pactflow.js.map +1 -1
- package/build/Makefile +2 -2
- package/build/pact.target.mk +14 -14
- package/ffi/libpact_ffi.dylib +0 -0
- package/ffi/libpact_ffi.so +0 -0
- package/ffi/libpact_ffi.so.gz +0 -0
- package/ffi/linuxaarch64/libpact_ffi.so +0 -0
- package/ffi/osxaarch64/libpact_ffi.dylib +0 -0
- package/ffi/pact-cpp.h +1497 -669
- package/ffi/pact.h +1505 -676
- package/ffi/pact_ffi.dll +0 -0
- package/ffi/pact_ffi.dll.lib +0 -0
- package/native/consumer.cc +34 -7
- package/package.json +17 -11
- package/src/can-deploy/CannotDeployError.d.ts +5 -0
- package/src/can-deploy/CannotDeployError.js +12 -0
- package/src/can-deploy/CannotDeployError.js.map +1 -0
- package/src/can-deploy/can-deploy.d.ts +10 -0
- package/src/{can-deploy.js → can-deploy/can-deploy.js} +23 -24
- package/src/can-deploy/can-deploy.js.map +1 -0
- package/src/can-deploy/index.d.ts +4 -0
- package/src/can-deploy/index.js +24 -0
- package/src/can-deploy/index.js.map +1 -0
- package/src/{can-deploy.d.ts → can-deploy/types.d.ts} +0 -13
- package/src/can-deploy/types.js +3 -0
- package/src/can-deploy/types.js.map +1 -0
- package/src/consumer/checkErrors.js +1 -1
- package/src/consumer/checkErrors.js.map +1 -1
- package/src/consumer/index.d.ts +0 -1
- package/src/consumer/index.js +72 -200
- package/src/consumer/index.js.map +1 -1
- package/src/consumer/internals.d.ts +4 -0
- package/src/consumer/internals.js +43 -0
- package/src/consumer/internals.js.map +1 -0
- package/src/ffi/index.d.ts +1 -1
- package/src/ffi/index.js +7 -3
- package/src/ffi/index.js.map +1 -1
- package/src/ffi/types.js.map +1 -1
- package/src/index.d.ts +3 -0
- package/src/index.js +8 -1
- package/src/index.js.map +1 -1
- package/src/logger/index.d.ts +2 -2
- package/src/logger/index.js +3 -3
- package/src/logger/index.js.map +1 -1
- package/src/logger/pino.js +1 -1
- package/src/logger/pino.js.map +1 -1
- package/src/message.d.ts +2 -9
- package/src/message.js +30 -10
- package/src/message.js.map +1 -1
- package/src/pact-environment.js +5 -1
- package/src/pact-environment.js.map +1 -1
- package/src/pact-standalone.d.ts +1 -1
- package/src/pact-standalone.js +8 -6
- package/src/pact-standalone.js.map +1 -1
- package/src/pact.d.ts +2 -3
- package/src/pact.js +20 -14
- package/src/pact.js.map +1 -1
- package/src/publisher.d.ts +2 -15
- package/src/publisher.js +37 -35
- package/src/publisher.js.map +1 -1
- package/src/server.d.ts +2 -2
- package/src/server.js +4 -3
- package/src/server.js.map +1 -1
- package/src/service.d.ts +5 -22
- package/src/service.js +14 -10
- package/src/service.js.map +1 -1
- package/src/spawn/arguments.d.ts +2 -4
- package/src/spawn/arguments.js.map +1 -1
- package/src/spawn/index.d.ts +2 -1
- package/src/spawn/index.js +7 -4
- package/src/spawn/index.js.map +1 -1
- package/src/spawn/spawn.js +15 -8
- package/src/spawn/spawn.js.map +1 -1
- package/src/stub.d.ts +2 -2
- package/src/stub.js +3 -3
- package/src/stub.js.map +1 -1
- package/src/types.d.ts +41 -0
- package/src/types.js +3 -0
- package/src/types.js.map +1 -0
- package/src/verifier/argumentMapper/arguments.js +21 -23
- package/src/verifier/argumentMapper/arguments.js.map +1 -1
- package/src/verifier/argumentMapper/index.js +11 -7
- package/src/verifier/argumentMapper/index.js.map +1 -1
- package/src/verifier/index.js +2 -2
- package/src/verifier/index.js.map +1 -1
- package/src/verifier/nativeVerifier.js +9 -5
- package/src/verifier/nativeVerifier.js.map +1 -1
- package/src/verifier/validateOptions.js +25 -22
- package/src/verifier/validateOptions.js.map +1 -1
- package/standalone/install.js +7 -11
- package/standalone/install.js.map +1 -1
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +5 -5
- package/src/can-deploy.js.map +0 -1
- package/tsconfig.spec.json +0 -7
package/ffi/pact-cpp.h
CHANGED
|
@@ -47,6 +47,40 @@ enum class ExpressionValueType {
|
|
|
47
47
|
ExpressionValueType_Boolean,
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Enum defining the categories that generators can be applied to
|
|
52
|
+
*/
|
|
53
|
+
enum class GeneratorCategory {
|
|
54
|
+
/**
|
|
55
|
+
* Request Method
|
|
56
|
+
*/
|
|
57
|
+
GeneratorCategory_METHOD,
|
|
58
|
+
/**
|
|
59
|
+
* Request Path
|
|
60
|
+
*/
|
|
61
|
+
GeneratorCategory_PATH,
|
|
62
|
+
/**
|
|
63
|
+
* Request/Response Header
|
|
64
|
+
*/
|
|
65
|
+
GeneratorCategory_HEADER,
|
|
66
|
+
/**
|
|
67
|
+
* Request Query Parameter
|
|
68
|
+
*/
|
|
69
|
+
GeneratorCategory_QUERY,
|
|
70
|
+
/**
|
|
71
|
+
* Body
|
|
72
|
+
*/
|
|
73
|
+
GeneratorCategory_BODY,
|
|
74
|
+
/**
|
|
75
|
+
* Response Status
|
|
76
|
+
*/
|
|
77
|
+
GeneratorCategory_STATUS,
|
|
78
|
+
/**
|
|
79
|
+
* Message metadata
|
|
80
|
+
*/
|
|
81
|
+
GeneratorCategory_METADATA,
|
|
82
|
+
};
|
|
83
|
+
|
|
50
84
|
/**
|
|
51
85
|
* Request or Response enum
|
|
52
86
|
*/
|
|
@@ -76,6 +110,44 @@ enum class LevelFilter {
|
|
|
76
110
|
LevelFilter_Trace,
|
|
77
111
|
};
|
|
78
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Enum defining the categories that matching rules can be applied to
|
|
115
|
+
*/
|
|
116
|
+
enum class MatchingRuleCategory {
|
|
117
|
+
/**
|
|
118
|
+
* Request Method
|
|
119
|
+
*/
|
|
120
|
+
MatchingRuleCategory_METHOD,
|
|
121
|
+
/**
|
|
122
|
+
* Request Path
|
|
123
|
+
*/
|
|
124
|
+
MatchingRuleCategory_PATH,
|
|
125
|
+
/**
|
|
126
|
+
* Request/Response Header
|
|
127
|
+
*/
|
|
128
|
+
MatchingRuleCategory_HEADER,
|
|
129
|
+
/**
|
|
130
|
+
* Request Query Parameter
|
|
131
|
+
*/
|
|
132
|
+
MatchingRuleCategory_QUERY,
|
|
133
|
+
/**
|
|
134
|
+
* Body
|
|
135
|
+
*/
|
|
136
|
+
MatchingRuleCategory_BODY,
|
|
137
|
+
/**
|
|
138
|
+
* Response Status
|
|
139
|
+
*/
|
|
140
|
+
MatchingRuleCategory_STATUS,
|
|
141
|
+
/**
|
|
142
|
+
* Message contents (body)
|
|
143
|
+
*/
|
|
144
|
+
MatchingRuleCategory_CONTENTS,
|
|
145
|
+
/**
|
|
146
|
+
* Message metadata
|
|
147
|
+
*/
|
|
148
|
+
MatchingRuleCategory_METADATA,
|
|
149
|
+
};
|
|
150
|
+
|
|
79
151
|
/**
|
|
80
152
|
* Enum defining the pact specification versions supported by the library
|
|
81
153
|
*/
|
|
@@ -106,6 +178,11 @@ enum class PactSpecification {
|
|
|
106
178
|
PactSpecification_V4,
|
|
107
179
|
};
|
|
108
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Asynchronous interactions as a sequence of messages
|
|
183
|
+
*/
|
|
184
|
+
struct AsynchronousMessage;
|
|
185
|
+
|
|
109
186
|
/**
|
|
110
187
|
* Struct that defines the consumer of the pact.
|
|
111
188
|
*/
|
|
@@ -116,11 +193,33 @@ struct Consumer;
|
|
|
116
193
|
*/
|
|
117
194
|
struct Generator;
|
|
118
195
|
|
|
196
|
+
/**
|
|
197
|
+
* An iterator that enables FFI iteration over the generators for a particular generator
|
|
198
|
+
* category.
|
|
199
|
+
*/
|
|
200
|
+
struct GeneratorCategoryIterator;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Struct that defines the HTTP request.
|
|
204
|
+
*/
|
|
205
|
+
struct HttpRequest;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Struct that defines the HTTP response.
|
|
209
|
+
*/
|
|
210
|
+
struct HttpResponse;
|
|
211
|
+
|
|
119
212
|
/**
|
|
120
213
|
* Set of all matching rules
|
|
121
214
|
*/
|
|
122
215
|
struct MatchingRule;
|
|
123
216
|
|
|
217
|
+
/**
|
|
218
|
+
* An iterator that enables FFI iteration over the matching rules for a particular matching rule
|
|
219
|
+
* category.
|
|
220
|
+
*/
|
|
221
|
+
struct MatchingRuleCategoryIterator;
|
|
222
|
+
|
|
124
223
|
/**
|
|
125
224
|
* Result of parsing a matching rule definition
|
|
126
225
|
*/
|
|
@@ -168,6 +267,11 @@ struct MatchingRuleResult;
|
|
|
168
267
|
*/
|
|
169
268
|
struct Message;
|
|
170
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Contents of a message interaction
|
|
272
|
+
*/
|
|
273
|
+
struct MessageContents;
|
|
274
|
+
|
|
171
275
|
/**
|
|
172
276
|
* An iterator that enables FFI iteration over metadata by putting all the keys on the heap
|
|
173
277
|
* and tracking which one we're currently at.
|
|
@@ -216,18 +320,28 @@ struct MismatchesIterator;
|
|
|
216
320
|
*/
|
|
217
321
|
struct Pact;
|
|
218
322
|
|
|
323
|
+
/**
|
|
324
|
+
* Opaque type for use as a pointer to a Pact interaction model
|
|
325
|
+
*/
|
|
326
|
+
struct PactInteraction;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* An iterator over the interactions in a pact.
|
|
330
|
+
*/
|
|
331
|
+
struct PactInteractionIterator;
|
|
332
|
+
|
|
219
333
|
/**
|
|
220
334
|
* An iterator over messages in a pact.
|
|
221
335
|
*/
|
|
222
336
|
struct PactMessageIterator;
|
|
223
337
|
|
|
224
338
|
/**
|
|
225
|
-
* An iterator over synchronous HTTP request/response interactions in a pact.
|
|
339
|
+
* An iterator over synchronous HTTP request/response interactions in a V4 pact.
|
|
226
340
|
*/
|
|
227
341
|
struct PactSyncHttpIterator;
|
|
228
342
|
|
|
229
343
|
/**
|
|
230
|
-
* An iterator over synchronous request/response messages in a pact.
|
|
344
|
+
* An iterator over synchronous request/response messages in a V4 pact.
|
|
231
345
|
*/
|
|
232
346
|
struct PactSyncMessageIterator;
|
|
233
347
|
|
|
@@ -269,6 +383,34 @@ struct SynchronousMessage;
|
|
|
269
383
|
*/
|
|
270
384
|
struct VerifierHandle;
|
|
271
385
|
|
|
386
|
+
/**
|
|
387
|
+
* A single key-value pair of a path and generator exported to the C-side.
|
|
388
|
+
*/
|
|
389
|
+
struct GeneratorKeyValuePair {
|
|
390
|
+
/**
|
|
391
|
+
* The generator path
|
|
392
|
+
*/
|
|
393
|
+
const char *path;
|
|
394
|
+
/**
|
|
395
|
+
* The generator
|
|
396
|
+
*/
|
|
397
|
+
const Generator *generator;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* A single key-value pair of a path and matching rule exported to the C-side.
|
|
402
|
+
*/
|
|
403
|
+
struct MatchingRuleKeyValuePair {
|
|
404
|
+
/**
|
|
405
|
+
* The matching rule path
|
|
406
|
+
*/
|
|
407
|
+
const char *path;
|
|
408
|
+
/**
|
|
409
|
+
* The matching rule
|
|
410
|
+
*/
|
|
411
|
+
const MatchingRule *rule;
|
|
412
|
+
};
|
|
413
|
+
|
|
272
414
|
/**
|
|
273
415
|
* A single key-value pair exported to the C-side.
|
|
274
416
|
*/
|
|
@@ -632,42 +774,28 @@ Pact *pactffi_parse_pact_json(const char *json);
|
|
|
632
774
|
void pactffi_pact_model_delete(Pact *pact);
|
|
633
775
|
|
|
634
776
|
/**
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
* # Usage
|
|
640
|
-
*
|
|
641
|
-
* ```c
|
|
642
|
-
* // Assuming `file_name` and `json_str` are already defined.
|
|
643
|
-
*
|
|
644
|
-
* MessagePact *message_pact = pactffi_message_pact_new_from_json(file_name, json_str);
|
|
645
|
-
* if (message_pact == NULLPTR) {
|
|
646
|
-
* // handle error.
|
|
647
|
-
* }
|
|
648
|
-
*
|
|
649
|
-
* Consumer *consumer = pactffi_message_pact_get_consumer(message_pact);
|
|
650
|
-
* if (consumer == NULLPTR) {
|
|
651
|
-
* // handle error.
|
|
652
|
-
* }
|
|
777
|
+
* Returns an iterator over all the interactions in the Pact. The iterator will have to be
|
|
778
|
+
* deleted using the `pactffi_pact_interaction_iter_delete` function. The iterator will
|
|
779
|
+
* contain a copy of the interactions, so it will not be affected but mutations to the Pact
|
|
780
|
+
* model and will still function if the Pact model is deleted.
|
|
653
781
|
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
* // handle error.
|
|
657
|
-
* }
|
|
658
|
-
*
|
|
659
|
-
* printf("%s\n", name);
|
|
660
|
-
*
|
|
661
|
-
* pactffi_string_delete(name);
|
|
662
|
-
* ```
|
|
782
|
+
* # Safety
|
|
783
|
+
* This function is safe as long as the Pact pointer is a valid pointer.
|
|
663
784
|
*
|
|
664
785
|
* # Errors
|
|
665
|
-
*
|
|
666
|
-
* This function will fail if it is passed a NULL pointer,
|
|
667
|
-
* or the Rust string contains an embedded NULL byte.
|
|
668
|
-
* In the case of error, a NULL pointer will be returned.
|
|
786
|
+
* On any error, this function will return a NULL pointer.
|
|
669
787
|
*/
|
|
670
|
-
|
|
788
|
+
PactInteractionIterator *pactffi_pact_model_interaction_iterator(Pact *pact);
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Returns the Pact specification enum that the Pact is for.
|
|
792
|
+
*/
|
|
793
|
+
PactSpecification pactffi_pact_spec_version(const Pact *pact);
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Frees the memory used by the Pact interaction model
|
|
797
|
+
*/
|
|
798
|
+
void pactffi_pact_interaction_delete(const PactInteraction *interaction);
|
|
671
799
|
|
|
672
800
|
/**
|
|
673
801
|
* Get a mutable pointer to a newly-created default message on the heap.
|
|
@@ -680,43 +808,29 @@ const char *pactffi_consumer_get_name(const Consumer *consumer);
|
|
|
680
808
|
*
|
|
681
809
|
* Returns NULL on error.
|
|
682
810
|
*/
|
|
683
|
-
|
|
811
|
+
AsynchronousMessage *pactffi_async_message_new();
|
|
684
812
|
|
|
685
813
|
/**
|
|
686
|
-
*
|
|
687
|
-
*
|
|
688
|
-
* # Safety
|
|
689
|
-
*
|
|
690
|
-
* This function is safe.
|
|
691
|
-
*
|
|
692
|
-
* # Error Handling
|
|
693
|
-
*
|
|
694
|
-
* If the JSON string is invalid or not UTF-8 encoded, returns a NULL.
|
|
814
|
+
* Destroy the `AsynchronousMessage` being pointed to.
|
|
695
815
|
*/
|
|
696
|
-
|
|
697
|
-
const char *json_str,
|
|
698
|
-
PactSpecification spec_version);
|
|
816
|
+
void pactffi_async_message_delete(const AsynchronousMessage *message);
|
|
699
817
|
|
|
700
818
|
/**
|
|
701
|
-
*
|
|
819
|
+
* Get the message contents of an `AsynchronousMessage` as a `MessageContents` pointer.
|
|
702
820
|
*
|
|
703
821
|
* # Safety
|
|
704
822
|
*
|
|
705
|
-
*
|
|
823
|
+
* The data pointed to by the pointer this function returns will be deleted when the message
|
|
824
|
+
* is deleted. Trying to use if after the message is deleted will result in undefined behaviour.
|
|
706
825
|
*
|
|
707
826
|
* # Error Handling
|
|
708
827
|
*
|
|
709
|
-
* If the
|
|
710
|
-
*/
|
|
711
|
-
Message *pactffi_message_new_from_body(const char *body, const char *content_type);
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
* Destroy the `Message` being pointed to.
|
|
828
|
+
* If the message is NULL, returns NULL.
|
|
715
829
|
*/
|
|
716
|
-
|
|
830
|
+
const MessageContents *pactffi_async_message_get_contents(const AsynchronousMessage *message);
|
|
717
831
|
|
|
718
832
|
/**
|
|
719
|
-
* Get the contents of
|
|
833
|
+
* Get the message contents of an `AsynchronousMessage` in string form.
|
|
720
834
|
*
|
|
721
835
|
* # Safety
|
|
722
836
|
*
|
|
@@ -731,10 +845,14 @@ void pactffi_message_delete(Message *message);
|
|
|
731
845
|
* no mechanism to differentiate with this function call alone between
|
|
732
846
|
* a NULL message and a missing message body.
|
|
733
847
|
*/
|
|
734
|
-
const char *
|
|
848
|
+
const char *pactffi_async_message_get_contents_str(const AsynchronousMessage *message);
|
|
735
849
|
|
|
736
850
|
/**
|
|
737
|
-
* Sets the contents of the message.
|
|
851
|
+
* Sets the contents of the message as a string.
|
|
852
|
+
*
|
|
853
|
+
* * `message` - the message to set the contents for
|
|
854
|
+
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
855
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
738
856
|
*
|
|
739
857
|
* # Safety
|
|
740
858
|
*
|
|
@@ -746,10 +864,12 @@ const char *pactffi_message_get_contents(const Message *message);
|
|
|
746
864
|
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
747
865
|
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
748
866
|
*/
|
|
749
|
-
void
|
|
867
|
+
void pactffi_async_message_set_contents_str(AsynchronousMessage *message,
|
|
868
|
+
const char *contents,
|
|
869
|
+
const char *content_type);
|
|
750
870
|
|
|
751
871
|
/**
|
|
752
|
-
* Get the length of the contents of a `
|
|
872
|
+
* Get the length of the contents of a `AsynchronousMessage`.
|
|
753
873
|
*
|
|
754
874
|
* # Safety
|
|
755
875
|
*
|
|
@@ -757,17 +877,17 @@ void pactffi_message_set_contents(Message *message, const char *contents, const
|
|
|
757
877
|
*
|
|
758
878
|
* # Error Handling
|
|
759
879
|
*
|
|
760
|
-
* If the message is NULL, returns 0. If the body of the
|
|
880
|
+
* If the message is NULL, returns 0. If the body of the request
|
|
761
881
|
* is missing, then this function also returns 0.
|
|
762
882
|
*/
|
|
763
|
-
size_t
|
|
883
|
+
size_t pactffi_async_message_get_contents_length(const AsynchronousMessage *message);
|
|
764
884
|
|
|
765
885
|
/**
|
|
766
|
-
* Get the contents of
|
|
886
|
+
* Get the contents of an `AsynchronousMessage` as a pointer to an array of bytes.
|
|
767
887
|
*
|
|
768
888
|
* # Safety
|
|
769
889
|
*
|
|
770
|
-
* The number of bytes in the buffer will be returned by `
|
|
890
|
+
* The number of bytes in the buffer will be returned by `pactffi_async_message_get_contents_length`.
|
|
771
891
|
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
772
892
|
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
773
893
|
*
|
|
@@ -776,11 +896,16 @@ size_t pactffi_message_get_contents_length(const Message *message);
|
|
|
776
896
|
* If the message is NULL, returns NULL. If the body of the message
|
|
777
897
|
* is missing, then this function also returns NULL.
|
|
778
898
|
*/
|
|
779
|
-
const unsigned char *
|
|
899
|
+
const unsigned char *pactffi_async_message_get_contents_bin(const AsynchronousMessage *message);
|
|
780
900
|
|
|
781
901
|
/**
|
|
782
902
|
* Sets the contents of the message as an array of bytes.
|
|
783
903
|
*
|
|
904
|
+
* * `message` - the message to set the contents for
|
|
905
|
+
* * `contents` - pointer to contents to copy from
|
|
906
|
+
* * `len` - number of bytes to copy from the contents pointer
|
|
907
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
908
|
+
*
|
|
784
909
|
* # Safety
|
|
785
910
|
*
|
|
786
911
|
* The contents pointer must be valid for reads of `len` bytes, and it must be properly aligned
|
|
@@ -791,10 +916,10 @@ const unsigned char *pactffi_message_get_contents_bin(const Message *message);
|
|
|
791
916
|
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
792
917
|
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
793
918
|
*/
|
|
794
|
-
void
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
919
|
+
void pactffi_async_message_set_contents_bin(AsynchronousMessage *message,
|
|
920
|
+
const unsigned char *contents,
|
|
921
|
+
size_t len,
|
|
922
|
+
const char *content_type);
|
|
798
923
|
|
|
799
924
|
/**
|
|
800
925
|
* Get a copy of the description.
|
|
@@ -803,8 +928,7 @@ void pactffi_message_set_contents_bin(Message *message,
|
|
|
803
928
|
*
|
|
804
929
|
* The returned string must be deleted with `pactffi_string_delete`.
|
|
805
930
|
*
|
|
806
|
-
* Since it is a copy, the returned string may safely outlive
|
|
807
|
-
* the `Message`.
|
|
931
|
+
* Since it is a copy, the returned string may safely outlive the `AsynchronousMessage`.
|
|
808
932
|
*
|
|
809
933
|
* # Errors
|
|
810
934
|
*
|
|
@@ -813,10 +937,10 @@ void pactffi_message_set_contents_bin(Message *message,
|
|
|
813
937
|
* This function may fail if the Rust string contains embedded
|
|
814
938
|
* null ('\0') bytes.
|
|
815
939
|
*/
|
|
816
|
-
const char *
|
|
940
|
+
const char *pactffi_async_message_get_description(const AsynchronousMessage *message);
|
|
817
941
|
|
|
818
942
|
/**
|
|
819
|
-
* Write the `description` field on the `
|
|
943
|
+
* Write the `description` field on the `AsynchronousMessage`.
|
|
820
944
|
*
|
|
821
945
|
* # Safety
|
|
822
946
|
*
|
|
@@ -830,7 +954,7 @@ const char *pactffi_message_get_description(const Message *message);
|
|
|
830
954
|
*
|
|
831
955
|
* Errors will be reported with a non-zero return value.
|
|
832
956
|
*/
|
|
833
|
-
int
|
|
957
|
+
int pactffi_async_message_set_description(AsynchronousMessage *message, const char *description);
|
|
834
958
|
|
|
835
959
|
/**
|
|
836
960
|
* Get a copy of the provider state at the given index from this message.
|
|
@@ -839,8 +963,7 @@ int pactffi_message_set_description(Message *message, const char *description);
|
|
|
839
963
|
*
|
|
840
964
|
* The returned structure must be deleted with `provider_state_delete`.
|
|
841
965
|
*
|
|
842
|
-
* Since it is a copy, the returned structure may safely outlive
|
|
843
|
-
* the `Message`.
|
|
966
|
+
* Since it is a copy, the returned structure may safely outlive the `AsynchronousMessage`.
|
|
844
967
|
*
|
|
845
968
|
* # Error Handling
|
|
846
969
|
*
|
|
@@ -849,7 +972,8 @@ int pactffi_message_set_description(Message *message, const char *description);
|
|
|
849
972
|
* This function may fail if the index requested is out of bounds,
|
|
850
973
|
* or if any of the Rust strings contain embedded null ('\0') bytes.
|
|
851
974
|
*/
|
|
852
|
-
const ProviderState *
|
|
975
|
+
const ProviderState *pactffi_async_message_get_provider_state(const AsynchronousMessage *message,
|
|
976
|
+
unsigned int index);
|
|
853
977
|
|
|
854
978
|
/**
|
|
855
979
|
* Get an iterator over provider states.
|
|
@@ -862,381 +986,385 @@ const ProviderState *pactffi_message_get_provider_state(const Message *message,
|
|
|
862
986
|
*
|
|
863
987
|
* Returns NULL if an error occurs.
|
|
864
988
|
*/
|
|
865
|
-
ProviderStateIterator *
|
|
989
|
+
ProviderStateIterator *pactffi_async_message_get_provider_state_iter(AsynchronousMessage *message);
|
|
866
990
|
|
|
867
991
|
/**
|
|
868
|
-
* Get
|
|
992
|
+
* Get a copy of this consumer's name.
|
|
869
993
|
*
|
|
870
|
-
*
|
|
994
|
+
* The copy must be deleted with `pactffi_string_delete`.
|
|
871
995
|
*
|
|
872
|
-
*
|
|
996
|
+
* # Usage
|
|
873
997
|
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
998
|
+
* ```c
|
|
999
|
+
* // Assuming `file_name` and `json_str` are already defined.
|
|
876
1000
|
*
|
|
877
|
-
*
|
|
1001
|
+
* MessagePact *message_pact = pactffi_message_pact_new_from_json(file_name, json_str);
|
|
1002
|
+
* if (message_pact == NULLPTR) {
|
|
1003
|
+
* // handle error.
|
|
1004
|
+
* }
|
|
878
1005
|
*
|
|
879
|
-
*
|
|
1006
|
+
* Consumer *consumer = pactffi_message_pact_get_consumer(message_pact);
|
|
1007
|
+
* if (consumer == NULLPTR) {
|
|
1008
|
+
* // handle error.
|
|
1009
|
+
* }
|
|
1010
|
+
*
|
|
1011
|
+
* char *name = pactffi_consumer_get_name(consumer);
|
|
1012
|
+
* if (name == NULL) {
|
|
1013
|
+
* // handle error.
|
|
1014
|
+
* }
|
|
1015
|
+
*
|
|
1016
|
+
* printf("%s\n", name);
|
|
1017
|
+
*
|
|
1018
|
+
* pactffi_string_delete(name);
|
|
1019
|
+
* ```
|
|
1020
|
+
*
|
|
1021
|
+
* # Errors
|
|
1022
|
+
*
|
|
1023
|
+
* This function will fail if it is passed a NULL pointer,
|
|
1024
|
+
* or the Rust string contains an embedded NULL byte.
|
|
1025
|
+
* In the case of error, a NULL pointer will be returned.
|
|
880
1026
|
*/
|
|
881
|
-
|
|
1027
|
+
const char *pactffi_consumer_get_name(const Consumer *consumer);
|
|
882
1028
|
|
|
883
1029
|
/**
|
|
884
|
-
*
|
|
1030
|
+
* Get the consumer from a Pact. This returns a copy of the consumer model, and needs to
|
|
1031
|
+
* be cleaned up with `pactffi_pact_consumer_delete` when no longer required.
|
|
1032
|
+
*
|
|
1033
|
+
* # Errors
|
|
1034
|
+
*
|
|
1035
|
+
* This function will fail if it is passed a NULL pointer.
|
|
1036
|
+
* In the case of error, a NULL pointer will be returned.
|
|
885
1037
|
*/
|
|
886
|
-
|
|
1038
|
+
const Consumer *pactffi_pact_get_consumer(const Pact *pact);
|
|
887
1039
|
|
|
888
1040
|
/**
|
|
889
|
-
*
|
|
1041
|
+
* Frees the memory used by the Pact consumer
|
|
1042
|
+
*/
|
|
1043
|
+
void pactffi_pact_consumer_delete(const Consumer *consumer);
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Get the message contents in string form.
|
|
890
1047
|
*
|
|
891
1048
|
* # Safety
|
|
892
1049
|
*
|
|
893
1050
|
* The returned string must be deleted with `pactffi_string_delete`.
|
|
894
1051
|
*
|
|
895
|
-
*
|
|
896
|
-
* the `Message`.
|
|
897
|
-
*
|
|
898
|
-
* The returned pointer will be NULL if the metadata does not contain
|
|
899
|
-
* the given key, or if an error occurred.
|
|
1052
|
+
* The returned string can outlive the message.
|
|
900
1053
|
*
|
|
901
1054
|
* # Error Handling
|
|
902
1055
|
*
|
|
903
|
-
*
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
*
|
|
907
|
-
* bytes.
|
|
1056
|
+
* If the message contents is NULL, returns NULL. If the body of the message
|
|
1057
|
+
* is missing, then this function also returns NULL. This means there's
|
|
1058
|
+
* no mechanism to differentiate with this function call alone between
|
|
1059
|
+
* a NULL message and a missing message body.
|
|
908
1060
|
*/
|
|
909
|
-
const char *
|
|
1061
|
+
const char *pactffi_message_contents_get_contents_str(const MessageContents *contents);
|
|
910
1062
|
|
|
911
1063
|
/**
|
|
912
|
-
*
|
|
913
|
-
*
|
|
1064
|
+
* Sets the contents of the message as a string.
|
|
1065
|
+
*
|
|
1066
|
+
* * `contents` - the message contents to set the contents for
|
|
1067
|
+
* * `contents_str` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
1068
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
914
1069
|
*
|
|
915
1070
|
* # Safety
|
|
916
1071
|
*
|
|
917
|
-
*
|
|
918
|
-
*
|
|
1072
|
+
* The message contents and content type must either be NULL pointers, or point to valid
|
|
1073
|
+
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
919
1074
|
*
|
|
920
1075
|
* # Error Handling
|
|
921
1076
|
*
|
|
922
|
-
*
|
|
923
|
-
*
|
|
1077
|
+
* If the contents string is a NULL pointer, it will set the message contents as null. If the content
|
|
1078
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
924
1079
|
*/
|
|
925
|
-
|
|
1080
|
+
void pactffi_message_contents_set_contents_str(MessageContents *contents,
|
|
1081
|
+
const char *contents_str,
|
|
1082
|
+
const char *content_type);
|
|
926
1083
|
|
|
927
1084
|
/**
|
|
928
|
-
* Get
|
|
1085
|
+
* Get the length of the message contents.
|
|
929
1086
|
*
|
|
930
1087
|
* # Safety
|
|
931
1088
|
*
|
|
932
|
-
* This
|
|
933
|
-
* not outlive the message.
|
|
934
|
-
*
|
|
935
|
-
* The message metadata also must not be modified during iteration. If it is,
|
|
936
|
-
* the old iterator must be deleted and a new iterator created.
|
|
1089
|
+
* This function is safe.
|
|
937
1090
|
*
|
|
938
1091
|
* # Error Handling
|
|
939
1092
|
*
|
|
940
|
-
*
|
|
941
|
-
*
|
|
942
|
-
* This function may fail if any of the Rust strings contain
|
|
943
|
-
* embedded null ('\0') bytes.
|
|
1093
|
+
* If the message is NULL, returns 0. If the body of the message
|
|
1094
|
+
* is missing, then this function also returns 0.
|
|
944
1095
|
*/
|
|
945
|
-
|
|
1096
|
+
size_t pactffi_message_contents_get_contents_length(const MessageContents *contents);
|
|
946
1097
|
|
|
947
1098
|
/**
|
|
948
|
-
* Get the
|
|
1099
|
+
* Get the contents of a message as a pointer to an array of bytes.
|
|
949
1100
|
*
|
|
950
1101
|
* # Safety
|
|
951
1102
|
*
|
|
952
|
-
* The
|
|
1103
|
+
* The number of bytes in the buffer will be returned by `pactffi_message_contents_get_contents_length`.
|
|
1104
|
+
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
1105
|
+
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
953
1106
|
*
|
|
954
1107
|
* # Error Handling
|
|
955
1108
|
*
|
|
956
|
-
* If
|
|
957
|
-
|
|
958
|
-
MessageMetadataPair *pactffi_message_metadata_iter_next(MessageMetadataIterator *iter);
|
|
959
|
-
|
|
960
|
-
/**
|
|
961
|
-
* Free the metadata iterator when you're done using it.
|
|
962
|
-
*/
|
|
963
|
-
void pactffi_message_metadata_iter_delete(MessageMetadataIterator *iter);
|
|
964
|
-
|
|
965
|
-
/**
|
|
966
|
-
* Free a pair of key and value returned from `message_metadata_iter_next`.
|
|
1109
|
+
* If the message is NULL, returns NULL. If the body of the message
|
|
1110
|
+
* is missing, then this function also returns NULL.
|
|
967
1111
|
*/
|
|
968
|
-
|
|
1112
|
+
const unsigned char *pactffi_message_contents_get_contents_bin(const MessageContents *contents);
|
|
969
1113
|
|
|
970
1114
|
/**
|
|
971
|
-
*
|
|
972
|
-
*
|
|
1115
|
+
* Sets the contents of the message as an array of bytes.
|
|
1116
|
+
*
|
|
1117
|
+
* * `message` - the message contents to set the contents for
|
|
1118
|
+
* * `contents_bin` - pointer to contents to copy from
|
|
1119
|
+
* * `len` - number of bytes to copy from the contents pointer
|
|
1120
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
973
1121
|
*
|
|
974
1122
|
* # Safety
|
|
975
1123
|
*
|
|
976
|
-
* The `
|
|
977
|
-
*
|
|
1124
|
+
* The contents pointer must be valid for reads of `len` bytes, and it must be properly aligned
|
|
1125
|
+
* and consecutive. Otherwise behaviour is undefined.
|
|
978
1126
|
*
|
|
979
1127
|
* # Error Handling
|
|
980
1128
|
*
|
|
981
|
-
*
|
|
982
|
-
|
|
983
|
-
MessagePact *pactffi_message_pact_new_from_json(const char *file_name, const char *json_str);
|
|
984
|
-
|
|
985
|
-
/**
|
|
986
|
-
* Delete the `MessagePact` being pointed to.
|
|
1129
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
1130
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
987
1131
|
*/
|
|
988
|
-
void
|
|
1132
|
+
void pactffi_message_contents_set_contents_bin(MessageContents *contents,
|
|
1133
|
+
const unsigned char *contents_bin,
|
|
1134
|
+
size_t len,
|
|
1135
|
+
const char *content_type);
|
|
989
1136
|
|
|
990
1137
|
/**
|
|
991
|
-
* Get
|
|
992
|
-
*
|
|
993
|
-
*
|
|
1138
|
+
* Get an iterator over the metadata of a message.
|
|
1139
|
+
*
|
|
1140
|
+
* The returned pointer must be deleted with `pactffi_message_metadata_iter_delete` when done
|
|
1141
|
+
* with it.
|
|
994
1142
|
*
|
|
995
1143
|
* # Safety
|
|
996
1144
|
*
|
|
997
|
-
* This
|
|
1145
|
+
* This iterator carries a pointer to the message contents, and must
|
|
1146
|
+
* not outlive the message.
|
|
1147
|
+
*
|
|
1148
|
+
* The message metadata also must not be modified during iteration. If it is,
|
|
1149
|
+
* the old iterator must be deleted and a new iterator created.
|
|
998
1150
|
*
|
|
999
1151
|
* # Error Handling
|
|
1000
1152
|
*
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
1153
|
+
* On failure, this function will return a NULL pointer.
|
|
1154
|
+
*
|
|
1155
|
+
* This function may fail if any of the Rust strings contain
|
|
1156
|
+
* embedded null ('\0') bytes.
|
|
1003
1157
|
*/
|
|
1004
|
-
|
|
1158
|
+
MessageMetadataIterator *pactffi_message_contents_get_metadata_iter(const MessageContents *contents);
|
|
1005
1159
|
|
|
1006
1160
|
/**
|
|
1007
|
-
* Get
|
|
1008
|
-
* This is a mutable borrow: The caller may mutate the Provider
|
|
1009
|
-
* through this pointer.
|
|
1161
|
+
* Get an iterator over the matching rules for a category of a message.
|
|
1010
1162
|
*
|
|
1011
|
-
*
|
|
1163
|
+
* The returned pointer must be deleted with `pactffi_matching_rules_iter_delete` when done
|
|
1164
|
+
* with it.
|
|
1012
1165
|
*
|
|
1013
|
-
*
|
|
1166
|
+
* Note that there could be multiple matching rules for the same key, so this iterator will
|
|
1167
|
+
* sequentially return each rule with the same key.
|
|
1014
1168
|
*
|
|
1015
|
-
*
|
|
1169
|
+
* For sample, given the following rules:
|
|
1170
|
+
* "$.a" => Type,
|
|
1171
|
+
* "$.b" => Regex("\\d+"), Number
|
|
1016
1172
|
*
|
|
1017
|
-
* This
|
|
1018
|
-
* In the case of error, a NULL pointer will be returned.
|
|
1019
|
-
*/
|
|
1020
|
-
Provider *pactffi_message_pact_get_provider(MessagePact *message_pact);
|
|
1021
|
-
|
|
1022
|
-
/**
|
|
1023
|
-
* Get an iterator over the messages of a message pact.
|
|
1173
|
+
* This iterator will return a sequence of 3 values: ("$.a", Type), ("$.b", Regex("\\d+")), ("$.b", Number)
|
|
1024
1174
|
*
|
|
1025
1175
|
* # Safety
|
|
1026
1176
|
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
* The message pact messages also must not be modified during iteration.
|
|
1031
|
-
* If they are, the old iterator must be deleted and a new iterator created.
|
|
1177
|
+
* The iterator contains a copy of the data, so is safe to use when the message or message
|
|
1178
|
+
* contents has been deleted.
|
|
1032
1179
|
*
|
|
1033
1180
|
* # Error Handling
|
|
1034
1181
|
*
|
|
1035
1182
|
* On failure, this function will return a NULL pointer.
|
|
1036
|
-
*
|
|
1037
|
-
* This function may fail if any of the Rust strings contain embedded
|
|
1038
|
-
* null ('\0') bytes.
|
|
1039
1183
|
*/
|
|
1040
|
-
|
|
1184
|
+
MatchingRuleCategoryIterator *pactffi_message_contents_get_matching_rule_iter(const MessageContents *contents,
|
|
1185
|
+
MatchingRuleCategory category);
|
|
1041
1186
|
|
|
1042
1187
|
/**
|
|
1043
|
-
* Get the
|
|
1044
|
-
*
|
|
1045
|
-
* # Safety
|
|
1188
|
+
* Get an iterator over the matching rules for a category of an HTTP request.
|
|
1046
1189
|
*
|
|
1047
|
-
*
|
|
1190
|
+
* The returned pointer must be deleted with `pactffi_matching_rules_iter_delete` when done
|
|
1191
|
+
* with it.
|
|
1048
1192
|
*
|
|
1049
|
-
*
|
|
1193
|
+
* For sample, given the following rules:
|
|
1194
|
+
* "$.a" => Type,
|
|
1195
|
+
* "$.b" => Regex("\\d+"), Number
|
|
1050
1196
|
*
|
|
1051
|
-
* This
|
|
1052
|
-
*/
|
|
1053
|
-
Message *pactffi_message_pact_message_iter_next(MessagePactMessageIterator *iter);
|
|
1054
|
-
|
|
1055
|
-
/**
|
|
1056
|
-
* Delete the iterator.
|
|
1057
|
-
*/
|
|
1058
|
-
void pactffi_message_pact_message_iter_delete(MessagePactMessageIterator *iter);
|
|
1059
|
-
|
|
1060
|
-
/**
|
|
1061
|
-
* Get a copy of the metadata value indexed by `key1` and `key2`.
|
|
1197
|
+
* This iterator will return a sequence of 3 values: ("$.a", Type), ("$.b", Regex("\\d+")), ("$.b", Number)
|
|
1062
1198
|
*
|
|
1063
1199
|
* # Safety
|
|
1064
1200
|
*
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1068
|
-
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1069
|
-
*
|
|
1070
|
-
* The returned pointer will be NULL if the metadata does not contain
|
|
1071
|
-
* the given key, or if an error occurred.
|
|
1201
|
+
* The iterator contains a copy of the data, so is safe to use when the interaction or request
|
|
1202
|
+
* contents has been deleted.
|
|
1072
1203
|
*
|
|
1073
1204
|
* # Error Handling
|
|
1074
1205
|
*
|
|
1075
1206
|
* On failure, this function will return a NULL pointer.
|
|
1076
|
-
*
|
|
1077
|
-
* This function may fail if the provided `key1` or `key2` strings contains
|
|
1078
|
-
* invalid UTF-8, or if the Rust string contains embedded null ('\0')
|
|
1079
|
-
* bytes.
|
|
1080
1207
|
*/
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
const char *key2);
|
|
1208
|
+
MatchingRuleCategoryIterator *pactffi_request_contents_get_matching_rule_iter(const HttpRequest *request,
|
|
1209
|
+
MatchingRuleCategory category);
|
|
1084
1210
|
|
|
1085
1211
|
/**
|
|
1086
|
-
* Get an iterator over the
|
|
1212
|
+
* Get an iterator over the matching rules for a category of an HTTP response.
|
|
1087
1213
|
*
|
|
1088
|
-
*
|
|
1214
|
+
* The returned pointer must be deleted with `pactffi_matching_rules_iter_delete` when done
|
|
1215
|
+
* with it.
|
|
1089
1216
|
*
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1217
|
+
* For sample, given the following rules:
|
|
1218
|
+
* "$.a" => Type,
|
|
1219
|
+
* "$.b" => Regex("\\d+"), Number
|
|
1092
1220
|
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1221
|
+
* This iterator will return a sequence of 3 values: ("$.a", Type), ("$.b", Regex("\\d+")), ("$.b", Number)
|
|
1222
|
+
*
|
|
1223
|
+
* # Safety
|
|
1224
|
+
*
|
|
1225
|
+
* The iterator contains a copy of the data, so is safe to use when the interaction or response
|
|
1226
|
+
* contents has been deleted.
|
|
1095
1227
|
*
|
|
1096
1228
|
* # Error Handling
|
|
1097
1229
|
*
|
|
1098
1230
|
* On failure, this function will return a NULL pointer.
|
|
1099
|
-
*
|
|
1100
|
-
* This function may fail if any of the Rust strings contain
|
|
1101
|
-
* embedded null ('\0') bytes.
|
|
1102
1231
|
*/
|
|
1103
|
-
|
|
1232
|
+
MatchingRuleCategoryIterator *pactffi_response_contents_get_matching_rule_iter(const HttpResponse *response,
|
|
1233
|
+
MatchingRuleCategory category);
|
|
1104
1234
|
|
|
1105
1235
|
/**
|
|
1106
|
-
* Get the
|
|
1236
|
+
* Get an iterator over the generators for a category of a message.
|
|
1237
|
+
*
|
|
1238
|
+
* The returned pointer must be deleted with `pactffi_generators_iter_delete` when done
|
|
1239
|
+
* with it.
|
|
1107
1240
|
*
|
|
1108
1241
|
* # Safety
|
|
1109
1242
|
*
|
|
1110
|
-
*
|
|
1243
|
+
* The iterator contains a copy of the data, so is safe to use when the message or message
|
|
1244
|
+
* contents has been deleted.
|
|
1111
1245
|
*
|
|
1112
1246
|
* # Error Handling
|
|
1113
1247
|
*
|
|
1114
|
-
*
|
|
1115
|
-
*/
|
|
1116
|
-
MessagePactMetadataTriple *pactffi_message_pact_metadata_iter_next(MessagePactMetadataIterator *iter);
|
|
1117
|
-
|
|
1118
|
-
/**
|
|
1119
|
-
* Free the metadata iterator when you're done using it.
|
|
1120
|
-
*/
|
|
1121
|
-
void pactffi_message_pact_metadata_iter_delete(MessagePactMetadataIterator *iter);
|
|
1122
|
-
|
|
1123
|
-
/**
|
|
1124
|
-
* Free a triple returned from `pactffi_message_pact_metadata_iter_next`.
|
|
1248
|
+
* On failure, this function will return a NULL pointer.
|
|
1125
1249
|
*/
|
|
1126
|
-
|
|
1250
|
+
GeneratorCategoryIterator *pactffi_message_contents_get_generators_iter(const MessageContents *contents,
|
|
1251
|
+
GeneratorCategory category);
|
|
1127
1252
|
|
|
1128
1253
|
/**
|
|
1129
|
-
* Get a
|
|
1130
|
-
*
|
|
1131
|
-
* The copy must be deleted with `pactffi_string_delete`.
|
|
1132
|
-
*
|
|
1133
|
-
* # Usage
|
|
1134
|
-
*
|
|
1135
|
-
* ```c
|
|
1136
|
-
* // Assuming `file_name` and `json_str` are already defined.
|
|
1137
|
-
*
|
|
1138
|
-
* MessagePact *message_pact = pactffi_message_pact_new_from_json(file_name, json_str);
|
|
1139
|
-
* if (message_pact == NULLPTR) {
|
|
1140
|
-
* // handle error.
|
|
1141
|
-
* }
|
|
1142
|
-
*
|
|
1143
|
-
* Provider *provider = pactffi_message_pact_get_provider(message_pact);
|
|
1144
|
-
* if (provider == NULLPTR) {
|
|
1145
|
-
* // handle error.
|
|
1146
|
-
* }
|
|
1254
|
+
* Get an iterator over the generators for a category of an HTTP request.
|
|
1147
1255
|
*
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1150
|
-
* // handle error.
|
|
1151
|
-
* }
|
|
1256
|
+
* The returned pointer must be deleted with `pactffi_generators_iter_delete` when done
|
|
1257
|
+
* with it.
|
|
1152
1258
|
*
|
|
1153
|
-
*
|
|
1259
|
+
* # Safety
|
|
1154
1260
|
*
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1261
|
+
* The iterator contains a copy of the data, so is safe to use when the interaction or request
|
|
1262
|
+
* contents has been deleted.
|
|
1157
1263
|
*
|
|
1158
|
-
* #
|
|
1264
|
+
* # Error Handling
|
|
1159
1265
|
*
|
|
1160
|
-
*
|
|
1161
|
-
* or the Rust string contains an embedded NULL byte.
|
|
1162
|
-
* In the case of error, a NULL pointer will be returned.
|
|
1266
|
+
* On failure, this function will return a NULL pointer.
|
|
1163
1267
|
*/
|
|
1164
|
-
|
|
1268
|
+
GeneratorCategoryIterator *pactffi_request_contents_get_generators_iter(const HttpRequest *request,
|
|
1269
|
+
GeneratorCategory category);
|
|
1165
1270
|
|
|
1166
1271
|
/**
|
|
1167
|
-
* Get
|
|
1272
|
+
* Get an iterator over the generators for a category of an HTTP response.
|
|
1273
|
+
*
|
|
1274
|
+
* The returned pointer must be deleted with `pactffi_generators_iter_delete` when done
|
|
1275
|
+
* with it.
|
|
1168
1276
|
*
|
|
1169
1277
|
* # Safety
|
|
1170
1278
|
*
|
|
1171
|
-
*
|
|
1279
|
+
* The iterator contains a copy of the data, so is safe to use when the interaction or response
|
|
1280
|
+
* contents has been deleted.
|
|
1172
1281
|
*
|
|
1173
1282
|
* # Error Handling
|
|
1174
1283
|
*
|
|
1175
|
-
*
|
|
1284
|
+
* On failure, this function will return a NULL pointer.
|
|
1176
1285
|
*/
|
|
1177
|
-
|
|
1286
|
+
GeneratorCategoryIterator *pactffi_response_contents_get_generators_iter(const HttpResponse *response,
|
|
1287
|
+
GeneratorCategory category);
|
|
1178
1288
|
|
|
1179
1289
|
/**
|
|
1180
|
-
*
|
|
1290
|
+
* Parse a matcher definition string into a MatchingRuleDefinition containing the example value,
|
|
1291
|
+
* and matching rules and any generator.
|
|
1181
1292
|
*
|
|
1182
|
-
*
|
|
1293
|
+
* The following are examples of matching rule definitions:
|
|
1294
|
+
* * `matching(type,'Name')` - type matcher with string value 'Name'
|
|
1295
|
+
* * `matching(number,100)` - number matcher
|
|
1296
|
+
* * `matching(datetime, 'yyyy-MM-dd','2000-01-01')` - datetime matcher with format string
|
|
1183
1297
|
*
|
|
1184
|
-
*
|
|
1185
|
-
* not outlive the provider state.
|
|
1298
|
+
* See [Matching Rule definition expressions](https://docs.rs/pact_models/latest/pact_models/matchingrules/expressions/index.html).
|
|
1186
1299
|
*
|
|
1187
|
-
* The
|
|
1188
|
-
* the old iterator must be deleted and a new iterator created.
|
|
1300
|
+
* The returned value needs to be freed up with the `pactffi_matcher_definition_delete` function.
|
|
1189
1301
|
*
|
|
1190
1302
|
* # Errors
|
|
1303
|
+
* If the expression is invalid, the MatchingRuleDefinition error will be set. You can check for
|
|
1304
|
+
* this value with the `pactffi_matcher_definition_error` function.
|
|
1191
1305
|
*
|
|
1192
|
-
*
|
|
1306
|
+
* # Safety
|
|
1193
1307
|
*
|
|
1194
|
-
* This function
|
|
1195
|
-
* embedded null ('\0') bytes.
|
|
1308
|
+
* This function is safe if the expression is a valid NULL terminated string pointer.
|
|
1196
1309
|
*/
|
|
1197
|
-
|
|
1310
|
+
const MatchingRuleDefinitionResult *pactffi_parse_matcher_definition(const char *expression);
|
|
1198
1311
|
|
|
1199
1312
|
/**
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1203
|
-
|
|
1204
|
-
*
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1209
|
-
* The
|
|
1210
|
-
*
|
|
1211
|
-
* # Error Handling
|
|
1313
|
+
* Returns any error message from parsing a matching definition expression. If there is no error,
|
|
1314
|
+
* it will return a NULL pointer, otherwise returns the error message as a NULL-terminated string.
|
|
1315
|
+
* The returned string must be freed using the `pactffi_string_delete` function once done with it.
|
|
1316
|
+
*/
|
|
1317
|
+
const char *pactffi_matcher_definition_error(const MatchingRuleDefinitionResult *definition);
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* Returns the value from parsing a matching definition expression. If there was an error,
|
|
1321
|
+
* it will return a NULL pointer, otherwise returns the value as a NULL-terminated string.
|
|
1322
|
+
* The returned string must be freed using the `pactffi_string_delete` function once done with it.
|
|
1212
1323
|
*
|
|
1213
|
-
*
|
|
1324
|
+
* Note that different expressions values can have types other than a string. Use
|
|
1325
|
+
* `pactffi_matcher_definition_value_type` to get the actual type of the value. This function
|
|
1326
|
+
* will always return the string representation of the value.
|
|
1214
1327
|
*/
|
|
1215
|
-
|
|
1328
|
+
const char *pactffi_matcher_definition_value(const MatchingRuleDefinitionResult *definition);
|
|
1216
1329
|
|
|
1217
1330
|
/**
|
|
1218
|
-
*
|
|
1331
|
+
* Frees the memory used by the result of parsing the matching definition expression
|
|
1219
1332
|
*/
|
|
1220
|
-
void
|
|
1333
|
+
void pactffi_matcher_definition_delete(const MatchingRuleDefinitionResult *definition);
|
|
1221
1334
|
|
|
1222
1335
|
/**
|
|
1223
|
-
*
|
|
1336
|
+
* Returns the generator from parsing a matching definition expression. If there was an error or
|
|
1337
|
+
* there is no associated generator, it will return a NULL pointer, otherwise returns the generator
|
|
1338
|
+
* as a pointer.
|
|
1339
|
+
*
|
|
1340
|
+
* The generator pointer will be a valid pointer as long as `pactffi_matcher_definition_delete`
|
|
1341
|
+
* has not been called on the definition. Using the generator pointer after the definition
|
|
1342
|
+
* has been deleted will result in undefined behaviour.
|
|
1224
1343
|
*/
|
|
1225
|
-
|
|
1344
|
+
const Generator *pactffi_matcher_definition_generator(const MatchingRuleDefinitionResult *definition);
|
|
1226
1345
|
|
|
1227
1346
|
/**
|
|
1228
|
-
*
|
|
1347
|
+
* Returns the type of the value from parsing a matching definition expression. If there was an
|
|
1348
|
+
* error parsing the expression, it will return Unknown.
|
|
1229
1349
|
*/
|
|
1230
|
-
|
|
1350
|
+
ExpressionValueType pactffi_matcher_definition_value_type(const MatchingRuleDefinitionResult *definition);
|
|
1231
1351
|
|
|
1232
1352
|
/**
|
|
1233
1353
|
* Free the iterator when you're done using it.
|
|
1234
1354
|
*/
|
|
1235
|
-
void
|
|
1355
|
+
void pactffi_matching_rule_iter_delete(MatchingRuleIterator *iter);
|
|
1236
1356
|
|
|
1237
1357
|
/**
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1358
|
+
* Returns an iterator over the matching rules from the parsed definition. The iterator needs to
|
|
1359
|
+
* be deleted with the `pactffi_matching_rule_iter_delete` function once done with it.
|
|
1360
|
+
*
|
|
1361
|
+
* If there was an error parsing the expression, this function will return a NULL pointer.
|
|
1362
|
+
*/
|
|
1363
|
+
MatchingRuleIterator *pactffi_matcher_definition_iter(const MatchingRuleDefinitionResult *definition);
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* Get the next matching rule or reference from the iterator. As the values returned are owned
|
|
1367
|
+
* by the iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1240
1368
|
* deleted.
|
|
1241
1369
|
*
|
|
1242
1370
|
* Will return a NULL pointer when the iterator has advanced past the end of the list.
|
|
@@ -1245,64 +1373,184 @@ void pactffi_pact_message_iter_delete(PactMessageIterator *iter);
|
|
|
1245
1373
|
*
|
|
1246
1374
|
* This function is safe.
|
|
1247
1375
|
*
|
|
1248
|
-
* Deleting a message returned by the iterator can lead to undefined behaviour.
|
|
1249
|
-
*
|
|
1250
1376
|
* # Error Handling
|
|
1251
1377
|
*
|
|
1252
1378
|
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1253
1379
|
*/
|
|
1254
|
-
|
|
1380
|
+
const MatchingRuleResult *pactffi_matching_rule_iter_next(MatchingRuleIterator *iter);
|
|
1255
1381
|
|
|
1256
1382
|
/**
|
|
1257
|
-
*
|
|
1258
|
-
* iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1259
|
-
* deleted.
|
|
1383
|
+
* Return the ID of the matching rule.
|
|
1260
1384
|
*
|
|
1261
|
-
*
|
|
1385
|
+
* The ID corresponds to the following rules:
|
|
1386
|
+
* | Rule | ID |
|
|
1387
|
+
* | ---- | -- |
|
|
1388
|
+
* | Equality | 1 |
|
|
1389
|
+
* | Regex | 2 |
|
|
1390
|
+
* | Type | 3 |
|
|
1391
|
+
* | MinType | 4 |
|
|
1392
|
+
* | MaxType | 5 |
|
|
1393
|
+
* | MinMaxType | 6 |
|
|
1394
|
+
* | Timestamp | 7 |
|
|
1395
|
+
* | Time | 8 |
|
|
1396
|
+
* | Date | 9 |
|
|
1397
|
+
* | Include | 10 |
|
|
1398
|
+
* | Number | 11 |
|
|
1399
|
+
* | Integer | 12 |
|
|
1400
|
+
* | Decimal | 13 |
|
|
1401
|
+
* | Null | 14 |
|
|
1402
|
+
* | ContentType | 15 |
|
|
1403
|
+
* | ArrayContains | 16 |
|
|
1404
|
+
* | Values | 17 |
|
|
1405
|
+
* | Boolean | 18 |
|
|
1406
|
+
* | StatusCode | 19 |
|
|
1407
|
+
* | NotEmpty | 20 |
|
|
1408
|
+
* | Semver | 21 |
|
|
1409
|
+
* | EachKey | 22 |
|
|
1410
|
+
* | EachValue | 23 |
|
|
1262
1411
|
*
|
|
1263
1412
|
* # Safety
|
|
1264
1413
|
*
|
|
1265
|
-
* This function is safe
|
|
1414
|
+
* This function is safe as long as the MatchingRuleResult pointer is a valid pointer and the
|
|
1415
|
+
* iterator has not been deleted.
|
|
1416
|
+
*/
|
|
1417
|
+
uint16_t pactffi_matching_rule_id(const MatchingRuleResult *rule_result);
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* Returns the associated value for the matching rule. If the matching rule does not have an
|
|
1421
|
+
* associated value, will return a NULL pointer.
|
|
1266
1422
|
*
|
|
1267
|
-
*
|
|
1423
|
+
* The associated values for the rules are:
|
|
1424
|
+
* | Rule | ID | VALUE |
|
|
1425
|
+
* | ---- | -- | ----- |
|
|
1426
|
+
* | Equality | 1 | NULL |
|
|
1427
|
+
* | Regex | 2 | Regex value |
|
|
1428
|
+
* | Type | 3 | NULL |
|
|
1429
|
+
* | MinType | 4 | Minimum value |
|
|
1430
|
+
* | MaxType | 5 | Maximum value |
|
|
1431
|
+
* | MinMaxType | 6 | "min:max" |
|
|
1432
|
+
* | Timestamp | 7 | Format string |
|
|
1433
|
+
* | Time | 8 | Format string |
|
|
1434
|
+
* | Date | 9 | Format string |
|
|
1435
|
+
* | Include | 10 | String value |
|
|
1436
|
+
* | Number | 11 | NULL |
|
|
1437
|
+
* | Integer | 12 | NULL |
|
|
1438
|
+
* | Decimal | 13 | NULL |
|
|
1439
|
+
* | Null | 14 | NULL |
|
|
1440
|
+
* | ContentType | 15 | Content type |
|
|
1441
|
+
* | ArrayContains | 16 | NULL |
|
|
1442
|
+
* | Values | 17 | NULL |
|
|
1443
|
+
* | Boolean | 18 | NULL |
|
|
1444
|
+
* | StatusCode | 19 | NULL |
|
|
1445
|
+
* | NotEmpty | 20 | NULL |
|
|
1446
|
+
* | Semver | 21 | NULL |
|
|
1447
|
+
* | EachKey | 22 | NULL |
|
|
1448
|
+
* | EachValue | 23 | NULL |
|
|
1268
1449
|
*
|
|
1269
|
-
*
|
|
1450
|
+
* Will return a NULL pointer if the matching rule was a reference or does not have an
|
|
1451
|
+
* associated value.
|
|
1270
1452
|
*
|
|
1271
|
-
*
|
|
1453
|
+
* # Safety
|
|
1454
|
+
*
|
|
1455
|
+
* This function is safe as long as the MatchingRuleResult pointer is a valid pointer and the
|
|
1456
|
+
* iterator it came from has not been deleted.
|
|
1272
1457
|
*/
|
|
1273
|
-
|
|
1458
|
+
const char *pactffi_matching_rule_value(const MatchingRuleResult *rule_result);
|
|
1274
1459
|
|
|
1275
1460
|
/**
|
|
1276
|
-
*
|
|
1461
|
+
* Returns the matching rule pointer for the matching rule. Will return a NULL pointer if the
|
|
1462
|
+
* matching rule result was a reference.
|
|
1463
|
+
*
|
|
1464
|
+
* # Safety
|
|
1465
|
+
*
|
|
1466
|
+
* This function is safe as long as the MatchingRuleResult pointer is a valid pointer and the
|
|
1467
|
+
* iterator it came from has not been deleted.
|
|
1277
1468
|
*/
|
|
1278
|
-
|
|
1469
|
+
const MatchingRule *pactffi_matching_rule_pointer(const MatchingRuleResult *rule_result);
|
|
1279
1470
|
|
|
1280
1471
|
/**
|
|
1281
|
-
*
|
|
1282
|
-
*
|
|
1283
|
-
* will be cleaned up when the iterator is deleted.
|
|
1472
|
+
* Return any matching rule reference to a attribute by name. This is when the matcher should
|
|
1473
|
+
* be configured to match the type of a structure. I.e.,
|
|
1284
1474
|
*
|
|
1285
|
-
*
|
|
1475
|
+
* ```json
|
|
1476
|
+
* {
|
|
1477
|
+
* "pact:match": "eachValue(matching($'person'))",
|
|
1478
|
+
* "person": {
|
|
1479
|
+
* "name": "Fred",
|
|
1480
|
+
* "age": 100
|
|
1481
|
+
* }
|
|
1482
|
+
* }
|
|
1483
|
+
* ```
|
|
1484
|
+
*
|
|
1485
|
+
* Will return a NULL pointer if the matching rule was not a reference.
|
|
1286
1486
|
*
|
|
1287
1487
|
* # Safety
|
|
1288
1488
|
*
|
|
1289
|
-
* This function is safe
|
|
1489
|
+
* This function is safe as long as the MatchingRuleResult pointer is a valid pointer and the
|
|
1490
|
+
* iterator has not been deleted.
|
|
1491
|
+
*/
|
|
1492
|
+
const char *pactffi_matching_rule_reference_name(const MatchingRuleResult *rule_result);
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* Get the JSON form of the generator.
|
|
1290
1496
|
*
|
|
1291
|
-
*
|
|
1497
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1292
1498
|
*
|
|
1293
|
-
* #
|
|
1499
|
+
* # Safety
|
|
1294
1500
|
*
|
|
1295
|
-
* This function will
|
|
1501
|
+
* This function will fail if it is passed a NULL pointer, or the owner of the generator has
|
|
1502
|
+
* been deleted.
|
|
1296
1503
|
*/
|
|
1297
|
-
|
|
1504
|
+
const char *pactffi_generator_to_json(const Generator *generator);
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Generate a string value using the provided generator and an optional JSON payload containing
|
|
1508
|
+
* any generator context. The context value is used for generators like `MockServerURL` (which
|
|
1509
|
+
* should contain details about the running mock server) and `ProviderStateGenerator` (which
|
|
1510
|
+
* should be the values returned from the Provider State callback function).
|
|
1511
|
+
*
|
|
1512
|
+
* If anything goes wrong, it will return a NULL pointer.
|
|
1513
|
+
*/
|
|
1514
|
+
const char *pactffi_generator_generate_string(const Generator *generator, const char *context_json);
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* Generate an integer value using the provided generator and an optional JSON payload containing
|
|
1518
|
+
* any generator context. The context value is used for generators like `ProviderStateGenerator`
|
|
1519
|
+
* (which should be the values returned from the Provider State callback function).
|
|
1520
|
+
*
|
|
1521
|
+
* If anything goes wrong or the generator is not a type that can generate an integer value, it
|
|
1522
|
+
* will return a zero value.
|
|
1523
|
+
*/
|
|
1524
|
+
unsigned short pactffi_generator_generate_integer(const Generator *generator,
|
|
1525
|
+
const char *context_json);
|
|
1298
1526
|
|
|
1299
1527
|
/**
|
|
1300
1528
|
* Free the iterator when you're done using it.
|
|
1301
1529
|
*/
|
|
1302
|
-
void
|
|
1530
|
+
void pactffi_generators_iter_delete(GeneratorCategoryIterator *iter);
|
|
1303
1531
|
|
|
1304
1532
|
/**
|
|
1305
|
-
* Get
|
|
1533
|
+
* Get the next path and generator out of the iterator, if possible.
|
|
1534
|
+
*
|
|
1535
|
+
* The returned pointer must be deleted with `pactffi_generator_iter_pair_delete`.
|
|
1536
|
+
*
|
|
1537
|
+
* # Safety
|
|
1538
|
+
*
|
|
1539
|
+
* The underlying data is owned by the `GeneratorKeyValuePair`, so is always safe to use.
|
|
1540
|
+
*
|
|
1541
|
+
* # Error Handling
|
|
1542
|
+
*
|
|
1543
|
+
* If no further data is present, returns NULL.
|
|
1544
|
+
*/
|
|
1545
|
+
const GeneratorKeyValuePair *pactffi_generators_iter_next(GeneratorCategoryIterator *iter);
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Free a pair of key and value returned from `pactffi_generators_iter_next`.
|
|
1549
|
+
*/
|
|
1550
|
+
void pactffi_generators_iter_pair_delete(const GeneratorKeyValuePair *pair);
|
|
1551
|
+
|
|
1552
|
+
/**
|
|
1553
|
+
* Get a mutable pointer to a newly-created default interaction on the heap.
|
|
1306
1554
|
*
|
|
1307
1555
|
* # Safety
|
|
1308
1556
|
*
|
|
@@ -1312,54 +1560,68 @@ void pactffi_pact_sync_http_iter_delete(PactSyncHttpIterator *iter);
|
|
|
1312
1560
|
*
|
|
1313
1561
|
* Returns NULL on error.
|
|
1314
1562
|
*/
|
|
1315
|
-
|
|
1563
|
+
SynchronousHttp *pactffi_sync_http_new();
|
|
1316
1564
|
|
|
1317
1565
|
/**
|
|
1318
|
-
* Destroy the `
|
|
1566
|
+
* Destroy the `SynchronousHttp` interaction being pointed to.
|
|
1319
1567
|
*/
|
|
1320
|
-
void
|
|
1568
|
+
void pactffi_sync_http_delete(const SynchronousHttp *interaction);
|
|
1321
1569
|
|
|
1322
1570
|
/**
|
|
1323
|
-
* Get the request
|
|
1571
|
+
* Get the request of a `SynchronousHttp` interaction.
|
|
1572
|
+
*
|
|
1573
|
+
* # Safety
|
|
1574
|
+
*
|
|
1575
|
+
* The data pointed to by the pointer this function returns will be deleted when the interaction
|
|
1576
|
+
* is deleted. Trying to use if after the interaction is deleted will result in undefined behaviour.
|
|
1577
|
+
*
|
|
1578
|
+
* # Error Handling
|
|
1579
|
+
*
|
|
1580
|
+
* If the interaction is NULL, returns NULL.
|
|
1581
|
+
*/
|
|
1582
|
+
const HttpRequest *pactffi_sync_http_get_request(const SynchronousHttp *interaction);
|
|
1583
|
+
|
|
1584
|
+
/**
|
|
1585
|
+
* Get the request contents of a `SynchronousHttp` interaction in string form.
|
|
1324
1586
|
*
|
|
1325
1587
|
* # Safety
|
|
1326
1588
|
*
|
|
1327
1589
|
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1328
1590
|
*
|
|
1329
|
-
* The returned string can outlive the
|
|
1591
|
+
* The returned string can outlive the interaction.
|
|
1330
1592
|
*
|
|
1331
1593
|
* # Error Handling
|
|
1332
1594
|
*
|
|
1333
|
-
* If the
|
|
1595
|
+
* If the interaction is NULL, returns NULL. If the body of the request
|
|
1334
1596
|
* is missing, then this function also returns NULL. This means there's
|
|
1335
1597
|
* no mechanism to differentiate with this function call alone between
|
|
1336
|
-
* a NULL
|
|
1598
|
+
* a NULL body and a missing body.
|
|
1337
1599
|
*/
|
|
1338
|
-
const char *
|
|
1600
|
+
const char *pactffi_sync_http_get_request_contents(const SynchronousHttp *interaction);
|
|
1339
1601
|
|
|
1340
1602
|
/**
|
|
1341
|
-
* Sets the request contents of the
|
|
1603
|
+
* Sets the request contents of the interaction.
|
|
1342
1604
|
*
|
|
1343
|
-
* * `
|
|
1605
|
+
* * `interaction` - the interaction to set the request contents for
|
|
1344
1606
|
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
1345
1607
|
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1346
1608
|
*
|
|
1347
1609
|
* # Safety
|
|
1348
1610
|
*
|
|
1349
|
-
* The
|
|
1611
|
+
* The request contents and content type must either be NULL pointers, or point to valid
|
|
1350
1612
|
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
1351
1613
|
*
|
|
1352
1614
|
* # Error Handling
|
|
1353
1615
|
*
|
|
1354
|
-
* If the contents is a NULL pointer, it will set the
|
|
1616
|
+
* If the contents is a NULL pointer, it will set the request contents as null. If the content
|
|
1355
1617
|
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1356
1618
|
*/
|
|
1357
|
-
void
|
|
1358
|
-
|
|
1359
|
-
|
|
1619
|
+
void pactffi_sync_http_set_request_contents(SynchronousHttp *interaction,
|
|
1620
|
+
const char *contents,
|
|
1621
|
+
const char *content_type);
|
|
1360
1622
|
|
|
1361
1623
|
/**
|
|
1362
|
-
* Get the length of the request contents of a `
|
|
1624
|
+
* Get the length of the request contents of a `SynchronousHttp` interaction.
|
|
1363
1625
|
*
|
|
1364
1626
|
* # Safety
|
|
1365
1627
|
*
|
|
@@ -1367,31 +1629,31 @@ void pactffi_sync_message_set_request_contents(SynchronousMessage *message,
|
|
|
1367
1629
|
*
|
|
1368
1630
|
* # Error Handling
|
|
1369
1631
|
*
|
|
1370
|
-
* If the
|
|
1632
|
+
* If the interaction is NULL, returns 0. If the body of the request
|
|
1371
1633
|
* is missing, then this function also returns 0.
|
|
1372
1634
|
*/
|
|
1373
|
-
size_t
|
|
1635
|
+
size_t pactffi_sync_http_get_request_contents_length(const SynchronousHttp *interaction);
|
|
1374
1636
|
|
|
1375
1637
|
/**
|
|
1376
|
-
* Get the request contents of a `
|
|
1638
|
+
* Get the request contents of a `SynchronousHttp` interaction as a pointer to an array of bytes.
|
|
1377
1639
|
*
|
|
1378
1640
|
* # Safety
|
|
1379
1641
|
*
|
|
1380
|
-
* The number of bytes in the buffer will be returned by `
|
|
1381
|
-
* It is safe to use the pointer while the
|
|
1382
|
-
* after the
|
|
1642
|
+
* The number of bytes in the buffer will be returned by `pactffi_sync_http_get_request_contents_length`.
|
|
1643
|
+
* It is safe to use the pointer while the interaction is not deleted or changed. Using the pointer
|
|
1644
|
+
* after the interaction is mutated or deleted may lead to undefined behaviour.
|
|
1383
1645
|
*
|
|
1384
1646
|
* # Error Handling
|
|
1385
1647
|
*
|
|
1386
|
-
* If the
|
|
1648
|
+
* If the interaction is NULL, returns NULL. If the body of the request
|
|
1387
1649
|
* is missing, then this function also returns NULL.
|
|
1388
1650
|
*/
|
|
1389
|
-
const unsigned char *
|
|
1651
|
+
const unsigned char *pactffi_sync_http_get_request_contents_bin(const SynchronousHttp *interaction);
|
|
1390
1652
|
|
|
1391
1653
|
/**
|
|
1392
|
-
* Sets the request contents of the
|
|
1654
|
+
* Sets the request contents of the interaction as an array of bytes.
|
|
1393
1655
|
*
|
|
1394
|
-
* * `
|
|
1656
|
+
* * `interaction` - the interaction to set the request contents for
|
|
1395
1657
|
* * `contents` - pointer to contents to copy from
|
|
1396
1658
|
* * `len` - number of bytes to copy from the contents pointer
|
|
1397
1659
|
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
@@ -1403,59 +1665,57 @@ const unsigned char *pactffi_sync_message_get_request_contents_bin(const Synchro
|
|
|
1403
1665
|
*
|
|
1404
1666
|
* # Error Handling
|
|
1405
1667
|
*
|
|
1406
|
-
* If the contents is a NULL pointer, it will set the
|
|
1668
|
+
* If the contents is a NULL pointer, it will set the request contents as null. If the content
|
|
1407
1669
|
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1408
1670
|
*/
|
|
1409
|
-
void
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1671
|
+
void pactffi_sync_http_set_request_contents_bin(SynchronousHttp *interaction,
|
|
1672
|
+
const unsigned char *contents,
|
|
1673
|
+
size_t len,
|
|
1674
|
+
const char *content_type);
|
|
1413
1675
|
|
|
1414
1676
|
/**
|
|
1415
|
-
* Get the
|
|
1677
|
+
* Get the response of a `SynchronousHttp` interaction.
|
|
1416
1678
|
*
|
|
1417
1679
|
* # Safety
|
|
1418
1680
|
*
|
|
1419
|
-
* The
|
|
1681
|
+
* The data pointed to by the pointer this function returns will be deleted when the interaction
|
|
1682
|
+
* is deleted. Trying to use if after the interaction is deleted will result in undefined behaviour.
|
|
1420
1683
|
*
|
|
1421
1684
|
* # Error Handling
|
|
1422
1685
|
*
|
|
1423
|
-
* If the
|
|
1686
|
+
* If the interaction is NULL, returns NULL.
|
|
1424
1687
|
*/
|
|
1425
|
-
|
|
1688
|
+
const HttpResponse *pactffi_sync_http_get_response(const SynchronousHttp *interaction);
|
|
1426
1689
|
|
|
1427
1690
|
/**
|
|
1428
|
-
* Get the response contents of a `
|
|
1691
|
+
* Get the response contents of a `SynchronousHttp` interaction in string form.
|
|
1429
1692
|
*
|
|
1430
1693
|
* # Safety
|
|
1431
1694
|
*
|
|
1432
1695
|
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1433
1696
|
*
|
|
1434
|
-
* The returned string can outlive the
|
|
1697
|
+
* The returned string can outlive the interaction.
|
|
1435
1698
|
*
|
|
1436
1699
|
* # Error Handling
|
|
1437
1700
|
*
|
|
1438
|
-
* If the
|
|
1701
|
+
* If the interaction is NULL, returns NULL.
|
|
1439
1702
|
*
|
|
1440
|
-
* If the body of the response
|
|
1703
|
+
* If the body of the response is missing, then this function also returns NULL.
|
|
1441
1704
|
* This means there's no mechanism to differentiate with this function call alone between
|
|
1442
|
-
* a NULL
|
|
1705
|
+
* a NULL body and a missing body.
|
|
1443
1706
|
*/
|
|
1444
|
-
const char *
|
|
1445
|
-
size_t index);
|
|
1707
|
+
const char *pactffi_sync_http_get_response_contents(const SynchronousHttp *interaction);
|
|
1446
1708
|
|
|
1447
1709
|
/**
|
|
1448
|
-
* Sets the response contents of the
|
|
1449
|
-
* in the message, the responses will be padded with default values.
|
|
1710
|
+
* Sets the response contents of the interaction.
|
|
1450
1711
|
*
|
|
1451
|
-
* * `
|
|
1452
|
-
* * `index` - index of the response to set. 0 is the first response.
|
|
1712
|
+
* * `interaction` - the interaction to set the response contents for
|
|
1453
1713
|
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
1454
1714
|
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1455
1715
|
*
|
|
1456
1716
|
* # Safety
|
|
1457
1717
|
*
|
|
1458
|
-
* The
|
|
1718
|
+
* The response contents and content type must either be NULL pointers, or point to valid
|
|
1459
1719
|
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
1460
1720
|
*
|
|
1461
1721
|
* # Error Handling
|
|
@@ -1463,13 +1723,12 @@ const char *pactffi_sync_message_get_response_contents(const SynchronousMessage
|
|
|
1463
1723
|
* If the contents is a NULL pointer, it will set the response contents as null. If the content
|
|
1464
1724
|
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1465
1725
|
*/
|
|
1466
|
-
void
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
const char *content_type);
|
|
1726
|
+
void pactffi_sync_http_set_response_contents(SynchronousHttp *interaction,
|
|
1727
|
+
const char *contents,
|
|
1728
|
+
const char *content_type);
|
|
1470
1729
|
|
|
1471
1730
|
/**
|
|
1472
|
-
* Get the length of the response contents of a `
|
|
1731
|
+
* Get the length of the response contents of a `SynchronousHttp` interaction.
|
|
1473
1732
|
*
|
|
1474
1733
|
* # Safety
|
|
1475
1734
|
*
|
|
@@ -1477,36 +1736,31 @@ void pactffi_sync_message_set_response_contents(SynchronousMessage *message,
|
|
|
1477
1736
|
*
|
|
1478
1737
|
* # Error Handling
|
|
1479
1738
|
*
|
|
1480
|
-
* If the
|
|
1739
|
+
* If the interaction is NULL or the index is not valid, returns 0. If the body of the response
|
|
1481
1740
|
* is missing, then this function also returns 0.
|
|
1482
1741
|
*/
|
|
1483
|
-
size_t
|
|
1484
|
-
size_t index);
|
|
1742
|
+
size_t pactffi_sync_http_get_response_contents_length(const SynchronousHttp *interaction);
|
|
1485
1743
|
|
|
1486
1744
|
/**
|
|
1487
|
-
* Get the response contents of a `
|
|
1745
|
+
* Get the response contents of a `SynchronousHttp` interaction as a pointer to an array of bytes.
|
|
1488
1746
|
*
|
|
1489
1747
|
* # Safety
|
|
1490
1748
|
*
|
|
1491
|
-
* The number of bytes in the buffer will be returned by `
|
|
1492
|
-
* It is safe to use the pointer while the
|
|
1493
|
-
* after the
|
|
1749
|
+
* The number of bytes in the buffer will be returned by `pactffi_sync_http_get_response_contents_length`.
|
|
1750
|
+
* It is safe to use the pointer while the interaction is not deleted or changed. Using the pointer
|
|
1751
|
+
* after the interaction is mutated or deleted may lead to undefined behaviour.
|
|
1494
1752
|
*
|
|
1495
1753
|
* # Error Handling
|
|
1496
1754
|
*
|
|
1497
|
-
* If the
|
|
1755
|
+
* If the interaction is NULL, returns NULL. If the body of the response
|
|
1498
1756
|
* is missing, then this function also returns NULL.
|
|
1499
1757
|
*/
|
|
1500
|
-
const unsigned char *
|
|
1501
|
-
size_t index);
|
|
1758
|
+
const unsigned char *pactffi_sync_http_get_response_contents_bin(const SynchronousHttp *interaction);
|
|
1502
1759
|
|
|
1503
1760
|
/**
|
|
1504
|
-
* Sets the response contents of the
|
|
1505
|
-
* is greater than the number of responses in the message, the responses will be padded with
|
|
1506
|
-
* default values.
|
|
1761
|
+
* Sets the response contents of the `SynchronousHttp` interaction as an array of bytes.
|
|
1507
1762
|
*
|
|
1508
|
-
* * `
|
|
1509
|
-
* * `index` - index of the response to set. 0 is the first response
|
|
1763
|
+
* * `interaction` - the interaction to set the response contents for
|
|
1510
1764
|
* * `contents` - pointer to contents to copy from
|
|
1511
1765
|
* * `len` - number of bytes to copy
|
|
1512
1766
|
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
@@ -1518,14 +1772,13 @@ const unsigned char *pactffi_sync_message_get_response_contents_bin(const Synchr
|
|
|
1518
1772
|
*
|
|
1519
1773
|
* # Error Handling
|
|
1520
1774
|
*
|
|
1521
|
-
* If the contents is a NULL pointer, it will set the
|
|
1775
|
+
* If the contents is a NULL pointer, it will set the response contents as null. If the content
|
|
1522
1776
|
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1523
1777
|
*/
|
|
1524
|
-
void
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
const char *content_type);
|
|
1778
|
+
void pactffi_sync_http_set_response_contents_bin(SynchronousHttp *interaction,
|
|
1779
|
+
const unsigned char *contents,
|
|
1780
|
+
size_t len,
|
|
1781
|
+
const char *content_type);
|
|
1529
1782
|
|
|
1530
1783
|
/**
|
|
1531
1784
|
* Get a copy of the description.
|
|
@@ -1535,7 +1788,7 @@ void pactffi_sync_message_set_response_contents_bin(SynchronousMessage *message,
|
|
|
1535
1788
|
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1536
1789
|
*
|
|
1537
1790
|
* Since it is a copy, the returned string may safely outlive
|
|
1538
|
-
* the `
|
|
1791
|
+
* the `SynchronousHttp` interaction.
|
|
1539
1792
|
*
|
|
1540
1793
|
* # Errors
|
|
1541
1794
|
*
|
|
@@ -1544,10 +1797,10 @@ void pactffi_sync_message_set_response_contents_bin(SynchronousMessage *message,
|
|
|
1544
1797
|
* This function may fail if the Rust string contains embedded
|
|
1545
1798
|
* null ('\0') bytes.
|
|
1546
1799
|
*/
|
|
1547
|
-
const char *
|
|
1800
|
+
const char *pactffi_sync_http_get_description(const SynchronousHttp *interaction);
|
|
1548
1801
|
|
|
1549
1802
|
/**
|
|
1550
|
-
* Write the `description` field on the `
|
|
1803
|
+
* Write the `description` field on the `SynchronousHttp`.
|
|
1551
1804
|
*
|
|
1552
1805
|
* # Safety
|
|
1553
1806
|
*
|
|
@@ -1561,17 +1814,17 @@ const char *pactffi_sync_message_get_description(const SynchronousMessage *messa
|
|
|
1561
1814
|
*
|
|
1562
1815
|
* Errors will be reported with a non-zero return value.
|
|
1563
1816
|
*/
|
|
1564
|
-
int
|
|
1817
|
+
int pactffi_sync_http_set_description(SynchronousHttp *interaction, const char *description);
|
|
1565
1818
|
|
|
1566
1819
|
/**
|
|
1567
|
-
* Get a copy of the provider state at the given index from this
|
|
1820
|
+
* Get a copy of the provider state at the given index from this interaction.
|
|
1568
1821
|
*
|
|
1569
1822
|
* # Safety
|
|
1570
1823
|
*
|
|
1571
1824
|
* The returned structure must be deleted with `provider_state_delete`.
|
|
1572
1825
|
*
|
|
1573
1826
|
* Since it is a copy, the returned structure may safely outlive
|
|
1574
|
-
* the `
|
|
1827
|
+
* the `SynchronousHttp`.
|
|
1575
1828
|
*
|
|
1576
1829
|
* # Error Handling
|
|
1577
1830
|
*
|
|
@@ -1580,8 +1833,8 @@ int pactffi_sync_message_set_description(SynchronousMessage *message, const char
|
|
|
1580
1833
|
* This function may fail if the index requested is out of bounds,
|
|
1581
1834
|
* or if any of the Rust strings contain embedded null ('\0') bytes.
|
|
1582
1835
|
*/
|
|
1583
|
-
const ProviderState *
|
|
1584
|
-
|
|
1836
|
+
const ProviderState *pactffi_sync_http_get_provider_state(const SynchronousHttp *interaction,
|
|
1837
|
+
unsigned int index);
|
|
1585
1838
|
|
|
1586
1839
|
/**
|
|
1587
1840
|
* Get an iterator over provider states.
|
|
@@ -1594,160 +1847,205 @@ const ProviderState *pactffi_sync_message_get_provider_state(const SynchronousMe
|
|
|
1594
1847
|
*
|
|
1595
1848
|
* Returns NULL if an error occurs.
|
|
1596
1849
|
*/
|
|
1597
|
-
ProviderStateIterator *
|
|
1850
|
+
ProviderStateIterator *pactffi_sync_http_get_provider_state_iter(SynchronousHttp *interaction);
|
|
1598
1851
|
|
|
1599
1852
|
/**
|
|
1600
|
-
*
|
|
1853
|
+
* Casts this interaction to a `SynchronousHttp` interaction. Returns a NULL pointer if the
|
|
1854
|
+
* interaction can not be casted to a `SynchronousHttp` interaction (for instance, it is a
|
|
1855
|
+
* message interaction). The returned pointer must be freed with `pactffi_sync_http_delete`
|
|
1856
|
+
* when no longer required.
|
|
1601
1857
|
*
|
|
1602
1858
|
* # Safety
|
|
1859
|
+
* This function is safe as long as the interaction pointer is a valid pointer.
|
|
1603
1860
|
*
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1606
|
-
* # Error Handling
|
|
1607
|
-
*
|
|
1608
|
-
* Returns NULL on error.
|
|
1861
|
+
* # Errors
|
|
1862
|
+
* On any error, this function will return a NULL pointer.
|
|
1609
1863
|
*/
|
|
1610
|
-
SynchronousHttp *
|
|
1864
|
+
const SynchronousHttp *pactffi_pact_interaction_as_synchronous_http(const PactInteraction *interaction);
|
|
1611
1865
|
|
|
1612
1866
|
/**
|
|
1613
|
-
*
|
|
1867
|
+
* Casts this interaction to a `Message` interaction. Returns a NULL pointer if the
|
|
1868
|
+
* interaction can not be casted to a `Message` interaction (for instance, it is a
|
|
1869
|
+
* http interaction). The returned pointer must be freed with `pactffi_message_delete`
|
|
1870
|
+
* when no longer required.
|
|
1871
|
+
*
|
|
1872
|
+
* Note that if the interaction is a V4 `AsynchronousMessage`, it will be converted to a V3
|
|
1873
|
+
* `Message` before being returned.
|
|
1874
|
+
*
|
|
1875
|
+
* # Safety
|
|
1876
|
+
* This function is safe as long as the interaction pointer is a valid pointer.
|
|
1877
|
+
*
|
|
1878
|
+
* # Errors
|
|
1879
|
+
* On any error, this function will return a NULL pointer.
|
|
1614
1880
|
*/
|
|
1615
|
-
|
|
1881
|
+
const Message *pactffi_pact_interaction_as_message(const PactInteraction *interaction);
|
|
1616
1882
|
|
|
1617
1883
|
/**
|
|
1618
|
-
*
|
|
1884
|
+
* Casts this interaction to a `AsynchronousMessage` interaction. Returns a NULL pointer if the
|
|
1885
|
+
* interaction can not be casted to a `AsynchronousMessage` interaction (for instance, it is a
|
|
1886
|
+
* http interaction). The returned pointer must be freed with `pactffi_async_message_delete`
|
|
1887
|
+
* when no longer required.
|
|
1619
1888
|
*
|
|
1620
|
-
*
|
|
1889
|
+
* Note that if the interaction is a V3 `Message`, it will be converted to a V4
|
|
1890
|
+
* `AsynchronousMessage` before being returned.
|
|
1621
1891
|
*
|
|
1622
|
-
*
|
|
1892
|
+
* # Safety
|
|
1893
|
+
* This function is safe as long as the interaction pointer is a valid pointer.
|
|
1623
1894
|
*
|
|
1624
|
-
*
|
|
1895
|
+
* # Errors
|
|
1896
|
+
* On any error, this function will return a NULL pointer.
|
|
1897
|
+
*/
|
|
1898
|
+
const AsynchronousMessage *pactffi_pact_interaction_as_asynchronous_message(const PactInteraction *interaction);
|
|
1899
|
+
|
|
1900
|
+
/**
|
|
1901
|
+
* Casts this interaction to a `SynchronousMessage` interaction. Returns a NULL pointer if the
|
|
1902
|
+
* interaction can not be casted to a `SynchronousMessage` interaction (for instance, it is a
|
|
1903
|
+
* http interaction). The returned pointer must be freed with `pactffi_sync_message_delete`
|
|
1904
|
+
* when no longer required.
|
|
1625
1905
|
*
|
|
1626
|
-
* #
|
|
1906
|
+
* # Safety
|
|
1907
|
+
* This function is safe as long as the interaction pointer is a valid pointer.
|
|
1627
1908
|
*
|
|
1628
|
-
*
|
|
1629
|
-
*
|
|
1630
|
-
* no mechanism to differentiate with this function call alone between
|
|
1631
|
-
* a NULL body and a missing body.
|
|
1909
|
+
* # Errors
|
|
1910
|
+
* On any error, this function will return a NULL pointer.
|
|
1632
1911
|
*/
|
|
1633
|
-
const
|
|
1912
|
+
const SynchronousMessage *pactffi_pact_interaction_as_synchronous_message(const PactInteraction *interaction);
|
|
1634
1913
|
|
|
1635
1914
|
/**
|
|
1636
|
-
*
|
|
1915
|
+
* Free the iterator when you're done using it.
|
|
1916
|
+
*/
|
|
1917
|
+
void pactffi_pact_message_iter_delete(PactMessageIterator *iter);
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* Get the next message from the message pact. As the messages returned are owned by the
|
|
1921
|
+
* iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1922
|
+
* deleted.
|
|
1637
1923
|
*
|
|
1638
|
-
*
|
|
1639
|
-
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
1640
|
-
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1924
|
+
* Will return a NULL pointer when the iterator has advanced past the end of the list.
|
|
1641
1925
|
*
|
|
1642
1926
|
* # Safety
|
|
1643
1927
|
*
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1928
|
+
* This function is safe.
|
|
1929
|
+
*
|
|
1930
|
+
* Deleting a message returned by the iterator can lead to undefined behaviour.
|
|
1646
1931
|
*
|
|
1647
1932
|
* # Error Handling
|
|
1648
1933
|
*
|
|
1649
|
-
*
|
|
1650
|
-
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1934
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1651
1935
|
*/
|
|
1652
|
-
|
|
1653
|
-
const char *contents,
|
|
1654
|
-
const char *content_type);
|
|
1936
|
+
Message *pactffi_pact_message_iter_next(PactMessageIterator *iter);
|
|
1655
1937
|
|
|
1656
1938
|
/**
|
|
1657
|
-
* Get the
|
|
1939
|
+
* Get the next synchronous request/response message from the V4 pact. As the messages returned are owned by the
|
|
1940
|
+
* iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1941
|
+
* deleted.
|
|
1942
|
+
*
|
|
1943
|
+
* Will return a NULL pointer when the iterator has advanced past the end of the list.
|
|
1658
1944
|
*
|
|
1659
1945
|
* # Safety
|
|
1660
1946
|
*
|
|
1661
1947
|
* This function is safe.
|
|
1662
1948
|
*
|
|
1949
|
+
* Deleting a message returned by the iterator can lead to undefined behaviour.
|
|
1950
|
+
*
|
|
1663
1951
|
* # Error Handling
|
|
1664
1952
|
*
|
|
1665
|
-
*
|
|
1666
|
-
* is missing, then this function also returns 0.
|
|
1953
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1667
1954
|
*/
|
|
1668
|
-
|
|
1955
|
+
SynchronousMessage *pactffi_pact_sync_message_iter_next(PactSyncMessageIterator *iter);
|
|
1669
1956
|
|
|
1670
1957
|
/**
|
|
1671
|
-
*
|
|
1958
|
+
* Free the iterator when you're done using it.
|
|
1959
|
+
*/
|
|
1960
|
+
void pactffi_pact_sync_message_iter_delete(PactSyncMessageIterator *iter);
|
|
1961
|
+
|
|
1962
|
+
/**
|
|
1963
|
+
* Get the next synchronous HTTP request/response interaction from the V4 pact. As the
|
|
1964
|
+
* interactions returned are owned by the iterator, they do not need to be deleted but
|
|
1965
|
+
* will be cleaned up when the iterator is deleted.
|
|
1966
|
+
*
|
|
1967
|
+
* Will return a NULL pointer when the iterator has advanced past the end of the list.
|
|
1672
1968
|
*
|
|
1673
1969
|
* # Safety
|
|
1674
1970
|
*
|
|
1675
|
-
*
|
|
1676
|
-
*
|
|
1677
|
-
*
|
|
1971
|
+
* This function is safe.
|
|
1972
|
+
*
|
|
1973
|
+
* Deleting an interaction returned by the iterator can lead to undefined behaviour.
|
|
1678
1974
|
*
|
|
1679
1975
|
* # Error Handling
|
|
1680
1976
|
*
|
|
1681
|
-
*
|
|
1682
|
-
* is missing, then this function also returns NULL.
|
|
1977
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1683
1978
|
*/
|
|
1684
|
-
|
|
1979
|
+
SynchronousHttp *pactffi_pact_sync_http_iter_next(PactSyncHttpIterator *iter);
|
|
1685
1980
|
|
|
1686
1981
|
/**
|
|
1687
|
-
*
|
|
1982
|
+
* Free the iterator when you're done using it.
|
|
1983
|
+
*/
|
|
1984
|
+
void pactffi_pact_sync_http_iter_delete(PactSyncHttpIterator *iter);
|
|
1985
|
+
|
|
1986
|
+
/**
|
|
1987
|
+
* Get the next interaction from the pact. As the interactions returned are owned by the
|
|
1988
|
+
* iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1989
|
+
* deleted.
|
|
1688
1990
|
*
|
|
1689
|
-
*
|
|
1690
|
-
* * `contents` - pointer to contents to copy from
|
|
1691
|
-
* * `len` - number of bytes to copy from the contents pointer
|
|
1692
|
-
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1991
|
+
* Will return a NULL pointer when the iterator has advanced past the end of the list.
|
|
1693
1992
|
*
|
|
1694
1993
|
* # Safety
|
|
1695
1994
|
*
|
|
1696
|
-
*
|
|
1697
|
-
*
|
|
1995
|
+
* This function is safe.
|
|
1996
|
+
*
|
|
1997
|
+
* Deleting an interaction returned by the iterator can lead to undefined behaviour.
|
|
1698
1998
|
*
|
|
1699
1999
|
* # Error Handling
|
|
1700
2000
|
*
|
|
1701
|
-
*
|
|
1702
|
-
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
2001
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1703
2002
|
*/
|
|
1704
|
-
|
|
1705
|
-
const unsigned char *contents,
|
|
1706
|
-
size_t len,
|
|
1707
|
-
const char *content_type);
|
|
2003
|
+
const PactInteraction *pactffi_pact_interaction_iter_next(PactInteractionIterator *iter);
|
|
1708
2004
|
|
|
1709
2005
|
/**
|
|
1710
|
-
*
|
|
1711
|
-
|
|
1712
|
-
*
|
|
2006
|
+
* Free the iterator when you're done using it.
|
|
2007
|
+
*/
|
|
2008
|
+
void pactffi_pact_interaction_iter_delete(PactInteractionIterator *iter);
|
|
2009
|
+
|
|
2010
|
+
/**
|
|
2011
|
+
* Get the JSON form of the matching rule.
|
|
1713
2012
|
*
|
|
1714
2013
|
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1715
2014
|
*
|
|
1716
|
-
*
|
|
1717
|
-
*
|
|
1718
|
-
* # Error Handling
|
|
1719
|
-
*
|
|
1720
|
-
* If the interaction is NULL, returns NULL.
|
|
2015
|
+
* # Safety
|
|
1721
2016
|
*
|
|
1722
|
-
*
|
|
1723
|
-
*
|
|
1724
|
-
* a NULL body and a missing body.
|
|
2017
|
+
* This function will fail if it is passed a NULL pointer, or the iterator that owns the
|
|
2018
|
+
* value of the matching rule has been deleted.
|
|
1725
2019
|
*/
|
|
1726
|
-
const char *
|
|
2020
|
+
const char *pactffi_matching_rule_to_json(const MatchingRule *rule);
|
|
1727
2021
|
|
|
1728
2022
|
/**
|
|
1729
|
-
*
|
|
2023
|
+
* Free the iterator when you're done using it.
|
|
2024
|
+
*/
|
|
2025
|
+
void pactffi_matching_rules_iter_delete(MatchingRuleCategoryIterator *iter);
|
|
2026
|
+
|
|
2027
|
+
/**
|
|
2028
|
+
* Get the next path and matching rule out of the iterator, if possible.
|
|
1730
2029
|
*
|
|
1731
|
-
*
|
|
1732
|
-
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
1733
|
-
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
2030
|
+
* The returned pointer must be deleted with `pactffi_matching_rules_iter_pair_delete`.
|
|
1734
2031
|
*
|
|
1735
2032
|
* # Safety
|
|
1736
2033
|
*
|
|
1737
|
-
* The
|
|
1738
|
-
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
2034
|
+
* The underlying data is owned by the `MatchingRuleKeyValuePair`, so is always safe to use.
|
|
1739
2035
|
*
|
|
1740
2036
|
* # Error Handling
|
|
1741
2037
|
*
|
|
1742
|
-
* If
|
|
1743
|
-
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
2038
|
+
* If no further data is present, returns NULL.
|
|
1744
2039
|
*/
|
|
1745
|
-
|
|
1746
|
-
const char *contents,
|
|
1747
|
-
const char *content_type);
|
|
2040
|
+
const MatchingRuleKeyValuePair *pactffi_matching_rules_iter_next(MatchingRuleCategoryIterator *iter);
|
|
1748
2041
|
|
|
1749
2042
|
/**
|
|
1750
|
-
*
|
|
2043
|
+
* Free a pair of key and value returned from `message_metadata_iter_next`.
|
|
2044
|
+
*/
|
|
2045
|
+
void pactffi_matching_rules_iter_pair_delete(const MatchingRuleKeyValuePair *pair);
|
|
2046
|
+
|
|
2047
|
+
/**
|
|
2048
|
+
* Get a mutable pointer to a newly-created default message on the heap.
|
|
1751
2049
|
*
|
|
1752
2050
|
* # Safety
|
|
1753
2051
|
*
|
|
@@ -1755,49 +2053,123 @@ void pactffi_sync_http_set_response_contents(SynchronousHttp *interaction,
|
|
|
1755
2053
|
*
|
|
1756
2054
|
* # Error Handling
|
|
1757
2055
|
*
|
|
1758
|
-
*
|
|
1759
|
-
* is missing, then this function also returns 0.
|
|
2056
|
+
* Returns NULL on error.
|
|
1760
2057
|
*/
|
|
1761
|
-
|
|
2058
|
+
Message *pactffi_message_new();
|
|
1762
2059
|
|
|
1763
2060
|
/**
|
|
1764
|
-
*
|
|
2061
|
+
* Constructs a `Message` from the JSON string
|
|
1765
2062
|
*
|
|
1766
2063
|
* # Safety
|
|
1767
2064
|
*
|
|
1768
|
-
*
|
|
1769
|
-
* It is safe to use the pointer while the interaction is not deleted or changed. Using the pointer
|
|
1770
|
-
* after the interaction is mutated or deleted may lead to undefined behaviour.
|
|
2065
|
+
* This function is safe.
|
|
1771
2066
|
*
|
|
1772
2067
|
* # Error Handling
|
|
1773
2068
|
*
|
|
1774
|
-
* If the
|
|
1775
|
-
* is missing, then this function also returns NULL.
|
|
2069
|
+
* If the JSON string is invalid or not UTF-8 encoded, returns a NULL.
|
|
1776
2070
|
*/
|
|
1777
|
-
|
|
2071
|
+
Message *pactffi_message_new_from_json(unsigned int index,
|
|
2072
|
+
const char *json_str,
|
|
2073
|
+
PactSpecification spec_version);
|
|
1778
2074
|
|
|
1779
2075
|
/**
|
|
1780
|
-
*
|
|
1781
|
-
*
|
|
1782
|
-
* * `interaction` - the interaction to set the response contents for
|
|
1783
|
-
* * `contents` - pointer to contents to copy from
|
|
1784
|
-
* * `len` - number of bytes to copy
|
|
1785
|
-
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
2076
|
+
* Constructs a `Message` from a body with a given content-type.
|
|
1786
2077
|
*
|
|
1787
2078
|
* # Safety
|
|
1788
2079
|
*
|
|
1789
|
-
*
|
|
1790
|
-
* and consecutive. Otherwise behaviour is undefined.
|
|
2080
|
+
* This function is safe.
|
|
1791
2081
|
*
|
|
1792
2082
|
* # Error Handling
|
|
1793
2083
|
*
|
|
1794
|
-
* If the
|
|
1795
|
-
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
2084
|
+
* If the body or content type are invalid or not UTF-8 encoded, returns NULL.
|
|
1796
2085
|
*/
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
2086
|
+
Message *pactffi_message_new_from_body(const char *body, const char *content_type);
|
|
2087
|
+
|
|
2088
|
+
/**
|
|
2089
|
+
* Destroy the `Message` being pointed to.
|
|
2090
|
+
*/
|
|
2091
|
+
void pactffi_message_delete(Message *message);
|
|
2092
|
+
|
|
2093
|
+
/**
|
|
2094
|
+
* Get the contents of a `Message` in string form.
|
|
2095
|
+
*
|
|
2096
|
+
* # Safety
|
|
2097
|
+
*
|
|
2098
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
2099
|
+
*
|
|
2100
|
+
* The returned string can outlive the message.
|
|
2101
|
+
*
|
|
2102
|
+
* # Error Handling
|
|
2103
|
+
*
|
|
2104
|
+
* If the message is NULL, returns NULL. If the body of the message
|
|
2105
|
+
* is missing, then this function also returns NULL. This means there's
|
|
2106
|
+
* no mechanism to differentiate with this function call alone between
|
|
2107
|
+
* a NULL message and a missing message body.
|
|
2108
|
+
*/
|
|
2109
|
+
const char *pactffi_message_get_contents(const Message *message);
|
|
2110
|
+
|
|
2111
|
+
/**
|
|
2112
|
+
* Sets the contents of the message.
|
|
2113
|
+
*
|
|
2114
|
+
* # Safety
|
|
2115
|
+
*
|
|
2116
|
+
* The message contents and content type must either be NULL pointers, or point to valid
|
|
2117
|
+
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
2118
|
+
*
|
|
2119
|
+
* # Error Handling
|
|
2120
|
+
*
|
|
2121
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
2122
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
2123
|
+
*/
|
|
2124
|
+
void pactffi_message_set_contents(Message *message, const char *contents, const char *content_type);
|
|
2125
|
+
|
|
2126
|
+
/**
|
|
2127
|
+
* Get the length of the contents of a `Message`.
|
|
2128
|
+
*
|
|
2129
|
+
* # Safety
|
|
2130
|
+
*
|
|
2131
|
+
* This function is safe.
|
|
2132
|
+
*
|
|
2133
|
+
* # Error Handling
|
|
2134
|
+
*
|
|
2135
|
+
* If the message is NULL, returns 0. If the body of the message
|
|
2136
|
+
* is missing, then this function also returns 0.
|
|
2137
|
+
*/
|
|
2138
|
+
size_t pactffi_message_get_contents_length(const Message *message);
|
|
2139
|
+
|
|
2140
|
+
/**
|
|
2141
|
+
* Get the contents of a `Message` as a pointer to an array of bytes.
|
|
2142
|
+
*
|
|
2143
|
+
* # Safety
|
|
2144
|
+
*
|
|
2145
|
+
* The number of bytes in the buffer will be returned by `pactffi_message_get_contents_length`.
|
|
2146
|
+
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
2147
|
+
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
2148
|
+
*
|
|
2149
|
+
* # Error Handling
|
|
2150
|
+
*
|
|
2151
|
+
* If the message is NULL, returns NULL. If the body of the message
|
|
2152
|
+
* is missing, then this function also returns NULL.
|
|
2153
|
+
*/
|
|
2154
|
+
const unsigned char *pactffi_message_get_contents_bin(const Message *message);
|
|
2155
|
+
|
|
2156
|
+
/**
|
|
2157
|
+
* Sets the contents of the message as an array of bytes.
|
|
2158
|
+
*
|
|
2159
|
+
* # Safety
|
|
2160
|
+
*
|
|
2161
|
+
* The contents pointer must be valid for reads of `len` bytes, and it must be properly aligned
|
|
2162
|
+
* and consecutive. Otherwise behaviour is undefined.
|
|
2163
|
+
*
|
|
2164
|
+
* # Error Handling
|
|
2165
|
+
*
|
|
2166
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
2167
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
2168
|
+
*/
|
|
2169
|
+
void pactffi_message_set_contents_bin(Message *message,
|
|
2170
|
+
const unsigned char *contents,
|
|
2171
|
+
size_t len,
|
|
2172
|
+
const char *content_type);
|
|
1801
2173
|
|
|
1802
2174
|
/**
|
|
1803
2175
|
* Get a copy of the description.
|
|
@@ -1807,7 +2179,7 @@ void pactffi_sync_http_set_response_contents_bin(SynchronousHttp *interaction,
|
|
|
1807
2179
|
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1808
2180
|
*
|
|
1809
2181
|
* Since it is a copy, the returned string may safely outlive
|
|
1810
|
-
* the `
|
|
2182
|
+
* the `Message`.
|
|
1811
2183
|
*
|
|
1812
2184
|
* # Errors
|
|
1813
2185
|
*
|
|
@@ -1816,10 +2188,10 @@ void pactffi_sync_http_set_response_contents_bin(SynchronousHttp *interaction,
|
|
|
1816
2188
|
* This function may fail if the Rust string contains embedded
|
|
1817
2189
|
* null ('\0') bytes.
|
|
1818
2190
|
*/
|
|
1819
|
-
const char *
|
|
2191
|
+
const char *pactffi_message_get_description(const Message *message);
|
|
1820
2192
|
|
|
1821
2193
|
/**
|
|
1822
|
-
* Write the `description` field on the `
|
|
2194
|
+
* Write the `description` field on the `Message`.
|
|
1823
2195
|
*
|
|
1824
2196
|
* # Safety
|
|
1825
2197
|
*
|
|
@@ -1833,17 +2205,17 @@ const char *pactffi_sync_http_get_description(const SynchronousHttp *interaction
|
|
|
1833
2205
|
*
|
|
1834
2206
|
* Errors will be reported with a non-zero return value.
|
|
1835
2207
|
*/
|
|
1836
|
-
int
|
|
2208
|
+
int pactffi_message_set_description(Message *message, const char *description);
|
|
1837
2209
|
|
|
1838
2210
|
/**
|
|
1839
|
-
* Get a copy of the provider state at the given index from this
|
|
2211
|
+
* Get a copy of the provider state at the given index from this message.
|
|
1840
2212
|
*
|
|
1841
2213
|
* # Safety
|
|
1842
2214
|
*
|
|
1843
2215
|
* The returned structure must be deleted with `provider_state_delete`.
|
|
1844
2216
|
*
|
|
1845
2217
|
* Since it is a copy, the returned structure may safely outlive
|
|
1846
|
-
* the `
|
|
2218
|
+
* the `Message`.
|
|
1847
2219
|
*
|
|
1848
2220
|
* # Error Handling
|
|
1849
2221
|
*
|
|
@@ -1852,8 +2224,7 @@ int pactffi_sync_http_set_description(SynchronousHttp *interaction, const char *
|
|
|
1852
2224
|
* This function may fail if the index requested is out of bounds,
|
|
1853
2225
|
* or if any of the Rust strings contain embedded null ('\0') bytes.
|
|
1854
2226
|
*/
|
|
1855
|
-
const ProviderState *
|
|
1856
|
-
unsigned int index);
|
|
2227
|
+
const ProviderState *pactffi_message_get_provider_state(const Message *message, unsigned int index);
|
|
1857
2228
|
|
|
1858
2229
|
/**
|
|
1859
2230
|
* Get an iterator over provider states.
|
|
@@ -1866,90 +2237,137 @@ const ProviderState *pactffi_sync_http_get_provider_state(const SynchronousHttp
|
|
|
1866
2237
|
*
|
|
1867
2238
|
* Returns NULL if an error occurs.
|
|
1868
2239
|
*/
|
|
1869
|
-
ProviderStateIterator *
|
|
2240
|
+
ProviderStateIterator *pactffi_message_get_provider_state_iter(Message *message);
|
|
1870
2241
|
|
|
1871
2242
|
/**
|
|
1872
|
-
*
|
|
1873
|
-
* and matching rules and any generator.
|
|
1874
|
-
*
|
|
1875
|
-
* The following are examples of matching rule definitions:
|
|
1876
|
-
* * `matching(type,'Name')` - type matcher with string value 'Name'
|
|
1877
|
-
* * `matching(number,100)` - number matcher
|
|
1878
|
-
* * `matching(datetime, 'yyyy-MM-dd','2000-01-01')` - datetime matcher with format string
|
|
2243
|
+
* Get the next value from the iterator.
|
|
1879
2244
|
*
|
|
1880
|
-
*
|
|
2245
|
+
* # Safety
|
|
1881
2246
|
*
|
|
1882
|
-
* The
|
|
2247
|
+
* The underlying data must not change during iteration.
|
|
1883
2248
|
*
|
|
1884
|
-
*
|
|
1885
|
-
*
|
|
1886
|
-
* this value with the `pactffi_matcher_definition_error` function.
|
|
2249
|
+
* If a previous call panicked, then the internal mutex will have been poisoned and this
|
|
2250
|
+
* function will return NULL.
|
|
1887
2251
|
*
|
|
1888
|
-
* #
|
|
2252
|
+
* # Error Handling
|
|
1889
2253
|
*
|
|
1890
|
-
*
|
|
2254
|
+
* Returns NULL if an error occurs.
|
|
1891
2255
|
*/
|
|
1892
|
-
|
|
2256
|
+
ProviderState *pactffi_provider_state_iter_next(ProviderStateIterator *iter);
|
|
1893
2257
|
|
|
1894
2258
|
/**
|
|
1895
|
-
*
|
|
1896
|
-
* it will return a NULL pointer, otherwise returns the error message as a NULL-terminated string.
|
|
1897
|
-
* The returned string must be freed using the `pactffi_string_delete` function once done with it.
|
|
2259
|
+
* Delete the iterator.
|
|
1898
2260
|
*/
|
|
1899
|
-
|
|
2261
|
+
void pactffi_provider_state_iter_delete(ProviderStateIterator *iter);
|
|
1900
2262
|
|
|
1901
2263
|
/**
|
|
1902
|
-
*
|
|
1903
|
-
* it will return a NULL pointer, otherwise returns the value as a NULL-terminated string.
|
|
1904
|
-
* The returned string must be freed using the `pactffi_string_delete` function once done with it.
|
|
2264
|
+
* Get a copy of the metadata value indexed by `key`.
|
|
1905
2265
|
*
|
|
1906
|
-
*
|
|
1907
|
-
*
|
|
1908
|
-
*
|
|
2266
|
+
* # Safety
|
|
2267
|
+
*
|
|
2268
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
2269
|
+
*
|
|
2270
|
+
* Since it is a copy, the returned string may safely outlive
|
|
2271
|
+
* the `Message`.
|
|
2272
|
+
*
|
|
2273
|
+
* The returned pointer will be NULL if the metadata does not contain
|
|
2274
|
+
* the given key, or if an error occurred.
|
|
2275
|
+
*
|
|
2276
|
+
* # Error Handling
|
|
2277
|
+
*
|
|
2278
|
+
* On failure, this function will return a NULL pointer.
|
|
2279
|
+
*
|
|
2280
|
+
* This function may fail if the provided `key` string contains
|
|
2281
|
+
* invalid UTF-8, or if the Rust string contains embedded null ('\0')
|
|
2282
|
+
* bytes.
|
|
1909
2283
|
*/
|
|
1910
|
-
const char *
|
|
2284
|
+
const char *pactffi_message_find_metadata(const Message *message, const char *key);
|
|
1911
2285
|
|
|
1912
2286
|
/**
|
|
1913
|
-
*
|
|
2287
|
+
* Insert the (`key`, `value`) pair into this Message's
|
|
2288
|
+
* `metadata` HashMap.
|
|
2289
|
+
*
|
|
2290
|
+
* # Safety
|
|
2291
|
+
*
|
|
2292
|
+
* This function returns an enum indicating the result;
|
|
2293
|
+
* see the comments on HashMapInsertStatus for details.
|
|
2294
|
+
*
|
|
2295
|
+
* # Error Handling
|
|
2296
|
+
*
|
|
2297
|
+
* This function may fail if the provided `key` or `value` strings
|
|
2298
|
+
* contain invalid UTF-8.
|
|
1914
2299
|
*/
|
|
1915
|
-
|
|
2300
|
+
int pactffi_message_insert_metadata(Message *message, const char *key, const char *value);
|
|
1916
2301
|
|
|
1917
2302
|
/**
|
|
1918
|
-
*
|
|
1919
|
-
* there is no associated generator, it will return a NULL pointer, otherwise returns the generator
|
|
1920
|
-
* as a pointer.
|
|
2303
|
+
* Get the next key and value out of the iterator, if possible.
|
|
1921
2304
|
*
|
|
1922
|
-
* The
|
|
1923
|
-
*
|
|
1924
|
-
*
|
|
2305
|
+
* The returned pointer must be deleted with `pactffi_message_metadata_pair_delete`.
|
|
2306
|
+
*
|
|
2307
|
+
* # Safety
|
|
2308
|
+
*
|
|
2309
|
+
* The underlying data must not change during iteration.
|
|
2310
|
+
*
|
|
2311
|
+
* # Error Handling
|
|
2312
|
+
*
|
|
2313
|
+
* If no further data is present, returns NULL.
|
|
1925
2314
|
*/
|
|
1926
|
-
|
|
2315
|
+
MessageMetadataPair *pactffi_message_metadata_iter_next(MessageMetadataIterator *iter);
|
|
1927
2316
|
|
|
1928
2317
|
/**
|
|
1929
|
-
*
|
|
1930
|
-
*
|
|
2318
|
+
* Get an iterator over the metadata of a message.
|
|
2319
|
+
*
|
|
2320
|
+
* # Safety
|
|
2321
|
+
*
|
|
2322
|
+
* This iterator carries a pointer to the message, and must
|
|
2323
|
+
* not outlive the message.
|
|
2324
|
+
*
|
|
2325
|
+
* The message metadata also must not be modified during iteration. If it is,
|
|
2326
|
+
* the old iterator must be deleted and a new iterator created.
|
|
2327
|
+
*
|
|
2328
|
+
* # Error Handling
|
|
2329
|
+
*
|
|
2330
|
+
* On failure, this function will return a NULL pointer.
|
|
2331
|
+
*
|
|
2332
|
+
* This function may fail if any of the Rust strings contain
|
|
2333
|
+
* embedded null ('\0') bytes.
|
|
1931
2334
|
*/
|
|
1932
|
-
|
|
2335
|
+
MessageMetadataIterator *pactffi_message_get_metadata_iter(Message *message);
|
|
1933
2336
|
|
|
1934
2337
|
/**
|
|
1935
|
-
* Free the iterator when you're done using it.
|
|
2338
|
+
* Free the metadata iterator when you're done using it.
|
|
1936
2339
|
*/
|
|
1937
|
-
void
|
|
2340
|
+
void pactffi_message_metadata_iter_delete(MessageMetadataIterator *iter);
|
|
1938
2341
|
|
|
1939
2342
|
/**
|
|
1940
|
-
*
|
|
1941
|
-
* be deleted with the `pactffi_matching_rule_iter_delete` function once done with it.
|
|
1942
|
-
*
|
|
1943
|
-
* If there was an error parsing the expression, this function will return a NULL pointer.
|
|
2343
|
+
* Free a pair of key and value returned from `message_metadata_iter_next`.
|
|
1944
2344
|
*/
|
|
1945
|
-
|
|
2345
|
+
void pactffi_message_metadata_pair_delete(MessageMetadataPair *pair);
|
|
1946
2346
|
|
|
1947
2347
|
/**
|
|
1948
|
-
*
|
|
1949
|
-
*
|
|
1950
|
-
* deleted.
|
|
2348
|
+
* Construct a new `MessagePact` from the JSON string.
|
|
2349
|
+
* The provided file name is used when generating error messages.
|
|
1951
2350
|
*
|
|
1952
|
-
*
|
|
2351
|
+
* # Safety
|
|
2352
|
+
*
|
|
2353
|
+
* The `file_name` and `json_str` parameters must both be valid UTF-8
|
|
2354
|
+
* encoded strings.
|
|
2355
|
+
*
|
|
2356
|
+
* # Error Handling
|
|
2357
|
+
*
|
|
2358
|
+
* On error, this function will return a null pointer.
|
|
2359
|
+
*/
|
|
2360
|
+
MessagePact *pactffi_message_pact_new_from_json(const char *file_name, const char *json_str);
|
|
2361
|
+
|
|
2362
|
+
/**
|
|
2363
|
+
* Delete the `MessagePact` being pointed to.
|
|
2364
|
+
*/
|
|
2365
|
+
void pactffi_message_pact_delete(MessagePact *message_pact);
|
|
2366
|
+
|
|
2367
|
+
/**
|
|
2368
|
+
* Get a pointer to the Consumer struct inside the MessagePact.
|
|
2369
|
+
* This is a mutable borrow: The caller may mutate the Consumer
|
|
2370
|
+
* through this pointer.
|
|
1953
2371
|
*
|
|
1954
2372
|
* # Safety
|
|
1955
2373
|
*
|
|
@@ -1957,166 +2375,576 @@ MatchingRuleIterator *pactffi_matcher_definition_iter(const MatchingRuleDefiniti
|
|
|
1957
2375
|
*
|
|
1958
2376
|
* # Error Handling
|
|
1959
2377
|
*
|
|
1960
|
-
* This function will
|
|
2378
|
+
* This function will only fail if it is passed a NULL pointer.
|
|
2379
|
+
* In the case of error, a NULL pointer will be returned.
|
|
1961
2380
|
*/
|
|
1962
|
-
|
|
2381
|
+
Consumer *pactffi_message_pact_get_consumer(MessagePact *message_pact);
|
|
1963
2382
|
|
|
1964
2383
|
/**
|
|
1965
|
-
*
|
|
1966
|
-
*
|
|
1967
|
-
*
|
|
1968
|
-
*
|
|
1969
|
-
*
|
|
1970
|
-
*
|
|
1971
|
-
*
|
|
1972
|
-
*
|
|
1973
|
-
*
|
|
1974
|
-
*
|
|
1975
|
-
*
|
|
1976
|
-
*
|
|
1977
|
-
|
|
1978
|
-
*
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
*
|
|
1982
|
-
*
|
|
1983
|
-
*
|
|
1984
|
-
*
|
|
1985
|
-
*
|
|
1986
|
-
*
|
|
1987
|
-
*
|
|
1988
|
-
*
|
|
1989
|
-
*
|
|
1990
|
-
*
|
|
1991
|
-
*
|
|
1992
|
-
*
|
|
2384
|
+
* Get a pointer to the Provider struct inside the MessagePact.
|
|
2385
|
+
* This is a mutable borrow: The caller may mutate the Provider
|
|
2386
|
+
* through this pointer.
|
|
2387
|
+
*
|
|
2388
|
+
* # Safety
|
|
2389
|
+
*
|
|
2390
|
+
* This function is safe.
|
|
2391
|
+
*
|
|
2392
|
+
* # Error Handling
|
|
2393
|
+
*
|
|
2394
|
+
* This function will only fail if it is passed a NULL pointer.
|
|
2395
|
+
* In the case of error, a NULL pointer will be returned.
|
|
2396
|
+
*/
|
|
2397
|
+
Provider *pactffi_message_pact_get_provider(MessagePact *message_pact);
|
|
2398
|
+
|
|
2399
|
+
/**
|
|
2400
|
+
* Get an iterator over the messages of a message pact.
|
|
2401
|
+
*
|
|
2402
|
+
* # Safety
|
|
2403
|
+
*
|
|
2404
|
+
* This iterator carries a pointer to the message pact, and must
|
|
2405
|
+
* not outlive the message pact.
|
|
2406
|
+
*
|
|
2407
|
+
* The message pact messages also must not be modified during iteration.
|
|
2408
|
+
* If they are, the old iterator must be deleted and a new iterator created.
|
|
2409
|
+
*
|
|
2410
|
+
* # Error Handling
|
|
2411
|
+
*
|
|
2412
|
+
* On failure, this function will return a NULL pointer.
|
|
2413
|
+
*
|
|
2414
|
+
* This function may fail if any of the Rust strings contain embedded
|
|
2415
|
+
* null ('\0') bytes.
|
|
2416
|
+
*/
|
|
2417
|
+
MessagePactMessageIterator *pactffi_message_pact_get_message_iter(MessagePact *message_pact);
|
|
2418
|
+
|
|
2419
|
+
/**
|
|
2420
|
+
* Get the next message from the message pact.
|
|
2421
|
+
*
|
|
2422
|
+
* # Safety
|
|
2423
|
+
*
|
|
2424
|
+
* This function is safe.
|
|
2425
|
+
*
|
|
2426
|
+
* # Error Handling
|
|
2427
|
+
*
|
|
2428
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
2429
|
+
*/
|
|
2430
|
+
Message *pactffi_message_pact_message_iter_next(MessagePactMessageIterator *iter);
|
|
2431
|
+
|
|
2432
|
+
/**
|
|
2433
|
+
* Delete the iterator.
|
|
2434
|
+
*/
|
|
2435
|
+
void pactffi_message_pact_message_iter_delete(MessagePactMessageIterator *iter);
|
|
2436
|
+
|
|
2437
|
+
/**
|
|
2438
|
+
* Get a copy of the metadata value indexed by `key1` and `key2`.
|
|
2439
|
+
*
|
|
2440
|
+
* # Safety
|
|
2441
|
+
*
|
|
2442
|
+
* Since it is a copy, the returned string may safely outlive
|
|
2443
|
+
* the `Message`.
|
|
2444
|
+
*
|
|
2445
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
2446
|
+
*
|
|
2447
|
+
* The returned pointer will be NULL if the metadata does not contain
|
|
2448
|
+
* the given key, or if an error occurred.
|
|
2449
|
+
*
|
|
2450
|
+
* # Error Handling
|
|
2451
|
+
*
|
|
2452
|
+
* On failure, this function will return a NULL pointer.
|
|
2453
|
+
*
|
|
2454
|
+
* This function may fail if the provided `key1` or `key2` strings contains
|
|
2455
|
+
* invalid UTF-8, or if the Rust string contains embedded null ('\0')
|
|
2456
|
+
* bytes.
|
|
2457
|
+
*/
|
|
2458
|
+
const char *pactffi_message_pact_find_metadata(const MessagePact *message_pact,
|
|
2459
|
+
const char *key1,
|
|
2460
|
+
const char *key2);
|
|
2461
|
+
|
|
2462
|
+
/**
|
|
2463
|
+
* Get an iterator over the metadata of a message pact.
|
|
2464
|
+
*
|
|
2465
|
+
* # Safety
|
|
2466
|
+
*
|
|
2467
|
+
* This iterator carries a pointer to the message pact, and must
|
|
2468
|
+
* not outlive the message pact.
|
|
2469
|
+
*
|
|
2470
|
+
* The message pact metadata also must not be modified during iteration. If it is,
|
|
2471
|
+
* the old iterator must be deleted and a new iterator created.
|
|
2472
|
+
*
|
|
2473
|
+
* # Error Handling
|
|
2474
|
+
*
|
|
2475
|
+
* On failure, this function will return a NULL pointer.
|
|
2476
|
+
*
|
|
2477
|
+
* This function may fail if any of the Rust strings contain
|
|
2478
|
+
* embedded null ('\0') bytes.
|
|
2479
|
+
*/
|
|
2480
|
+
MessagePactMetadataIterator *pactffi_message_pact_get_metadata_iter(MessagePact *message_pact);
|
|
2481
|
+
|
|
2482
|
+
/**
|
|
2483
|
+
* Get the next triple out of the iterator, if possible
|
|
2484
|
+
*
|
|
2485
|
+
* # Safety
|
|
2486
|
+
*
|
|
2487
|
+
* This operation is invalid if the underlying data has been changed during iteration.
|
|
2488
|
+
*
|
|
2489
|
+
* # Error Handling
|
|
2490
|
+
*
|
|
2491
|
+
* Returns null if no next element is present.
|
|
2492
|
+
*/
|
|
2493
|
+
MessagePactMetadataTriple *pactffi_message_pact_metadata_iter_next(MessagePactMetadataIterator *iter);
|
|
2494
|
+
|
|
2495
|
+
/**
|
|
2496
|
+
* Free the metadata iterator when you're done using it.
|
|
2497
|
+
*/
|
|
2498
|
+
void pactffi_message_pact_metadata_iter_delete(MessagePactMetadataIterator *iter);
|
|
2499
|
+
|
|
2500
|
+
/**
|
|
2501
|
+
* Free a triple returned from `pactffi_message_pact_metadata_iter_next`.
|
|
2502
|
+
*/
|
|
2503
|
+
void pactffi_message_pact_metadata_triple_delete(MessagePactMetadataTriple *triple);
|
|
2504
|
+
|
|
2505
|
+
/**
|
|
2506
|
+
* Get a copy of this provider's name.
|
|
2507
|
+
*
|
|
2508
|
+
* The copy must be deleted with `pactffi_string_delete`.
|
|
2509
|
+
*
|
|
2510
|
+
* # Usage
|
|
2511
|
+
*
|
|
2512
|
+
* ```c
|
|
2513
|
+
* // Assuming `file_name` and `json_str` are already defined.
|
|
2514
|
+
*
|
|
2515
|
+
* MessagePact *message_pact = pactffi_message_pact_new_from_json(file_name, json_str);
|
|
2516
|
+
* if (message_pact == NULLPTR) {
|
|
2517
|
+
* // handle error.
|
|
2518
|
+
* }
|
|
2519
|
+
*
|
|
2520
|
+
* Provider *provider = pactffi_message_pact_get_provider(message_pact);
|
|
2521
|
+
* if (provider == NULLPTR) {
|
|
2522
|
+
* // handle error.
|
|
2523
|
+
* }
|
|
2524
|
+
*
|
|
2525
|
+
* char *name = pactffi_provider_get_name(provider);
|
|
2526
|
+
* if (name == NULL) {
|
|
2527
|
+
* // handle error.
|
|
2528
|
+
* }
|
|
2529
|
+
*
|
|
2530
|
+
* printf("%s\n", name);
|
|
2531
|
+
*
|
|
2532
|
+
* pactffi_string_delete(name);
|
|
2533
|
+
* ```
|
|
2534
|
+
*
|
|
2535
|
+
* # Errors
|
|
2536
|
+
*
|
|
2537
|
+
* This function will fail if it is passed a NULL pointer,
|
|
2538
|
+
* or the Rust string contains an embedded NULL byte.
|
|
2539
|
+
* In the case of error, a NULL pointer will be returned.
|
|
2540
|
+
*/
|
|
2541
|
+
const char *pactffi_provider_get_name(const Provider *provider);
|
|
2542
|
+
|
|
2543
|
+
/**
|
|
2544
|
+
* Get the provider from a Pact. This returns a copy of the provider model, and needs to
|
|
2545
|
+
* be cleaned up with `pactffi_pact_provider_delete` when no longer required.
|
|
2546
|
+
*
|
|
2547
|
+
* # Errors
|
|
2548
|
+
*
|
|
2549
|
+
* This function will fail if it is passed a NULL pointer.
|
|
2550
|
+
* In the case of error, a NULL pointer will be returned.
|
|
2551
|
+
*/
|
|
2552
|
+
const Provider *pactffi_pact_get_provider(const Pact *pact);
|
|
2553
|
+
|
|
2554
|
+
/**
|
|
2555
|
+
* Frees the memory used by the Pact provider
|
|
2556
|
+
*/
|
|
2557
|
+
void pactffi_pact_provider_delete(const Provider *provider);
|
|
2558
|
+
|
|
2559
|
+
/**
|
|
2560
|
+
* Get the name of the provider state as a string, which needs to be deleted with `pactffi_string_delete`.
|
|
2561
|
+
*
|
|
2562
|
+
* # Safety
|
|
2563
|
+
*
|
|
2564
|
+
* This function is safe.
|
|
2565
|
+
*
|
|
2566
|
+
* # Error Handling
|
|
2567
|
+
*
|
|
2568
|
+
* If the provider_state param is NULL, this returns NULL.
|
|
2569
|
+
*/
|
|
2570
|
+
const char *pactffi_provider_state_get_name(const ProviderState *provider_state);
|
|
2571
|
+
|
|
2572
|
+
/**
|
|
2573
|
+
* Get an iterator over the params of a provider state.
|
|
2574
|
+
*
|
|
2575
|
+
* # Safety
|
|
2576
|
+
*
|
|
2577
|
+
* This iterator carries a pointer to the provider state, and must
|
|
2578
|
+
* not outlive the provider state.
|
|
2579
|
+
*
|
|
2580
|
+
* The provider state params also must not be modified during iteration. If it is,
|
|
2581
|
+
* the old iterator must be deleted and a new iterator created.
|
|
2582
|
+
*
|
|
2583
|
+
* # Errors
|
|
2584
|
+
*
|
|
2585
|
+
* On failure, this function will return a NULL pointer.
|
|
2586
|
+
*
|
|
2587
|
+
* This function may fail if any of the Rust strings contain
|
|
2588
|
+
* embedded null ('\0') bytes.
|
|
2589
|
+
*/
|
|
2590
|
+
ProviderStateParamIterator *pactffi_provider_state_get_param_iter(ProviderState *provider_state);
|
|
2591
|
+
|
|
2592
|
+
/**
|
|
2593
|
+
* Get the next key and value out of the iterator, if possible
|
|
2594
|
+
*
|
|
2595
|
+
* Returns a pointer to a heap allocated array of 2 elements, the pointer to the
|
|
2596
|
+
* key string on the heap, and the pointer to the value string on the heap.
|
|
2597
|
+
*
|
|
2598
|
+
* # Safety
|
|
2599
|
+
*
|
|
2600
|
+
* The underlying data must not be modified during iteration.
|
|
2601
|
+
*
|
|
2602
|
+
* The user needs to free both the contained strings and the array.
|
|
2603
|
+
*
|
|
2604
|
+
* # Error Handling
|
|
2605
|
+
*
|
|
2606
|
+
* Returns NULL if there's no further elements or the iterator is NULL.
|
|
2607
|
+
*/
|
|
2608
|
+
ProviderStateParamPair *pactffi_provider_state_param_iter_next(ProviderStateParamIterator *iter);
|
|
2609
|
+
|
|
2610
|
+
/**
|
|
2611
|
+
* Free the provider state when you're done using it.
|
|
2612
|
+
*/
|
|
2613
|
+
void pactffi_provider_state_delete(ProviderState *provider_state);
|
|
2614
|
+
|
|
2615
|
+
/**
|
|
2616
|
+
* Free the provider state param iterator when you're done using it.
|
|
2617
|
+
*/
|
|
2618
|
+
void pactffi_provider_state_param_iter_delete(ProviderStateParamIterator *iter);
|
|
2619
|
+
|
|
2620
|
+
/**
|
|
2621
|
+
* Free a pair of key and value returned from `pactffi_provider_state_param_iter_next`.
|
|
2622
|
+
*/
|
|
2623
|
+
void pactffi_provider_state_param_pair_delete(ProviderStateParamPair *pair);
|
|
2624
|
+
|
|
2625
|
+
/**
|
|
2626
|
+
* Get a mutable pointer to a newly-created default message on the heap.
|
|
2627
|
+
*
|
|
2628
|
+
* # Safety
|
|
2629
|
+
*
|
|
2630
|
+
* This function is safe.
|
|
2631
|
+
*
|
|
2632
|
+
* # Error Handling
|
|
2633
|
+
*
|
|
2634
|
+
* Returns NULL on error.
|
|
2635
|
+
*/
|
|
2636
|
+
SynchronousMessage *pactffi_sync_message_new();
|
|
2637
|
+
|
|
2638
|
+
/**
|
|
2639
|
+
* Destroy the `Message` being pointed to.
|
|
2640
|
+
*/
|
|
2641
|
+
void pactffi_sync_message_delete(SynchronousMessage *message);
|
|
2642
|
+
|
|
2643
|
+
/**
|
|
2644
|
+
* Get the request contents of a `SynchronousMessage` in string form.
|
|
2645
|
+
*
|
|
2646
|
+
* # Safety
|
|
2647
|
+
*
|
|
2648
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
2649
|
+
*
|
|
2650
|
+
* The returned string can outlive the message.
|
|
2651
|
+
*
|
|
2652
|
+
* # Error Handling
|
|
2653
|
+
*
|
|
2654
|
+
* If the message is NULL, returns NULL. If the body of the request message
|
|
2655
|
+
* is missing, then this function also returns NULL. This means there's
|
|
2656
|
+
* no mechanism to differentiate with this function call alone between
|
|
2657
|
+
* a NULL message and a missing message body.
|
|
2658
|
+
*/
|
|
2659
|
+
const char *pactffi_sync_message_get_request_contents_str(const SynchronousMessage *message);
|
|
2660
|
+
|
|
2661
|
+
/**
|
|
2662
|
+
* Sets the request contents of the message.
|
|
2663
|
+
*
|
|
2664
|
+
* * `message` - the message to set the request contents for
|
|
2665
|
+
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
2666
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
2667
|
+
*
|
|
2668
|
+
* # Safety
|
|
2669
|
+
*
|
|
2670
|
+
* The message contents and content type must either be NULL pointers, or point to valid
|
|
2671
|
+
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
2672
|
+
*
|
|
2673
|
+
* # Error Handling
|
|
2674
|
+
*
|
|
2675
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
2676
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
2677
|
+
*/
|
|
2678
|
+
void pactffi_sync_message_set_request_contents_str(SynchronousMessage *message,
|
|
2679
|
+
const char *contents,
|
|
2680
|
+
const char *content_type);
|
|
2681
|
+
|
|
2682
|
+
/**
|
|
2683
|
+
* Get the length of the request contents of a `SynchronousMessage`.
|
|
2684
|
+
*
|
|
2685
|
+
* # Safety
|
|
2686
|
+
*
|
|
2687
|
+
* This function is safe.
|
|
2688
|
+
*
|
|
2689
|
+
* # Error Handling
|
|
2690
|
+
*
|
|
2691
|
+
* If the message is NULL, returns 0. If the body of the request
|
|
2692
|
+
* is missing, then this function also returns 0.
|
|
2693
|
+
*/
|
|
2694
|
+
size_t pactffi_sync_message_get_request_contents_length(const SynchronousMessage *message);
|
|
2695
|
+
|
|
2696
|
+
/**
|
|
2697
|
+
* Get the request contents of a `SynchronousMessage` as a pointer to an array of bytes.
|
|
2698
|
+
*
|
|
2699
|
+
* # Safety
|
|
2700
|
+
*
|
|
2701
|
+
* The number of bytes in the buffer will be returned by `pactffi_sync_message_get_request_contents_length`.
|
|
2702
|
+
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
2703
|
+
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
2704
|
+
*
|
|
2705
|
+
* # Error Handling
|
|
2706
|
+
*
|
|
2707
|
+
* If the message is NULL, returns NULL. If the body of the message
|
|
2708
|
+
* is missing, then this function also returns NULL.
|
|
2709
|
+
*/
|
|
2710
|
+
const unsigned char *pactffi_sync_message_get_request_contents_bin(const SynchronousMessage *message);
|
|
2711
|
+
|
|
2712
|
+
/**
|
|
2713
|
+
* Sets the request contents of the message as an array of bytes.
|
|
2714
|
+
*
|
|
2715
|
+
* * `message` - the message to set the request contents for
|
|
2716
|
+
* * `contents` - pointer to contents to copy from
|
|
2717
|
+
* * `len` - number of bytes to copy from the contents pointer
|
|
2718
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
1993
2719
|
*
|
|
1994
2720
|
* # Safety
|
|
1995
2721
|
*
|
|
1996
|
-
*
|
|
1997
|
-
*
|
|
2722
|
+
* The contents pointer must be valid for reads of `len` bytes, and it must be properly aligned
|
|
2723
|
+
* and consecutive. Otherwise behaviour is undefined.
|
|
2724
|
+
*
|
|
2725
|
+
* # Error Handling
|
|
2726
|
+
*
|
|
2727
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
2728
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
1998
2729
|
*/
|
|
1999
|
-
|
|
2730
|
+
void pactffi_sync_message_set_request_contents_bin(SynchronousMessage *message,
|
|
2731
|
+
const unsigned char *contents,
|
|
2732
|
+
size_t len,
|
|
2733
|
+
const char *content_type);
|
|
2000
2734
|
|
|
2001
2735
|
/**
|
|
2002
|
-
*
|
|
2003
|
-
* associated value, will return a NULL pointer.
|
|
2736
|
+
* Get the request contents of an `SynchronousMessage` as a `MessageContents` pointer.
|
|
2004
2737
|
*
|
|
2005
|
-
*
|
|
2006
|
-
* | Rule | ID | VALUE |
|
|
2007
|
-
* | ---- | -- | ----- |
|
|
2008
|
-
* | Equality | 1 | NULL |
|
|
2009
|
-
* | Regex | 2 | Regex value |
|
|
2010
|
-
* | Type | 3 | NULL |
|
|
2011
|
-
* | MinType | 4 | Minimum value |
|
|
2012
|
-
* | MaxType | 5 | Maximum value |
|
|
2013
|
-
* | MinMaxType | 6 | "min:max" |
|
|
2014
|
-
* | Timestamp | 7 | Format string |
|
|
2015
|
-
* | Time | 8 | Format string |
|
|
2016
|
-
* | Date | 9 | Format string |
|
|
2017
|
-
* | Include | 10 | String value |
|
|
2018
|
-
* | Number | 11 | NULL |
|
|
2019
|
-
* | Integer | 12 | NULL |
|
|
2020
|
-
* | Decimal | 13 | NULL |
|
|
2021
|
-
* | Null | 14 | NULL |
|
|
2022
|
-
* | ContentType | 15 | Content type |
|
|
2023
|
-
* | ArrayContains | 16 | NULL |
|
|
2024
|
-
* | Values | 17 | NULL |
|
|
2025
|
-
* | Boolean | 18 | NULL |
|
|
2026
|
-
* | StatusCode | 19 | NULL |
|
|
2027
|
-
* | NotEmpty | 20 | NULL |
|
|
2028
|
-
* | Semver | 21 | NULL |
|
|
2029
|
-
* | EachKey | 22 | NULL |
|
|
2030
|
-
* | EachValue | 23 | NULL |
|
|
2738
|
+
* # Safety
|
|
2031
2739
|
*
|
|
2032
|
-
*
|
|
2033
|
-
*
|
|
2740
|
+
* The data pointed to by the pointer this function returns will be deleted when the message
|
|
2741
|
+
* is deleted. Trying to use if after the message is deleted will result in undefined behaviour.
|
|
2742
|
+
*
|
|
2743
|
+
* # Error Handling
|
|
2744
|
+
*
|
|
2745
|
+
* If the message is NULL, returns NULL.
|
|
2746
|
+
*/
|
|
2747
|
+
const MessageContents *pactffi_sync_message_get_request_contents(const SynchronousMessage *message);
|
|
2748
|
+
|
|
2749
|
+
/**
|
|
2750
|
+
* Get the number of response messages in the `SynchronousMessage`.
|
|
2034
2751
|
*
|
|
2035
2752
|
* # Safety
|
|
2036
2753
|
*
|
|
2037
|
-
*
|
|
2038
|
-
*
|
|
2754
|
+
* The message pointer must point to a valid SynchronousMessage.
|
|
2755
|
+
*
|
|
2756
|
+
* # Error Handling
|
|
2757
|
+
*
|
|
2758
|
+
* If the message is NULL, returns 0.
|
|
2039
2759
|
*/
|
|
2040
|
-
|
|
2760
|
+
size_t pactffi_sync_message_get_number_responses(const SynchronousMessage *message);
|
|
2041
2761
|
|
|
2042
2762
|
/**
|
|
2043
|
-
*
|
|
2044
|
-
* matching rule result was a reference.
|
|
2763
|
+
* Get the response contents of a `SynchronousMessage` in string form.
|
|
2045
2764
|
*
|
|
2046
2765
|
* # Safety
|
|
2047
2766
|
*
|
|
2048
|
-
*
|
|
2049
|
-
*
|
|
2767
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
2768
|
+
*
|
|
2769
|
+
* The returned string can outlive the message.
|
|
2770
|
+
*
|
|
2771
|
+
* # Error Handling
|
|
2772
|
+
*
|
|
2773
|
+
* If the message is NULL or the index is not valid, returns NULL.
|
|
2774
|
+
*
|
|
2775
|
+
* If the body of the response message is missing, then this function also returns NULL.
|
|
2776
|
+
* This means there's no mechanism to differentiate with this function call alone between
|
|
2777
|
+
* a NULL message and a missing message body.
|
|
2050
2778
|
*/
|
|
2051
|
-
const
|
|
2779
|
+
const char *pactffi_sync_message_get_response_contents_str(const SynchronousMessage *message,
|
|
2780
|
+
size_t index);
|
|
2052
2781
|
|
|
2053
2782
|
/**
|
|
2054
|
-
*
|
|
2055
|
-
*
|
|
2783
|
+
* Sets the response contents of the message as a string. If index is greater than the number of responses
|
|
2784
|
+
* in the message, the responses will be padded with default values.
|
|
2056
2785
|
*
|
|
2057
|
-
*
|
|
2058
|
-
*
|
|
2059
|
-
*
|
|
2060
|
-
*
|
|
2061
|
-
* "name": "Fred",
|
|
2062
|
-
* "age": 100
|
|
2063
|
-
* }
|
|
2064
|
-
* }
|
|
2065
|
-
* ```
|
|
2786
|
+
* * `message` - the message to set the response contents for
|
|
2787
|
+
* * `index` - index of the response to set. 0 is the first response.
|
|
2788
|
+
* * `contents` - pointer to contents to copy from. Must be a valid NULL-terminated UTF-8 string pointer.
|
|
2789
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
2066
2790
|
*
|
|
2067
|
-
*
|
|
2791
|
+
* # Safety
|
|
2792
|
+
*
|
|
2793
|
+
* The message contents and content type must either be NULL pointers, or point to valid
|
|
2794
|
+
* UTF-8 encoded NULL-terminated strings. Otherwise behaviour is undefined.
|
|
2795
|
+
*
|
|
2796
|
+
* # Error Handling
|
|
2797
|
+
*
|
|
2798
|
+
* If the contents is a NULL pointer, it will set the response contents as null. If the content
|
|
2799
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
2800
|
+
*/
|
|
2801
|
+
void pactffi_sync_message_set_response_contents_str(SynchronousMessage *message,
|
|
2802
|
+
size_t index,
|
|
2803
|
+
const char *contents,
|
|
2804
|
+
const char *content_type);
|
|
2805
|
+
|
|
2806
|
+
/**
|
|
2807
|
+
* Get the length of the response contents of a `SynchronousMessage`.
|
|
2068
2808
|
*
|
|
2069
2809
|
* # Safety
|
|
2070
2810
|
*
|
|
2071
|
-
* This function is safe
|
|
2072
|
-
*
|
|
2811
|
+
* This function is safe.
|
|
2812
|
+
*
|
|
2813
|
+
* # Error Handling
|
|
2814
|
+
*
|
|
2815
|
+
* If the message is NULL or the index is not valid, returns 0. If the body of the request
|
|
2816
|
+
* is missing, then this function also returns 0.
|
|
2073
2817
|
*/
|
|
2074
|
-
|
|
2818
|
+
size_t pactffi_sync_message_get_response_contents_length(const SynchronousMessage *message,
|
|
2819
|
+
size_t index);
|
|
2075
2820
|
|
|
2076
2821
|
/**
|
|
2077
|
-
* Get the
|
|
2822
|
+
* Get the response contents of a `SynchronousMessage` as a pointer to an array of bytes.
|
|
2078
2823
|
*
|
|
2079
|
-
*
|
|
2824
|
+
* # Safety
|
|
2825
|
+
*
|
|
2826
|
+
* The number of bytes in the buffer will be returned by `pactffi_sync_message_get_response_contents_length`.
|
|
2827
|
+
* It is safe to use the pointer while the message is not deleted or changed. Using the pointer
|
|
2828
|
+
* after the message is mutated or deleted may lead to undefined behaviour.
|
|
2829
|
+
*
|
|
2830
|
+
* # Error Handling
|
|
2831
|
+
*
|
|
2832
|
+
* If the message is NULL or the index is not valid, returns NULL. If the body of the message
|
|
2833
|
+
* is missing, then this function also returns NULL.
|
|
2834
|
+
*/
|
|
2835
|
+
const unsigned char *pactffi_sync_message_get_response_contents_bin(const SynchronousMessage *message,
|
|
2836
|
+
size_t index);
|
|
2837
|
+
|
|
2838
|
+
/**
|
|
2839
|
+
* Sets the response contents of the message at the given index as an array of bytes. If index
|
|
2840
|
+
* is greater than the number of responses in the message, the responses will be padded with
|
|
2841
|
+
* default values.
|
|
2842
|
+
*
|
|
2843
|
+
* * `message` - the message to set the response contents for
|
|
2844
|
+
* * `index` - index of the response to set. 0 is the first response
|
|
2845
|
+
* * `contents` - pointer to contents to copy from
|
|
2846
|
+
* * `len` - number of bytes to copy
|
|
2847
|
+
* * `content_type` - pointer to the NULL-terminated UTF-8 string containing the content type of the data.
|
|
2080
2848
|
*
|
|
2081
2849
|
* # Safety
|
|
2082
2850
|
*
|
|
2083
|
-
*
|
|
2084
|
-
*
|
|
2851
|
+
* The contents pointer must be valid for reads of `len` bytes, and it must be properly aligned
|
|
2852
|
+
* and consecutive. Otherwise behaviour is undefined.
|
|
2853
|
+
*
|
|
2854
|
+
* # Error Handling
|
|
2855
|
+
*
|
|
2856
|
+
* If the contents is a NULL pointer, it will set the message contents as null. If the content
|
|
2857
|
+
* type is a null pointer, or can't be parsed, it will set the content type as unknown.
|
|
2085
2858
|
*/
|
|
2086
|
-
|
|
2859
|
+
void pactffi_sync_message_set_response_contents_bin(SynchronousMessage *message,
|
|
2860
|
+
size_t index,
|
|
2861
|
+
const unsigned char *contents,
|
|
2862
|
+
size_t len,
|
|
2863
|
+
const char *content_type);
|
|
2087
2864
|
|
|
2088
2865
|
/**
|
|
2089
|
-
* Get the
|
|
2866
|
+
* Get the response contents of an `SynchronousMessage` as a `MessageContents` pointer.
|
|
2867
|
+
*
|
|
2868
|
+
* # Safety
|
|
2869
|
+
*
|
|
2870
|
+
* The data pointed to by the pointer this function returns will be deleted when the message
|
|
2871
|
+
* is deleted. Trying to use if after the message is deleted will result in undefined behaviour.
|
|
2872
|
+
*
|
|
2873
|
+
* # Error Handling
|
|
2874
|
+
*
|
|
2875
|
+
* If the message is NULL or the index is not valid, returns NULL.
|
|
2876
|
+
*/
|
|
2877
|
+
const MessageContents *pactffi_sync_message_get_response_contents(const SynchronousMessage *message,
|
|
2878
|
+
size_t index);
|
|
2879
|
+
|
|
2880
|
+
/**
|
|
2881
|
+
* Get a copy of the description.
|
|
2882
|
+
*
|
|
2883
|
+
* # Safety
|
|
2090
2884
|
*
|
|
2091
2885
|
* The returned string must be deleted with `pactffi_string_delete`.
|
|
2092
2886
|
*
|
|
2887
|
+
* Since it is a copy, the returned string may safely outlive
|
|
2888
|
+
* the `SynchronousMessage`.
|
|
2889
|
+
*
|
|
2890
|
+
* # Errors
|
|
2891
|
+
*
|
|
2892
|
+
* On failure, this function will return a NULL pointer.
|
|
2893
|
+
*
|
|
2894
|
+
* This function may fail if the Rust string contains embedded
|
|
2895
|
+
* null ('\0') bytes.
|
|
2896
|
+
*/
|
|
2897
|
+
const char *pactffi_sync_message_get_description(const SynchronousMessage *message);
|
|
2898
|
+
|
|
2899
|
+
/**
|
|
2900
|
+
* Write the `description` field on the `SynchronousMessage`.
|
|
2901
|
+
*
|
|
2093
2902
|
* # Safety
|
|
2094
2903
|
*
|
|
2095
|
-
*
|
|
2096
|
-
*
|
|
2904
|
+
* `description` must contain valid UTF-8. Invalid UTF-8
|
|
2905
|
+
* will be replaced with U+FFFD REPLACEMENT CHARACTER.
|
|
2906
|
+
*
|
|
2907
|
+
* This function will only reallocate if the new string
|
|
2908
|
+
* does not fit in the existing buffer.
|
|
2909
|
+
*
|
|
2910
|
+
* # Error Handling
|
|
2911
|
+
*
|
|
2912
|
+
* Errors will be reported with a non-zero return value.
|
|
2097
2913
|
*/
|
|
2098
|
-
|
|
2914
|
+
int pactffi_sync_message_set_description(SynchronousMessage *message, const char *description);
|
|
2099
2915
|
|
|
2100
2916
|
/**
|
|
2101
|
-
*
|
|
2102
|
-
* any generator context. The context value is used for generators like `MockServerURL` (which
|
|
2103
|
-
* should contain details about the running mock server) and `ProviderStateGenerator` (which
|
|
2104
|
-
* should be the values returned from the Provider State callback function).
|
|
2917
|
+
* Get a copy of the provider state at the given index from this message.
|
|
2105
2918
|
*
|
|
2106
|
-
*
|
|
2919
|
+
* # Safety
|
|
2920
|
+
*
|
|
2921
|
+
* The returned structure must be deleted with `provider_state_delete`.
|
|
2922
|
+
*
|
|
2923
|
+
* Since it is a copy, the returned structure may safely outlive
|
|
2924
|
+
* the `SynchronousMessage`.
|
|
2925
|
+
*
|
|
2926
|
+
* # Error Handling
|
|
2927
|
+
*
|
|
2928
|
+
* On failure, this function will return a variant other than Success.
|
|
2929
|
+
*
|
|
2930
|
+
* This function may fail if the index requested is out of bounds,
|
|
2931
|
+
* or if any of the Rust strings contain embedded null ('\0') bytes.
|
|
2107
2932
|
*/
|
|
2108
|
-
const
|
|
2933
|
+
const ProviderState *pactffi_sync_message_get_provider_state(const SynchronousMessage *message,
|
|
2934
|
+
unsigned int index);
|
|
2109
2935
|
|
|
2110
2936
|
/**
|
|
2111
|
-
*
|
|
2112
|
-
* any generator context. The context value is used for generators like `ProviderStateGenerator`
|
|
2113
|
-
* (which should be the values returned from the Provider State callback function).
|
|
2937
|
+
* Get an iterator over provider states.
|
|
2114
2938
|
*
|
|
2115
|
-
*
|
|
2116
|
-
*
|
|
2939
|
+
* # Safety
|
|
2940
|
+
*
|
|
2941
|
+
* The underlying data must not change during iteration.
|
|
2942
|
+
*
|
|
2943
|
+
* # Error Handling
|
|
2944
|
+
*
|
|
2945
|
+
* Returns NULL if an error occurs.
|
|
2117
2946
|
*/
|
|
2118
|
-
|
|
2119
|
-
const char *context_json);
|
|
2947
|
+
ProviderStateIterator *pactffi_sync_message_get_provider_state_iter(SynchronousMessage *message);
|
|
2120
2948
|
|
|
2121
2949
|
/**
|
|
2122
2950
|
* Delete a string previously returned by this FFI.
|