1 /*
2  * Copyright 2025 Matheus C. França
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License") @trusted;
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 module ada.c.ada;
18 
19 @nogc nothrow @safe extern (C)
20 {
21    /++
22  + A struct representing a string owned by the ada_url instance.
23  + The string is managed by the Ada library and does not require manual freeing.
24  +/
25    struct ada_string
26    {
27       const(char)* data = void; /// Pointer to the string data.
28       size_t length = void; /// Length of the string.
29    }
30 
31    /++
32  + A struct representing a string that must be freed by the caller.
33  + Typically used for strings returned by the Ada library that require manual memory management.
34  +/
35    struct ada_owned_string
36    {
37       const(char)* data = void; /// Pointer to the string data.
38       size_t length = void; /// Length of the string.
39    }
40 
41    /++
42  + A struct representing the components of a parsed URL.
43  + Each field indicates the position or value of a URL component, with `ada_url_omitted` indicating an absent component.
44  +/
45    struct ada_url_components
46    {
47       uint protocol_end = void; /// End position of the protocol (e.g., after "http:").
48       uint username_end = void; /// End position of the username.
49       uint host_start = void; /// Start position of the host.
50       uint host_end = void; /// End position of the host.
51       uint port = void; /// Port number, or `ada_url_omitted` if not present.
52       uint pathname_start = void; /// Start position of the pathname.
53       uint search_start = void; /// Start position of the search (query) component.
54       uint hash_start = void; /// Start position of the hash (fragment) component.
55    }
56 
57    /++
58  + A struct representing a key-value pair in search parameters.
59  +/
60    struct ada_string_pair
61    {
62       ada_string key = void; /// The key string.
63       ada_string value = void; /// The value string.
64    }
65 
66    /++
67  + A constant representing an omitted URL component.
68  + Equivalent to `uint32_t(-1)` in the Ada library, used in `ada_url_components` to indicate absence.
69  +/
70    enum uint ada_url_omitted = 0xffffffff;
71 
72    /++
73  + An opaque pointer type representing a parsed URL in the Ada library.
74  +/
75    alias ada_url = void*;
76 
77    /++
78  + An opaque pointer type representing URL search (query) parameters in the Ada library.
79  +/
80    alias ada_url_search_params = void*;
81 
82    /++
83  + An opaque pointer type representing a collection of strings (e.g., multiple values for a query parameter).
84  +/
85    alias ada_strings = void*;
86 
87    /++
88  + An opaque pointer type representing an iterator over search parameter keys.
89  +/
90    alias ada_url_search_params_keys_iter = void*;
91 
92    /++
93  + An opaque pointer type representing an iterator over search parameter values.
94  +/
95    alias ada_url_search_params_values_iter = void*;
96 
97    /++
98  + An opaque pointer type representing an iterator over search parameter key-value pairs.
99  +/
100    alias ada_url_search_params_entries_iter = void*;
101 
102    /++
103  + Parses a URL string and returns a handle to the parsed URL.
104  + The input must be a null-terminated C string (ASCII or UTF-8).
105  + Params:
106  +   input = The URL string to parse.
107  +   length = The length of the input string.
108  + Returns: An `ada_url` handle, which must be freed with `ada_free`.
109  +/
110    ada_url ada_parse(scope const(char)* input, size_t length) @trusted;
111 
112    /++
113  + Parses a URL string with a base URL for relative URL resolution.
114  + Both input and base must be null-terminated C strings (ASCII or UTF-8).
115  + Params:
116  +   input = The URL string to parse.
117  +   input_length = The length of the input string.
118  +   base = The base URL string.
119  +   base_length = The length of the base URL string.
120  + Returns: An `ada_url` handle, which must be freed with `ada_free`.
121  +/
122    ada_url ada_parse_with_base(scope const(char)* input, size_t input_length, scope const(char)* base, size_t base_length) @trusted;
123 
124    /++
125  + Checks if a URL string can be parsed.
126  + The input must be a null-terminated C string (ASCII or UTF-8).
127  + Params:
128  +   input = The URL string to check.
129  +   length = The length of the input string.
130  + Returns: true if the URL can be parsed, false otherwise.
131  +/
132    bool ada_can_parse(scope const(char)* input, size_t length) @trusted;
133 
134    /++
135  + Checks if a URL string can be parsed with a base URL.
136  + Both input and base must be null-terminated C strings (ASCII or UTF-8).
137  + Params:
138  +   input = The URL string to check.
139  +   input_length = The length of the input string.
140  +   base = The base URL string.
141  +   base_length = The length of the base URL string.
142  + Returns: true if the URL can be parsed, false otherwise.
143  +/
144    bool ada_can_parse_with_base(scope const(char)* input, size_t input_length, scope const(char)* base, size_t base_length) @trusted;
145 
146    /++
147  + Frees the resources associated with a parsed URL.
148  + Params:
149  +   result = The `ada_url` handle to free.
150  +/
151    void ada_free(scope ada_url result) @trusted;
152 
153    /++
154  + Frees the resources associated with an owned string.
155  + Params:
156  +   owned = The `ada_owned_string` to free.
157  +/
158    void ada_free_owned_string(ada_owned_string owned) @trusted;
159 
160    /++
161  + Creates a copy of a parsed URL.
162  + Params:
163  +   input = The `ada_url` handle to copy.
164  + Returns: A new `ada_url` handle, which must be freed with `ada_free`.
165  +/
166    ada_url ada_copy(scope ada_url input) @trusted;
167 
168    /++
169  + Checks if a parsed URL is valid.
170  + Params:
171  +   result = The `ada_url` handle to check.
172  + Returns: true if the URL is valid, false otherwise.
173  +/
174    bool ada_is_valid(scope ada_url result) @trusted;
175 
176    /++
177  + Retrieves the origin of a parsed URL (e.g., protocol + host + port).
178  + Returns an empty string if the URL is invalid.
179  + Params:
180  +   result = The `ada_url` handle.
181  + Returns: An `ada_owned_string` containing the origin, which must be freed with `ada_free_owned_string`.
182  +/
183    ada_owned_string ada_get_origin(scope ada_url result) @trusted;
184 
185    /++
186  + Retrieves the full URL (href) as a string.
187  + Returns an empty string if the URL is invalid.
188  + Params:
189  +   result = The `ada_url` handle.
190  + Returns: An `ada_string` containing the href.
191  +/
192    ada_string ada_get_href(scope ada_url result) @trusted;
193 
194    /++
195  + Retrieves the username component of a parsed URL.
196  + Returns an empty string if the URL is invalid or no username is present.
197  + Params:
198  +   result = The `ada_url` handle.
199  + Returns: An `ada_string` containing the username.
200  +/
201    ada_string ada_get_username(scope ada_url result) @trusted;
202 
203    /++
204  + Retrieves the password component of a parsed URL.
205  + Returns an empty string if the URL is invalid or no password is present.
206  + Params:
207  +   result = The `ada_url` handle.
208  + Returns: An `ada_string` containing the password.
209  +/
210    ada_string ada_get_password(scope ada_url result) @trusted;
211 
212    /++
213  + Retrieves the port component of a parsed URL.
214  + Returns an empty string if the URL is invalid or no port is present.
215  + Params:
216  +   result = The `ada_url` handle.
217  + Returns: An `ada_string` containing the port.
218  +/
219    ada_string ada_get_port(scope ada_url result) @trusted;
220 
221    /++
222  + Retrieves the hash (fragment) component of a parsed URL.
223  + Returns an empty string if the URL is invalid or no hash is present.
224  + Params:
225  +   result = The `ada_url` handle.
226  + Returns: An `ada_string` containing the hash.
227  +/
228    ada_string ada_get_hash(scope ada_url result) @trusted;
229 
230    /++
231  + Retrieves the host component of a parsed URL (hostname + port).
232  + Returns an empty string if the URL is invalid or no host is present.
233  + Params:
234  +   result = The `ada_url` handle.
235  + Returns: An `ada_string` containing the host.
236  +/
237    ada_string ada_get_host(scope ada_url result) @trusted;
238 
239    /++
240  + Retrieves the hostname component of a parsed URL.
241  + Returns an empty string if the URL is invalid or no hostname is present.
242  + Params:
243  +   result = The `ada_url` handle.
244  + Returns: An `ada_string` containing the hostname.
245  +/
246    ada_string ada_get_hostname(scope ada_url result) @trusted;
247 
248    /++
249  + Retrieves the pathname component of a parsed URL.
250  + Returns an empty string if the URL is invalid or no pathname is present.
251  + Params:
252  +   result = The `ada_url` handle.
253  + Returns: An `ada_string` containing the pathname.
254  +/
255    ada_string ada_get_pathname(scope ada_url result) @trusted;
256 
257    /++
258  + Retrieves the search (query) component of a parsed URL.
259  + Returns an empty string if the URL is invalid or no search is present.
260  + Params:
261  +   result = The `ada_url` handle.
262  + Returns: An `ada_string` containing the search.
263  +/
264    ada_string ada_get_search(scope ada_url result) @trusted;
265 
266    /++
267  + Retrieves the protocol component of a parsed URL (e.g., "http:").
268  + Returns an empty string if the URL is invalid or no protocol is present.
269  + Params:
270  +   result = The `ada_url` handle.
271  + Returns: An `ada_string` containing the protocol.
272  +/
273    ada_string ada_get_protocol(scope ada_url result) @trusted;
274 
275    /++
276  + Retrieves the host type of a parsed URL.
277  + Returns an undefined value if the URL is invalid.
278  + Params:
279  +   result = The `ada_url` handle.
280  + Returns: A ubyte representing the host type (as defined by the Ada library).
281  +/
282    ubyte ada_get_host_type(scope ada_url result) @trusted;
283 
284    /++
285  + Retrieves the scheme type of a parsed URL.
286  + Returns an undefined value if the URL is invalid.
287  + Params:
288  +   result = The `ada_url` handle.
289  + Returns: A ubyte representing the scheme type (as defined by the Ada library).
290  +/
291    ubyte ada_get_scheme_type(scope ada_url result) @trusted;
292 
293    /++
294  + Sets the full URL (href) of a parsed URL.
295  + Has no effect if the URL is invalid.
296  + Params:
297  +   result = The `ada_url` handle.
298  +   input = The new URL string (null-terminated C string).
299  +   length = The length of the input string.
300  + Returns: true if successful, false otherwise.
301  +/
302    bool ada_set_href(scope ada_url result, scope const(char)* input, size_t length) @trusted;
303 
304    /++
305  + Sets the host component of a parsed URL.
306  + Has no effect if the URL is invalid.
307  + Params:
308  +   result = The `ada_url` handle.
309  +   input = The new host string (null-terminated C string).
310  +   length = The length of the input string.
311  + Returns: true if successful, false otherwise.
312  +/
313    bool ada_set_host(scope ada_url result, scope const(char)* input, size_t length) @trusted;
314 
315    /++
316  + Sets the hostname component of a parsed URL.
317  + Has no effect if the URL is invalid.
318  + Params:
319  +   result = The `ada_url` handle.
320  +   input = The new hostname string (null-terminated C string).
321  +   length = The length of the input string.
322  + Returns: true if successful, false otherwise.
323  +/
324    bool ada_set_hostname(scope ada_url result, scope const(char)* input, size_t length) @trusted;
325 
326    /++
327  + Sets the protocol component of a parsed URL.
328  + Has no effect if the URL is invalid.
329  + Params:
330  +   result = The `ada_url` handle.
331  +   input = The new protocol string (null-terminated C string, e.g., "http:").
332  +   length = The length of the input string.
333  + Returns: true if successful, false otherwise.
334  +/
335    bool ada_set_protocol(scope ada_url result, scope const(char)* input, size_t length) @trusted;
336 
337    /++
338  + Sets the username component of a parsed URL.
339  + Has no effect if the URL is invalid.
340  + Params:
341  +   result = The `ada_url` handle.
342  +   input = The new username string (null-terminated C string).
343  +   length = The length of the input string.
344  + Returns: true if successful, false otherwise.
345  +/
346    bool ada_set_username(scope ada_url result, scope const(char)* input, size_t length) @trusted;
347 
348    /++
349  + Sets the password component of a parsed URL.
350  + Has no effect if the URL is invalid.
351  + Params:
352  +   result = The `ada_url` handle.
353  +   input = The new password string (null-terminated C string).
354  +   length = The length of the input string.
355  + Returns: true if successful, false otherwise.
356  +/
357    bool ada_set_password(scope ada_url result, scope const(char)* input, size_t length) @trusted;
358 
359    /++
360  + Sets the port component of a parsed URL.
361  + Has no effect if the URL is invalid.
362  + Params:
363  +   result = The `ada_url` handle.
364  +   input = The new port string (null-terminated C string).
365  +   length = The length of the input string.
366  + Returns: true if successful, false otherwise.
367  +/
368    bool ada_set_port(scope ada_url result, scope const(char)* input, size_t length) @trusted;
369 
370    /++
371  + Sets the pathname component of a parsed URL.
372  + Has no effect if the URL is invalid.
373  + Params:
374  +   result = The `ada_url` handle.
375  +   input = The new pathname string (null-terminated C string).
376  +   length = The length of the input string.
377  + Returns: true if successful, false otherwise.
378  +/
379    bool ada_set_pathname(scope ada_url result, scope const(char)* input, size_t length) @trusted;
380 
381    /++
382  + Sets the search (query) component of a parsed URL.
383  + Has no effect if the URL is invalid.
384  + Params:
385  +   result = The `ada_url` handle.
386  +   input = The new search string (null-terminated C string).
387  +   length = The length of the input string.
388  +/
389    void ada_set_search(scope ada_url result, scope const(char)* input, size_t length) @trusted;
390 
391    /++
392  + Sets the hash (fragment) component of a parsed URL.
393  + Has no effect if the URL is invalid.
394  + Params:
395  +   result = The `ada_url` handle.
396  +   input = The new hash string (null-terminated C string).
397  +   length = The length of the input string.
398  +/
399    void ada_set_hash(scope ada_url result, scope const(char)* input, size_t length) @trusted;
400 
401    /++
402  + Clears the port component of a parsed URL.
403  + Has no effect if the URL is invalid.
404  + Params:
405  +   result = The `ada_url` handle.
406  +/
407    void ada_clear_port(scope ada_url result) @trusted;
408 
409    /++
410  + Clears the hash (fragment) component of a parsed URL.
411  + Has no effect if the URL is invalid.
412  + Params:
413  +   result = The `ada_url` handle.
414  +/
415    void ada_clear_hash(scope ada_url result) @trusted;
416 
417    /++
418  + Clears the search (query) component of a parsed URL.
419  + Has no effect if the URL is invalid.
420  + Params:
421  +   result = The `ada_url` handle.
422  +/
423    void ada_clear_search(scope ada_url result) @trusted;
424 
425    /++
426  + Checks if a parsed URL has credentials (username or password).
427  + Returns false if the URL is invalid.
428  + Params:
429  +   result = The `ada_url` handle.
430  + Returns: true if credentials are present, false otherwise.
431  +/
432    bool ada_has_credentials(scope ada_url result) @trusted;
433 
434    /++
435  + Checks if a parsed URL has an empty hostname.
436  + Returns false if the URL is invalid.
437  + Params:
438  +   result = The `ada_url` handle.
439  + Returns: true if the hostname is empty, false otherwise.
440  +/
441    bool ada_has_empty_hostname(scope ada_url result) @trusted;
442 
443    /++
444  + Checks if a parsed URL has a hostname.
445  + Returns false if the URL is invalid.
446  + Params:
447  +   result = The `ada_url` handle.
448  + Returns: true if a hostname is present, false otherwise.
449  +/
450    bool ada_has_hostname(scope ada_url result) @trusted;
451 
452    /++
453  + Checks if a parsed URL has a non-empty username.
454  + Returns false if the URL is invalid.
455  + Params:
456  +   result = The `ada_url` handle.
457  + Returns: true if the username is non-empty, false otherwise.
458  +/
459    bool ada_has_non_empty_username(scope ada_url result) @trusted;
460 
461    /++
462  + Checks if a parsed URL has a non-empty password.
463  + Returns false if the URL is invalid.
464  + Params:
465  +   result = The `ada_url` handle.
466  + Returns: true if the password is non-empty, false otherwise.
467  +/
468    bool ada_has_non_empty_password(scope ada_url result) @trusted;
469 
470    /++
471  + Checks if a parsed URL has a port.
472  + Returns false if the URL is invalid.
473  + Params:
474  +   result = The `ada_url` handle.
475  + Returns: true if a port is present, false otherwise.
476  +/
477    bool ada_has_port(scope ada_url result) @trusted;
478 
479    /++
480  + Checks if a parsed URL has a password.
481  + Returns false if the URL is invalid.
482  + Params:
483  +   result = The `ada_url` handle.
484  + Returns: true if a password is present, false otherwise.
485  +/
486    bool ada_has_password(scope ada_url result) @trusted;
487 
488    /++
489  + Checks if a parsed URL has a hash (fragment).
490  + Returns false if the URL is invalid.
491  + Params:
492  +   result = The `ada_url` handle.
493  + Returns: true if a hash is present, false otherwise.
494  +/
495    bool ada_has_hash(scope ada_url result) @trusted;
496 
497    /++
498  + Checks if a parsed URL has a search (query) component.
499  + Returns false if the URL is invalid.
500  + Params:
501  +   result = The `ada_url` handle.
502  + Returns: true if a search is present, false otherwise.
503  +/
504    bool ada_has_search(scope ada_url result) @trusted;
505 
506    /++
507  + Retrieves the internal components of a parsed URL.
508  + Params:
509  +   result = The `ada_url` handle.
510  + Returns: A pointer to the `ada_url_components` struct, or null if the URL is invalid.
511  +/
512    scope ada_url_components* ada_get_components(scope ada_url result) @trusted;
513 
514    /++
515  + Converts an IDNA-encoded string to Unicode.
516  + Params:
517  +   input = The input string (null-terminated C string).
518  +   length = The length of the input string.
519  + Returns: An `ada_owned_string` containing the Unicode string, which must be freed with `ada_free_owned_string`.
520  +/
521    ada_owned_string ada_idna_to_unicode(scope const(char)* input, size_t length) @trusted;
522 
523    /++
524  + Converts a Unicode string to IDNA-encoded ASCII.
525  + Params:
526  +   input = The input string (null-terminated C string).
527  +   length = The length of the input string.
528  + Returns: An `ada_owned_string` containing the ASCII string, which must be freed with `ada_free_owned_string`.
529  +/
530    ada_owned_string ada_idna_to_ascii(scope const(char)* input, size_t length) @trusted;
531 
532    /++
533  + Parses a query string into search parameters.
534  + Params:
535  +   input = The query string (null-terminated C string).
536  +   length = The length of the input string.
537  + Returns: An `ada_url_search_params` handle, which must be freed with `ada_free_search_params`.
538  +/
539    ada_url_search_params ada_parse_search_params(scope const(char)* input, size_t length) @trusted;
540 
541    /++
542  + Frees the resources associated with search parameters.
543  + Params:
544  +   result = The `ada_url_search_params` handle to free.
545  +/
546    void ada_free_search_params(scope ada_url_search_params result) @trusted;
547 
548    /++
549  + Retrieves the number of key-value pairs in search parameters.
550  + Params:
551  +   result = The `ada_url_search_params` handle.
552  + Returns: The number of pairs.
553  +/
554    size_t ada_search_params_size(scope ada_url_search_params result) @trusted;
555 
556    /++
557  + Sorts the search parameters by key.
558  + Params:
559  +   result = The `ada_url_search_params` handle.
560  +/
561    void ada_search_params_sort(scope ada_url_search_params result) @trusted;
562 
563    /++
564  + Converts search parameters to a query string.
565  + Params:
566  +   result = The `ada_url_search_params` handle.
567  + Returns: An `ada_owned_string` containing the query string, which must be freed with `ada_free_owned_string`.
568  +/
569    ada_owned_string ada_search_params_to_string(scope ada_url_search_params result) @trusted;
570 
571    /++
572  + Appends a key-value pair to search parameters.
573  + Params:
574  +   result = The `ada_url_search_params` handle.
575  +   key = The key string (null-terminated C string).
576  +   key_length = The length of the key string.
577  +   value = The value string (null-terminated C string).
578  +   value_length = The length of the value string.
579  +/
580    void ada_search_params_append(scope ada_url_search_params result, scope const(char)* key, size_t key_length, const(
581          char)* value, size_t value_length) @trusted;
582 
583    /++
584  + Sets a key-value pair in search parameters, replacing any existing values for the key.
585  + Params:
586  +   result = The `ada_url_search_params` handle.
587  +   key = The key string (null-terminated C string).
588  +   key_length = The length of the key string.
589  +   value = The value string (null-terminated C string).
590  +   value_length = The length of the value string.
591  +/
592    void ada_search_params_set(scope ada_url_search_params result, scope const(char)* key, size_t key_length, const(
593          char)* value, size_t value_length) @trusted;
594 
595    /++
596  + Removes all values for a given key in search parameters.
597  + Params:
598  +   result = The `ada_url_search_params` handle.
599  +   key = The key string (null-terminated C string).
600  +   key_length = The length of the key string.
601  +/
602    void ada_search_params_remove(scope ada_url_search_params result, scope const(char)* key, size_t key_length) @trusted;
603 
604    /++
605  + Removes a specific key-value pair from search parameters.
606  + Params:
607  +   result = The `ada_url_search_params` handle.
608  +   key = The key string (null-terminated C string).
609  +   key_length = The length of the key string.
610  +   value = The value string (null-terminated C string).
611  +   value_length = The length of the value string.
612  +/
613    void ada_search_params_remove_value(scope ada_url_search_params result, scope const(char)* key, size_t key_length, const(
614          char)* value, size_t value_length) @trusted;
615 
616    /++
617  + Checks if a key exists in search parameters.
618  + Params:
619  +   result = The `ada_url_search_params` handle.
620  +   key = The key string "::" (null-terminated C string).
621  +   key_length = The length of the key string.
622  + Returns: true if the key exists, false otherwise.
623  +/
624    bool ada_search_params_has(scope ada_url_search_params result, scope const(char)* key, size_t key_length) @trusted;
625 
626    /++
627  + Checks if a key-value pair exists in search parameters.
628  + Params:
629  +   result = The `ada_url_search_params` handle.
630  +   key = The key string (null-terminated C string).
631  +   key_length = The length of the key string.
632  +   value = The value string (null-terminated C string).
633  +   value_length = The length of the value string.
634  + Returns: true if the key-value pair exists, false otherwise.
635  +/
636    bool ada_search_params_has_value(scope ada_url_search_params result, scope const(char)* key, size_t key_length, const(
637          char)* value, size_t value_length) @trusted;
638 
639    /++
640  + Retrieves the value for a given key in search parameters.
641  + Params:
642  +   result = The `ada_url_search_params` handle.
643  +   key = The key string (null-terminated C string).
644  +   key_length = The length of the key string.
645  + Returns: An `ada_string` containing the value, or empty if not found.
646  +/
647    ada_string ada_search_params_get(scope ada_url_search_params result, scope const(char)* key, size_t key_length) @trusted;
648 
649    /++
650  + Retrieves all values for a given key in search parameters.
651  + Params:
652  +   result = The `ada_url_search_params` handle.
653  +   key = The key string (null-terminated C string).
654  +   key_length = The length of the key string.
655  + Returns: An `ada_strings` handle containing all values, which must be freed with `ada_free_strings`.
656  +/
657    ada_strings ada_search_params_get_all(scope ada_url_search_params result, scope const(char)* key, size_t key_length) @trusted;
658 
659    /++
660  + Resets search parameters to a new query string.
661  + Params:
662  +   result = The `ada_url_search_params` handle.
663  +   input = The new query string (null-terminated C string).
664  +   length = The length of the input string.
665  +/
666    void ada_search_params_reset(scope ada_url_search_params result, scope const(char)* input, size_t length) @trusted;
667 
668    /++
669  + Retrieves an iterator for the keys in search parameters.
670  + Params:
671  +   result = The `ada_url_search_params` handle.
672  + Returns: An `ada_url_search_params_keys_iter` handle, which must be freed with `ada_free_search_params_keys_iter`.
673  +/
674    ada_url_search_params_keys_iter ada_search_params_get_keys(scope ada_url_search_params result) @trusted;
675 
676    /++
677  + Retrieves an iterator for the values in search parameters.
678  + Params:
679  +   result = The `ada_url_search_params` handle.
680  + Returns: An `ada_url_search_params_values_iter` handle, which must be freed with `ada_free_search_params_values_iter`.
681  +/
682    ada_url_search_params_values_iter ada_search_params_get_values(scope ada_url_search_params result) @trusted;
683 
684    /++
685  + Retrieves an iterator for the key-value pairs in search parameters.
686  + Params:
687  +   result = The `ada_url_search_params` handle.
688  + Returns: An `ada_url_search_params_entries_iter` handle, which must be freed with `ada_free_search_params_entries_iter`.
689  +/
690    ada_url_search_params_entries_iter ada_search_params_get_entries(
691       scope ada_url_search_params result) @trusted;
692 
693    /++
694  + Frees the resources associated with a string collection.
695  + Params:
696  +   result = The `ada_strings` handle to free.
697  +/
698    void ada_free_strings(ada_strings result) @trusted;
699 
700    /++
701  + Retrieves the number of strings in a collection.
702  + Params:
703  +   result = The `ada_strings` handle.
704  + Returns: The number of strings.
705  +/
706    size_t ada_strings_size(ada_strings result) @trusted;
707 
708    /++
709  + Retrieves a string at a specific index in a collection.
710  + Params:
711  +   result = The `ada_strings` handle.
712  +   index = The index of the string to retrieve.
713  + Returns: An `ada_string` containing the string at the specified index.
714  +/
715    ada_string ada_strings_get(ada_strings result, size_t index) @trusted;
716 
717    /++
718  + Frees the resources associated with a search parameters keys iterator.
719  + Params:
720  +   result = The `ada_url_search_params_keys_iter` handle to free.
721  +/
722    void ada_free_search_params_keys_iter(scope ada_url_search_params_keys_iter result) @trusted;
723 
724    /++
725  + Retrieves the next key from a search parameters keys iterator.
726  + Params:
727  +   result = The `ada_url_search_params_keys_iter` handle.
728  + Returns: An `ada_string` containing the next key, or empty if no more keys.
729  +/
730    ada_string ada_search_params_keys_iter_next(scope ada_url_search_params_keys_iter result) @trusted;
731 
732    /++
733  + Checks if there are more keys in a search parameters keys iterator.
734  + Params:
735  +   result = The `ada_url_search_params_keys_iter` handle.
736  + Returns: true if there are more keys, false otherwise.
737  +/
738    bool ada_search_params_keys_iter_has_next(scope ada_url_search_params_keys_iter result) @trusted;
739 
740    /++
741  + Frees the resources associated with a search parameters values iterator.
742  + Params:
743  +   result = The `ada_url_search_params_values_iter` handle to free.
744  +/
745    void ada_free_search_params_values_iter(scope ada_url_search_params_values_iter result) @trusted;
746 
747    /++
748  + Retrieves the next value from a search parameters values iterator.
749  + Params:
750  +   result = The `ada_url_search_params_values_iter` handle.
751  + Returns: An `ada_string` containing the next value, or empty if no more values.
752  +/
753    ada_string ada_search_params_values_iter_next(scope ada_url_search_params_values_iter result) @trusted;
754 
755    /++
756  + Checks if there are more values in a search parameters values iterator.
757  + Params:
758  +   result = The `ada_url_search_params_values_iter` handle.
759  + Returns: true if there are more values, false otherwise.
760  +/
761    bool ada_search_params_values_iter_has_next(scope ada_url_search_params_values_iter result) @trusted;
762 
763    /++
764  + Frees the resources associated with a search parameters entries iterator.
765  + Params:
766  +   result = The `ada_url_search_params_entries_iter` handle to free.
767  +/
768    void ada_free_search_params_entries_iter(scope ada_url_search_params_entries_iter result) @trusted;
769 
770    /++
771  + Retrieves the next key-value pair from a search parameters entries iterator.
772  + Params:
773  +   result = The `ada_url_search_params_entries_iter` handle.
774  + Returns: An `ada_string_pair` containing the next key-value pair, or empty if no more entries.
775  +/
776    ada_string_pair ada_search_params_entries_iter_next(
777       scope ada_url_search_params_entries_iter result) @trusted;
778 
779    /++
780  + Checks if there are more key-value pairs in a search parameters entries iterator.
781  + Params:
782  +   result = The `ada_url_search_params_entries_iter` handle.
783  + Returns: true if there are more entries, false otherwise.
784  +/
785    bool ada_search_params_entries_iter_has_next(scope ada_url_search_params_entries_iter result) @trusted;
786 }