1 // machine generated, do not edit
2 
3 module sokol.fetch;
4 
5 enum LogItem {
6     Ok,
7     Malloc_failed,
8     File_path_utf8_decoding_failed,
9     Send_queue_full,
10     Request_channel_index_too_big,
11     Request_path_is_null,
12     Request_path_too_long,
13     Request_callback_missing,
14     Request_chunk_size_greater_buffer_size,
15     Request_userdata_ptr_is_set_but_userdata_size_is_null,
16     Request_userdata_ptr_is_null_but_userdata_size_is_not,
17     Request_userdata_size_too_big,
18     Clamping_num_channels_to_max_channels,
19     Request_pool_exhausted,
20 }
21 extern(C)
22 struct Logger {
23     extern(C) void function(const(char)*, uint, uint, const(char)*, uint, const(char)*, void*) func = null;
24     void* user_data = null;
25 }
26 extern(C)
27 struct Range {
28     const(void)* ptr = null;
29     size_t size = 0;
30 }
31 extern(C)
32 struct Allocator {
33     extern(C) void* function(size_t, void*) alloc_fn = null;
34     extern(C) void function(void*, void*) free_fn = null;
35     void* user_data = null;
36 }
37 extern(C)
38 struct Desc {
39     uint max_requests = 0;
40     uint num_channels = 0;
41     uint num_lanes = 0;
42     Allocator allocator;
43     Logger logger;
44 }
45 extern(C)
46 struct Handle {
47     uint id = 0;
48 }
49 enum Error {
50     No_error,
51     File_not_found,
52     No_buffer,
53     Buffer_too_small,
54     Unexpected_eof,
55     Invalid_http_status,
56     Cancelled,
57 }
58 extern(C)
59 struct Response {
60     Handle handle;
61     bool dispatched = false;
62     bool fetched = false;
63     bool paused = false;
64     bool finished = false;
65     bool failed = false;
66     bool cancelled = false;
67     Error error_code;
68     uint channel = 0;
69     uint lane = 0;
70     const(char)* path = null;
71     void* user_data = null;
72     uint data_offset = 0;
73     Range data;
74     Range buffer;
75 }
76 extern(C)
77 struct Request {
78     uint channel = 0;
79     const(char)* path = null;
80     extern(C) void function(const Response *) callback = null;
81     uint chunk_size = 0;
82     Range buffer;
83     Range user_data;
84 }
85 extern(C) void sfetch_setup(const Desc *) @system @nogc nothrow;
86 void setup(scope ref Desc desc) @trusted @nogc nothrow {
87     sfetch_setup(&desc);
88 }
89 extern(C) void sfetch_shutdown() @system @nogc nothrow;
90 void shutdown() @trusted @nogc nothrow {
91     sfetch_shutdown();
92 }
93 extern(C) bool sfetch_valid() @system @nogc nothrow;
94 bool valid() @trusted @nogc nothrow {
95     return sfetch_valid();
96 }
97 extern(C) Desc sfetch_desc() @system @nogc nothrow;
98 Desc desc() @trusted @nogc nothrow {
99     return sfetch_desc();
100 }
101 extern(C) int sfetch_max_userdata_bytes() @system @nogc nothrow;
102 int maxUserdataBytes() @trusted @nogc nothrow {
103     return sfetch_max_userdata_bytes();
104 }
105 extern(C) int sfetch_max_path() @system @nogc nothrow;
106 int maxPath() @trusted @nogc nothrow {
107     return sfetch_max_path();
108 }
109 extern(C) Handle sfetch_send(const Request *) @system @nogc nothrow;
110 Handle send(scope ref Request request) @trusted @nogc nothrow {
111     return sfetch_send(&request);
112 }
113 extern(C) bool sfetch_handle_valid(Handle) @system @nogc nothrow;
114 bool handleValid(Handle h) @trusted @nogc nothrow {
115     return sfetch_handle_valid(h);
116 }
117 extern(C) void sfetch_dowork() @system @nogc nothrow;
118 void dowork() @trusted @nogc nothrow {
119     sfetch_dowork();
120 }
121 extern(C) void sfetch_bind_buffer(Handle, Range) @system @nogc nothrow;
122 void bindBuffer(Handle h, Range buffer) @trusted @nogc nothrow {
123     sfetch_bind_buffer(h, buffer);
124 }
125 extern(C) void* sfetch_unbind_buffer(Handle) @system @nogc nothrow;
126 scope void* unbindBuffer(Handle h) @trusted @nogc nothrow {
127     return sfetch_unbind_buffer(h);
128 }
129 extern(C) void sfetch_cancel(Handle) @system @nogc nothrow;
130 void cancel(Handle h) @trusted @nogc nothrow {
131     sfetch_cancel(h);
132 }
133 extern(C) void sfetch_pause(Handle) @system @nogc nothrow;
134 void pause(Handle h) @trusted @nogc nothrow {
135     sfetch_pause(h);
136 }
137 extern(C) void sfetch_continue(Handle) @system @nogc nothrow;
138 void continueFetching(Handle h) @trusted @nogc nothrow {
139     sfetch_continue(h);
140 }