-
-
Save jedisct1/fd7df66e892f3df4e5911a705cd90a8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type handle = i32; | |
type char = u8; | |
type ptr<T> = usize; // all pointers are usize'd | |
type mut_ptr<T> = usize; // all pointers are usize'd | |
type untyped_ptr = usize; // all pointers are usize'd | |
type union_member = usize; // all pointers are usize'd | |
type struct<T> = T; // structs are references already in AS) | |
type wasi_string = ptr<char>; | |
/** xqd_status */ | |
export namespace xqd_status { | |
// @ts-ignore: decorator | |
@inline | |
export const OK: xqd_status = 0; | |
// @ts-ignore: decorator | |
@inline | |
export const ERROR: xqd_status = 1; | |
// @ts-ignore: decorator | |
@inline | |
export const INVAL: xqd_status = 2; | |
// @ts-ignore: decorator | |
@inline | |
export const BADF: xqd_status = 3; | |
// @ts-ignore: decorator | |
@inline | |
export const BUFLEN: xqd_status = 4; | |
// @ts-ignore: decorator | |
@inline | |
export const UNSUPPORTED: xqd_status = 5; | |
// @ts-ignore: decorator | |
@inline | |
export const BADALIGN: xqd_status = 6; | |
// @ts-ignore: decorator | |
@inline | |
export const HTTPPARSE: xqd_status = 7; | |
// @ts-ignore: decorator | |
@inline | |
export const HTTPUSER: xqd_status = 8; | |
// @ts-ignore: decorator | |
@inline | |
export const HTTPINCOMPLETE: xqd_status = 9; | |
} | |
export type xqd_status = u32; | |
/** http_version */ | |
export namespace http_version { | |
// @ts-ignore: decorator | |
@inline | |
export const HTTP_09: http_version = 0; | |
// @ts-ignore: decorator | |
@inline | |
export const HTTP_10: http_version = 1; | |
// @ts-ignore: decorator | |
@inline | |
export const HTTP_11: http_version = 2; | |
// @ts-ignore: decorator | |
@inline | |
export const H2: http_version = 3; | |
// @ts-ignore: decorator | |
@inline | |
export const H3: http_version = 4; | |
} | |
export type http_version = u32; | |
/** http_status */ | |
export type http_status = u16; | |
/** body_write_end */ | |
export namespace body_write_end { | |
// @ts-ignore: decorator | |
@inline | |
export const BACK: body_write_end = 0; | |
// @ts-ignore: decorator | |
@inline | |
export const FRONT: body_write_end = 1; | |
} | |
export type body_write_end = u32; | |
/** body_handle */ | |
export type body_handle = handle; | |
/** request_handle */ | |
export type request_handle = handle; | |
/** response_handle */ | |
export type response_handle = handle; | |
/** pending_request_handle */ | |
export type pending_request_handle = handle; | |
/** endpoint_handle */ | |
export type endpoint_handle = handle; | |
/** header_cursor */ | |
export type header_cursor = u32; | |
/** cache_override_tag */ | |
export namespace cache_override_tag { | |
// @ts-ignore: decorator | |
@inline | |
export const NONE: cache_override_tag = 1; | |
// @ts-ignore: decorator | |
@inline | |
export const PASS: cache_override_tag = 2; | |
// @ts-ignore: decorator | |
@inline | |
export const TTL: cache_override_tag = 4; | |
// @ts-ignore: decorator | |
@inline | |
export const STALE_WHILE_REVALIDATE: cache_override_tag = 8; | |
} | |
export type cache_override_tag = u32; | |
// ----------------------[xqd]---------------------- | |
/** uap_parse */ | |
/** | |
* in: user_agent, user_agent_len, family, family_len, family_nwritten_out, major, major_len, major_nwritten_out, minor, minor_len, minor_nwritten_out, patch, patch_len, patch_nwritten_out | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "uap_parse") | |
export declare function uap_parse( | |
user_agent: ptr<char>, user_agent_len: usize, family: ptr<char>, family_len: usize, family_nwritten_out: ptr<usize>, major: ptr<char>, major_len: usize, major_nwritten_out: ptr<usize>, minor: ptr<char>, minor_len: usize, minor_nwritten_out: ptr<usize>, patch: ptr<char>, patch_len: usize, patch_nwritten_out: ptr<usize> | |
): xqd_status /* err */; | |
/** body_append */ | |
/** | |
* in: dest, src | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "body_append") | |
export declare function body_append( | |
dest: body_handle, src: body_handle | |
): xqd_status /* err */; | |
/** body_new */ | |
/** | |
* in: | |
* out: err, h | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "body_new") | |
export declare function body_new( | |
h_ptr: mut_ptr<body_handle> | |
): xqd_status /* err */; | |
/** body_read */ | |
/** | |
* in: h, buf, buf_len | |
* out: err, nread | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "body_read") | |
export declare function body_read( | |
h: body_handle, buf: ptr<u8>, buf_len: usize, | |
nread_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** body_write */ | |
/** | |
* in: h, buf, end | |
* out: err, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "body_write") | |
export declare function body_write( | |
h: body_handle, buf: untyped_ptr, buf_size: untyped_ptr, end: body_write_end, | |
nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** init */ | |
/** | |
* in: abi_version | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "init") | |
export declare function init( | |
abi_version: u64 | |
): xqd_status /* err */; | |
/** log_endpoint_get */ | |
/** | |
* in: name | |
* out: err, endpoint_handle_out | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "log_endpoint_get") | |
export declare function log_endpoint_get( | |
name: untyped_ptr, name_size: untyped_ptr, | |
endpoint_handle_out_ptr: mut_ptr<endpoint_handle> | |
): xqd_status /* err */; | |
/** log_write */ | |
/** | |
* in: h, msg | |
* out: err, nwritten_out | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "log_write") | |
export declare function log_write( | |
h: endpoint_handle, msg: untyped_ptr, msg_size: untyped_ptr, | |
nwritten_out_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** req_body_downstream_get */ | |
/** | |
* in: | |
* out: err, req, body | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_body_downstream_get") | |
export declare function req_body_downstream_get( | |
req_ptr: mut_ptr<request_handle>, body_ptr: mut_ptr<body_handle> | |
): xqd_status /* err */; | |
/** req_cache_override_set */ | |
/** | |
* in: h, tag, ttl, stale_while_revalidate | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_cache_override_set") | |
export declare function req_cache_override_set( | |
h: request_handle, tag: cache_override_tag, ttl: u32, stale_while_revalidate: u32 | |
): xqd_status /* err */; | |
/** req_downstream_tls_cipher_openssl_name */ | |
/** | |
* in: cipher_out, cipher_max_len | |
* out: err, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_downstream_tls_cipher_openssl_name") | |
export declare function req_downstream_tls_cipher_openssl_name( | |
cipher_out: ptr<char>, cipher_max_len: usize, | |
nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** req_downstream_tls_protocol */ | |
/** | |
* in: protocol_out, protocol_max_len | |
* out: err, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_downstream_tls_protocol") | |
export declare function req_downstream_tls_protocol( | |
protocol_out: ptr<char>, protocol_max_len: usize, | |
nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** req_downstream_tls_client_hello */ | |
/** | |
* in: chello_out, chello_max_len | |
* out: err, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_downstream_tls_client_hello") | |
export declare function req_downstream_tls_client_hello( | |
chello_out: ptr<char>, chello_max_len: usize, | |
nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** req_new */ | |
/** | |
* in: | |
* out: err, h | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_new") | |
export declare function req_new( | |
h_ptr: mut_ptr<request_handle> | |
): xqd_status /* err */; | |
/** req_header_names_get */ | |
/** | |
* in: h, buf, buf_len | |
* out: err, ending_cursor, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_header_names_get") | |
export declare function req_header_names_get( | |
h: request_handle, buf: ptr<char>, buf_len: usize, | |
ending_cursor_ptr: mut_ptr<header_cursor>, nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** req_original_header_names_get */ | |
/** | |
* in: h, buf, buf_len | |
* out: err, ending_cursor, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_original_header_names_get") | |
export declare function req_original_header_names_get( | |
h: request_handle, buf: ptr<char>, buf_len: usize, | |
ending_cursor_ptr: mut_ptr<header_cursor>, nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** req_header_values_get */ | |
/** | |
* in: h, name, buf, buf_len, cursor | |
* out: err, ending_cursor, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_header_values_get") | |
export declare function req_header_values_get( | |
h: request_handle, name: wasi_string, name_size: usize, buf: ptr<char>, buf_len: usize, cursor: header_cursor, | |
ending_cursor_ptr: mut_ptr<header_cursor>, nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** req_header_values_set */ | |
/** | |
* in: h, name, values | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_header_values_set") | |
export declare function req_header_values_set( | |
h: request_handle, name: wasi_string, name_size: usize, values: untyped_ptr, values_size: untyped_ptr | |
): xqd_status /* err */; | |
/** req_header_insert */ | |
/** | |
* in: h, name, value | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_header_insert") | |
export declare function req_header_insert( | |
h: request_handle, name: wasi_string, name_size: usize, value: wasi_string, value_size: usize | |
): xqd_status /* err */; | |
/** req_header_append */ | |
/** | |
* in: h, name, value | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_header_append") | |
export declare function req_header_append( | |
h: request_handle, name: wasi_string, name_size: usize, value: wasi_string, value_size: usize | |
): xqd_status /* err */; | |
/** req_method_get */ | |
/** | |
* in: h, buf, buf_len | |
* out: err, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_method_get") | |
export declare function req_method_get( | |
h: request_handle, buf: ptr<char>, buf_len: usize, | |
nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** req_method_set */ | |
/** | |
* in: h, method | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_method_set") | |
export declare function req_method_set( | |
h: request_handle, method: wasi_string, method_size: usize | |
): xqd_status /* err */; | |
/** req_uri_get */ | |
/** | |
* in: h, buf, buf_len | |
* out: err, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_uri_get") | |
export declare function req_uri_get( | |
h: request_handle, buf: ptr<char>, buf_len: usize, | |
nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** req_uri_set */ | |
/** | |
* in: h, uri | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_uri_set") | |
export declare function req_uri_set( | |
h: request_handle, uri: wasi_string, uri_size: usize | |
): xqd_status /* err */; | |
/** req_version_get */ | |
/** | |
* in: h | |
* out: err, version | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_version_get") | |
export declare function req_version_get( | |
h: request_handle, | |
version_ptr: mut_ptr<http_version> | |
): xqd_status /* err */; | |
/** req_version_set */ | |
/** | |
* in: h, version | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_version_set") | |
export declare function req_version_set( | |
h: request_handle, version: http_version | |
): xqd_status /* err */; | |
/** req_send */ | |
/** | |
* in: h, b, backend | |
* out: err, resp, resp_body | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_send") | |
export declare function req_send( | |
h: request_handle, b: body_handle, backend: wasi_string, backend_size: usize, | |
resp_ptr: mut_ptr<response_handle>, resp_body_ptr: mut_ptr<body_handle> | |
): xqd_status /* err */; | |
/** req_send_async */ | |
/** | |
* in: h, b, backend | |
* out: err, pending_req | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "req_send_async") | |
export declare function req_send_async( | |
h: request_handle, b: body_handle, backend: wasi_string, backend_size: usize, | |
pending_req_ptr: mut_ptr<pending_request_handle> | |
): xqd_status /* err */; | |
/** pending_req_poll */ | |
/** | |
* in: h | |
* out: err, is_done, resp, resp_body | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "pending_req_poll") | |
export declare function pending_req_poll( | |
h: pending_request_handle, | |
is_done_ptr: mut_ptr<u32>, resp_ptr: mut_ptr<response_handle>, resp_body_ptr: mut_ptr<body_handle> | |
): xqd_status /* err */; | |
/** pending_req_wait */ | |
/** | |
* in: h | |
* out: err, resp, resp_body | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "pending_req_wait") | |
export declare function pending_req_wait( | |
h: pending_request_handle, | |
resp_ptr: mut_ptr<response_handle>, resp_body_ptr: mut_ptr<body_handle> | |
): xqd_status /* err */; | |
/** pending_req_select */ | |
/** | |
* in: hs | |
* out: err, done_idx, resp, resp_body | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "pending_req_select") | |
export declare function pending_req_select( | |
hs: untyped_ptr, hs_size: untyped_ptr, | |
done_idx_ptr: mut_ptr<u32>, resp_ptr: mut_ptr<response_handle>, resp_body_ptr: mut_ptr<body_handle> | |
): xqd_status /* err */; | |
/** resp_new */ | |
/** | |
* in: | |
* out: err, h | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_new") | |
export declare function resp_new( | |
h_ptr: mut_ptr<response_handle> | |
): xqd_status /* err */; | |
/** resp_header_names_get */ | |
/** | |
* in: h, buf, buf_len | |
* out: err, ending_cursor, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_header_names_get") | |
export declare function resp_header_names_get( | |
h: response_handle, buf: ptr<char>, buf_len: usize, | |
ending_cursor_ptr: mut_ptr<header_cursor>, nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** resp_header_values_get */ | |
/** | |
* in: h, name, buf, buf_len, cursor | |
* out: err, ending_cursor, nwritten | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_header_values_get") | |
export declare function resp_header_values_get( | |
h: response_handle, name: wasi_string, name_size: usize, buf: ptr<char>, buf_len: usize, cursor: header_cursor, | |
ending_cursor_ptr: mut_ptr<header_cursor>, nwritten_ptr: mut_ptr<usize> | |
): xqd_status /* err */; | |
/** resp_header_values_set */ | |
/** | |
* in: h, name, values | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_header_values_set") | |
export declare function resp_header_values_set( | |
h: response_handle, name: wasi_string, name_size: usize, values: untyped_ptr, values_size: untyped_ptr | |
): xqd_status /* err */; | |
/** resp_header_insert */ | |
/** | |
* in: h, name, value | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_header_insert") | |
export declare function resp_header_insert( | |
h: response_handle, name: wasi_string, name_size: usize, value: wasi_string, value_size: usize | |
): xqd_status /* err */; | |
/** resp_header_append */ | |
/** | |
* in: h, name, value | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_header_append") | |
export declare function resp_header_append( | |
h: response_handle, name: wasi_string, name_size: usize, value: wasi_string, value_size: usize | |
): xqd_status /* err */; | |
/** resp_version_get */ | |
/** | |
* in: h | |
* out: err, version | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_version_get") | |
export declare function resp_version_get( | |
h: response_handle, | |
version_ptr: mut_ptr<http_version> | |
): xqd_status /* err */; | |
/** resp_version_set */ | |
/** | |
* in: h, version | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_version_set") | |
export declare function resp_version_set( | |
h: response_handle, version: http_version | |
): xqd_status /* err */; | |
/** resp_send_downstream */ | |
/** | |
* in: h, b, streaming | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_send_downstream") | |
export declare function resp_send_downstream( | |
h: response_handle, b: body_handle, streaming: u32 | |
): xqd_status /* err */; | |
/** resp_status_get */ | |
/** | |
* in: h | |
* out: err, status | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_status_get") | |
export declare function resp_status_get( | |
h: response_handle, | |
status_ptr: mut_ptr<http_status> | |
): xqd_status /* err */; | |
/** resp_status_set */ | |
/** | |
* in: h, status | |
* out: err | |
*/ | |
// @ts-ignore: decorator | |
@external("xqd", "resp_status_set") | |
export declare function resp_status_set( | |
h: response_handle, status: http_status | |
): xqd_status /* err */; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment