1#![allow(non_upper_case_globals)]
24#![allow(non_camel_case_types)]
25#![allow(non_snake_case)]
26#![allow(deref_nullptr)]
28#![allow(dead_code)]
30
31use std::fmt;
32use std::os::raw::{c_char, c_int};
33use std::ptr;
34
35include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
36
37pub const CREATE_OPTIONS_STRUCT_VERSION: i32 = 2;
48
49impl Default for MQTTAsync_createOptions {
50 fn default() -> Self {
52 Self {
53 struct_id: [
54 b'M' as c_char,
55 b'Q' as c_char,
56 b'C' as c_char,
57 b'O' as c_char,
58 ],
59 struct_version: CREATE_OPTIONS_STRUCT_VERSION,
60 sendWhileDisconnected: 0,
61 maxBufferedMessages: 100,
62 MQTTVersion: MQTTVERSION_5 as c_int,
63 allowDisconnectedSendAtAnyTime: 0,
64 deleteOldestMessages: 0,
65 restoreMessages: 1,
66 persistQoS0: 1,
67 }
68 }
69}
70
71impl MQTTAsync_createOptions {
72 pub fn new() -> Self {
74 Self::default()
75 }
76
77 pub fn new_v3() -> Self {
79 Self {
80 MQTTVersion: MQTTVERSION_DEFAULT as c_int,
81 ..Self::default()
82 }
83 }
84
85 pub fn new_v5() -> Self {
87 Self::default()
88 }
89}
90
91pub const CONNECT_OPTIONS_STRUCT_VERSION: i32 = 8;
100
101impl Default for MQTTAsync_connectOptions {
102 fn default() -> Self {
103 Self {
104 struct_id: [
105 b'M' as c_char,
106 b'Q' as c_char,
107 b'T' as c_char,
108 b'C' as c_char,
109 ],
110 struct_version: CONNECT_OPTIONS_STRUCT_VERSION,
111 keepAliveInterval: 60,
112 cleansession: 1,
113 maxInflight: 65535,
114 will: ptr::null_mut(),
115 username: ptr::null(),
116 password: ptr::null(),
117 connectTimeout: 30,
118 retryInterval: 0,
119 ssl: ptr::null_mut(),
120 onSuccess: None,
121 onFailure: None,
122 context: ptr::null_mut(),
123 serverURIcount: 0,
124 serverURIs: ptr::null(),
125 MQTTVersion: 0,
126 automaticReconnect: 0,
127 minRetryInterval: 1,
128 maxRetryInterval: 60,
129 binarypwd: MQTTAsync_connectOptions__bindgen_ty_1 {
130 len: 0,
131 data: ptr::null(),
132 },
133 cleanstart: 0,
134 connectProperties: ptr::null_mut(),
135 willProperties: ptr::null_mut(),
136 onSuccess5: None,
137 onFailure5: None,
138 httpHeaders: ptr::null(),
139 httpProxy: ptr::null(),
140 httpsProxy: ptr::null(),
141 }
142 }
143}
144
145impl MQTTAsync_connectOptions {
146 pub fn new() -> Self {
148 Self::default()
149 }
150
151 pub fn new_v3() -> Self {
153 Self::default()
154 }
155
156 pub fn new_v5() -> Self {
158 Self {
159 cleansession: 0,
160 cleanstart: 1,
161 MQTTVersion: MQTTVERSION_5 as i32,
162 ..Self::default()
163 }
164 }
165
166 pub fn new_ws() -> Self {
168 Self {
169 keepAliveInterval: 45,
170 ..Self::default()
171 }
172 }
173
174 pub fn new_ws_v5() -> Self {
176 Self {
177 keepAliveInterval: 45,
178 ..Self::new_v5()
179 }
180 }
181}
182
183pub const WILL_OPTIONS_STRUCT_VERSION: i32 = 1;
188
189impl Default for MQTTAsync_willOptions {
190 fn default() -> MQTTAsync_willOptions {
191 MQTTAsync_willOptions {
192 struct_id: [
193 b'M' as c_char,
194 b'Q' as c_char,
195 b'T' as c_char,
196 b'W' as c_char,
197 ],
198 struct_version: WILL_OPTIONS_STRUCT_VERSION,
199 topicName: ptr::null(),
200 message: ptr::null(),
201 retained: 0,
202 qos: 0,
203 payload: MQTTAsync_willOptions__bindgen_ty_1 {
204 len: 0,
205 data: ptr::null(),
206 },
207 }
208 }
209}
210
211pub const SSL_OPTIONS_STRUCT_VERSION: i32 = 5;
213
214impl Default for MQTTAsync_SSLOptions {
215 fn default() -> MQTTAsync_SSLOptions {
216 MQTTAsync_SSLOptions {
217 struct_id: [
218 b'M' as c_char,
219 b'Q' as c_char,
220 b'T' as c_char,
221 b'S' as c_char,
222 ],
223 struct_version: SSL_OPTIONS_STRUCT_VERSION,
224 trustStore: ptr::null(),
225 keyStore: ptr::null(),
226 privateKey: ptr::null(),
227 privateKeyPassword: ptr::null(),
228 enabledCipherSuites: ptr::null(),
229 enableServerCertAuth: 1,
230 sslVersion: MQTT_SSL_VERSION_DEFAULT as i32,
231 verify: 0,
232 CApath: ptr::null(),
233 ssl_error_cb: None,
234 ssl_error_context: ptr::null_mut(),
235 ssl_psk_cb: None,
236 ssl_psk_context: ptr::null_mut(),
237 disableDefaultTrustStore: 0,
238 protos: ptr::null(),
239 protos_len: 0,
240 }
241 }
242}
243
244pub const SUBSCRIBE_OPTIONS_STRUCT_VERSION: i32 = 0;
246
247impl Default for MQTTSubscribe_options {
249 fn default() -> MQTTSubscribe_options {
250 MQTTSubscribe_options {
251 struct_id: [
252 b'M' as c_char,
253 b'Q' as c_char,
254 b'S' as c_char,
255 b'O' as c_char,
256 ],
257 struct_version: SUBSCRIBE_OPTIONS_STRUCT_VERSION,
258 noLocal: 0,
259 retainAsPublished: 0,
260 retainHandling: 0,
261 }
262 }
263}
264
265pub const RESPONSE_OPTIONS_STRUCT_VERSION: i32 = 1;
267
268impl Default for MQTTAsync_responseOptions {
269 fn default() -> MQTTAsync_responseOptions {
270 MQTTAsync_responseOptions {
271 struct_id: [
272 b'M' as c_char,
273 b'Q' as c_char,
274 b'T' as c_char,
275 b'R' as c_char,
276 ],
277 struct_version: RESPONSE_OPTIONS_STRUCT_VERSION,
278 onSuccess: None,
279 onFailure: None,
280 context: ptr::null_mut(),
281 token: 0,
282 onSuccess5: None,
283 onFailure5: None,
284 properties: MQTTProperties::default(),
285 subscribeOptions: MQTTSubscribe_options::default(),
286 subscribeOptionsCount: 0,
287 subscribeOptionsList: ptr::null_mut(),
288 }
289 }
290}
291
292impl fmt::Debug for MQTTProperty {
296 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
297 write!(f, "[]")
299 }
300}
301
302impl Default for MQTTProperties {
303 fn default() -> MQTTProperties {
304 MQTTProperties {
305 count: 0,
306 max_count: 0,
307 length: 0,
308 array: ptr::null_mut(),
309 }
310 }
311}
312
313impl Default for MQTTLenString {
314 fn default() -> MQTTLenString {
315 MQTTLenString {
316 len: 0,
317 data: ptr::null_mut(),
318 }
319 }
320}
321
322pub const MESSAGE_STRUCT_VERSION: i32 = 1;
327
328impl Default for MQTTAsync_message {
329 fn default() -> MQTTAsync_message {
330 MQTTAsync_message {
331 struct_id: [
332 b'M' as c_char,
333 b'Q' as c_char,
334 b'T' as c_char,
335 b'M' as c_char,
336 ],
337 struct_version: MESSAGE_STRUCT_VERSION,
338 payloadlen: 0,
339 payload: ptr::null_mut(),
340 qos: 0,
341 retained: 0,
342 dup: 0,
343 msgid: 0,
344 properties: MQTTProperties::default(),
345 }
346 }
347}
348
349pub const DISCONNECT_OPTIONS_STRUCT_VERSION: i32 = 1;
354
355impl Default for MQTTAsync_disconnectOptions {
356 fn default() -> MQTTAsync_disconnectOptions {
357 MQTTAsync_disconnectOptions {
358 struct_id: [
359 b'M' as c_char,
360 b'Q' as c_char,
361 b'T' as c_char,
362 b'D' as c_char,
363 ],
364 struct_version: DISCONNECT_OPTIONS_STRUCT_VERSION,
365 timeout: 0,
366 onSuccess: None,
367 onFailure: None,
368 context: ptr::null_mut(),
369 properties: MQTTProperties::default(),
370 reasonCode: 0,
371 onSuccess5: None,
372 onFailure5: None,
373 }
374 }
375}
376
377impl Default for MQTTClient_persistence {
381 fn default() -> Self {
382 MQTTClient_persistence {
383 context: ptr::null_mut(),
384 popen: None,
385 pclose: None,
386 pput: None,
387 pget: None,
388 premove: None,
389 pkeys: None,
390 pclear: None,
391 pcontainskey: None,
392 }
393 }
394}
395
396impl MQTTAsync_nameValue {
400 pub fn new(name: *const c_char, value: *const c_char) -> Self {
401 Self { name, value }
402 }
403}
404
405impl Default for MQTTAsync_nameValue {
406 fn default() -> Self {
407 Self {
408 name: ptr::null(),
409 value: ptr::null(),
410 }
411 }
412}
413
414#[cfg(test)]
418mod tests {}