1 /++
2 + Machine generated D bindings for Sokol library.
3 + 
4 +     Source header: sokol_fetch.h
5 +     Module: sokol.fetch
6 + 
7 +     Do not edit manually; regenerate using gen_d.py.
8 +/
9 module sokol.fetch;
10 
11 enum LogItem {
12     Ok,
13     Malloc_failed,
14     File_path_utf8_decoding_failed,
15     Send_queue_full,
16     Request_channel_index_too_big,
17     Request_path_is_null,
18     Request_path_too_long,
19     Request_callback_missing,
20     Request_chunk_size_greater_buffer_size,
21     Request_userdata_ptr_is_set_but_userdata_size_is_null,
22     Request_userdata_ptr_is_null_but_userdata_size_is_not,
23     Request_userdata_size_too_big,
24     Clamping_num_channels_to_max_channels,
25     Request_pool_exhausted,
26 }
27 /++
28 + sfetch_logger_t
29 + 
30 +     Used in sfetch_desc_t to provide a custom logging and error reporting
31 +     callback to sokol-fetch.
32 +/
33 extern(C) struct Logger {
34     extern(C) void function(const(char)*, uint, uint, const(char)*, uint, const(char)*, void*) func = null;
35     void* user_data = null;
36 }
37 /++
38 + sfetch_range_t
39 + 
40 +     A pointer-size pair struct to pass memory ranges into and out of sokol-fetch.
41 +     When initialized from a value type (array or struct) you can use the
42 +     SFETCH_RANGE() helper macro to build an sfetch_range_t struct.
43 +/
44 extern(C) struct Range {
45     const(void)* ptr = null;
46     size_t size = 0;
47 }
48 /++
49 + sfetch_allocator_t
50 + 
51 +     Used in sfetch_desc_t to provide custom memory-alloc and -free functions
52 +     to sokol_fetch.h. If memory management should be overridden, both the
53 +     alloc and free function must be provided (e.g. it's not valid to
54 +     override one function but not the other).
55 +/
56 extern(C) struct Allocator {
57     extern(C) void* function(size_t, void*) alloc_fn = null;
58     extern(C) void function(void*, void*) free_fn = null;
59     void* user_data = null;
60 }
61 /++
62 + configuration values for sfetch_setup()
63 +/
64 extern(C) struct Desc {
65     uint max_requests = 0;
66     uint num_channels = 0;
67     uint num_lanes = 0;
68     Allocator allocator = {};
69     Logger logger = {};
70 }
71 /++
72 + a request handle to identify an active fetch request, returned by sfetch_send()
73 +/
74 extern(C) struct Handle {
75     uint id = 0;
76 }
77 /++
78 + error codes
79 +/
80 enum Error {
81     No_error,
82     File_not_found,
83     No_buffer,
84     Buffer_too_small,
85     Unexpected_eof,
86     Invalid_http_status,
87     Cancelled,
88     Js_other,
89 }
90 /++
91 + the response struct passed to the response callback
92 +/
93 extern(C) struct Response {
94     Handle handle = {};
95     bool dispatched = false;
96     bool fetched = false;
97     bool paused = false;
98     bool finished = false;
99     bool failed = false;
100     bool cancelled = false;
101     Error error_code = Error.No_error;
102     uint channel = 0;
103     uint lane = 0;
104     const(char)* path = null;
105     void* user_data = null;
106     uint data_offset = 0;
107     Range data = {};
108     Range buffer = {};
109 }
110 /++
111 + request parameters passed to sfetch_send()
112 +/
113 extern(C) struct Request {
114     uint channel = 0;
115     const(char)* path = null;
116     extern(C) void function(const Response*) callback = null;
117     uint chunk_size = 0;
118     Range buffer = {};
119     Range user_data = {};
120 }
121 /++
122 + setup sokol-fetch (can be called on multiple threads)
123 +/
124 extern(C) void sfetch_setup(const Desc* desc) @system @nogc nothrow pure;
125 void setup(scope ref Desc desc) @trusted @nogc nothrow pure {
126     sfetch_setup(&desc);
127 }
128 /++
129 + discard a sokol-fetch context
130 +/
131 extern(C) void sfetch_shutdown() @system @nogc nothrow pure;
132 void shutdown() @trusted @nogc nothrow pure {
133     sfetch_shutdown();
134 }
135 /++
136 + return true if sokol-fetch has been setup
137 +/
138 extern(C) bool sfetch_valid() @system @nogc nothrow pure;
139 bool valid() @trusted @nogc nothrow pure {
140     return sfetch_valid();
141 }
142 /++
143 + get the desc struct that was passed to sfetch_setup()
144 +/
145 extern(C) Desc sfetch_desc() @system @nogc nothrow pure;
146 Desc desc() @trusted @nogc nothrow pure {
147     return sfetch_desc();
148 }
149 /++
150 + return the max userdata size in number of bytes (SFETCH_MAX_USERDATA_UINT64 * sizeof(uint64_t))
151 +/
152 extern(C) int sfetch_max_userdata_bytes() @system @nogc nothrow pure;
153 int maxUserdataBytes() @trusted @nogc nothrow pure {
154     return sfetch_max_userdata_bytes();
155 }
156 /++
157 + return the value of the SFETCH_MAX_PATH implementation config value
158 +/
159 extern(C) int sfetch_max_path() @system @nogc nothrow pure;
160 int maxPath() @trusted @nogc nothrow pure {
161     return sfetch_max_path();
162 }
163 /++
164 + send a fetch-request, get handle to request back
165 +/
166 extern(C) Handle sfetch_send(const Request* request) @system @nogc nothrow pure;
167 Handle send(scope ref Request request) @trusted @nogc nothrow pure {
168     return sfetch_send(&request);
169 }
170 /++
171 + return true if a handle is valid *and* the request is alive
172 +/
173 extern(C) bool sfetch_handle_valid(Handle h) @system @nogc nothrow pure;
174 bool handleValid(Handle h) @trusted @nogc nothrow pure {
175     return sfetch_handle_valid(h);
176 }
177 /++
178 + do per-frame work, moves requests into and out of IO threads, and invokes response-callbacks
179 +/
180 extern(C) void sfetch_dowork() @system @nogc nothrow pure;
181 void dowork() @trusted @nogc nothrow pure {
182     sfetch_dowork();
183 }
184 /++
185 + bind a data buffer to a request (request must not currently have a buffer bound, must be called from response callback
186 +/
187 extern(C) void sfetch_bind_buffer(Handle h, Range buffer) @system @nogc nothrow pure;
188 void bindBuffer(Handle h, Range buffer) @trusted @nogc nothrow pure {
189     sfetch_bind_buffer(h, buffer);
190 }
191 /++
192 + clear the 'buffer binding' of a request, returns previous buffer pointer (can be 0), must be called from response callback
193 +/
194 extern(C) void* sfetch_unbind_buffer(Handle h) @system @nogc nothrow pure;
195 void* unbindBuffer(Handle h) @trusted @nogc nothrow pure {
196     return sfetch_unbind_buffer(h);
197 }
198 /++
199 + cancel a request that's in flight (will call response callback with .cancelled + .finished)
200 +/
201 extern(C) void sfetch_cancel(Handle h) @system @nogc nothrow pure;
202 void cancel(Handle h) @trusted @nogc nothrow pure {
203     sfetch_cancel(h);
204 }
205 /++
206 + pause a request (will call response callback each frame with .paused)
207 +/
208 extern(C) void sfetch_pause(Handle h) @system @nogc nothrow pure;
209 void pause(Handle h) @trusted @nogc nothrow pure {
210     sfetch_pause(h);
211 }
212 /++
213 + continue a paused request
214 +/
215 extern(C) void sfetch_continue(Handle h) @system @nogc nothrow pure;
216 void continueFetching(Handle h) @trusted @nogc nothrow pure {
217     sfetch_continue(h);
218 }