stem-mqtt 0.0.0-stage → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1510 @@
1
+ import koffi from "koffi";
2
+
3
+
4
+ import {
5
+
6
+ configureRuntimeHooks,
7
+
8
+ ffiFunctions,
9
+
10
+ getFfiBindings,
11
+
12
+ getFfiTypes,
13
+
14
+ } from "./mqtt_broker-ffi.js";
15
+
16
+
17
+ import {
18
+
19
+ createForeignBytes,
20
+
21
+ RustBufferValue,
22
+
23
+ } from "../runtime/ffi-types.js";
24
+
25
+
26
+ import {
27
+
28
+ AbstractFfiConverterByteArray,
29
+
30
+ FfiConverterArray,
31
+
32
+ FfiConverterBool,
33
+
34
+ FfiConverterBytes,
35
+
36
+ FfiConverterOptional,
37
+
38
+ FfiConverterString,
39
+
40
+ FfiConverterUInt16,
41
+
42
+ FfiConverterUInt32,
43
+
44
+ } from "../runtime/ffi-converters.js";
45
+
46
+
47
+ import {
48
+
49
+ UnexpectedEnumCase,
50
+
51
+ } from "../runtime/errors.js";
52
+
53
+
54
+ import {
55
+
56
+ rustCallAsync,
57
+
58
+ rustFutureContinuationCallback,
59
+
60
+ } from "../runtime/async-rust-call.js";
61
+
62
+
63
+ import {
64
+
65
+ clearPendingForeignFutures,
66
+
67
+ createCallbackRegistry,
68
+
69
+ invokeCallbackMethod,
70
+
71
+ } from "../runtime/callbacks.js";
72
+
73
+
74
+ import {
75
+
76
+ createObjectConverter,
77
+
78
+ createObjectFactory,
79
+
80
+ UniffiObjectBase,
81
+
82
+ UNIFFI_OBJECT_HANDLE_SIZE,
83
+
84
+ } from "../runtime/objects.js";
85
+
86
+
87
+ import {
88
+
89
+ CALL_SUCCESS,
90
+
91
+ UniffiRustCaller,
92
+
93
+ createRustCallStatus,
94
+
95
+ } from "../runtime/rust-call.js";
96
+
97
+
98
+ export const componentMetadata = Object.freeze({
99
+ namespace: "mqtt_broker",
100
+ packageName: "mqtt_broker",
101
+ cdylibName: "mqtt_broker",
102
+ nodeEngine: ">=16",
103
+ bundledPrebuilds: true,
104
+ manualLoad: false,
105
+ });
106
+
107
+ export { ffiMetadata } from "./mqtt_broker-ffi.js";
108
+
109
+
110
+ function uniffiNotImplemented(member) {
111
+ throw new Error(`${member} is not implemented yet. Koffi-backed bindings are still pending.`);
112
+ }
113
+
114
+ const uniffiTextEncoder = new TextEncoder();
115
+ const uniffiTextDecoder = new TextDecoder();
116
+ const uniffiSuccessRustCallStatus = createRustCallStatus();
117
+ const UNIFFI_MAX_CACHED_RUST_CALL_STATUSES = 32;
118
+ const uniffiRustCallStatusPool = [];
119
+
120
+ function uniffiLiftString(bytes) {
121
+ return uniffiTextDecoder.decode(bytes);
122
+ }
123
+
124
+ function uniffiDecodeRustCallStatus(status) {
125
+ return status == null
126
+ ? uniffiSuccessRustCallStatus
127
+ : koffi.decode(status, 0, "int8_t") === 0
128
+ ? uniffiSuccessRustCallStatus
129
+ : koffi.decode(status, getFfiTypes().RustCallStatus);
130
+ }
131
+
132
+ function uniffiWriteRustCallStatus(status, value) {
133
+ if (
134
+ status != null
135
+ && (
136
+ value.code !== 0
137
+ || value.error_buf.data !== null
138
+ || value.error_buf.len !== 0n
139
+ || value.error_buf.capacity !== 0n
140
+ )
141
+ ) {
142
+ koffi.encode(status, getFfiTypes().RustCallStatus, value);
143
+ }
144
+ return status;
145
+ }
146
+
147
+ function uniffiAcquireRustCallStatus() {
148
+ const status = uniffiRustCallStatusPool.pop();
149
+ if (status != null) {
150
+ return status;
151
+ }
152
+ return koffi.alloc(getFfiTypes().RustCallStatus, 1);
153
+ }
154
+
155
+ function uniffiReleaseRustCallStatus(status) {
156
+ if (status == null) {
157
+ return;
158
+ }
159
+
160
+ koffi.encode(status, getFfiTypes().RustCallStatus, uniffiSuccessRustCallStatus);
161
+ if (uniffiRustCallStatusPool.length < UNIFFI_MAX_CACHED_RUST_CALL_STATUSES) {
162
+ uniffiRustCallStatusPool.push(status);
163
+ return;
164
+ }
165
+
166
+ koffi.free(status);
167
+ }
168
+
169
+ const uniffiRustCaller = new UniffiRustCaller({
170
+ createStatus: uniffiAcquireRustCallStatus,
171
+ disposeStatus: uniffiReleaseRustCallStatus,
172
+ readStatus: uniffiDecodeRustCallStatus,
173
+ writeStatus: uniffiWriteRustCallStatus,
174
+ liftString: uniffiLiftString,
175
+ });
176
+
177
+ function uniffiFreeRustBuffer(buffer) {
178
+ return uniffiRustCaller.rustCall(
179
+ (status) => ffiFunctions.ffi_mqtt_broker_rustbuffer_free(buffer, status),
180
+ { liftString: uniffiLiftString },
181
+ );
182
+ }
183
+
184
+ const uniffiDefaultRustCallOptions = Object.freeze({
185
+ freeRustBuffer: uniffiFreeRustBuffer,
186
+ liftString: uniffiLiftString,
187
+ rustCaller: uniffiRustCaller,
188
+ });
189
+ const uniffiRustCallOptionsByErrorConverter = new WeakMap();
190
+ const uniffiOptionalConverterCache = new WeakMap();
191
+ const uniffiArrayConverterCache = new WeakMap();
192
+ const uniffiLibraryFunctionCache = new WeakMap();
193
+
194
+ function uniffiRustCallOptions(errorConverter = undefined) {
195
+ if (errorConverter == null) {
196
+ return uniffiDefaultRustCallOptions;
197
+ }
198
+
199
+ if (typeof errorConverter !== "object" && typeof errorConverter !== "function") {
200
+ return Object.freeze({
201
+ errorHandler: (errorBytes) => errorConverter.lift(errorBytes),
202
+ freeRustBuffer: uniffiFreeRustBuffer,
203
+ liftString: uniffiLiftString,
204
+ rustCaller: uniffiRustCaller,
205
+ });
206
+ }
207
+
208
+ const cachedOptions = uniffiRustCallOptionsByErrorConverter.get(errorConverter);
209
+ if (cachedOptions != null) {
210
+ return cachedOptions;
211
+ }
212
+
213
+ const options = Object.freeze({
214
+ errorHandler: (errorBytes) => errorConverter.lift(errorBytes),
215
+ freeRustBuffer: uniffiFreeRustBuffer,
216
+ liftString: uniffiLiftString,
217
+ rustCaller: uniffiRustCaller,
218
+ });
219
+ uniffiRustCallOptionsByErrorConverter.set(errorConverter, options);
220
+ return options;
221
+ }
222
+
223
+ function uniffiOptionalConverter(innerConverter) {
224
+ let converter = uniffiOptionalConverterCache.get(innerConverter);
225
+ if (converter == null) {
226
+ converter = new FfiConverterOptional(innerConverter);
227
+ uniffiOptionalConverterCache.set(innerConverter, converter);
228
+ }
229
+ return converter;
230
+ }
231
+
232
+ function uniffiArrayConverter(innerConverter) {
233
+ let converter = uniffiArrayConverterCache.get(innerConverter);
234
+ if (converter == null) {
235
+ converter = new FfiConverterArray(innerConverter);
236
+ uniffiArrayConverterCache.set(innerConverter, converter);
237
+ }
238
+ return converter;
239
+ }
240
+
241
+ function uniffiGetCachedLibraryFunction(cacheKey, create) {
242
+ const bindings = getFfiBindings();
243
+ const library = bindings.library;
244
+ let libraryCache = uniffiLibraryFunctionCache.get(library);
245
+ if (libraryCache == null) {
246
+ libraryCache = new Map();
247
+ uniffiLibraryFunctionCache.set(library, libraryCache);
248
+ }
249
+
250
+ let cachedFunction = libraryCache.get(cacheKey);
251
+ if (cachedFunction == null) {
252
+ cachedFunction = create(bindings);
253
+ libraryCache.set(cacheKey, cachedFunction);
254
+ }
255
+ return cachedFunction;
256
+ }
257
+
258
+ function uniffiCopyIntoRustBuffer(bytes) {
259
+ return uniffiRustCaller.rustCall(
260
+ (status) => ffiFunctions.ffi_mqtt_broker_rustbuffer_from_bytes(createForeignBytes(bytes), status),
261
+ uniffiRustCallOptions(),
262
+ );
263
+ }
264
+
265
+ function uniffiLowerString(value) {
266
+ return uniffiCopyIntoRustBuffer(uniffiTextEncoder.encode(value));
267
+ }
268
+
269
+ function uniffiLiftStringFromRustBuffer(value) {
270
+ return uniffiLiftString(new RustBufferValue(value).consumeIntoUint8Array(uniffiFreeRustBuffer));
271
+ }
272
+
273
+ function uniffiLowerBytes(value) {
274
+ return uniffiCopyIntoRustBuffer(value);
275
+ }
276
+
277
+ function uniffiLiftBytesFromRustBuffer(value) {
278
+ return new RustBufferValue(value).consumeIntoUint8Array(uniffiFreeRustBuffer);
279
+ }
280
+
281
+ function uniffiLowerIntoRustBuffer(converter, value) {
282
+ return uniffiCopyIntoRustBuffer(converter.lower(value));
283
+ }
284
+
285
+ function uniffiLiftFromRustBuffer(converter, value) {
286
+ return converter.lift(uniffiLiftBytesFromRustBuffer(value));
287
+ }
288
+
289
+ function uniffiRequireRecordObject(typeName, value) {
290
+ if (typeof value !== "object" || value == null) {
291
+ throw new TypeError(`${typeName} values must be non-null objects.`);
292
+ }
293
+ return value;
294
+ }
295
+
296
+ function uniffiRequireFlatEnumValue(enumValues, typeName, value) {
297
+ for (const enumValue of Object.values(enumValues)) {
298
+ if (enumValue === value) {
299
+ return enumValue;
300
+ }
301
+ }
302
+ throw new TypeError(`${typeName} values must be one of ${Object.values(enumValues).map((item) => JSON.stringify(item)).join(", ")}.`);
303
+ }
304
+
305
+ function uniffiRequireTaggedEnumValue(typeName, value) {
306
+ const enumValue = uniffiRequireRecordObject(typeName, value);
307
+ if (typeof enumValue.tag !== "string") {
308
+ throw new TypeError(`${typeName} values must be tagged objects with a string tag field.`);
309
+ }
310
+ return enumValue;
311
+ }
312
+
313
+ function uniffiNotImplementedConverter(typeName) {
314
+ const fail = (member) => {
315
+ throw new Error(`${typeName} converter ${member} is not implemented yet.`);
316
+ };
317
+ return Object.freeze({
318
+ lower() {
319
+ return fail("lower");
320
+ },
321
+ lift() {
322
+ return fail("lift");
323
+ },
324
+ write() {
325
+ return fail("write");
326
+ },
327
+ read() {
328
+ return fail("read");
329
+ },
330
+ allocationSize() {
331
+ return fail("allocationSize");
332
+ },
333
+ });
334
+ }
335
+
336
+ let uniffiRustFutureContinuationPointer = null;
337
+
338
+ function uniffiGetRustFutureContinuationPointer() {
339
+ if (uniffiRustFutureContinuationPointer == null) {
340
+ const bindings = getFfiBindings();
341
+ uniffiRustFutureContinuationPointer = koffi.register(
342
+ rustFutureContinuationCallback,
343
+ koffi.pointer(bindings.ffiCallbacks.RustFutureContinuationCallback),
344
+ );
345
+ }
346
+ return uniffiRustFutureContinuationPointer;
347
+ }
348
+
349
+ /**
350
+ * The verdict of one round of an MQTT 5.0 enhanced authentication exchange.
351
+ */
352
+ export const EnhancedAuthOutcome = Object.freeze({
353
+ /**
354
+ * Send [`EnhancedAuthStep::data`] to the client as a challenge and wait
355
+ * for its response.
356
+ */
357
+ "Continue": "Continue",
358
+ /**
359
+ * Authentication succeeded; [`EnhancedAuthStep::data`] (if non-empty) is
360
+ * returned to the client in the CONNACK (e.g. a SCRAM server-final message).
361
+ */
362
+ "Success": "Success",
363
+ /**
364
+ * Refuse the connection.
365
+ */
366
+ "Failure": "Failure",
367
+ });
368
+
369
+ /**
370
+ * MQTT Quality of Service level, as used in the broker's own API
371
+ * ([`MqttBrokerConfig::max_qos`], [`MqttBrokerEventListener`], [`crate::BrokerEvent`]).
372
+ *
373
+ * This is deliberately the **broker's own** enum rather than a re-export of
374
+ * `mqtt_client::QoS`. A type defined in another crate is an *external type*
375
+ * to UniFFI, and several binding generators (Node.js) can't handle those;
376
+ * owning it makes `mqtt_broker`'s bindings fully self-contained in every
377
+ * language — one package, no dependency on the client component's generated
378
+ * code. The cost is a second `QoS` next to the client's (identical, with
379
+ * lossless `From` conversions in Rust).
380
+ */
381
+ export const QoS = Object.freeze({
382
+ /**
383
+ * QoS 0 — fire and forget.
384
+ */
385
+ "AtMostOnce": "AtMostOnce",
386
+ /**
387
+ * QoS 1 — acknowledged delivery, may be duplicated.
388
+ */
389
+ "AtLeastOnce": "AtLeastOnce",
390
+ /**
391
+ * QoS 2 — exactly-once delivery.
392
+ */
393
+ "ExactlyOnce": "ExactlyOnce",
394
+ });
395
+
396
+ /**
397
+ * A broker event, as returned by the pull-style `MqttBroker::next_event`
398
+ * (the polling twin of [`MqttBrokerEventListener`](crate::config::MqttBrokerEventListener)).
399
+ */
400
+ export const BrokerEvent = Object.freeze({
401
+ ClientConnected(client_id) {
402
+ return Object.freeze({
403
+ tag: "ClientConnected",
404
+ "client_id": client_id,
405
+ });
406
+ },
407
+ ClientDisconnected(client_id, reason) {
408
+ return Object.freeze({
409
+ tag: "ClientDisconnected",
410
+ "client_id": client_id,
411
+ "reason": reason,
412
+ });
413
+ },
414
+ MessagePublished(client_id, topic, qos) {
415
+ return Object.freeze({
416
+ tag: "MessagePublished",
417
+ "client_id": client_id,
418
+ "topic": topic,
419
+ "qos": qos,
420
+ });
421
+ },
422
+ });
423
+
424
+ /**
425
+ * Errors produced while starting or stopping an [`crate::MqttBroker`].
426
+ */
427
+ export class MqttBrokerError extends globalThis.Error {
428
+ constructor(tag, message = tag) {
429
+ super(message);
430
+ this.name = "MqttBrokerError";
431
+ this.tag = tag;
432
+ }
433
+ }
434
+
435
+ /**
436
+ * `start()` was called while the broker was already running.
437
+ */
438
+ export class MqttBrokerErrorAlreadyRunning extends MqttBrokerError {
439
+ constructor(message = undefined) {
440
+ super("AlreadyRunning", message ?? "AlreadyRunning");
441
+ this.name = "MqttBrokerErrorAlreadyRunning";
442
+ this.message = message ?? "AlreadyRunning";
443
+ }
444
+ }
445
+
446
+ /**
447
+ * A listening socket could not be bound or queried.
448
+ */
449
+ export class MqttBrokerErrorIo extends MqttBrokerError {
450
+ constructor(message = undefined) {
451
+ super("Io", message ?? "Io");
452
+ this.name = "MqttBrokerErrorIo";
453
+ this.message = message ?? "Io";
454
+ }
455
+ }
456
+
457
+ /**
458
+ * TLS certificate, key, or verifier configuration was invalid.
459
+ */
460
+ export class MqttBrokerErrorTls extends MqttBrokerError {
461
+ constructor(message = undefined) {
462
+ super("Tls", message ?? "Tls");
463
+ this.name = "MqttBrokerErrorTls";
464
+ this.message = message ?? "Tls";
465
+ }
466
+ }
467
+
468
+ const FfiConverterBrokerTlsConfig = new (class extends AbstractFfiConverterByteArray {
469
+ allocationSize(value) {
470
+ const recordValue = uniffiRequireRecordObject("BrokerTlsConfig", value);
471
+ return FfiConverterUInt16.allocationSize(recordValue["port"]) + FfiConverterBytes.allocationSize(recordValue["cert_pem"]) + FfiConverterBytes.allocationSize(recordValue["key_pem"]) + uniffiOptionalConverter(FfiConverterBytes).allocationSize(recordValue["client_ca_pem"]);
472
+ }
473
+
474
+ write(value, writer) {
475
+ const recordValue = uniffiRequireRecordObject("BrokerTlsConfig", value);
476
+ FfiConverterUInt16.write(recordValue["port"], writer);
477
+ FfiConverterBytes.write(recordValue["cert_pem"], writer);
478
+ FfiConverterBytes.write(recordValue["key_pem"], writer);
479
+ uniffiOptionalConverter(FfiConverterBytes).write(recordValue["client_ca_pem"], writer);
480
+ }
481
+
482
+ read(reader) {
483
+ return {
484
+ "port": FfiConverterUInt16.read(reader),
485
+ "cert_pem": FfiConverterBytes.read(reader),
486
+ "key_pem": FfiConverterBytes.read(reader),
487
+ "client_ca_pem": uniffiOptionalConverter(FfiConverterBytes).read(reader),
488
+ };
489
+ }
490
+ })();
491
+ const FfiConverterEnhancedAuthStep = new (class extends AbstractFfiConverterByteArray {
492
+ allocationSize(value) {
493
+ const recordValue = uniffiRequireRecordObject("EnhancedAuthStep", value);
494
+ return FfiConverterEnhancedAuthOutcome.allocationSize(recordValue["outcome"]) + FfiConverterBytes.allocationSize(recordValue["data"]);
495
+ }
496
+
497
+ write(value, writer) {
498
+ const recordValue = uniffiRequireRecordObject("EnhancedAuthStep", value);
499
+ FfiConverterEnhancedAuthOutcome.write(recordValue["outcome"], writer);
500
+ FfiConverterBytes.write(recordValue["data"], writer);
501
+ }
502
+
503
+ read(reader) {
504
+ return {
505
+ "outcome": FfiConverterEnhancedAuthOutcome.read(reader),
506
+ "data": FfiConverterBytes.read(reader),
507
+ };
508
+ }
509
+ })();
510
+ const FfiConverterMqttBrokerConfig = new (class extends AbstractFfiConverterByteArray {
511
+ allocationSize(value) {
512
+ const recordValue = uniffiRequireRecordObject("MqttBrokerConfig", value);
513
+ return FfiConverterString.allocationSize(recordValue["bind_address"]) + FfiConverterUInt16.allocationSize(recordValue["port"]) + uniffiOptionalConverter(FfiConverterUInt16).allocationSize(recordValue["ws_port"]) + FfiConverterBool.allocationSize(recordValue["allow_anonymous"]) + FfiConverterUInt32.allocationSize(recordValue["max_clients"]) + FfiConverterQoS.allocationSize(recordValue["max_qos"]) + FfiConverterUInt32.allocationSize(recordValue["max_retained_messages"]) + FfiConverterUInt32.allocationSize(recordValue["max_queued_per_client"]) + FfiConverterUInt32.allocationSize(recordValue["redelivery_interval_secs"]) + uniffiOptionalConverter(FfiConverterBrokerTlsConfig).allocationSize(recordValue["tls"]) + FfiConverterUInt32.allocationSize(recordValue["max_packet_size"]) + FfiConverterUInt32.allocationSize(recordValue["max_outbound_queue"]) + FfiConverterUInt32.allocationSize(recordValue["session_expiry_secs"]);
514
+ }
515
+
516
+ write(value, writer) {
517
+ const recordValue = uniffiRequireRecordObject("MqttBrokerConfig", value);
518
+ FfiConverterString.write(recordValue["bind_address"], writer);
519
+ FfiConverterUInt16.write(recordValue["port"], writer);
520
+ uniffiOptionalConverter(FfiConverterUInt16).write(recordValue["ws_port"], writer);
521
+ FfiConverterBool.write(recordValue["allow_anonymous"], writer);
522
+ FfiConverterUInt32.write(recordValue["max_clients"], writer);
523
+ FfiConverterQoS.write(recordValue["max_qos"], writer);
524
+ FfiConverterUInt32.write(recordValue["max_retained_messages"], writer);
525
+ FfiConverterUInt32.write(recordValue["max_queued_per_client"], writer);
526
+ FfiConverterUInt32.write(recordValue["redelivery_interval_secs"], writer);
527
+ uniffiOptionalConverter(FfiConverterBrokerTlsConfig).write(recordValue["tls"], writer);
528
+ FfiConverterUInt32.write(recordValue["max_packet_size"], writer);
529
+ FfiConverterUInt32.write(recordValue["max_outbound_queue"], writer);
530
+ FfiConverterUInt32.write(recordValue["session_expiry_secs"], writer);
531
+ }
532
+
533
+ read(reader) {
534
+ return {
535
+ "bind_address": FfiConverterString.read(reader),
536
+ "port": FfiConverterUInt16.read(reader),
537
+ "ws_port": uniffiOptionalConverter(FfiConverterUInt16).read(reader),
538
+ "allow_anonymous": FfiConverterBool.read(reader),
539
+ "max_clients": FfiConverterUInt32.read(reader),
540
+ "max_qos": FfiConverterQoS.read(reader),
541
+ "max_retained_messages": FfiConverterUInt32.read(reader),
542
+ "max_queued_per_client": FfiConverterUInt32.read(reader),
543
+ "redelivery_interval_secs": FfiConverterUInt32.read(reader),
544
+ "tls": uniffiOptionalConverter(FfiConverterBrokerTlsConfig).read(reader),
545
+ "max_packet_size": FfiConverterUInt32.read(reader),
546
+ "max_outbound_queue": FfiConverterUInt32.read(reader),
547
+ "session_expiry_secs": FfiConverterUInt32.read(reader),
548
+ };
549
+ }
550
+ })();
551
+ const FfiConverterEnhancedAuthOutcome = new (class extends AbstractFfiConverterByteArray {
552
+ allocationSize(value) {
553
+ uniffiRequireFlatEnumValue(EnhancedAuthOutcome, "EnhancedAuthOutcome", value);
554
+ return 4;
555
+ }
556
+
557
+ write(value, writer) {
558
+ const enumValue = uniffiRequireFlatEnumValue(EnhancedAuthOutcome, "EnhancedAuthOutcome", value);
559
+ switch (enumValue) {
560
+ case EnhancedAuthOutcome["Continue"]:
561
+ writer.writeInt32(1);
562
+ return;
563
+ case EnhancedAuthOutcome["Success"]:
564
+ writer.writeInt32(2);
565
+ return;
566
+ case EnhancedAuthOutcome["Failure"]:
567
+ writer.writeInt32(3);
568
+ return;
569
+ default:
570
+ throw new UnexpectedEnumCase(`Unexpected EnhancedAuthOutcome case ${String(enumValue)}.`);
571
+ }
572
+ }
573
+
574
+ read(reader) {
575
+ const enumTag = reader.readInt32();
576
+ switch (enumTag) {
577
+ case 1:
578
+ return EnhancedAuthOutcome["Continue"];
579
+ case 2:
580
+ return EnhancedAuthOutcome["Success"];
581
+ case 3:
582
+ return EnhancedAuthOutcome["Failure"];
583
+ default:
584
+ throw new UnexpectedEnumCase(`Unexpected EnhancedAuthOutcome case ${String(enumTag)}.`);
585
+ }
586
+ }
587
+ })();
588
+ const FfiConverterQoS = new (class extends AbstractFfiConverterByteArray {
589
+ allocationSize(value) {
590
+ uniffiRequireFlatEnumValue(QoS, "QoS", value);
591
+ return 4;
592
+ }
593
+
594
+ write(value, writer) {
595
+ const enumValue = uniffiRequireFlatEnumValue(QoS, "QoS", value);
596
+ switch (enumValue) {
597
+ case QoS["AtMostOnce"]:
598
+ writer.writeInt32(1);
599
+ return;
600
+ case QoS["AtLeastOnce"]:
601
+ writer.writeInt32(2);
602
+ return;
603
+ case QoS["ExactlyOnce"]:
604
+ writer.writeInt32(3);
605
+ return;
606
+ default:
607
+ throw new UnexpectedEnumCase(`Unexpected QoS case ${String(enumValue)}.`);
608
+ }
609
+ }
610
+
611
+ read(reader) {
612
+ const enumTag = reader.readInt32();
613
+ switch (enumTag) {
614
+ case 1:
615
+ return QoS["AtMostOnce"];
616
+ case 2:
617
+ return QoS["AtLeastOnce"];
618
+ case 3:
619
+ return QoS["ExactlyOnce"];
620
+ default:
621
+ throw new UnexpectedEnumCase(`Unexpected QoS case ${String(enumTag)}.`);
622
+ }
623
+ }
624
+ })();
625
+ const FfiConverterBrokerEvent = new (class extends AbstractFfiConverterByteArray {
626
+ allocationSize(value) {
627
+ const enumValue = uniffiRequireTaggedEnumValue("BrokerEvent", value);
628
+ switch (enumValue.tag) {
629
+ case "ClientConnected":
630
+ return 4 + FfiConverterString.allocationSize(enumValue["client_id"]);
631
+ case "ClientDisconnected":
632
+ return 4 + FfiConverterString.allocationSize(enumValue["client_id"]) + FfiConverterString.allocationSize(enumValue["reason"]);
633
+ case "MessagePublished":
634
+ return 4 + FfiConverterString.allocationSize(enumValue["client_id"]) + FfiConverterString.allocationSize(enumValue["topic"]) + FfiConverterQoS.allocationSize(enumValue["qos"]);
635
+ default:
636
+ throw new UnexpectedEnumCase(`Unexpected BrokerEvent case ${String(enumValue.tag)}.`);
637
+ }
638
+ }
639
+
640
+ write(value, writer) {
641
+ const enumValue = uniffiRequireTaggedEnumValue("BrokerEvent", value);
642
+ switch (enumValue.tag) {
643
+ case "ClientConnected":
644
+ writer.writeInt32(1);
645
+ FfiConverterString.write(enumValue["client_id"], writer);
646
+ return;
647
+ case "ClientDisconnected":
648
+ writer.writeInt32(2);
649
+ FfiConverterString.write(enumValue["client_id"], writer);
650
+ FfiConverterString.write(enumValue["reason"], writer);
651
+ return;
652
+ case "MessagePublished":
653
+ writer.writeInt32(3);
654
+ FfiConverterString.write(enumValue["client_id"], writer);
655
+ FfiConverterString.write(enumValue["topic"], writer);
656
+ FfiConverterQoS.write(enumValue["qos"], writer);
657
+ return;
658
+ default:
659
+ throw new UnexpectedEnumCase(`Unexpected BrokerEvent case ${String(enumValue.tag)}.`);
660
+ }
661
+ }
662
+
663
+ read(reader) {
664
+ const enumTag = reader.readInt32();
665
+ switch (enumTag) {
666
+ case 1:
667
+ return BrokerEvent.ClientConnected(FfiConverterString.read(reader));
668
+ case 2:
669
+ return BrokerEvent.ClientDisconnected(FfiConverterString.read(reader), FfiConverterString.read(reader));
670
+ case 3:
671
+ return BrokerEvent.MessagePublished(FfiConverterString.read(reader), FfiConverterString.read(reader), FfiConverterQoS.read(reader));
672
+ default:
673
+ throw new UnexpectedEnumCase(`Unexpected BrokerEvent case ${String(enumTag)}.`);
674
+ }
675
+ }
676
+ })();
677
+ const FfiConverterMqttBrokerError = new (class extends AbstractFfiConverterByteArray {
678
+ allocationSize(value) {
679
+ if (value instanceof MqttBrokerErrorAlreadyRunning) {
680
+ return 4;
681
+ }
682
+ if (value instanceof MqttBrokerErrorIo) {
683
+ return 4;
684
+ }
685
+ if (value instanceof MqttBrokerErrorTls) {
686
+ return 4;
687
+ }
688
+ throw new TypeError("MqttBrokerError values must be instances of MqttBrokerErrorAlreadyRunning, MqttBrokerErrorIo, MqttBrokerErrorTls.");
689
+ }
690
+
691
+ write(value, writer) {
692
+ if (value instanceof MqttBrokerErrorAlreadyRunning) {
693
+ writer.writeInt32(1);
694
+ return;
695
+ }
696
+ if (value instanceof MqttBrokerErrorIo) {
697
+ writer.writeInt32(2);
698
+ return;
699
+ }
700
+ if (value instanceof MqttBrokerErrorTls) {
701
+ writer.writeInt32(3);
702
+ return;
703
+ }
704
+ throw new TypeError("MqttBrokerError values must be instances of MqttBrokerErrorAlreadyRunning, MqttBrokerErrorIo, MqttBrokerErrorTls.");
705
+ }
706
+
707
+ read(reader) {
708
+ const enumTag = reader.readInt32();
709
+ switch (enumTag) {
710
+ case 1:
711
+ return new MqttBrokerErrorAlreadyRunning(FfiConverterString.read(reader));
712
+ case 2:
713
+ return new MqttBrokerErrorIo(FfiConverterString.read(reader));
714
+ case 3:
715
+ return new MqttBrokerErrorTls(FfiConverterString.read(reader));
716
+ default:
717
+ throw new UnexpectedEnumCase(`Unexpected MqttBrokerError case ${String(enumTag)}.`);
718
+ }
719
+ }
720
+ })();
721
+ class UniffiMqttAuthProviderProxy extends UniffiObjectBase {
722
+
723
+ authenticate(client_id, username, password) {
724
+ const loweredSelf = uniffiMqttAuthProviderFactory.cloneHandle(this);
725
+ const ffiMethod =
726
+ uniffiMqttAuthProviderFactory.usesGenericAbi(this)
727
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttauthprovider_authenticate_generic_abi
728
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttauthprovider_authenticate;
729
+ const loweredClientId = uniffiLowerString(client_id);
730
+ const loweredUsername = uniffiLowerIntoRustBuffer(uniffiOptionalConverter(FfiConverterString), username);
731
+ const loweredPassword = uniffiLowerIntoRustBuffer(uniffiOptionalConverter(FfiConverterBytes), password);
732
+ const uniffiResult = uniffiRustCaller.rustCall(
733
+ (status) => ffiMethod(loweredSelf, loweredClientId, loweredUsername, loweredPassword, status),
734
+ uniffiRustCallOptions(),
735
+ );
736
+ return FfiConverterBool.lift(uniffiResult);
737
+ }
738
+ }
739
+
740
+ const uniffiMqttAuthProviderFactory = createObjectFactory({
741
+ typeName: "MqttAuthProvider",
742
+ createInstance: () => Object.create(UniffiMqttAuthProviderProxy.prototype),
743
+ cloneHandle(handle) {
744
+ return uniffiRustCaller.rustCall(
745
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_clone_mqttauthprovider(handle, status),
746
+ uniffiRustCallOptions(),
747
+ );
748
+ },
749
+ freeHandle(handle) {
750
+ uniffiRustCaller.rustCall(
751
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_free_mqttauthprovider(handle, status),
752
+ uniffiRustCallOptions(),
753
+ );
754
+ },
755
+ });
756
+
757
+ function uniffiValidateMqttAuthProviderImplementation(implementation) {
758
+ if ((typeof implementation !== "object" && typeof implementation !== "function") || implementation == null) {
759
+ throw new TypeError(`${"MqttAuthProvider"} implementations must be objects with callable methods.`);
760
+ }
761
+ if (typeof implementation.authenticate !== "function") {
762
+ throw new TypeError(`${"MqttAuthProvider"} is missing required method authenticate().`);
763
+ }
764
+ return implementation;
765
+ }
766
+
767
+ const uniffiMqttAuthProviderRegistry = createCallbackRegistry({
768
+ interfaceName: "MqttAuthProvider",
769
+ validate: uniffiValidateMqttAuthProviderImplementation,
770
+ });
771
+
772
+ function uniffiRegisterMqttAuthProviderVtable(bindings, registrations, vtableReferences) {
773
+ const authenticateCallback = koffi.register(
774
+ (uniffiHandle, client_id, username, password, uniffiOutReturn, callStatus) => {
775
+ const uniffiStatus = callStatus == null
776
+ ? createRustCallStatus()
777
+ : koffi.decode(callStatus, bindings.ffiTypes.RustCallStatus);
778
+ const uniffiResult = invokeCallbackMethod({
779
+ registry: uniffiMqttAuthProviderRegistry,
780
+ handle: uniffiHandle,
781
+ methodName: "authenticate",
782
+ args: [
783
+ uniffiLiftStringFromRustBuffer(client_id),
784
+ uniffiLiftFromRustBuffer(uniffiOptionalConverter(FfiConverterString), username),
785
+ uniffiLiftFromRustBuffer(uniffiOptionalConverter(FfiConverterBytes), password),
786
+ ],
787
+ lowerString: (value) => uniffiLowerString(value),
788
+ status: uniffiStatus,
789
+ });
790
+ if (callStatus != null) {
791
+ koffi.encode(callStatus, bindings.ffiTypes.RustCallStatus, uniffiStatus);
792
+ }
793
+ if (uniffiStatus.code !== CALL_SUCCESS) {
794
+ return;
795
+ }
796
+ const loweredReturn = FfiConverterBool.lower(uniffiResult);
797
+ koffi.encode(uniffiOutReturn, "int8_t", loweredReturn);
798
+ },
799
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceMqttAuthProviderMethod0),
800
+ );
801
+ registrations.push(authenticateCallback);
802
+ const uniffiFree = koffi.register(
803
+ (uniffiHandle) => uniffiMqttAuthProviderRegistry.remove(uniffiHandle),
804
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceFree),
805
+ );
806
+ registrations.push(uniffiFree);
807
+ const uniffiClone = koffi.register(
808
+ (uniffiHandle) => uniffiMqttAuthProviderRegistry.cloneHandle(uniffiHandle),
809
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceClone),
810
+ );
811
+ registrations.push(uniffiClone);
812
+ const uniffiVtable = koffi.alloc(bindings.ffiStructs.VTableCallbackInterfaceMqttAuthProvider, 1);
813
+ koffi.encode(uniffiVtable, bindings.ffiStructs.VTableCallbackInterfaceMqttAuthProvider, {
814
+ uniffi_free: uniffiFree,
815
+ uniffi_clone: uniffiClone,
816
+ "authenticate": authenticateCallback,
817
+
818
+ });
819
+ vtableReferences.push(uniffiVtable);
820
+ bindings.ffiFunctions.uniffi_mqtt_broker_fn_init_callback_vtable_mqttauthprovider(uniffiVtable);
821
+ }
822
+
823
+ const FfiConverterMqttAuthProvider = Object.freeze({
824
+ lower(value) {
825
+ if (uniffiMqttAuthProviderFactory.isInstance(value)) {
826
+ return uniffiMqttAuthProviderFactory.cloneHandle(value);
827
+ }
828
+ return uniffiMqttAuthProviderRegistry.register(value);
829
+ },
830
+ lift(handle) {
831
+ return uniffiMqttAuthProviderFactory.create(handle);
832
+ },
833
+ write(value, writer) {
834
+ writer.writeUInt64(this.lower(value));
835
+ },
836
+ read(reader) {
837
+ return this.lift(reader.readUInt64());
838
+ },
839
+ allocationSize() {
840
+ return UNIFFI_OBJECT_HANDLE_SIZE;
841
+ },
842
+ });
843
+ class UniffiMqttBrokerEventListenerProxy extends UniffiObjectBase {
844
+
845
+ on_client_connected(client_id) {
846
+ const loweredSelf = uniffiMqttBrokerEventListenerFactory.cloneHandle(this);
847
+ const ffiMethod =
848
+ uniffiMqttBrokerEventListenerFactory.usesGenericAbi(this)
849
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbrokereventlistener_on_client_connected_generic_abi
850
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbrokereventlistener_on_client_connected;
851
+ const loweredClientId = uniffiLowerString(client_id);
852
+ uniffiRustCaller.rustCall(
853
+ (status) => ffiMethod(loweredSelf, loweredClientId, status),
854
+ uniffiRustCallOptions(),
855
+ );
856
+ }
857
+
858
+ on_client_disconnected(client_id, reason) {
859
+ const loweredSelf = uniffiMqttBrokerEventListenerFactory.cloneHandle(this);
860
+ const ffiMethod =
861
+ uniffiMqttBrokerEventListenerFactory.usesGenericAbi(this)
862
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbrokereventlistener_on_client_disconnected_generic_abi
863
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbrokereventlistener_on_client_disconnected;
864
+ const loweredClientId = uniffiLowerString(client_id);
865
+ const loweredReason = uniffiLowerString(reason);
866
+ uniffiRustCaller.rustCall(
867
+ (status) => ffiMethod(loweredSelf, loweredClientId, loweredReason, status),
868
+ uniffiRustCallOptions(),
869
+ );
870
+ }
871
+
872
+ on_message_published(client_id, topic, qos) {
873
+ const loweredSelf = uniffiMqttBrokerEventListenerFactory.cloneHandle(this);
874
+ const ffiMethod =
875
+ uniffiMqttBrokerEventListenerFactory.usesGenericAbi(this)
876
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbrokereventlistener_on_message_published_generic_abi
877
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbrokereventlistener_on_message_published;
878
+ const loweredClientId = uniffiLowerString(client_id);
879
+ const loweredTopic = uniffiLowerString(topic);
880
+ const loweredQos = uniffiLowerIntoRustBuffer(FfiConverterQoS, qos);
881
+ uniffiRustCaller.rustCall(
882
+ (status) => ffiMethod(loweredSelf, loweredClientId, loweredTopic, loweredQos, status),
883
+ uniffiRustCallOptions(),
884
+ );
885
+ }
886
+ }
887
+
888
+ const uniffiMqttBrokerEventListenerFactory = createObjectFactory({
889
+ typeName: "MqttBrokerEventListener",
890
+ createInstance: () => Object.create(UniffiMqttBrokerEventListenerProxy.prototype),
891
+ cloneHandle(handle) {
892
+ return uniffiRustCaller.rustCall(
893
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_clone_mqttbrokereventlistener(handle, status),
894
+ uniffiRustCallOptions(),
895
+ );
896
+ },
897
+ freeHandle(handle) {
898
+ uniffiRustCaller.rustCall(
899
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_free_mqttbrokereventlistener(handle, status),
900
+ uniffiRustCallOptions(),
901
+ );
902
+ },
903
+ });
904
+
905
+ function uniffiValidateMqttBrokerEventListenerImplementation(implementation) {
906
+ if ((typeof implementation !== "object" && typeof implementation !== "function") || implementation == null) {
907
+ throw new TypeError(`${"MqttBrokerEventListener"} implementations must be objects with callable methods.`);
908
+ }
909
+ if (typeof implementation.on_client_connected !== "function") {
910
+ throw new TypeError(`${"MqttBrokerEventListener"} is missing required method on_client_connected().`);
911
+ }
912
+ if (typeof implementation.on_client_disconnected !== "function") {
913
+ throw new TypeError(`${"MqttBrokerEventListener"} is missing required method on_client_disconnected().`);
914
+ }
915
+ if (typeof implementation.on_message_published !== "function") {
916
+ throw new TypeError(`${"MqttBrokerEventListener"} is missing required method on_message_published().`);
917
+ }
918
+ return implementation;
919
+ }
920
+
921
+ const uniffiMqttBrokerEventListenerRegistry = createCallbackRegistry({
922
+ interfaceName: "MqttBrokerEventListener",
923
+ validate: uniffiValidateMqttBrokerEventListenerImplementation,
924
+ });
925
+
926
+ function uniffiRegisterMqttBrokerEventListenerVtable(bindings, registrations, vtableReferences) {
927
+ const on_client_connectedCallback = koffi.register(
928
+ (uniffiHandle, client_id, uniffiOutReturn, callStatus) => {
929
+ const uniffiStatus = callStatus == null
930
+ ? createRustCallStatus()
931
+ : koffi.decode(callStatus, bindings.ffiTypes.RustCallStatus);
932
+ const uniffiResult = invokeCallbackMethod({
933
+ registry: uniffiMqttBrokerEventListenerRegistry,
934
+ handle: uniffiHandle,
935
+ methodName: "on_client_connected",
936
+ args: [
937
+ uniffiLiftStringFromRustBuffer(client_id),
938
+ ],
939
+ lowerString: (value) => uniffiLowerString(value),
940
+ status: uniffiStatus,
941
+ });
942
+ if (callStatus != null) {
943
+ koffi.encode(callStatus, bindings.ffiTypes.RustCallStatus, uniffiStatus);
944
+ }
945
+ if (uniffiStatus.code !== CALL_SUCCESS) {
946
+ return;
947
+ }
948
+ },
949
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceMqttBrokerEventListenerMethod0),
950
+ );
951
+ registrations.push(on_client_connectedCallback);
952
+ const on_client_disconnectedCallback = koffi.register(
953
+ (uniffiHandle, client_id, reason, uniffiOutReturn, callStatus) => {
954
+ const uniffiStatus = callStatus == null
955
+ ? createRustCallStatus()
956
+ : koffi.decode(callStatus, bindings.ffiTypes.RustCallStatus);
957
+ const uniffiResult = invokeCallbackMethod({
958
+ registry: uniffiMqttBrokerEventListenerRegistry,
959
+ handle: uniffiHandle,
960
+ methodName: "on_client_disconnected",
961
+ args: [
962
+ uniffiLiftStringFromRustBuffer(client_id),
963
+ uniffiLiftStringFromRustBuffer(reason),
964
+ ],
965
+ lowerString: (value) => uniffiLowerString(value),
966
+ status: uniffiStatus,
967
+ });
968
+ if (callStatus != null) {
969
+ koffi.encode(callStatus, bindings.ffiTypes.RustCallStatus, uniffiStatus);
970
+ }
971
+ if (uniffiStatus.code !== CALL_SUCCESS) {
972
+ return;
973
+ }
974
+ },
975
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceMqttBrokerEventListenerMethod1),
976
+ );
977
+ registrations.push(on_client_disconnectedCallback);
978
+ const on_message_publishedCallback = koffi.register(
979
+ (uniffiHandle, client_id, topic, qos, uniffiOutReturn, callStatus) => {
980
+ const uniffiStatus = callStatus == null
981
+ ? createRustCallStatus()
982
+ : koffi.decode(callStatus, bindings.ffiTypes.RustCallStatus);
983
+ const uniffiResult = invokeCallbackMethod({
984
+ registry: uniffiMqttBrokerEventListenerRegistry,
985
+ handle: uniffiHandle,
986
+ methodName: "on_message_published",
987
+ args: [
988
+ uniffiLiftStringFromRustBuffer(client_id),
989
+ uniffiLiftStringFromRustBuffer(topic),
990
+ uniffiLiftFromRustBuffer(FfiConverterQoS, qos),
991
+ ],
992
+ lowerString: (value) => uniffiLowerString(value),
993
+ status: uniffiStatus,
994
+ });
995
+ if (callStatus != null) {
996
+ koffi.encode(callStatus, bindings.ffiTypes.RustCallStatus, uniffiStatus);
997
+ }
998
+ if (uniffiStatus.code !== CALL_SUCCESS) {
999
+ return;
1000
+ }
1001
+ },
1002
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceMqttBrokerEventListenerMethod2),
1003
+ );
1004
+ registrations.push(on_message_publishedCallback);
1005
+ const uniffiFree = koffi.register(
1006
+ (uniffiHandle) => uniffiMqttBrokerEventListenerRegistry.remove(uniffiHandle),
1007
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceFree),
1008
+ );
1009
+ registrations.push(uniffiFree);
1010
+ const uniffiClone = koffi.register(
1011
+ (uniffiHandle) => uniffiMqttBrokerEventListenerRegistry.cloneHandle(uniffiHandle),
1012
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceClone),
1013
+ );
1014
+ registrations.push(uniffiClone);
1015
+ const uniffiVtable = koffi.alloc(bindings.ffiStructs.VTableCallbackInterfaceMqttBrokerEventListener, 1);
1016
+ koffi.encode(uniffiVtable, bindings.ffiStructs.VTableCallbackInterfaceMqttBrokerEventListener, {
1017
+ uniffi_free: uniffiFree,
1018
+ uniffi_clone: uniffiClone,
1019
+ "on_client_connected": on_client_connectedCallback,
1020
+ "on_client_disconnected": on_client_disconnectedCallback,
1021
+ "on_message_published": on_message_publishedCallback,
1022
+
1023
+ });
1024
+ vtableReferences.push(uniffiVtable);
1025
+ bindings.ffiFunctions.uniffi_mqtt_broker_fn_init_callback_vtable_mqttbrokereventlistener(uniffiVtable);
1026
+ }
1027
+
1028
+ const FfiConverterMqttBrokerEventListener = Object.freeze({
1029
+ lower(value) {
1030
+ if (uniffiMqttBrokerEventListenerFactory.isInstance(value)) {
1031
+ return uniffiMqttBrokerEventListenerFactory.cloneHandle(value);
1032
+ }
1033
+ return uniffiMqttBrokerEventListenerRegistry.register(value);
1034
+ },
1035
+ lift(handle) {
1036
+ return uniffiMqttBrokerEventListenerFactory.create(handle);
1037
+ },
1038
+ write(value, writer) {
1039
+ writer.writeUInt64(this.lower(value));
1040
+ },
1041
+ read(reader) {
1042
+ return this.lift(reader.readUInt64());
1043
+ },
1044
+ allocationSize() {
1045
+ return UNIFFI_OBJECT_HANDLE_SIZE;
1046
+ },
1047
+ });
1048
+ class UniffiMqttEnhancedAuthProviderProxy extends UniffiObjectBase {
1049
+
1050
+ step(client_id, method, data, round) {
1051
+ const loweredSelf = uniffiMqttEnhancedAuthProviderFactory.cloneHandle(this);
1052
+ const ffiMethod =
1053
+ uniffiMqttEnhancedAuthProviderFactory.usesGenericAbi(this)
1054
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttenhancedauthprovider_step_generic_abi
1055
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttenhancedauthprovider_step;
1056
+ const loweredClientId = uniffiLowerString(client_id);
1057
+ const loweredMethod = uniffiLowerString(method);
1058
+ const loweredData = uniffiLowerIntoRustBuffer(uniffiOptionalConverter(FfiConverterBytes), data);
1059
+ const loweredRound = FfiConverterUInt32.lower(round);
1060
+ const uniffiResult = uniffiRustCaller.rustCall(
1061
+ (status) => ffiMethod(loweredSelf, loweredClientId, loweredMethod, loweredData, loweredRound, status),
1062
+ uniffiRustCallOptions(),
1063
+ );
1064
+ return uniffiLiftFromRustBuffer(FfiConverterEnhancedAuthStep, uniffiResult);
1065
+ }
1066
+ }
1067
+
1068
+ const uniffiMqttEnhancedAuthProviderFactory = createObjectFactory({
1069
+ typeName: "MqttEnhancedAuthProvider",
1070
+ createInstance: () => Object.create(UniffiMqttEnhancedAuthProviderProxy.prototype),
1071
+ cloneHandle(handle) {
1072
+ return uniffiRustCaller.rustCall(
1073
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_clone_mqttenhancedauthprovider(handle, status),
1074
+ uniffiRustCallOptions(),
1075
+ );
1076
+ },
1077
+ freeHandle(handle) {
1078
+ uniffiRustCaller.rustCall(
1079
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_free_mqttenhancedauthprovider(handle, status),
1080
+ uniffiRustCallOptions(),
1081
+ );
1082
+ },
1083
+ });
1084
+
1085
+ function uniffiValidateMqttEnhancedAuthProviderImplementation(implementation) {
1086
+ if ((typeof implementation !== "object" && typeof implementation !== "function") || implementation == null) {
1087
+ throw new TypeError(`${"MqttEnhancedAuthProvider"} implementations must be objects with callable methods.`);
1088
+ }
1089
+ if (typeof implementation.step !== "function") {
1090
+ throw new TypeError(`${"MqttEnhancedAuthProvider"} is missing required method step().`);
1091
+ }
1092
+ return implementation;
1093
+ }
1094
+
1095
+ const uniffiMqttEnhancedAuthProviderRegistry = createCallbackRegistry({
1096
+ interfaceName: "MqttEnhancedAuthProvider",
1097
+ validate: uniffiValidateMqttEnhancedAuthProviderImplementation,
1098
+ });
1099
+
1100
+ function uniffiRegisterMqttEnhancedAuthProviderVtable(bindings, registrations, vtableReferences) {
1101
+ const stepCallback = koffi.register(
1102
+ (uniffiHandle, client_id, method, data, round, uniffiOutReturn, callStatus) => {
1103
+ const uniffiStatus = callStatus == null
1104
+ ? createRustCallStatus()
1105
+ : koffi.decode(callStatus, bindings.ffiTypes.RustCallStatus);
1106
+ const uniffiResult = invokeCallbackMethod({
1107
+ registry: uniffiMqttEnhancedAuthProviderRegistry,
1108
+ handle: uniffiHandle,
1109
+ methodName: "step",
1110
+ args: [
1111
+ uniffiLiftStringFromRustBuffer(client_id),
1112
+ uniffiLiftStringFromRustBuffer(method),
1113
+ uniffiLiftFromRustBuffer(uniffiOptionalConverter(FfiConverterBytes), data),
1114
+ FfiConverterUInt32.lift(round),
1115
+ ],
1116
+ lowerString: (value) => uniffiLowerString(value),
1117
+ status: uniffiStatus,
1118
+ });
1119
+ if (callStatus != null) {
1120
+ koffi.encode(callStatus, bindings.ffiTypes.RustCallStatus, uniffiStatus);
1121
+ }
1122
+ if (uniffiStatus.code !== CALL_SUCCESS) {
1123
+ return;
1124
+ }
1125
+ const loweredReturn = uniffiLowerIntoRustBuffer(FfiConverterEnhancedAuthStep, uniffiResult);
1126
+ koffi.encode(uniffiOutReturn, bindings.ffiTypes.RustBuffer, loweredReturn);
1127
+ },
1128
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceMqttEnhancedAuthProviderMethod0),
1129
+ );
1130
+ registrations.push(stepCallback);
1131
+ const uniffiFree = koffi.register(
1132
+ (uniffiHandle) => uniffiMqttEnhancedAuthProviderRegistry.remove(uniffiHandle),
1133
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceFree),
1134
+ );
1135
+ registrations.push(uniffiFree);
1136
+ const uniffiClone = koffi.register(
1137
+ (uniffiHandle) => uniffiMqttEnhancedAuthProviderRegistry.cloneHandle(uniffiHandle),
1138
+ koffi.pointer(bindings.ffiCallbacks.CallbackInterfaceClone),
1139
+ );
1140
+ registrations.push(uniffiClone);
1141
+ const uniffiVtable = koffi.alloc(bindings.ffiStructs.VTableCallbackInterfaceMqttEnhancedAuthProvider, 1);
1142
+ koffi.encode(uniffiVtable, bindings.ffiStructs.VTableCallbackInterfaceMqttEnhancedAuthProvider, {
1143
+ uniffi_free: uniffiFree,
1144
+ uniffi_clone: uniffiClone,
1145
+ "step": stepCallback,
1146
+
1147
+ });
1148
+ vtableReferences.push(uniffiVtable);
1149
+ bindings.ffiFunctions.uniffi_mqtt_broker_fn_init_callback_vtable_mqttenhancedauthprovider(uniffiVtable);
1150
+ }
1151
+
1152
+ const FfiConverterMqttEnhancedAuthProvider = Object.freeze({
1153
+ lower(value) {
1154
+ if (uniffiMqttEnhancedAuthProviderFactory.isInstance(value)) {
1155
+ return uniffiMqttEnhancedAuthProviderFactory.cloneHandle(value);
1156
+ }
1157
+ return uniffiMqttEnhancedAuthProviderRegistry.register(value);
1158
+ },
1159
+ lift(handle) {
1160
+ return uniffiMqttEnhancedAuthProviderFactory.create(handle);
1161
+ },
1162
+ write(value, writer) {
1163
+ writer.writeUInt64(this.lower(value));
1164
+ },
1165
+ read(reader) {
1166
+ return this.lift(reader.readUInt64());
1167
+ },
1168
+ allocationSize() {
1169
+ return UNIFFI_OBJECT_HANDLE_SIZE;
1170
+ },
1171
+ });
1172
+
1173
+ const uniffiRegisteredCallbackPointers = [];
1174
+ const uniffiRegisteredCallbackVtables = [];
1175
+
1176
+ function uniffiRegisterCallbackVtables(bindings) {
1177
+ uniffiRegisterMqttAuthProviderVtable(bindings, uniffiRegisteredCallbackPointers, uniffiRegisteredCallbackVtables);
1178
+ uniffiRegisterMqttBrokerEventListenerVtable(bindings, uniffiRegisteredCallbackPointers, uniffiRegisteredCallbackVtables);
1179
+ uniffiRegisterMqttEnhancedAuthProviderVtable(bindings, uniffiRegisteredCallbackPointers, uniffiRegisteredCallbackVtables);
1180
+ }
1181
+
1182
+ function uniffiUnregisterCallbackVtables() {
1183
+ clearPendingForeignFutures();
1184
+ uniffiMqttAuthProviderRegistry.clear();
1185
+ uniffiMqttBrokerEventListenerRegistry.clear();
1186
+ uniffiMqttEnhancedAuthProviderRegistry.clear();
1187
+ while (uniffiRegisteredCallbackPointers.length > 0) {
1188
+ koffi.unregister(uniffiRegisteredCallbackPointers.pop());
1189
+ }
1190
+ uniffiRegisteredCallbackVtables.length = 0;
1191
+ }
1192
+
1193
+ configureRuntimeHooks({
1194
+ onLoad(bindings) {
1195
+ uniffiRegisterCallbackVtables(bindings);
1196
+ },
1197
+ onUnload() {
1198
+ if (uniffiRustFutureContinuationPointer != null) {
1199
+ koffi.unregister(uniffiRustFutureContinuationPointer);
1200
+ uniffiRustFutureContinuationPointer = null;
1201
+ }
1202
+ uniffiUnregisterCallbackVtables();
1203
+ },
1204
+ });
1205
+
1206
+ /**
1207
+ * A running (or not-yet-started) MQTT broker instance, speaking both MQTT
1208
+ * 3.1.1 and MQTT 5.0 — the protocol version is negotiated independently
1209
+ * per connection from each client's CONNECT packet.
1210
+ *
1211
+ * Dropping a broker stops it (listeners are closed and live connections
1212
+ * told to shut down); there is no way to reach a broker that has no
1213
+ * remaining handle, so leaving it running would just leak its ports.
1214
+ */
1215
+ export class MqttBroker extends UniffiObjectBase {
1216
+ constructor(config) {
1217
+ super();
1218
+ const loweredConfig = uniffiLowerIntoRustBuffer(FfiConverterMqttBrokerConfig, config);
1219
+ const pointer = uniffiRustCaller.rustCall(
1220
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_constructor_mqttbroker_new(loweredConfig, status),
1221
+ uniffiRustCallOptions(),
1222
+ );
1223
+ return uniffiMqttBrokerObjectFactory.attach(this, pointer);
1224
+ }
1225
+
1226
+ /**
1227
+ * The TCP port actually bound (useful when `config.port == 0` was used
1228
+ * to request an ephemeral port, e.g. in tests).
1229
+ */
1230
+ bound_port() {
1231
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1232
+ const ffiMethod =
1233
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1234
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_bound_port_generic_abi
1235
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_bound_port;
1236
+ const uniffiResult = uniffiRustCaller.rustCall(
1237
+ (status) => ffiMethod(loweredSelf, status),
1238
+ uniffiRustCallOptions(),
1239
+ );
1240
+ return uniffiLiftFromRustBuffer(uniffiOptionalConverter(FfiConverterUInt16), uniffiResult);
1241
+ }
1242
+
1243
+ /**
1244
+ * The TLS port actually bound, if `config.tls` is set.
1245
+ */
1246
+ bound_tls_port() {
1247
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1248
+ const ffiMethod =
1249
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1250
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_bound_tls_port_generic_abi
1251
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_bound_tls_port;
1252
+ const uniffiResult = uniffiRustCaller.rustCall(
1253
+ (status) => ffiMethod(loweredSelf, status),
1254
+ uniffiRustCallOptions(),
1255
+ );
1256
+ return uniffiLiftFromRustBuffer(uniffiOptionalConverter(FfiConverterUInt16), uniffiResult);
1257
+ }
1258
+
1259
+ /**
1260
+ * The WebSocket port actually bound, if `config.ws_port` is set.
1261
+ */
1262
+ bound_ws_port() {
1263
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1264
+ const ffiMethod =
1265
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1266
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_bound_ws_port_generic_abi
1267
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_bound_ws_port;
1268
+ const uniffiResult = uniffiRustCaller.rustCall(
1269
+ (status) => ffiMethod(loweredSelf, status),
1270
+ uniffiRustCallOptions(),
1271
+ );
1272
+ return uniffiLiftFromRustBuffer(uniffiOptionalConverter(FfiConverterUInt16), uniffiResult);
1273
+ }
1274
+
1275
+ /**
1276
+ * Number of currently connected clients.
1277
+ */
1278
+ client_count() {
1279
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1280
+ const ffiMethod =
1281
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1282
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_client_count_generic_abi
1283
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_client_count;
1284
+ const uniffiResult = uniffiRustCaller.rustCall(
1285
+ (status) => ffiMethod(loweredSelf, status),
1286
+ uniffiRustCallOptions(),
1287
+ );
1288
+ return FfiConverterUInt32.lift(uniffiResult);
1289
+ }
1290
+
1291
+ /**
1292
+ * Pull-style alternative to [`set_event_listener`](Self::set_event_listener)
1293
+ * for runtimes that can't receive callbacks from Rust threads (Dart,
1294
+ * Haskell): keep up to `capacity` events for [`next_event`](Self::next_event).
1295
+ * `0` turns the queue off; when it fills up the oldest event is dropped.
1296
+ */
1297
+ enable_event_queue(capacity) {
1298
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1299
+ const ffiMethod =
1300
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1301
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_enable_event_queue_generic_abi
1302
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_enable_event_queue;
1303
+ const loweredCapacity = FfiConverterUInt32.lower(capacity);
1304
+ uniffiRustCaller.rustCall(
1305
+ (status) => ffiMethod(loweredSelf, loweredCapacity, status),
1306
+ uniffiRustCallOptions(),
1307
+ );
1308
+ }
1309
+
1310
+ is_running() {
1311
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1312
+ const ffiMethod =
1313
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1314
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_is_running_generic_abi
1315
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_is_running;
1316
+ const uniffiResult = uniffiRustCaller.rustCall(
1317
+ (status) => ffiMethod(loweredSelf, status),
1318
+ uniffiRustCallOptions(),
1319
+ );
1320
+ return FfiConverterBool.lift(uniffiResult);
1321
+ }
1322
+
1323
+ /**
1324
+ * The next queued [`BrokerEvent`], waiting up to `timeout_ms`
1325
+ * milliseconds; `None` if none arrived. Requires
1326
+ * [`enable_event_queue`](Self::enable_event_queue).
1327
+ */
1328
+ async next_event(timeout_ms) {
1329
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1330
+ const ffiMethod =
1331
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1332
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_next_event_generic_abi
1333
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_next_event;
1334
+ const loweredTimeoutMs = FfiConverterUInt32.lower(timeout_ms);
1335
+ const completeFunc = (rustFuture, status) => ffiFunctions.ffi_mqtt_broker_rust_future_complete_rust_buffer(rustFuture, status);
1336
+ return rustCallAsync({
1337
+ rustFutureFunc: () => ffiMethod(loweredSelf, loweredTimeoutMs),
1338
+ pollFunc: (rustFuture, _continuationCallback, continuationHandle) => ffiFunctions.ffi_mqtt_broker_rust_future_poll_rust_buffer(rustFuture, uniffiGetRustFutureContinuationPointer(), continuationHandle),
1339
+ cancelFunc: (rustFuture) => ffiFunctions.ffi_mqtt_broker_rust_future_cancel_rust_buffer(rustFuture),
1340
+ completeFunc,
1341
+ freeFunc: (rustFuture) => ffiFunctions.ffi_mqtt_broker_rust_future_free_rust_buffer(rustFuture),
1342
+ liftFunc: (uniffiResult) => uniffiLiftFromRustBuffer(uniffiOptionalConverter(FfiConverterBrokerEvent), uniffiResult),
1343
+ ...uniffiRustCallOptions(),
1344
+ });
1345
+ }
1346
+
1347
+ /**
1348
+ * Register a pluggable authentication provider. Must be called before
1349
+ * [`start`](Self::start) to affect connections made right away, but
1350
+ * may be replaced at any time.
1351
+ */
1352
+ set_auth_provider(provider) {
1353
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1354
+ const ffiMethod =
1355
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1356
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_set_auth_provider_generic_abi
1357
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_set_auth_provider;
1358
+ const loweredProvider = FfiConverterMqttAuthProvider.lower(provider);
1359
+ uniffiRustCaller.rustCall(
1360
+ (status) => ffiMethod(loweredSelf, loweredProvider, status),
1361
+ uniffiRustCallOptions(),
1362
+ );
1363
+ }
1364
+
1365
+ /**
1366
+ * Register the MQTT 5.0 enhanced-authentication provider (multi-round
1367
+ * challenge/response during CONNECT). Without one, a CONNECT that names
1368
+ * an `Authentication Method` is refused with "Bad authentication method".
1369
+ */
1370
+ set_enhanced_auth_provider(provider) {
1371
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1372
+ const ffiMethod =
1373
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1374
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_set_enhanced_auth_provider_generic_abi
1375
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_set_enhanced_auth_provider;
1376
+ const loweredProvider = FfiConverterMqttEnhancedAuthProvider.lower(provider);
1377
+ uniffiRustCaller.rustCall(
1378
+ (status) => ffiMethod(loweredSelf, loweredProvider, status),
1379
+ uniffiRustCallOptions(),
1380
+ );
1381
+ }
1382
+
1383
+ /**
1384
+ * Register a listener for connect/disconnect/publish events.
1385
+ */
1386
+ set_event_listener(listener) {
1387
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1388
+ const ffiMethod =
1389
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1390
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_set_event_listener_generic_abi
1391
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_set_event_listener;
1392
+ const loweredListener = FfiConverterMqttBrokerEventListener.lower(listener);
1393
+ uniffiRustCaller.rustCall(
1394
+ (status) => ffiMethod(loweredSelf, loweredListener, status),
1395
+ uniffiRustCallOptions(),
1396
+ );
1397
+ }
1398
+
1399
+ /**
1400
+ * Bind the listening socket(s) and start accepting connections. Also
1401
+ * binds a second, MQTT-over-WebSocket listener on `config.ws_port` and
1402
+ * a TLS listener on `config.tls` when those are configured.
1403
+ *
1404
+ * All-or-nothing: every socket is bound (and the TLS configuration
1405
+ * validated) *before* anything starts accepting, so a failure — say
1406
+ * the WebSocket port is taken — leaves the broker cleanly stopped
1407
+ * instead of half-running with some listeners already live.
1408
+ */
1409
+ async start() {
1410
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1411
+ const ffiMethod =
1412
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1413
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_start_generic_abi
1414
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_start;
1415
+ const completeFunc = (rustFuture, status) => ffiFunctions.ffi_mqtt_broker_rust_future_complete_void(rustFuture, status);
1416
+ return rustCallAsync({
1417
+ rustFutureFunc: () => ffiMethod(loweredSelf),
1418
+ pollFunc: (rustFuture, _continuationCallback, continuationHandle) => ffiFunctions.ffi_mqtt_broker_rust_future_poll_void(rustFuture, uniffiGetRustFutureContinuationPointer(), continuationHandle),
1419
+ cancelFunc: (rustFuture) => ffiFunctions.ffi_mqtt_broker_rust_future_cancel_void(rustFuture),
1420
+ completeFunc,
1421
+ freeFunc: (rustFuture) => ffiFunctions.ffi_mqtt_broker_rust_future_free_void(rustFuture),
1422
+ liftFunc: (_uniffiResult) => undefined,
1423
+ ...uniffiRustCallOptions(FfiConverterMqttBrokerError),
1424
+ });
1425
+ }
1426
+
1427
+ /**
1428
+ * Stop the broker: close the listening sockets and ask every
1429
+ * connected client's connection to shut down. Sessions that persist
1430
+ * across disconnects (`clean_start = false`) are kept in memory, so a
1431
+ * later [`start`](Self::start) resumes them. Calling `stop()` on a
1432
+ * broker that isn't running is a no-op.
1433
+ */
1434
+ async stop() {
1435
+ const loweredSelf = uniffiMqttBrokerObjectFactory.cloneHandle(this);
1436
+ const ffiMethod =
1437
+ uniffiMqttBrokerObjectFactory.usesGenericAbi(this)
1438
+ ? ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_stop_generic_abi
1439
+ : ffiFunctions.uniffi_mqtt_broker_fn_method_mqttbroker_stop;
1440
+ const completeFunc = (rustFuture, status) => ffiFunctions.ffi_mqtt_broker_rust_future_complete_void(rustFuture, status);
1441
+ return rustCallAsync({
1442
+ rustFutureFunc: () => ffiMethod(loweredSelf),
1443
+ pollFunc: (rustFuture, _continuationCallback, continuationHandle) => ffiFunctions.ffi_mqtt_broker_rust_future_poll_void(rustFuture, uniffiGetRustFutureContinuationPointer(), continuationHandle),
1444
+ cancelFunc: (rustFuture) => ffiFunctions.ffi_mqtt_broker_rust_future_cancel_void(rustFuture),
1445
+ completeFunc,
1446
+ freeFunc: (rustFuture) => ffiFunctions.ffi_mqtt_broker_rust_future_free_void(rustFuture),
1447
+ liftFunc: (_uniffiResult) => undefined,
1448
+ ...uniffiRustCallOptions(FfiConverterMqttBrokerError),
1449
+ });
1450
+ }
1451
+ }
1452
+
1453
+ const uniffiMqttBrokerObjectFactory = createObjectFactory({
1454
+ typeName: "MqttBroker",
1455
+ createInstance: () => Object.create(MqttBroker.prototype),
1456
+ cloneFreeUsesUniffiHandle: true,
1457
+ cloneHandleGeneric(handle) {
1458
+ return uniffiRustCaller.rustCall(
1459
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_clone_mqttbroker_generic_abi(handle, status),
1460
+ uniffiRustCallOptions(),
1461
+ );
1462
+ },
1463
+ cloneHandleRawExternal(handle) {
1464
+ const rawExternalCloneHandle = uniffiGetCachedLibraryFunction(
1465
+ "uniffi_mqtt_broker_fn_clone_mqttbroker:raw-external",
1466
+ (bindings) => bindings.library.func(
1467
+ "uniffi_mqtt_broker_fn_clone_mqttbroker",
1468
+ bindings.ffiTypes.VoidPointer,
1469
+ [bindings.ffiTypes.VoidPointer, koffi.pointer(bindings.ffiTypes.RustCallStatus)],
1470
+ ),
1471
+ );
1472
+ return uniffiRustCaller.rustCall(
1473
+ (status) => rawExternalCloneHandle(handle, status),
1474
+ uniffiRustCallOptions(),
1475
+ );
1476
+ },
1477
+ cloneHandle(handle) {
1478
+ return uniffiRustCaller.rustCall(
1479
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_clone_mqttbroker(handle, status),
1480
+ uniffiRustCallOptions(),
1481
+ );
1482
+ },
1483
+ freeHandleGeneric(handle) {
1484
+ uniffiRustCaller.rustCall(
1485
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_free_mqttbroker_generic_abi(handle, status),
1486
+ uniffiRustCallOptions(),
1487
+ );
1488
+ },
1489
+ freeHandleRawExternal(handle) {
1490
+ const rawExternalFreeHandle = uniffiGetCachedLibraryFunction(
1491
+ "uniffi_mqtt_broker_fn_free_mqttbroker:raw-external",
1492
+ (bindings) => bindings.library.func(
1493
+ "uniffi_mqtt_broker_fn_free_mqttbroker",
1494
+ "void",
1495
+ [bindings.ffiTypes.VoidPointer, koffi.pointer(bindings.ffiTypes.RustCallStatus)],
1496
+ ),
1497
+ );
1498
+ uniffiRustCaller.rustCall(
1499
+ (status) => rawExternalFreeHandle(handle, status),
1500
+ uniffiRustCallOptions(),
1501
+ );
1502
+ },
1503
+ freeHandle(handle) {
1504
+ uniffiRustCaller.rustCall(
1505
+ (status) => ffiFunctions.uniffi_mqtt_broker_fn_free_mqttbroker(handle, status),
1506
+ uniffiRustCallOptions(),
1507
+ );
1508
+ },
1509
+ });
1510
+ const FfiConverterMqttBroker = createObjectConverter(uniffiMqttBrokerObjectFactory);