@@ -2,78 +2,144 @@ package pdk
2
2
3
3
type extismPointer uint64
4
4
5
+ // extismInputLength returns the number of bytes provided by the host via its input methods.
6
+ //
5
7
//go:wasmimport extism:host/env input_length
6
- func extism_input_length () uint64
8
+ func extismInputLength () uint64
7
9
10
+ // extismLength returns the number of bytes associated with the block of host memory
11
+ // located at `offset`.
12
+ //
8
13
//go:wasmimport extism:host/env length
9
- func extism_length ( extismPointer ) uint64
14
+ func extismLength ( offset extismPointer ) uint64
10
15
11
16
//go:wasmimport extism:host/env length_unsafe
12
- func extism_length_unsafe (extismPointer ) uint64
17
+ func extismLengthUnsafe (extismPointer ) uint64
13
18
19
+ // extismAlloc allocates `length` bytes of data with host memory for use by the plugin
20
+ // and returns its offset within the host memory block.
21
+ //
14
22
//go:wasmimport extism:host/env alloc
15
- func extism_alloc ( uint64 ) extismPointer
23
+ func extismAlloc ( length uint64 ) extismPointer
16
24
25
+ // extismFree releases the bytes previously allocated with `extism_alloc` at the given `offset`.
26
+ //
17
27
//go:wasmimport extism:host/env free
18
- func extism_free ( extismPointer )
28
+ func extismFree ( offset extismPointer )
19
29
30
+ // extismInputLoadU8 returns the byte at location `offset` of the "input" data from the host.
31
+ //
20
32
//go:wasmimport extism:host/env input_load_u8
21
- func extism_input_load_u8_ (extismPointer ) uint32
22
-
23
- func extism_input_load_u8 (p extismPointer ) uint8 {
24
- return uint8 (extism_input_load_u8_ (p ))
33
+ func extismInputLoadU8_ (offset extismPointer ) uint32
34
+ func extismInputLoadU8 (offset extismPointer ) uint8 {
35
+ return uint8 (extismInputLoadU8_ (offset ))
25
36
}
26
37
38
+ // extismInputLoadU64 returns the 64-bit unsigned integer of the "input" data from the host.
39
+ // Note that `offset` must lie on an 8-byte boundary.
40
+ //
27
41
//go:wasmimport extism:host/env input_load_u64
28
- func extism_input_load_u64 ( extismPointer ) uint64
42
+ func extismInputLoadU64 ( offset extismPointer ) uint64
29
43
44
+ // extismOutputSet sets the "output" data from the plugin to the host to be the memory that
45
+ // has been written at `offset` with the given `length`.
46
+ // The memory can be immediately freed because the host makes a copy for its use.
47
+ //
30
48
//go:wasmimport extism:host/env output_set
31
- func extism_output_set ( extismPointer , uint64 )
49
+ func extismOutputSet ( offset extismPointer , length uint64 )
32
50
51
+ // extismErrorSet sets the "error" data from the plugin to the host to be the memory that
52
+ // has been written at `offset`.
53
+ // The memory can be immediately freed because the host makes a copy for its use.
54
+ //
33
55
//go:wasmimport extism:host/env error_set
34
- func extism_error_set ( extismPointer )
56
+ func extismErrorSet ( offset extismPointer )
35
57
58
+ // extismConfigGet returns the host memory block offset for the "config" data associated with
59
+ // the key which is represented by the UTF-8 string which as been previously written at `offset`.
60
+ // The memory for the key can be immediately freed because the host has its own copy.
61
+ //
36
62
//go:wasmimport extism:host/env config_get
37
- func extism_config_get ( extismPointer ) extismPointer
63
+ func extismConfigGet ( offset extismPointer ) extismPointer
38
64
65
+ // extismVarGet returns the host memory block offset for the "var" data associated with
66
+ // the key which is represented by the UTF-8 string which as been previously written at `offset`.
67
+ // The memory for the key can be immediately freed because the host has its own copy.
68
+ //
39
69
//go:wasmimport extism:host/env var_get
40
- func extism_var_get (extismPointer ) extismPointer
41
-
70
+ func extismVarGet (offset extismPointer ) extismPointer
71
+
72
+ // extismVarSet sets the host "var" memory keyed by the UTF-8 string located at `offset`
73
+ // to be the value which has been previously written at `valueOffset`.
74
+ //
75
+ // A `valueOffset` of 0 causes the old value associated with this key to be freed on the host
76
+ // and the association to be completely removed.
77
+ //
78
+ // The memory for the key can be immediately freed because the host has its own copy.
79
+ // The memory for the value, however, should not be freed, as that erases the value from the host.
80
+ //
42
81
//go:wasmimport extism:host/env var_set
43
- func extism_var_set ( extismPointer , extismPointer )
82
+ func extismVarSet ( offset , valueOffset extismPointer )
44
83
84
+ // extismStoreU8 stores the byte `v` at location `offset` in the host memory block.
85
+ //
45
86
//go:wasmimport extism:host/env store_u8
46
- func extism_store_u8_ (extismPointer , uint32 )
47
- func extism_store_u8 ( p extismPointer , v uint8 ) {
48
- extism_store_u8_ ( p , uint32 (v ))
87
+ func extismStoreU8_ (extismPointer , uint32 )
88
+ func extismStoreU8 ( offset extismPointer , v uint8 ) {
89
+ extismStoreU8_ ( offset , uint32 (v ))
49
90
}
50
91
92
+ // extismLoadU8 returns the byte located at `offset` in the host memory block.
93
+ //
51
94
//go:wasmimport extism:host/env load_u8
52
- func extism_load_u8_ ( extismPointer ) uint32
53
- func extism_load_u8 ( p extismPointer ) uint8 {
54
- return uint8 (extism_load_u8_ ( p ))
95
+ func extismLoadU8_ ( offset extismPointer ) uint32
96
+ func extismLoadU8 ( offset extismPointer ) uint8 {
97
+ return uint8 (extismLoadU8_ ( offset ))
55
98
}
56
99
100
+ // extismStoreU64 stores the 64-bit unsigned integer value `v` at location `offset` in the host memory block.
101
+ // Note that `offset` must lie on an 8-byte boundary.
102
+ //
57
103
//go:wasmimport extism:host/env store_u64
58
- func extism_store_u64 ( extismPointer , uint64 )
104
+ func extismStoreU64 ( offset extismPointer , v uint64 )
59
105
106
+ // extismLoadU64 returns the 64-bit unsigned integer at location `offset` in the host memory block.
107
+ // Note that `offset` must lie on an 8-byte boundary.
108
+ //
60
109
//go:wasmimport extism:host/env load_u64
61
- func extism_load_u64 ( extismPointer ) uint64
110
+ func extismLoadU64 ( offset extismPointer ) uint64
62
111
112
+ // extismHTTPRequest sends the HTTP `request` to the Extism host with the provided `body` (0 means no body)
113
+ // and returns back the memory offset to the response body.
114
+ //
63
115
//go:wasmimport extism:host/env http_request
64
- func extism_http_request ( extismPointer , extismPointer ) extismPointer
116
+ func extismHTTPRequest ( request , body extismPointer ) extismPointer
65
117
118
+ // extismHTTPStatusCode returns the status code for the last-sent `extism_http_request` call.
119
+ //
66
120
//go:wasmimport extism:host/env http_status_code
67
- func extism_http_status_code () int32
121
+ func extismHTTPStatusCode () int32
68
122
123
+ // extismLogInfo logs an "info" string to the host from the previously-written UTF-8 string written to `offset`.
124
+ // Note that the memory at `offset` can be immediately freed because it is immediately logged.
125
+ //
69
126
//go:wasmimport extism:host/env log_info
70
- func extism_log_info ( extismPointer )
127
+ func extismLogInfo ( offset extismPointer )
71
128
129
+ // extismLogDebug logs a "debug" string to the host from the previously-written UTF-8 string written to `offset`.
130
+ // Note that the memory at `offset` can be immediately freed because it is immediately logged.
131
+ //
72
132
//go:wasmimport extism:host/env log_debug
73
- func extism_log_debug ( extismPointer )
133
+ func extismLogDebug ( offset extismPointer )
74
134
135
+ // extismLogWarn logs a "warning" string to the host from the previously-written UTF-8 string written to `offset`.
136
+ // Note that the memory at `offset` can be immediately freed because it is immediately logged.
137
+ //
75
138
//go:wasmimport extism:host/env log_warn
76
- func extism_log_warn ( extismPointer )
139
+ func extismLogWarn ( offset extismPointer )
77
140
141
+ // extismLogError logs an "error" string to the host from the previously-written UTF-8 string written to `offset`.
142
+ // Note that the memory at `offset` can be immediately freed because it is immediately logged.
143
+ //
78
144
//go:wasmimport extism:host/env log_error
79
- func extism_log_error ( extismPointer )
145
+ func extismLogError ( offset extismPointer )
0 commit comments