Skip to main content

fastly_sys/
lib.rs

1// TODO ACF 2020-12-01: remove once this is fixed: https://github.com/rust-lang/rust/issues/79581
2#![allow(clashing_extern_declarations)]
3
4//! FFI bindings to the Fastly Compute ABI.
5//!
6//! This is a low-level package; the [`fastly`](https://docs.rs/fastly) crate wraps these functions
7//! in a much friendlier, Rust-like interface. You should not have to depend on this crate
8//! explicitly in your `Cargo.toml`.
9//!
10//! # Versioning and compatibility
11//!
12//! The Cargo version of this package was previously set according to compatibility with the
13//! Compute platform. Since the [`v0.25.0` release of the Fastly
14//! CLI](https://github.com/fastly/cli/releases/tag/v0.25.0), the CLI is configured with the range
15//! of `fastly-sys` versions that are currently compatible with the Compute platform. The Cargo
16//! version of this package since `0.4.0` instead follows the [Cargo SemVer compatibility
17//! guidelines](https://doc.rust-lang.org/cargo/reference/semver.html).
18use fastly_shared::FastlyStatus;
19
20pub mod fastly_cache;
21pub mod fastly_config_store;
22pub mod fastly_http_cache;
23
24// The following type aliases are used for readability of definitions in this module. They should
25// not be confused with types of similar names in the `fastly` crate which are used to provide safe
26// wrappers around these definitions.
27
28pub type AclHandle = u32;
29pub type AsyncItemHandle = u32;
30pub type BodyHandle = u32;
31pub type DictionaryHandle = u32;
32pub type KVStoreHandle = u32;
33pub type PendingObjectStoreDeleteHandle = u32;
34pub type PendingObjectStoreInsertHandle = u32;
35pub type PendingObjectStoreListHandle = u32;
36pub type PendingObjectStoreLookupHandle = u32;
37pub type PendingRequestHandle = u32;
38pub type RequestHandle = u32;
39pub type RequestPromiseHandle = u32;
40pub type ResponseHandle = u32;
41pub type SecretHandle = u32;
42pub type SecretStoreHandle = u32;
43
44#[repr(C)]
45pub struct DynamicBackendConfig {
46    pub host_override: *const u8,
47    pub host_override_len: u32,
48    pub connect_timeout_ms: u32,
49    pub first_byte_timeout_ms: u32,
50    pub between_bytes_timeout_ms: u32,
51    pub ssl_min_version: u32,
52    pub ssl_max_version: u32,
53    pub cert_hostname: *const u8,
54    pub cert_hostname_len: u32,
55    pub ca_cert: *const u8,
56    pub ca_cert_len: u32,
57    pub ciphers: *const u8,
58    pub ciphers_len: u32,
59    pub sni_hostname: *const u8,
60    pub sni_hostname_len: u32,
61    pub client_certificate: *const u8,
62    pub client_certificate_len: u32,
63    pub client_key: SecretHandle,
64    pub http_keepalive_time_ms: u32,
65    pub tcp_keepalive_enable: u32,
66    pub tcp_keepalive_interval_secs: u32,
67    pub tcp_keepalive_probes: u32,
68    pub tcp_keepalive_time_secs: u32,
69    pub max_connections: u32,
70    pub max_use: u32,
71    pub max_lifetime_ms: u32,
72}
73
74impl Default for DynamicBackendConfig {
75    fn default() -> Self {
76        DynamicBackendConfig {
77            host_override: std::ptr::null(),
78            host_override_len: 0,
79            connect_timeout_ms: 0,
80            first_byte_timeout_ms: 0,
81            between_bytes_timeout_ms: 0,
82            ssl_min_version: 0,
83            ssl_max_version: 0,
84            cert_hostname: std::ptr::null(),
85            cert_hostname_len: 0,
86            ca_cert: std::ptr::null(),
87            ca_cert_len: 0,
88            ciphers: std::ptr::null(),
89            ciphers_len: 0,
90            sni_hostname: std::ptr::null(),
91            sni_hostname_len: 0,
92            client_certificate: std::ptr::null(),
93            client_certificate_len: 0,
94            client_key: 0,
95            http_keepalive_time_ms: 0,
96            tcp_keepalive_enable: 0,
97            tcp_keepalive_interval_secs: 0,
98            tcp_keepalive_probes: 0,
99            tcp_keepalive_time_secs: 0,
100            max_connections: 0,
101            max_use: 0,
102            max_lifetime_ms: 0,
103        }
104    }
105}
106
107/// Selects the behavior for an insert when the new key matches an existing key.
108///
109/// A KV store maintains the property that its keys are unique from each other. If an insert
110/// has a key that doesn't match any key already in the store, then the pair of the key and the
111/// new value is inserted into the store. However, if the insert's key does match a key already
112/// in the store, then no new key-value pair is inserted, and the insert's mode
113/// determines what it does instead.
114#[repr(C)]
115#[derive(Default, Clone, Copy)]
116pub enum InsertMode {
117    /// Updates the existing key's value by overwriting it with the new value.
118    ///
119    /// This is the default mode.
120    #[default]
121    Overwrite,
122
123    /// Fails, leaving the existing key's value unmodified.
124    ///
125    /// With this mode, the insert fails with a “precondition failed” error, and
126    /// does not modify the existing value. Inserts with this mode will only “add” new key-value
127    /// pairs; they are prevented from modifying any existing ones.
128    Add,
129
130    /// Updates the existing key's value by appending the new value to it.
131    Append,
132
133    /// Updates the existing key's value by prepending the new value to it.
134    Prepend,
135}
136
137#[repr(C)]
138pub struct InsertConfig {
139    pub mode: InsertMode,
140    pub unused: u32,
141    pub metadata: *const u8,
142    pub metadata_len: u32,
143    pub time_to_live_sec: u32,
144    pub if_generation_match: u64,
145}
146
147impl Default for InsertConfig {
148    fn default() -> Self {
149        InsertConfig {
150            mode: InsertMode::Overwrite,
151            unused: 0,
152            metadata: std::ptr::null(),
153            metadata_len: 0,
154            time_to_live_sec: 0,
155            if_generation_match: 0,
156        }
157    }
158}
159
160/// Modes of KV Store list operations.
161///
162/// This type serves to facilitate alternative methods of cache interactions with list operations.
163#[repr(C)]
164#[derive(Default, Clone)]
165pub enum ListMode {
166    /// The default method of listing. Performs an un-cached list on every invocation.
167    #[default]
168    Strong,
169    /// Returns a cached list response to improve performance.
170    ///
171    /// The data may be slightly out of sync with the store, but repeated calls are faster.
172    ///
173    /// The word “eventual” here refers to eventual consistency.
174    Eventual,
175    /// Handles unexpected or unknown list modes returned by the upstream API.
176    ///
177    /// This variant is a catch-all and should not be constructed manually by SDK consumers.
178    Other(String),
179}
180
181#[repr(C)]
182#[derive(Default, Clone)]
183pub enum ListModeInternal {
184    #[default]
185    Strong,
186    Eventual,
187}
188
189#[repr(C)]
190pub struct ListConfig {
191    pub mode: ListModeInternal,
192    pub cursor: *const u8,
193    pub cursor_len: u32,
194    pub limit: u32,
195    pub prefix: *const u8,
196    pub prefix_len: u32,
197}
198
199impl Default for ListConfig {
200    fn default() -> Self {
201        ListConfig {
202            mode: ListModeInternal::Strong,
203            cursor: std::ptr::null(),
204            cursor_len: 0,
205            limit: 0,
206            prefix: std::ptr::null(),
207            prefix_len: 0,
208        }
209    }
210}
211
212#[repr(C)]
213#[derive(Default)]
214pub struct LookupConfig {
215    // reserved is just a placeholder,
216    // can be removed when somethin real is added
217    reserved: u32,
218}
219
220#[repr(C)]
221#[derive(Default)]
222pub struct DeleteConfig {
223    // reserved is just a placeholder,
224    // can be removed when somethin real is added
225    reserved: u32,
226}
227
228bitflags::bitflags! {
229    /// `Content-Encoding` codings.
230    #[derive(Default)]
231    #[repr(transparent)]
232    pub struct ContentEncodings: u32 {
233        const GZIP = 1 << 0;
234    }
235}
236
237bitflags::bitflags! {
238    /// `BackendConfigOptions` codings.
239    #[derive(Default)]
240    #[repr(transparent)]
241    pub struct BackendConfigOptions: u32 {
242        const RESERVED = 1 << 0;
243        const HOST_OVERRIDE = 1 << 1;
244        const CONNECT_TIMEOUT = 1 << 2;
245        const FIRST_BYTE_TIMEOUT = 1 << 3;
246        const BETWEEN_BYTES_TIMEOUT = 1 << 4;
247        const USE_SSL = 1 << 5;
248        const SSL_MIN_VERSION = 1 << 6;
249        const SSL_MAX_VERSION = 1 << 7;
250        const CERT_HOSTNAME = 1 << 8;
251        const CA_CERT = 1 << 9;
252        const CIPHERS = 1 << 10;
253        const SNI_HOSTNAME = 1 << 11;
254        const DONT_POOL = 1 << 12;
255        const CLIENT_CERT = 1 << 13;
256        const GRPC = 1 << 14;
257        const KEEPALIVE = 1 << 15;
258        const POOLING_LIMITS = 1 << 16;
259        const PREFER_IPV4 = 1 << 17;
260    }
261    /// `InsertConfigOptions` codings.
262    #[derive(Default)]
263    #[repr(transparent)]
264    pub struct InsertConfigOptions: u32 {
265        const RESERVED = 1 << 0;
266        const BACKGROUND_FETCH = 1 << 1;
267        const RESERVED_2 = 1 << 2;
268        const METADATA = 1 << 3;
269        const TIME_TO_LIVE_SEC = 1 << 4;
270        const IF_GENERATION_MATCH = 1 << 5;
271    }
272    /// `ListConfigOptions` codings.
273    #[derive(Default)]
274    #[repr(transparent)]
275    pub struct ListConfigOptions: u32 {
276        const RESERVED = 1 << 0;
277        const CURSOR = 1 << 1;
278        const LIMIT = 1 << 2;
279        const PREFIX = 1 << 3;
280    }
281    /// `LookupConfigOptions` codings.
282    #[derive(Default)]
283    #[repr(transparent)]
284    pub struct LookupConfigOptions: u32 {
285        const RESERVED = 1 << 0;
286    }
287    /// `DeleteConfigOptions` codings.
288    #[derive(Default)]
289    #[repr(transparent)]
290    pub struct DeleteConfigOptions: u32 {
291        const RESERVED = 1 << 0;
292    }
293}
294
295pub mod fastly_abi {
296    use super::*;
297
298    #[link(wasm_import_module = "fastly_abi")]
299    extern "C" {
300        #[link_name = "init"]
301        /// Tell the runtime what ABI version this program is using (FASTLY_ABI_VERSION)
302        pub fn init(abi_version: u64) -> FastlyStatus;
303    }
304}
305
306#[deprecated(since = "0.11.6")]
307pub mod fastly_uap {
308    use super::*;
309
310    #[link(wasm_import_module = "fastly_uap")]
311    extern "C" {
312        #[link_name = "parse"]
313        pub fn parse(
314            user_agent: *const u8,
315            user_agent_max_len: usize,
316            family: *mut u8,
317            family_max_len: usize,
318            family_written: *mut usize,
319            major: *mut u8,
320            major_max_len: usize,
321            major_written: *mut usize,
322            minor: *mut u8,
323            minor_max_len: usize,
324            minor_written: *mut usize,
325            patch: *mut u8,
326            patch_max_len: usize,
327            patch_written: *mut usize,
328        ) -> FastlyStatus;
329    }
330}
331
332pub mod fastly_http_body {
333    use super::*;
334
335    #[link(wasm_import_module = "fastly_http_body")]
336    extern "C" {
337        #[link_name = "append"]
338        pub fn append(dst_handle: BodyHandle, src_handle: BodyHandle) -> FastlyStatus;
339
340        #[link_name = "new"]
341        pub fn new(handle_out: *mut BodyHandle) -> FastlyStatus;
342
343        #[link_name = "read"]
344        pub fn read(
345            body_handle: BodyHandle,
346            buf: *mut u8,
347            buf_len: usize,
348            nread_out: *mut usize,
349        ) -> FastlyStatus;
350
351        // overeager warning for extern declarations is a rustc bug: https://github.com/rust-lang/rust/issues/79581
352        #[allow(clashing_extern_declarations)]
353        #[link_name = "write"]
354        pub fn write(
355            body_handle: BodyHandle,
356            buf: *const u8,
357            buf_len: usize,
358            end: fastly_shared::BodyWriteEnd,
359            nwritten_out: *mut usize,
360        ) -> FastlyStatus;
361
362        /// Close a body, freeing its resources and causing any sends to finish.
363        #[link_name = "close"]
364        pub fn close(body_handle: BodyHandle) -> FastlyStatus;
365
366        /// Abandon a streaming body, freeing its resources and informing the peer that the stream
367        /// is incomplete.
368        #[link_name = "abandon"]
369        pub fn abandon(body_handle: BodyHandle) -> FastlyStatus;
370
371        #[link_name = "trailer_append"]
372        pub fn trailer_append(
373            body_handle: BodyHandle,
374            name: *const u8,
375            name_len: usize,
376            value: *const u8,
377            value_len: usize,
378        ) -> FastlyStatus;
379
380        #[link_name = "trailer_names_get"]
381        pub fn trailer_names_get(
382            body_handle: BodyHandle,
383            buf: *mut u8,
384            buf_len: usize,
385            cursor: u32,
386            ending_cursor: *mut i64,
387            nwritten: *mut usize,
388        ) -> FastlyStatus;
389
390        #[link_name = "trailer_value_get"]
391        pub fn trailer_value_get(
392            body_handle: BodyHandle,
393            name: *const u8,
394            name_len: usize,
395            value: *mut u8,
396            value_max_len: usize,
397            nwritten: *mut usize,
398        ) -> FastlyStatus;
399
400        #[link_name = "trailer_values_get"]
401        pub fn trailer_values_get(
402            body_handle: BodyHandle,
403            name: *const u8,
404            name_len: usize,
405            buf: *mut u8,
406            buf_len: usize,
407            cursor: u32,
408            ending_cursor: *mut i64,
409            nwritten: *mut usize,
410        ) -> FastlyStatus;
411
412        #[link_name = "known_length"]
413        pub fn known_length(body_handle: BodyHandle, length_out: *mut u64) -> FastlyStatus;
414    }
415}
416
417pub mod fastly_log {
418    use super::*;
419
420    #[link(wasm_import_module = "fastly_log")]
421    extern "C" {
422        #[link_name = "endpoint_get"]
423        pub fn endpoint_get(
424            name: *const u8,
425            name_len: usize,
426            endpoint_handle_out: *mut u32,
427        ) -> FastlyStatus;
428
429        // overeager warning for extern declarations is a rustc bug: https://github.com/rust-lang/rust/issues/79581
430        #[allow(clashing_extern_declarations)]
431        #[link_name = "write"]
432        pub fn write(
433            endpoint_handle: u32,
434            msg: *const u8,
435            msg_len: usize,
436            nwritten_out: *mut usize,
437        ) -> FastlyStatus;
438
439    }
440}
441
442pub mod fastly_http_downstream {
443    use super::*;
444
445    #[derive(Default)]
446    #[repr(C)]
447    pub struct NextRequestOptions {
448        pub timeout_ms: u64,
449    }
450
451    bitflags::bitflags! {
452        /// Request options.
453        #[derive(Default)]
454        #[repr(transparent)]
455        pub struct NextRequestOptionsMask: u32 {
456            const RESERVED = 1 << 0;
457            const TIMEOUT = 1 << 1;
458        }
459    }
460
461    #[link(wasm_import_module = "fastly_http_downstream")]
462    extern "C" {
463        #[link_name = "next_request"]
464        pub fn next_request(
465            options_mask: NextRequestOptionsMask,
466            options: *const NextRequestOptions,
467            handle_out: *mut RequestPromiseHandle,
468        ) -> FastlyStatus;
469
470        #[link_name = "next_request_wait"]
471        pub fn next_request_wait(
472            handle: RequestPromiseHandle,
473            req_handle_out: *mut RequestHandle,
474            body_handle_out: *mut BodyHandle,
475        ) -> FastlyStatus;
476
477        #[link_name = "next_request_abandon"]
478        pub fn next_request_abandon(handle: RequestPromiseHandle) -> FastlyStatus;
479
480        #[link_name = "downstream_original_header_names"]
481        pub fn downstream_original_header_names(
482            req_handle: RequestHandle,
483            buf: *mut u8,
484            buf_len: usize,
485            cursor: u32,
486            ending_cursor: *mut i64,
487            nwritten: *mut usize,
488        ) -> FastlyStatus;
489
490        #[link_name = "downstream_original_header_count"]
491        pub fn downstream_original_header_count(
492            req_handle: RequestHandle,
493            count_out: *mut u32,
494        ) -> FastlyStatus;
495
496        #[link_name = "downstream_client_ip_addr"]
497        pub fn downstream_client_ip_addr(
498            req_handle: RequestHandle,
499            addr_octets_out: *mut u8,
500            nwritten_out: *mut usize,
501        ) -> FastlyStatus;
502
503        #[link_name = "downstream_server_ip_addr"]
504        pub fn downstream_server_ip_addr(
505            req_handle: RequestHandle,
506            addr_octets_out: *mut u8,
507            nwritten_out: *mut usize,
508        ) -> FastlyStatus;
509
510        #[link_name = "downstream_client_h2_fingerprint"]
511        pub fn downstream_client_h2_fingerprint(
512            req_handle: RequestHandle,
513            h2fp_out: *mut u8,
514            h2fp_max_len: usize,
515            nwritten: *mut usize,
516        ) -> FastlyStatus;
517
518        #[link_name = "downstream_client_request_id"]
519        pub fn downstream_client_request_id(
520            req_handle: RequestHandle,
521            reqid_out: *mut u8,
522            reqid_max_len: usize,
523            nwritten: *mut usize,
524        ) -> FastlyStatus;
525
526        #[link_name = "downstream_client_oh_fingerprint"]
527        pub fn downstream_client_oh_fingerprint(
528            req_handle: RequestHandle,
529            ohfp_out: *mut u8,
530            ohfp_max_len: usize,
531            nwritten: *mut usize,
532        ) -> FastlyStatus;
533
534        #[link_name = "downstream_client_ddos_detected"]
535        pub fn downstream_client_ddos_detected(
536            req_handle: RequestHandle,
537            ddos_detected_out: *mut u32,
538        ) -> FastlyStatus;
539
540        #[link_name = "downstream_tls_cipher_openssl_name"]
541        pub fn downstream_tls_cipher_openssl_name(
542            req_handle: RequestHandle,
543            cipher_out: *mut u8,
544            cipher_max_len: usize,
545            nwritten: *mut usize,
546        ) -> FastlyStatus;
547
548        #[link_name = "downstream_tls_protocol"]
549        pub fn downstream_tls_protocol(
550            req_handle: RequestHandle,
551            protocol_out: *mut u8,
552            protocol_max_len: usize,
553            nwritten: *mut usize,
554        ) -> FastlyStatus;
555
556        #[link_name = "downstream_tls_client_hello"]
557        pub fn downstream_tls_client_hello(
558            req_handle: RequestHandle,
559            client_hello_out: *mut u8,
560            client_hello_max_len: usize,
561            nwritten: *mut usize,
562        ) -> FastlyStatus;
563
564        #[link_name = "downstream_tls_client_servername"]
565        pub fn downstream_tls_client_servername(
566            req_handle: RequestHandle,
567            sni_out: *mut u8,
568            sni_max_len: usize,
569            nwritten: *mut usize,
570        ) -> FastlyStatus;
571
572        #[link_name = "downstream_tls_ja3_md5"]
573        pub fn downstream_tls_ja3_md5(
574            req_handle: RequestHandle,
575            ja3_md5_out: *mut u8,
576            nwritten_out: *mut usize,
577        ) -> FastlyStatus;
578
579        #[link_name = "downstream_tls_ja4"]
580        pub fn downstream_tls_ja4(
581            req_handle: RequestHandle,
582            ja4_out: *mut u8,
583            ja4_max_len: usize,
584            nwritten: *mut usize,
585        ) -> FastlyStatus;
586
587        #[link_name = "downstream_compliance_region"]
588        pub fn downstream_compliance_region(
589            req_handle: RequestHandle,
590            region_out: *mut u8,
591            region_max_len: usize,
592            nwritten: *mut usize,
593        ) -> FastlyStatus;
594
595        #[link_name = "downstream_tls_raw_client_certificate"]
596        pub fn downstream_tls_raw_client_certificate(
597            req_handle: RequestHandle,
598            client_hello_out: *mut u8,
599            client_hello_max_len: usize,
600            nwritten: *mut usize,
601        ) -> FastlyStatus;
602
603        #[link_name = "downstream_tls_client_cert_verify_result"]
604        pub fn downstream_tls_client_cert_verify_result(
605            req_handle: RequestHandle,
606            verify_result_out: *mut u32,
607        ) -> FastlyStatus;
608
609        #[link_name = "fastly_key_is_valid"]
610        pub fn fastly_key_is_valid(
611            req_handle: RequestHandle,
612            is_valid_out: *mut u32,
613        ) -> FastlyStatus;
614
615        #[link_name = "downstream_bot_analyzed"]
616        pub fn downstream_bot_analyzed(
617            req_handle: RequestHandle,
618            bot_analyzed_out: *mut u32,
619        ) -> FastlyStatus;
620
621        #[link_name = "downstream_bot_detected"]
622        pub fn downstream_bot_detected(
623            req_handle: RequestHandle,
624            bot_detected_out: *mut u32,
625        ) -> FastlyStatus;
626
627        #[link_name = "downstream_bot_name"]
628        pub fn downstream_bot_name(
629            req_handle: RequestHandle,
630            bot_name_out: *mut u8,
631            bot_name_max_len: usize,
632            nwritten: *mut usize,
633        ) -> FastlyStatus;
634
635        #[link_name = "downstream_bot_category"]
636        pub fn downstream_bot_category(
637            req_handle: RequestHandle,
638            bot_category_out: *mut u8,
639            bot_category_max_len: usize,
640            nwritten: *mut usize,
641        ) -> FastlyStatus;
642
643        #[link_name = "downstream_bot_category_kind"]
644        pub fn downstream_bot_category_kind(
645            req_handle: RequestHandle,
646            bot_category_kind_out: *mut u32,
647        ) -> FastlyStatus;
648
649        #[link_name = "downstream_bot_verified"]
650        pub fn downstream_bot_verified(
651            req_handle: RequestHandle,
652            bot_verified_out: *mut u32,
653        ) -> FastlyStatus;
654    }
655}
656
657pub mod fastly_http_req {
658    use super::*;
659
660    bitflags::bitflags! {
661        #[derive(Default)]
662        #[repr(transparent)]
663        pub struct SendErrorDetailMask: u32 {
664            const RESERVED = 1 << 0;
665            const DNS_ERROR_RCODE = 1 << 1;
666            const DNS_ERROR_INFO_CODE = 1 << 2;
667            const TLS_ALERT_ID = 1 << 3;
668            const H2_ERROR = 1 << 4;
669        }
670    }
671
672    #[repr(u32)]
673    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
674    #[non_exhaustive]
675    pub enum SendErrorDetailTag {
676        Uninitialized,
677        Ok,
678        DnsTimeout,
679        DnsError,
680        DestinationNotFound,
681        DestinationUnavailable,
682        DestinationIpUnroutable,
683        ConnectionRefused,
684        ConnectionTerminated,
685        ConnectionTimeout,
686        ConnectionLimitReached,
687        TlsCertificateError,
688        TlsConfigurationError,
689        HttpIncompleteResponse,
690        HttpResponseHeaderSectionTooLarge,
691        HttpResponseBodyTooLarge,
692        HttpResponseTimeout,
693        HttpResponseStatusInvalid,
694        HttpUpgradeFailed,
695        HttpProtocolError,
696        HttpRequestCacheKeyInvalid,
697        HttpRequestUriInvalid,
698        InternalError,
699        TlsAlertReceived,
700        TlsProtocolError,
701        H2Error,
702    }
703
704    #[repr(C)]
705    #[derive(Clone, Debug, PartialEq, Eq)]
706    #[non_exhaustive]
707    pub struct SendErrorDetail {
708        pub tag: SendErrorDetailTag,
709        pub mask: SendErrorDetailMask,
710        pub dns_error_rcode: u16,
711        pub dns_error_info_code: u16,
712        pub tls_alert_id: u8,
713        pub h2_error_frame: u8,
714        pub h2_error_code: u32,
715    }
716
717    impl SendErrorDetail {
718        pub fn uninitialized_all() -> Self {
719            Self {
720                tag: SendErrorDetailTag::Uninitialized,
721                mask: SendErrorDetailMask::all(),
722                dns_error_rcode: Default::default(),
723                dns_error_info_code: Default::default(),
724                tls_alert_id: Default::default(),
725                h2_error_frame: Default::default(),
726                h2_error_code: Default::default(),
727            }
728        }
729    }
730
731    bitflags::bitflags! {
732        #[repr(transparent)]
733        pub struct InspectInfoMask: u32 {
734            const RESERVED = 1 << 0;
735            const CORP = 1 << 1;
736            const WORKSPACE = 1 << 2;
737            const OVERRIDE_CLIENT_IP = 1 << 3;
738        }
739    }
740
741    #[repr(C)]
742    pub struct InspectInfo {
743        pub corp: *const u8,
744        pub corp_len: u32,
745        pub workspace: *const u8,
746        pub workspace_len: u32,
747        pub override_client_ip_ptr: *const u8,
748        pub override_client_ip_len: u32,
749    }
750
751    impl Default for InspectInfo {
752        fn default() -> Self {
753            InspectInfo {
754                corp: std::ptr::null(),
755                corp_len: 0,
756                workspace: std::ptr::null(),
757                workspace_len: 0,
758                override_client_ip_ptr: std::ptr::null(),
759                override_client_ip_len: 0,
760            }
761        }
762    }
763
764    #[link(wasm_import_module = "fastly_http_req")]
765    extern "C" {
766        #[link_name = "body_downstream_get"]
767        pub fn body_downstream_get(
768            req_handle_out: *mut RequestHandle,
769            body_handle_out: *mut BodyHandle,
770        ) -> FastlyStatus;
771
772        #[link_name = "cache_override_set"]
773        pub fn cache_override_set(
774            req_handle: RequestHandle,
775            tag: u32,
776            ttl: u32,
777            swr: u32,
778        ) -> FastlyStatus;
779
780        #[link_name = "cache_override_v2_set"]
781        pub fn cache_override_v2_set(
782            req_handle: RequestHandle,
783            tag: u32,
784            ttl: u32,
785            swr: u32,
786            sk: *const u8,
787            sk_len: usize,
788        ) -> FastlyStatus;
789
790        #[link_name = "framing_headers_mode_set"]
791        pub fn framing_headers_mode_set(
792            req_handle: RequestHandle,
793            mode: fastly_shared::FramingHeadersMode,
794        ) -> FastlyStatus;
795
796        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
797        #[link_name = "downstream_client_ip_addr"]
798        pub fn downstream_client_ip_addr(
799            addr_octets_out: *mut u8,
800            nwritten_out: *mut usize,
801        ) -> FastlyStatus;
802
803        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
804        #[link_name = "downstream_server_ip_addr"]
805        pub fn downstream_server_ip_addr(
806            addr_octets_out: *mut u8,
807            nwritten_out: *mut usize,
808        ) -> FastlyStatus;
809
810        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
811        #[link_name = "downstream_client_h2_fingerprint"]
812        pub fn downstream_client_h2_fingerprint(
813            h2fp_out: *mut u8,
814            h2fp_max_len: usize,
815            nwritten: *mut usize,
816        ) -> FastlyStatus;
817
818        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
819        #[link_name = "downstream_client_request_id"]
820        pub fn downstream_client_request_id(
821            reqid_out: *mut u8,
822            reqid_max_len: usize,
823            nwritten: *mut usize,
824        ) -> FastlyStatus;
825
826        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
827        #[link_name = "downstream_client_oh_fingerprint"]
828        pub fn downstream_client_oh_fingerprint(
829            ohfp_out: *mut u8,
830            ohfp_max_len: usize,
831            nwritten: *mut usize,
832        ) -> FastlyStatus;
833
834        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
835        #[link_name = "downstream_client_ddos_detected"]
836        pub fn downstream_client_ddos_detected(ddos_detected_out: *mut u32) -> FastlyStatus;
837
838        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
839        #[link_name = "downstream_tls_cipher_openssl_name"]
840        pub fn downstream_tls_cipher_openssl_name(
841            cipher_out: *mut u8,
842            cipher_max_len: usize,
843            nwritten: *mut usize,
844        ) -> FastlyStatus;
845
846        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
847        #[link_name = "downstream_tls_protocol"]
848        pub fn downstream_tls_protocol(
849            protocol_out: *mut u8,
850            protocol_max_len: usize,
851            nwritten: *mut usize,
852        ) -> FastlyStatus;
853
854        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
855        #[link_name = "downstream_tls_client_hello"]
856        pub fn downstream_tls_client_hello(
857            client_hello_out: *mut u8,
858            client_hello_max_len: usize,
859            nwritten: *mut usize,
860        ) -> FastlyStatus;
861
862        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
863        #[link_name = "downstream_tls_ja3_md5"]
864        pub fn downstream_tls_ja3_md5(
865            ja3_md5_out: *mut u8,
866            nwritten_out: *mut usize,
867        ) -> FastlyStatus;
868
869        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
870        #[link_name = "downstream_tls_ja4"]
871        pub fn downstream_tls_ja4(
872            ja4_out: *mut u8,
873            ja4_max_len: usize,
874            nwritten: *mut usize,
875        ) -> FastlyStatus;
876
877        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
878        #[link_name = "downstream_compliance_region"]
879        pub fn downstream_compliance_region(
880            region_out: *mut u8,
881            region_max_len: usize,
882            nwritten: *mut usize,
883        ) -> FastlyStatus;
884
885        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
886        #[link_name = "downstream_tls_raw_client_certificate"]
887        pub fn downstream_tls_raw_client_certificate(
888            client_hello_out: *mut u8,
889            client_hello_max_len: usize,
890            nwritten: *mut usize,
891        ) -> FastlyStatus;
892
893        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
894        #[link_name = "downstream_tls_client_cert_verify_result"]
895        pub fn downstream_tls_client_cert_verify_result(
896            verify_result_out: *mut u32,
897        ) -> FastlyStatus;
898
899        #[link_name = "header_append"]
900        pub fn header_append(
901            req_handle: RequestHandle,
902            name: *const u8,
903            name_len: usize,
904            value: *const u8,
905            value_len: usize,
906        ) -> FastlyStatus;
907
908        #[link_name = "header_insert"]
909        pub fn header_insert(
910            req_handle: RequestHandle,
911            name: *const u8,
912            name_len: usize,
913            value: *const u8,
914            value_len: usize,
915        ) -> FastlyStatus;
916
917        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
918        #[link_name = "original_header_names_get"]
919        pub fn original_header_names_get(
920            buf: *mut u8,
921            buf_len: usize,
922            cursor: u32,
923            ending_cursor: *mut i64,
924            nwritten: *mut usize,
925        ) -> FastlyStatus;
926
927        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
928        #[link_name = "original_header_count"]
929        pub fn original_header_count(count_out: *mut u32) -> FastlyStatus;
930
931        #[link_name = "header_names_get"]
932        pub fn header_names_get(
933            req_handle: RequestHandle,
934            buf: *mut u8,
935            buf_len: usize,
936            cursor: u32,
937            ending_cursor: *mut i64,
938            nwritten: *mut usize,
939        ) -> FastlyStatus;
940
941        #[link_name = "header_values_get"]
942        pub fn header_values_get(
943            req_handle: RequestHandle,
944            name: *const u8,
945            name_len: usize,
946            buf: *mut u8,
947            buf_len: usize,
948            cursor: u32,
949            ending_cursor: *mut i64,
950            nwritten: *mut usize,
951        ) -> FastlyStatus;
952
953        #[link_name = "header_values_set"]
954        pub fn header_values_set(
955            req_handle: RequestHandle,
956            name: *const u8,
957            name_len: usize,
958            values: *const u8,
959            values_len: usize,
960        ) -> FastlyStatus;
961
962        #[link_name = "header_value_get"]
963        pub fn header_value_get(
964            req_handle: RequestHandle,
965            name: *const u8,
966            name_len: usize,
967            value: *mut u8,
968            value_max_len: usize,
969            nwritten: *mut usize,
970        ) -> FastlyStatus;
971
972        #[link_name = "header_remove"]
973        pub fn header_remove(
974            req_handle: RequestHandle,
975            name: *const u8,
976            name_len: usize,
977        ) -> FastlyStatus;
978
979        #[link_name = "method_get"]
980        pub fn method_get(
981            req_handle: RequestHandle,
982            method: *mut u8,
983            method_max_len: usize,
984            nwritten: *mut usize,
985        ) -> FastlyStatus;
986
987        #[link_name = "method_set"]
988        pub fn method_set(
989            req_handle: RequestHandle,
990            method: *const u8,
991            method_len: usize,
992        ) -> FastlyStatus;
993
994        #[link_name = "new"]
995        pub fn new(req_handle_out: *mut RequestHandle) -> FastlyStatus;
996
997        #[link_name = "send_v2"]
998        pub fn send_v2(
999            req_handle: RequestHandle,
1000            body_handle: BodyHandle,
1001            backend: *const u8,
1002            backend_len: usize,
1003            error_detail: *mut SendErrorDetail,
1004            resp_handle_out: *mut ResponseHandle,
1005            resp_body_handle_out: *mut BodyHandle,
1006        ) -> FastlyStatus;
1007
1008        #[link_name = "send_v3"]
1009        pub fn send_v3(
1010            req_handle: RequestHandle,
1011            body_handle: BodyHandle,
1012            backend: *const u8,
1013            backend_len: usize,
1014            error_detail: *mut SendErrorDetail,
1015            resp_handle_out: *mut ResponseHandle,
1016            resp_body_handle_out: *mut BodyHandle,
1017        ) -> FastlyStatus;
1018
1019        #[link_name = "send_async"]
1020        pub fn send_async(
1021            req_handle: RequestHandle,
1022            body_handle: BodyHandle,
1023            backend: *const u8,
1024            backend_len: usize,
1025            pending_req_handle_out: *mut PendingRequestHandle,
1026        ) -> FastlyStatus;
1027
1028        #[link_name = "send_async_streaming"]
1029        pub fn send_async_streaming(
1030            req_handle: RequestHandle,
1031            body_handle: BodyHandle,
1032            backend: *const u8,
1033            backend_len: usize,
1034            pending_req_handle_out: *mut PendingRequestHandle,
1035        ) -> FastlyStatus;
1036
1037        #[link_name = "send_async_v2"]
1038        pub fn send_async_v2(
1039            req_handle: RequestHandle,
1040            body_handle: BodyHandle,
1041            backend: *const u8,
1042            backend_len: usize,
1043            streaming: u32,
1044            pending_req_handle_out: *mut PendingRequestHandle,
1045        ) -> FastlyStatus;
1046
1047        #[link_name = "upgrade_websocket"]
1048        pub fn upgrade_websocket(backend: *const u8, backend_len: usize) -> FastlyStatus;
1049
1050        #[link_name = "redirect_to_websocket_proxy_v2"]
1051        pub fn redirect_to_websocket_proxy_v2(
1052            req: RequestHandle,
1053            backend: *const u8,
1054            backend_len: usize,
1055        ) -> FastlyStatus;
1056
1057        #[link_name = "redirect_to_grip_proxy_v2"]
1058        pub fn redirect_to_grip_proxy_v2(
1059            req: RequestHandle,
1060            backend: *const u8,
1061            backend_len: usize,
1062        ) -> FastlyStatus;
1063
1064        #[link_name = "register_dynamic_backend"]
1065        pub fn register_dynamic_backend(
1066            name_prefix: *const u8,
1067            name_prefix_len: usize,
1068            target: *const u8,
1069            target_len: usize,
1070            config_mask: BackendConfigOptions,
1071            config: *const DynamicBackendConfig,
1072        ) -> FastlyStatus;
1073
1074        #[link_name = "uri_get"]
1075        pub fn uri_get(
1076            req_handle: RequestHandle,
1077            uri: *mut u8,
1078            uri_max_len: usize,
1079            nwritten: *mut usize,
1080        ) -> FastlyStatus;
1081
1082        #[link_name = "uri_set"]
1083        pub fn uri_set(req_handle: RequestHandle, uri: *const u8, uri_len: usize) -> FastlyStatus;
1084
1085        #[link_name = "version_get"]
1086        pub fn version_get(req_handle: RequestHandle, version: *mut u32) -> FastlyStatus;
1087
1088        #[link_name = "version_set"]
1089        pub fn version_set(req_handle: RequestHandle, version: u32) -> FastlyStatus;
1090
1091        #[link_name = "pending_req_poll_v2"]
1092        pub fn pending_req_poll_v2(
1093            pending_req_handle: PendingRequestHandle,
1094            error_detail: *mut SendErrorDetail,
1095            is_done_out: *mut i32,
1096            resp_handle_out: *mut ResponseHandle,
1097            resp_body_handle_out: *mut BodyHandle,
1098        ) -> FastlyStatus;
1099
1100        #[link_name = "pending_req_select_v2"]
1101        pub fn pending_req_select_v2(
1102            pending_req_handles: *const PendingRequestHandle,
1103            pending_req_handles_len: usize,
1104            error_detail: *mut SendErrorDetail,
1105            done_index_out: *mut i32,
1106            resp_handle_out: *mut ResponseHandle,
1107            resp_body_handle_out: *mut BodyHandle,
1108        ) -> FastlyStatus;
1109
1110        #[link_name = "pending_req_wait_v2"]
1111        pub fn pending_req_wait_v2(
1112            pending_req_handle: PendingRequestHandle,
1113            error_detail: *mut SendErrorDetail,
1114            resp_handle_out: *mut ResponseHandle,
1115            resp_body_handle_out: *mut BodyHandle,
1116        ) -> FastlyStatus;
1117
1118        #[deprecated(since = "0.12.0", note = "kept for backward compatibility")]
1119        #[link_name = "fastly_key_is_valid"]
1120        pub fn fastly_key_is_valid(is_valid_out: *mut u32) -> FastlyStatus;
1121
1122        #[link_name = "close"]
1123        pub fn close(req_handle: RequestHandle) -> FastlyStatus;
1124
1125        #[link_name = "auto_decompress_response_set"]
1126        pub fn auto_decompress_response_set(
1127            req_handle: RequestHandle,
1128            encodings: ContentEncodings,
1129        ) -> FastlyStatus;
1130
1131        #[link_name = "inspect"]
1132        pub fn inspect(
1133            request_handle: RequestHandle,
1134            body_handle: BodyHandle,
1135            add_info_mask: InspectInfoMask,
1136            add_info: *const InspectInfo,
1137            buf: *mut u8,
1138            buf_len: usize,
1139            nwritten: *mut usize,
1140        ) -> FastlyStatus;
1141
1142        #[link_name = "on_behalf_of"]
1143        pub fn on_behalf_of(
1144            request_handle: RequestHandle,
1145            service: *const u8,
1146            service_len: usize,
1147        ) -> FastlyStatus;
1148    }
1149}
1150
1151pub mod fastly_http_resp {
1152    use super::*;
1153
1154    #[link(wasm_import_module = "fastly_http_resp")]
1155    extern "C" {
1156        #[link_name = "header_append"]
1157        pub fn header_append(
1158            resp_handle: ResponseHandle,
1159            name: *const u8,
1160            name_len: usize,
1161            value: *const u8,
1162            value_len: usize,
1163        ) -> FastlyStatus;
1164
1165        #[link_name = "header_insert"]
1166        pub fn header_insert(
1167            resp_handle: ResponseHandle,
1168            name: *const u8,
1169            name_len: usize,
1170            value: *const u8,
1171            value_len: usize,
1172        ) -> FastlyStatus;
1173
1174        #[link_name = "header_names_get"]
1175        pub fn header_names_get(
1176            resp_handle: ResponseHandle,
1177            buf: *mut u8,
1178            buf_len: usize,
1179            cursor: u32,
1180            ending_cursor: *mut i64,
1181            nwritten: *mut usize,
1182        ) -> FastlyStatus;
1183
1184        #[link_name = "header_value_get"]
1185        pub fn header_value_get(
1186            resp_handle: ResponseHandle,
1187            name: *const u8,
1188            name_len: usize,
1189            value: *mut u8,
1190            value_max_len: usize,
1191            nwritten: *mut usize,
1192        ) -> FastlyStatus;
1193
1194        #[link_name = "header_values_get"]
1195        pub fn header_values_get(
1196            resp_handle: ResponseHandle,
1197            name: *const u8,
1198            name_len: usize,
1199            buf: *mut u8,
1200            buf_len: usize,
1201            cursor: u32,
1202            ending_cursor: *mut i64,
1203            nwritten: *mut usize,
1204        ) -> FastlyStatus;
1205
1206        #[link_name = "header_values_set"]
1207        pub fn header_values_set(
1208            resp_handle: ResponseHandle,
1209            name: *const u8,
1210            name_len: usize,
1211            values: *const u8,
1212            values_len: usize,
1213        ) -> FastlyStatus;
1214
1215        #[link_name = "header_remove"]
1216        pub fn header_remove(
1217            resp_handle: ResponseHandle,
1218            name: *const u8,
1219            name_len: usize,
1220        ) -> FastlyStatus;
1221
1222        #[link_name = "new"]
1223        pub fn new(resp_handle_out: *mut ResponseHandle) -> FastlyStatus;
1224
1225        #[link_name = "send_downstream"]
1226        pub fn send_downstream(
1227            resp_handle: ResponseHandle,
1228            body_handle: BodyHandle,
1229            streaming: u32,
1230        ) -> FastlyStatus;
1231
1232        #[link_name = "status_get"]
1233        pub fn status_get(resp_handle: ResponseHandle, status: *mut u16) -> FastlyStatus;
1234
1235        #[link_name = "status_set"]
1236        pub fn status_set(resp_handle: ResponseHandle, status: u16) -> FastlyStatus;
1237
1238        #[link_name = "version_get"]
1239        pub fn version_get(resp_handle: ResponseHandle, version: *mut u32) -> FastlyStatus;
1240
1241        #[link_name = "version_set"]
1242        pub fn version_set(resp_handle: ResponseHandle, version: u32) -> FastlyStatus;
1243
1244        #[link_name = "framing_headers_mode_set"]
1245        pub fn framing_headers_mode_set(
1246            resp_handle: ResponseHandle,
1247            mode: fastly_shared::FramingHeadersMode,
1248        ) -> FastlyStatus;
1249
1250        #[doc(hidden)]
1251        #[link_name = "http_keepalive_mode_set"]
1252        pub fn http_keepalive_mode_set(
1253            resp_handle: ResponseHandle,
1254            mode: fastly_shared::HttpKeepaliveMode,
1255        ) -> FastlyStatus;
1256
1257        #[link_name = "close"]
1258        pub fn close(resp_handle: ResponseHandle) -> FastlyStatus;
1259
1260        #[link_name = "get_addr_dest_ip"]
1261        pub fn get_addr_dest_ip(
1262            resp_handle: ResponseHandle,
1263            addr_octets_out: *mut u8,
1264            nwritten_out: *mut usize,
1265        ) -> FastlyStatus;
1266
1267        #[link_name = "get_addr_dest_port"]
1268        pub fn get_addr_dest_port(resp_handle: ResponseHandle, port_out: *mut u16) -> FastlyStatus;
1269    }
1270}
1271
1272pub mod fastly_dictionary {
1273    use super::*;
1274
1275    #[link(wasm_import_module = "fastly_dictionary")]
1276    extern "C" {
1277        #[link_name = "open"]
1278        pub fn open(
1279            name: *const u8,
1280            name_len: usize,
1281            dict_handle_out: *mut DictionaryHandle,
1282        ) -> FastlyStatus;
1283
1284        #[link_name = "get"]
1285        pub fn get(
1286            dict_handle: DictionaryHandle,
1287            key: *const u8,
1288            key_len: usize,
1289            value: *mut u8,
1290            value_max_len: usize,
1291            nwritten: *mut usize,
1292        ) -> FastlyStatus;
1293    }
1294}
1295
1296pub mod fastly_geo {
1297    use super::*;
1298
1299    #[link(wasm_import_module = "fastly_geo")]
1300    extern "C" {
1301        #[link_name = "lookup"]
1302        pub fn lookup(
1303            addr_octets: *const u8,
1304            addr_len: usize,
1305            buf: *mut u8,
1306            buf_len: usize,
1307            nwritten_out: *mut usize,
1308        ) -> FastlyStatus;
1309    }
1310}
1311
1312pub mod fastly_device_detection {
1313    use super::*;
1314
1315    #[link(wasm_import_module = "fastly_device_detection")]
1316    extern "C" {
1317        #[link_name = "lookup"]
1318        pub fn lookup(
1319            user_agent: *const u8,
1320            user_agent_max_len: usize,
1321            buf: *mut u8,
1322            buf_len: usize,
1323            nwritten_out: *mut usize,
1324        ) -> FastlyStatus;
1325    }
1326}
1327
1328pub mod fastly_erl {
1329    use super::*;
1330
1331    #[link(wasm_import_module = "fastly_erl")]
1332    extern "C" {
1333        #[link_name = "check_rate"]
1334        pub fn check_rate(
1335            rc: *const u8,
1336            rc_max_len: usize,
1337            entry: *const u8,
1338            entry_max_len: usize,
1339            delta: u32,
1340            window: u32,
1341            limit: u32,
1342            pb: *const u8,
1343            pb_max_len: usize,
1344            ttl: u32,
1345            value: *mut u32,
1346        ) -> FastlyStatus;
1347
1348        #[link_name = "ratecounter_increment"]
1349        pub fn ratecounter_increment(
1350            rc: *const u8,
1351            rc_max_len: usize,
1352            entry: *const u8,
1353            entry_max_len: usize,
1354            delta: u32,
1355        ) -> FastlyStatus;
1356
1357        #[link_name = "ratecounter_lookup_rate"]
1358        pub fn ratecounter_lookup_rate(
1359            rc: *const u8,
1360            rc_max_len: usize,
1361            entry: *const u8,
1362            entry_max_len: usize,
1363            window: u32,
1364            value: *mut u32,
1365        ) -> FastlyStatus;
1366
1367        #[link_name = "ratecounter_lookup_count"]
1368        pub fn ratecounter_lookup_count(
1369            rc: *const u8,
1370            rc_max_len: usize,
1371            entry: *const u8,
1372            entry_max_len: usize,
1373            duration: u32,
1374            value: *mut u32,
1375        ) -> FastlyStatus;
1376
1377        #[link_name = "penaltybox_add"]
1378        pub fn penaltybox_add(
1379            pb: *const u8,
1380            pb_max_len: usize,
1381            entry: *const u8,
1382            entry_max_len: usize,
1383            ttl: u32,
1384        ) -> FastlyStatus;
1385
1386        #[link_name = "penaltybox_has"]
1387        pub fn penaltybox_has(
1388            pb: *const u8,
1389            pb_max_len: usize,
1390            entry: *const u8,
1391            entry_max_len: usize,
1392            value: *mut u32,
1393        ) -> FastlyStatus;
1394    }
1395}
1396
1397pub mod fastly_kv_store {
1398    use super::*;
1399
1400    #[repr(u32)]
1401    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
1402    pub enum KvError {
1403        Uninitialized,
1404        Ok,
1405        BadRequest,
1406        NotFound,
1407        PreconditionFailed,
1408        PayloadTooLarge,
1409        InternalError,
1410    }
1411
1412    // TODO ACF 2023-04-11: keep the object store name here until the ABI is updated
1413    #[link(wasm_import_module = "fastly_object_store")]
1414    extern "C" {
1415        #[link_name = "open"]
1416        pub fn open(
1417            name_ptr: *const u8,
1418            name_len: usize,
1419            kv_store_handle_out: *mut KVStoreHandle,
1420        ) -> FastlyStatus;
1421
1422        #[deprecated(note = "kept for backward compatibility")]
1423        #[link_name = "lookup"]
1424        pub fn lookup(
1425            kv_store_handle: KVStoreHandle,
1426            key_ptr: *const u8,
1427            key_len: usize,
1428            body_handle_out: *mut BodyHandle,
1429        ) -> FastlyStatus;
1430
1431        #[deprecated(note = "kept for backward compatibility")]
1432        #[link_name = "lookup_async"]
1433        pub fn lookup_async(
1434            kv_store_handle: KVStoreHandle,
1435            key_ptr: *const u8,
1436            key_len: usize,
1437            pending_body_handle_out: *mut PendingObjectStoreLookupHandle,
1438        ) -> FastlyStatus;
1439
1440        #[deprecated(note = "kept for backward compatibility")]
1441        #[link_name = "pending_lookup_wait"]
1442        pub fn pending_lookup_wait(
1443            pending_handle: PendingObjectStoreLookupHandle,
1444            body_handle_out: *mut BodyHandle,
1445        ) -> FastlyStatus;
1446
1447        #[deprecated(note = "kept for backward compatibility")]
1448        #[link_name = "insert"]
1449        pub fn insert(
1450            kv_store_handle: KVStoreHandle,
1451            key_ptr: *const u8,
1452            key_len: usize,
1453            body_handle: BodyHandle,
1454        ) -> FastlyStatus;
1455
1456        #[deprecated(note = "kept for backward compatibility")]
1457        #[link_name = "insert_async"]
1458        pub fn insert_async(
1459            kv_store_handle: KVStoreHandle,
1460            key_ptr: *const u8,
1461            key_len: usize,
1462            body_handle: BodyHandle,
1463            pending_body_handle_out: *mut PendingObjectStoreInsertHandle,
1464        ) -> FastlyStatus;
1465
1466        #[deprecated(note = "kept for backward compatibility")]
1467        #[link_name = "pending_insert_wait"]
1468        pub fn pending_insert_wait(
1469            pending_body_handle: PendingObjectStoreInsertHandle,
1470            kv_error_out: *mut KvError,
1471        ) -> FastlyStatus;
1472
1473        #[deprecated(note = "kept for backward compatibility")]
1474        #[link_name = "delete_async"]
1475        pub fn delete_async(
1476            kv_store_handle: KVStoreHandle,
1477            key_ptr: *const u8,
1478            key_len: usize,
1479            pending_body_handle_out: *mut PendingObjectStoreDeleteHandle,
1480        ) -> FastlyStatus;
1481
1482        #[deprecated(note = "kept for backward compatibility")]
1483        #[link_name = "pending_delete_wait"]
1484        pub fn pending_delete_wait(
1485            pending_body_handle: PendingObjectStoreDeleteHandle,
1486        ) -> FastlyStatus;
1487    }
1488
1489    #[link(wasm_import_module = "fastly_kv_store")]
1490    extern "C" {
1491        #[link_name = "open"]
1492        pub fn open_v2(
1493            name_ptr: *const u8,
1494            name_len: usize,
1495            kv_store_handle_out: *mut KVStoreHandle,
1496        ) -> FastlyStatus;
1497
1498        #[link_name = "lookup"]
1499        pub fn lookup_v2(
1500            kv_store_handle: KVStoreHandle,
1501            key_ptr: *const u8,
1502            key_len: usize,
1503            lookup_config_mask: LookupConfigOptions,
1504            lookup_config: *const LookupConfig,
1505            pending_body_handle_out: *mut PendingObjectStoreLookupHandle,
1506        ) -> FastlyStatus;
1507
1508        #[link_name = "lookup_wait"]
1509        pub fn pending_lookup_wait_v2(
1510            pending_handle: PendingObjectStoreLookupHandle,
1511            body_handle_out: *mut BodyHandle,
1512            metadata_buf: *mut u8,
1513            metadata_buf_len: usize,
1514            nwritten_out: *mut usize,
1515            generation_out: *mut u32,
1516            kv_error_out: *mut KvError,
1517        ) -> FastlyStatus;
1518
1519        #[link_name = "lookup_wait_v2"]
1520        pub fn lookup_wait_v2(
1521            pending_handle: PendingObjectStoreLookupHandle,
1522            body_handle_out: *mut BodyHandle,
1523            metadata_buf: *mut u8,
1524            metadata_buf_len: usize,
1525            nwritten_out: *mut usize,
1526            generation_out: *mut u64,
1527            kv_error_out: *mut KvError,
1528        ) -> FastlyStatus;
1529
1530        #[link_name = "insert"]
1531        pub fn insert_v2(
1532            kv_store_handle: KVStoreHandle,
1533            key_ptr: *const u8,
1534            key_len: usize,
1535            body_handle: BodyHandle,
1536            insert_config_mask: InsertConfigOptions,
1537            insert_config: *const InsertConfig,
1538            pending_body_handle_out: *mut PendingObjectStoreInsertHandle,
1539        ) -> FastlyStatus;
1540
1541        #[link_name = "insert_wait"]
1542        pub fn pending_insert_wait_v2(
1543            pending_body_handle: PendingObjectStoreInsertHandle,
1544            kv_error_out: *mut KvError,
1545        ) -> FastlyStatus;
1546
1547        #[link_name = "delete"]
1548        pub fn delete_v2(
1549            kv_store_handle: KVStoreHandle,
1550            key_ptr: *const u8,
1551            key_len: usize,
1552            delete_config_mask: DeleteConfigOptions,
1553            delete_config: *const DeleteConfig,
1554            pending_body_handle_out: *mut PendingObjectStoreDeleteHandle,
1555        ) -> FastlyStatus;
1556
1557        #[link_name = "delete_wait"]
1558        pub fn pending_delete_wait_v2(
1559            pending_body_handle: PendingObjectStoreDeleteHandle,
1560            kv_error_out: *mut KvError,
1561        ) -> FastlyStatus;
1562
1563        #[link_name = "list"]
1564        pub fn list_v2(
1565            kv_store_handle: KVStoreHandle,
1566            list_config_mask: ListConfigOptions,
1567            list_config: *const ListConfig,
1568            pending_body_handle_out: *mut PendingObjectStoreListHandle,
1569        ) -> FastlyStatus;
1570
1571        #[link_name = "list_wait"]
1572        pub fn pending_list_wait_v2(
1573            pending_body_handle: PendingObjectStoreListHandle,
1574            body_handle_out: *mut BodyHandle,
1575            kv_error_out: *mut KvError,
1576        ) -> FastlyStatus;
1577    }
1578}
1579
1580pub mod fastly_secret_store {
1581    use super::*;
1582
1583    #[link(wasm_import_module = "fastly_secret_store")]
1584    extern "C" {
1585        #[link_name = "open"]
1586        pub fn open(
1587            secret_store_name_ptr: *const u8,
1588            secret_store_name_len: usize,
1589            secret_store_handle_out: *mut SecretStoreHandle,
1590        ) -> FastlyStatus;
1591
1592        #[link_name = "get"]
1593        pub fn get(
1594            secret_store_handle: SecretStoreHandle,
1595            secret_name_ptr: *const u8,
1596            secret_name_len: usize,
1597            secret_handle_out: *mut SecretHandle,
1598        ) -> FastlyStatus;
1599
1600        #[link_name = "plaintext"]
1601        pub fn plaintext(
1602            secret_handle: SecretHandle,
1603            plaintext_buf: *mut u8,
1604            plaintext_max_len: usize,
1605            nwritten_out: *mut usize,
1606        ) -> FastlyStatus;
1607
1608        #[link_name = "from_bytes"]
1609        pub fn from_bytes(
1610            plaintext_buf: *const u8,
1611            plaintext_len: usize,
1612            secret_handle_out: *mut SecretHandle,
1613        ) -> FastlyStatus;
1614    }
1615}
1616
1617pub mod fastly_backend {
1618    use super::*;
1619
1620    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
1621    #[repr(u32)]
1622    pub enum BackendHealth {
1623        Unknown,
1624        Healthy,
1625        Unhealthy,
1626    }
1627
1628    #[link(wasm_import_module = "fastly_backend")]
1629    extern "C" {
1630        #[link_name = "exists"]
1631        pub fn exists(
1632            backend_ptr: *const u8,
1633            backend_len: usize,
1634            backend_exists_out: *mut u32,
1635        ) -> FastlyStatus;
1636
1637        #[link_name = "is_healthy"]
1638        pub fn is_healthy(
1639            backend_ptr: *const u8,
1640            backend_len: usize,
1641            backend_health_out: *mut BackendHealth,
1642        ) -> FastlyStatus;
1643
1644        #[link_name = "is_dynamic"]
1645        pub fn is_dynamic(
1646            backend_ptr: *const u8,
1647            backend_len: usize,
1648            value: *mut u32,
1649        ) -> FastlyStatus;
1650
1651        #[link_name = "get_host"]
1652        pub fn get_host(
1653            backend_ptr: *const u8,
1654            backend_len: usize,
1655            value: *mut u8,
1656            value_max_len: usize,
1657            nwritten: *mut usize,
1658        ) -> FastlyStatus;
1659
1660        #[link_name = "get_override_host"]
1661        pub fn get_override_host(
1662            backend_ptr: *const u8,
1663            backend_len: usize,
1664            value: *mut u8,
1665            value_max_len: usize,
1666            nwritten: *mut usize,
1667        ) -> FastlyStatus;
1668
1669        #[link_name = "get_port"]
1670        pub fn get_port(
1671            backend_ptr: *const u8,
1672            backend_len: usize,
1673            value: *mut u16,
1674        ) -> FastlyStatus;
1675
1676        #[link_name = "get_connect_timeout_ms"]
1677        pub fn get_connect_timeout_ms(
1678            backend_ptr: *const u8,
1679            backend_len: usize,
1680            value: *mut u32,
1681        ) -> FastlyStatus;
1682
1683        #[link_name = "get_first_byte_timeout_ms"]
1684        pub fn get_first_byte_timeout_ms(
1685            backend_ptr: *const u8,
1686            backend_len: usize,
1687            value: *mut u32,
1688        ) -> FastlyStatus;
1689
1690        #[link_name = "get_between_bytes_timeout_ms"]
1691        pub fn get_between_bytes_timeout_ms(
1692            backend_ptr: *const u8,
1693            backend_len: usize,
1694            value: *mut u32,
1695        ) -> FastlyStatus;
1696
1697        #[link_name = "get_http_keepalive_time"]
1698        pub fn get_http_keepalive_time(
1699            backend_ptr: *const u8,
1700            backend_len: usize,
1701            value: *mut u32,
1702        ) -> FastlyStatus;
1703
1704        #[link_name = "get_tcp_keepalive_enable"]
1705        pub fn get_tcp_keepalive_enable(
1706            backend_ptr: *const u8,
1707            backend_len: usize,
1708            value: *mut u32,
1709        ) -> FastlyStatus;
1710
1711        #[link_name = "get_tcp_keepalive_interval"]
1712        pub fn get_tcp_keepalive_interval(
1713            backend_ptr: *const u8,
1714            backend_len: usize,
1715            value: *mut u32,
1716        ) -> FastlyStatus;
1717
1718        #[link_name = "get_tcp_keepalive_probes"]
1719        pub fn get_tcp_keepalive_probes(
1720            backend_ptr: *const u8,
1721            backend_len: usize,
1722            value: *mut u32,
1723        ) -> FastlyStatus;
1724
1725        #[link_name = "get_tcp_keepalive_time"]
1726        pub fn get_tcp_keepalive_time(
1727            backend_ptr: *const u8,
1728            backend_len: usize,
1729            value: *mut u32,
1730        ) -> FastlyStatus;
1731
1732        #[link_name = "is_ssl"]
1733        pub fn is_ssl(backend_ptr: *const u8, backend_len: usize, value: *mut u32) -> FastlyStatus;
1734
1735        #[link_name = "get_ssl_min_version"]
1736        pub fn get_ssl_min_version(
1737            backend_ptr: *const u8,
1738            backend_len: usize,
1739            value: *mut u32,
1740        ) -> FastlyStatus;
1741
1742        #[link_name = "get_ssl_max_version"]
1743        pub fn get_ssl_max_version(
1744            backend_ptr: *const u8,
1745            backend_len: usize,
1746            value: *mut u32,
1747        ) -> FastlyStatus;
1748    }
1749}
1750
1751pub mod fastly_async_io {
1752    use super::*;
1753
1754    #[link(wasm_import_module = "fastly_async_io")]
1755    extern "C" {
1756        #[link_name = "select"]
1757        pub fn select(
1758            async_item_handles: *const AsyncItemHandle,
1759            async_item_handles_len: usize,
1760            timeout_ms: u32,
1761            done_index_out: *mut u32,
1762        ) -> FastlyStatus;
1763
1764        #[link_name = "is_ready"]
1765        pub fn is_ready(async_item_handle: AsyncItemHandle, ready_out: *mut u32) -> FastlyStatus;
1766    }
1767}
1768
1769pub mod fastly_image_optimizer {
1770    use super::*;
1771
1772    bitflags::bitflags! {
1773        #[repr(transparent)]
1774        pub struct ImageOptimizerTransformConfigOptions: u32 {
1775            const RESERVED = 1 << 0;
1776            const SDK_CLAIMS_OPTS = 1 << 1;
1777        }
1778    }
1779
1780    #[repr(C, align(8))]
1781    pub struct ImageOptimizerTransformConfig {
1782        pub sdk_claims_opts: *const u8,
1783        pub sdk_claims_opts_len: u32,
1784    }
1785
1786    impl Default for ImageOptimizerTransformConfig {
1787        fn default() -> Self {
1788            ImageOptimizerTransformConfig {
1789                sdk_claims_opts: std::ptr::null(),
1790                sdk_claims_opts_len: 0,
1791            }
1792        }
1793    }
1794
1795    #[repr(u32)]
1796    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
1797    pub enum ImageOptimizerErrorTag {
1798        Uninitialized,
1799        Ok,
1800        Error,
1801        Warning,
1802    }
1803
1804    #[repr(C, align(8))]
1805    #[derive(Clone, Debug, PartialEq, Eq)]
1806    pub struct ImageOptimizerErrorDetail {
1807        pub tag: ImageOptimizerErrorTag,
1808        pub message: *const u8,
1809        pub message_len: usize,
1810    }
1811
1812    impl ImageOptimizerErrorDetail {
1813        pub fn uninitialized() -> Self {
1814            Self {
1815                tag: ImageOptimizerErrorTag::Uninitialized,
1816                message: std::ptr::null(),
1817                message_len: 0,
1818            }
1819        }
1820    }
1821
1822    #[link(wasm_import_module = "fastly_image_optimizer")]
1823    extern "C" {
1824        #[link_name = "transform_image_optimizer_request"]
1825        pub fn transform_image_optimizer_request(
1826            origin_image_request: RequestHandle,
1827            origin_image_request_body: BodyHandle,
1828            origin_image_backend: *const u8,
1829            origin_image_backend_len: usize,
1830            io_transform_config_options: ImageOptimizerTransformConfigOptions,
1831            io_transform_config: *const ImageOptimizerTransformConfig,
1832            io_error_detail: *mut ImageOptimizerErrorDetail,
1833            resp_handle_out: *mut ResponseHandle,
1834            resp_body_handle_out: *mut BodyHandle,
1835        ) -> FastlyStatus;
1836    }
1837}
1838
1839pub mod fastly_purge {
1840    use super::*;
1841
1842    bitflags::bitflags! {
1843        #[derive(Default)]
1844        #[repr(transparent)]
1845        pub struct PurgeOptionsMask: u32 {
1846            const SOFT_PURGE = 1 << 0;
1847            const RET_BUF = 1 << 1;
1848        }
1849    }
1850
1851    #[derive(Debug)]
1852    #[repr(C)]
1853    pub struct PurgeOptions {
1854        pub ret_buf_ptr: *mut u8,
1855        pub ret_buf_len: usize,
1856        pub ret_buf_nwritten_out: *mut usize,
1857    }
1858
1859    #[link(wasm_import_module = "fastly_purge")]
1860    extern "C" {
1861        #[link_name = "purge_surrogate_key"]
1862        pub fn purge_surrogate_key(
1863            surrogate_key_ptr: *const u8,
1864            surrogate_key_len: usize,
1865            options_mask: PurgeOptionsMask,
1866            options: *mut PurgeOptions,
1867        ) -> FastlyStatus;
1868    }
1869}
1870
1871pub mod fastly_compute_runtime {
1872    use super::*;
1873
1874    #[link(wasm_import_module = "fastly_compute_runtime")]
1875    extern "C" {
1876        #[link_name = "get_vcpu_ms"]
1877        pub fn get_vcpu_ms(ms_out: *mut u64) -> FastlyStatus;
1878    }
1879
1880    #[link(wasm_import_module = "fastly_compute_runtime")]
1881    extern "C" {
1882        #[link_name = "get_heap_mib"]
1883        pub fn get_heap_mib(mb_out: *mut u32) -> fastly_shared::FastlyStatus;
1884    }
1885}
1886
1887pub mod fastly_acl {
1888    use super::*;
1889
1890    #[repr(u32)]
1891    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
1892    pub enum AclError {
1893        Uninitialized,
1894        Ok,
1895        NoContent,
1896        TooManyRequests,
1897    }
1898
1899    #[link(wasm_import_module = "fastly_acl")]
1900    extern "C" {
1901        #[link_name = "open"]
1902        pub fn open(
1903            acl_name_ptr: *const u8,
1904            acl_name_len: usize,
1905            acl_handle_out: *mut AclHandle,
1906        ) -> FastlyStatus;
1907
1908        #[link_name = "lookup"]
1909        pub fn lookup(
1910            acl_handle: AclHandle,
1911            ip_octets: *const u8,
1912            ip_len: usize,
1913            body_handle_out: *mut BodyHandle,
1914            acl_error_out: *mut AclError,
1915        ) -> FastlyStatus;
1916    }
1917}
1918
1919pub mod fastly_shielding {
1920    use super::*;
1921
1922    bitflags::bitflags! {
1923        #[derive(Default)]
1924        #[repr(transparent)]
1925        pub struct ShieldBackendOptions: u32 {
1926            const RESERVED = 1 << 0;
1927            const CACHE_KEY = 1 << 1;
1928            const FIRST_BYTE_TIMEOUT = 1 << 2;
1929        }
1930    }
1931
1932    #[repr(C)]
1933    pub struct ShieldBackendConfig {
1934        pub cache_key: *const u8,
1935        pub cache_key_len: u32,
1936        pub first_byte_timeout_ms: u32,
1937    }
1938
1939    impl Default for ShieldBackendConfig {
1940        fn default() -> Self {
1941            ShieldBackendConfig {
1942                cache_key: std::ptr::null(),
1943                cache_key_len: 0,
1944                first_byte_timeout_ms: 0,
1945            }
1946        }
1947    }
1948
1949    //   (@interface func (export "shield_info")
1950    //     (param $name string)
1951    //     (param $info_block (@witx pointer (@witx char8)))
1952    //     (param $info_block_max_len (@witx usize))
1953    //     (result $err (expected $num_bytes (error $fastly_status)))
1954    //   )
1955
1956    #[link(wasm_import_module = "fastly_shielding")]
1957    extern "C" {
1958
1959        /// Get information about the given shield in the Fastly network
1960        #[link_name = "shield_info"]
1961        pub fn shield_info(
1962            name: *const u8,
1963            name_len: usize,
1964            info_block: *mut u8,
1965            info_block_len: usize,
1966            nwritten_out: *mut u32,
1967        ) -> FastlyStatus;
1968
1969        /// Turn a pop name into a backend that we can send requests to.
1970        #[link_name = "backend_for_shield"]
1971        pub fn backend_for_shield(
1972            name: *const u8,
1973            name_len: usize,
1974            options_mask: ShieldBackendOptions,
1975            options: *const ShieldBackendConfig,
1976            backend_name: *mut u8,
1977            backend_name_len: usize,
1978            nwritten_out: *mut u32,
1979        ) -> FastlyStatus;
1980    }
1981}
1982
1983/// WIT for the Fastly APIs in the `fastly:compute/service@0.1.0` world.
1984#[cfg(not(target_env = "p1"))]
1985pub mod service0_1_0;
1986
1987#[cfg(not(target_env = "p1"))]
1988impl From<service0_1_0::fastly::compute::types::Error> for fastly_shared::FastlyStatus {
1989    fn from(error: service0_1_0::fastly::compute::types::Error) -> Self {
1990        use service0_1_0::fastly::compute::types::Error;
1991        match error {
1992            Error::InvalidArgument => Self::INVAL,
1993            Error::Unsupported => Self::UNSUPPORTED,
1994            Error::LimitExceeded => Self::LIMITEXCEEDED,
1995            Error::GenericError => Self::ERROR,
1996            Error::BufferLen(_) => Self::BUFLEN,
1997            Error::CannotRead => Self::NONE,
1998            Error::AuxiliaryError => Self::BADF,
1999            Error::HttpInvalid => Self::HTTPINVALID,
2000            Error::HttpUser => Self::HTTPUSER,
2001            Error::HttpIncomplete => Self::HTTPINCOMPLETE,
2002            Error::HttpHeadTooLarge => Self::HTTPHEADTOOLARGE,
2003            Error::HttpInvalidStatus => Self::HTTPINVALIDSTATUS,
2004        }
2005    }
2006}
2007
2008#[cfg(not(target_env = "p1"))]
2009impl From<std::net::IpAddr> for service0_1_0::fastly::compute::types::IpAddress {
2010    fn from(addr: std::net::IpAddr) -> Self {
2011        use std::net::IpAddr;
2012        match addr {
2013            IpAddr::V4(v4) => Self::Ipv4(v4.octets().into()),
2014            IpAddr::V6(v6) => Self::Ipv6(v6.segments().into()),
2015        }
2016    }
2017}
2018
2019#[cfg(not(target_env = "p1"))]
2020impl From<service0_1_0::fastly::compute::types::IpAddress> for std::net::IpAddr {
2021    fn from(addr: service0_1_0::fastly::compute::types::IpAddress) -> Self {
2022        use service0_1_0::fastly::compute::types::IpAddress;
2023        match addr {
2024            IpAddress::Ipv4(v4) => Self::V4(<[u8; 4]>::from(v4).into()),
2025            IpAddress::Ipv6(v6) => Self::V6(<[u16; 8]>::from(v6).into()),
2026        }
2027    }
2028}
2029
2030#[cfg(not(target_env = "p1"))]
2031impl From<service0_1_0::fastly::compute::http_types::HttpVersion> for http::version::Version {
2032    fn from(version: service0_1_0::fastly::compute::http_types::HttpVersion) -> Self {
2033        use service0_1_0::fastly::compute::http_types::HttpVersion;
2034        match version {
2035            HttpVersion::Http09 => Self::HTTP_09,
2036            HttpVersion::Http10 => Self::HTTP_10,
2037            HttpVersion::Http11 => Self::HTTP_11,
2038            HttpVersion::H2 => Self::HTTP_2,
2039            HttpVersion::H3 => Self::HTTP_3,
2040        }
2041    }
2042}
2043
2044#[cfg(not(target_env = "p1"))]
2045impl TryFrom<http::version::Version> for service0_1_0::fastly::compute::http_types::HttpVersion {
2046    type Error = ();
2047
2048    fn try_from(version: http::version::Version) -> Result<Self, Self::Error> {
2049        use http::version::Version;
2050        Ok(match version {
2051            Version::HTTP_09 => Self::Http09,
2052            Version::HTTP_10 => Self::Http10,
2053            Version::HTTP_11 => Self::Http11,
2054            Version::HTTP_2 => Self::H2,
2055            Version::HTTP_3 => Self::H3,
2056            _ => return Err(()),
2057        })
2058    }
2059}
2060
2061#[cfg(not(target_env = "p1"))]
2062impl From<fastly_shared::FramingHeadersMode>
2063    for service0_1_0::fastly::compute::http_types::FramingHeadersMode
2064{
2065    fn from(mode: fastly_shared::FramingHeadersMode) -> Self {
2066        use fastly_shared::FramingHeadersMode;
2067        match mode {
2068            FramingHeadersMode::Automatic => Self::Automatic,
2069            FramingHeadersMode::ManuallyFromHeaders => Self::ManuallyFromHeaders,
2070        }
2071    }
2072}
2073
2074#[cfg(not(target_env = "p1"))]
2075impl From<service0_1_0::fastly::compute::http_types::FramingHeadersMode>
2076    for fastly_shared::FramingHeadersMode
2077{
2078    fn from(mode: service0_1_0::fastly::compute::http_types::FramingHeadersMode) -> Self {
2079        use service0_1_0::fastly::compute::http_types::FramingHeadersMode;
2080        match mode {
2081            FramingHeadersMode::Automatic => Self::Automatic,
2082            FramingHeadersMode::ManuallyFromHeaders => Self::ManuallyFromHeaders,
2083        }
2084    }
2085}
2086
2087#[cfg(not(target_env = "p1"))]
2088impl From<fastly_shared::HttpKeepaliveMode>
2089    for service0_1_0::fastly::compute::http_resp::KeepaliveMode
2090{
2091    fn from(mode: fastly_shared::HttpKeepaliveMode) -> Self {
2092        use fastly_shared::HttpKeepaliveMode;
2093        match mode {
2094            HttpKeepaliveMode::Automatic => Self::Automatic,
2095            HttpKeepaliveMode::NoKeepalive => Self::NoKeepalive,
2096        }
2097    }
2098}
2099
2100#[cfg(not(target_env = "p1"))]
2101impl From<service0_1_0::fastly::compute::http_resp::KeepaliveMode>
2102    for fastly_shared::HttpKeepaliveMode
2103{
2104    fn from(mode: service0_1_0::fastly::compute::http_resp::KeepaliveMode) -> Self {
2105        use service0_1_0::fastly::compute::http_resp::KeepaliveMode;
2106        match mode {
2107            KeepaliveMode::Automatic => Self::Automatic,
2108            KeepaliveMode::NoKeepalive => Self::NoKeepalive,
2109        }
2110    }
2111}