react-native-nitro-ark 0.0.26 → 0.0.28

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.
@@ -1,932 +0,0 @@
1
- #pragma once
2
- #include <algorithm>
3
- #include <array>
4
- #include <cassert>
5
- #include <cstddef>
6
- #include <cstdint>
7
- #include <initializer_list>
8
- #include <iterator>
9
- #include <new>
10
- #include <stdexcept>
11
- #include <string>
12
- #include <type_traits>
13
- #include <utility>
14
- #if __cplusplus >= 201703L
15
- #include <string_view>
16
- #endif
17
- #if __cplusplus >= 202002L
18
- #include <ranges>
19
- #endif
20
-
21
- namespace rust {
22
- inline namespace cxxbridge1 {
23
- // #include "rust/cxx.h"
24
-
25
- #ifndef CXXBRIDGE1_PANIC
26
- #define CXXBRIDGE1_PANIC
27
- template <typename Exception>
28
- void panic [[noreturn]] (const char *msg);
29
- #endif // CXXBRIDGE1_PANIC
30
-
31
- struct unsafe_bitcopy_t;
32
-
33
- namespace {
34
- template <typename T>
35
- class impl;
36
- } // namespace
37
-
38
- class Opaque;
39
-
40
- template <typename T>
41
- ::std::size_t size_of();
42
- template <typename T>
43
- ::std::size_t align_of();
44
-
45
- #ifndef CXXBRIDGE1_RUST_STRING
46
- #define CXXBRIDGE1_RUST_STRING
47
- class String final {
48
- public:
49
- String() noexcept;
50
- String(const String &) noexcept;
51
- String(String &&) noexcept;
52
- ~String() noexcept;
53
-
54
- String(const std::string &);
55
- String(const char *);
56
- String(const char *, std::size_t);
57
- String(const char16_t *);
58
- String(const char16_t *, std::size_t);
59
- #ifdef __cpp_char8_t
60
- String(const char8_t *s);
61
- String(const char8_t *s, std::size_t len);
62
- #endif
63
-
64
- static String lossy(const std::string &) noexcept;
65
- static String lossy(const char *) noexcept;
66
- static String lossy(const char *, std::size_t) noexcept;
67
- static String lossy(const char16_t *) noexcept;
68
- static String lossy(const char16_t *, std::size_t) noexcept;
69
-
70
- String &operator=(const String &) & noexcept;
71
- String &operator=(String &&) & noexcept;
72
-
73
- explicit operator std::string() const;
74
-
75
- const char *data() const noexcept;
76
- std::size_t size() const noexcept;
77
- std::size_t length() const noexcept;
78
- bool empty() const noexcept;
79
-
80
- const char *c_str() noexcept;
81
-
82
- std::size_t capacity() const noexcept;
83
- void reserve(size_t new_cap) noexcept;
84
-
85
- using iterator = char *;
86
- iterator begin() noexcept;
87
- iterator end() noexcept;
88
-
89
- using const_iterator = const char *;
90
- const_iterator begin() const noexcept;
91
- const_iterator end() const noexcept;
92
- const_iterator cbegin() const noexcept;
93
- const_iterator cend() const noexcept;
94
-
95
- bool operator==(const String &) const noexcept;
96
- bool operator!=(const String &) const noexcept;
97
- bool operator<(const String &) const noexcept;
98
- bool operator<=(const String &) const noexcept;
99
- bool operator>(const String &) const noexcept;
100
- bool operator>=(const String &) const noexcept;
101
-
102
- void swap(String &) noexcept;
103
-
104
- String(unsafe_bitcopy_t, const String &) noexcept;
105
-
106
- private:
107
- struct lossy_t;
108
- String(lossy_t, const char *, std::size_t) noexcept;
109
- String(lossy_t, const char16_t *, std::size_t) noexcept;
110
- friend void swap(String &lhs, String &rhs) noexcept { lhs.swap(rhs); }
111
-
112
- std::array<std::uintptr_t, 3> repr;
113
- };
114
- #endif // CXXBRIDGE1_RUST_STRING
115
-
116
- #ifndef CXXBRIDGE1_RUST_STR
117
- #define CXXBRIDGE1_RUST_STR
118
- class Str final {
119
- public:
120
- Str() noexcept;
121
- Str(const String &) noexcept;
122
- Str(const std::string &);
123
- Str(const char *);
124
- Str(const char *, std::size_t);
125
-
126
- Str &operator=(const Str &) & noexcept = default;
127
-
128
- explicit operator std::string() const;
129
- #if __cplusplus >= 201703L
130
- explicit operator std::string_view() const;
131
- #endif
132
-
133
- const char *data() const noexcept;
134
- std::size_t size() const noexcept;
135
- std::size_t length() const noexcept;
136
- bool empty() const noexcept;
137
-
138
- Str(const Str &) noexcept = default;
139
- ~Str() noexcept = default;
140
-
141
- using iterator = const char *;
142
- using const_iterator = const char *;
143
- const_iterator begin() const noexcept;
144
- const_iterator end() const noexcept;
145
- const_iterator cbegin() const noexcept;
146
- const_iterator cend() const noexcept;
147
-
148
- bool operator==(const Str &) const noexcept;
149
- bool operator!=(const Str &) const noexcept;
150
- bool operator<(const Str &) const noexcept;
151
- bool operator<=(const Str &) const noexcept;
152
- bool operator>(const Str &) const noexcept;
153
- bool operator>=(const Str &) const noexcept;
154
-
155
- void swap(Str &) noexcept;
156
-
157
- private:
158
- class uninit;
159
- Str(uninit) noexcept;
160
- friend impl<Str>;
161
-
162
- std::array<std::uintptr_t, 2> repr;
163
- };
164
- #endif // CXXBRIDGE1_RUST_STR
165
-
166
- #ifndef CXXBRIDGE1_RUST_SLICE
167
- #define CXXBRIDGE1_RUST_SLICE
168
- namespace detail {
169
- template <bool>
170
- struct copy_assignable_if {};
171
-
172
- template <>
173
- struct copy_assignable_if<false> {
174
- copy_assignable_if() noexcept = default;
175
- copy_assignable_if(const copy_assignable_if &) noexcept = default;
176
- copy_assignable_if &operator=(const copy_assignable_if &) & noexcept = delete;
177
- copy_assignable_if &operator=(copy_assignable_if &&) & noexcept = default;
178
- };
179
- } // namespace detail
180
-
181
- template <typename T>
182
- class Slice final
183
- : private detail::copy_assignable_if<std::is_const<T>::value> {
184
- public:
185
- using value_type = T;
186
-
187
- Slice() noexcept;
188
- Slice(T *, std::size_t count) noexcept;
189
-
190
- template <typename C>
191
- explicit Slice(C &c) : Slice(c.data(), c.size()) {}
192
-
193
- Slice &operator=(const Slice<T> &) & noexcept = default;
194
- Slice &operator=(Slice<T> &&) & noexcept = default;
195
-
196
- T *data() const noexcept;
197
- std::size_t size() const noexcept;
198
- std::size_t length() const noexcept;
199
- bool empty() const noexcept;
200
-
201
- T &operator[](std::size_t n) const noexcept;
202
- T &at(std::size_t n) const;
203
- T &front() const noexcept;
204
- T &back() const noexcept;
205
-
206
- Slice(const Slice<T> &) noexcept = default;
207
- ~Slice() noexcept = default;
208
-
209
- class iterator;
210
- iterator begin() const noexcept;
211
- iterator end() const noexcept;
212
-
213
- void swap(Slice &) noexcept;
214
-
215
- private:
216
- class uninit;
217
- Slice(uninit) noexcept;
218
- friend impl<Slice>;
219
- friend void sliceInit(void *, const void *, std::size_t) noexcept;
220
- friend void *slicePtr(const void *) noexcept;
221
- friend std::size_t sliceLen(const void *) noexcept;
222
-
223
- std::array<std::uintptr_t, 2> repr;
224
- };
225
-
226
- #ifdef __cpp_deduction_guides
227
- template <typename C>
228
- explicit Slice(C &c)
229
- -> Slice<std::remove_reference_t<decltype(*std::declval<C>().data())>>;
230
- #endif // __cpp_deduction_guides
231
-
232
- template <typename T>
233
- class Slice<T>::iterator final {
234
- public:
235
- #if __cplusplus >= 202002L
236
- using iterator_category = std::contiguous_iterator_tag;
237
- #else
238
- using iterator_category = std::random_access_iterator_tag;
239
- #endif
240
- using value_type = T;
241
- using difference_type = std::ptrdiff_t;
242
- using pointer = typename std::add_pointer<T>::type;
243
- using reference = typename std::add_lvalue_reference<T>::type;
244
-
245
- reference operator*() const noexcept;
246
- pointer operator->() const noexcept;
247
- reference operator[](difference_type) const noexcept;
248
-
249
- iterator &operator++() noexcept;
250
- iterator operator++(int) noexcept;
251
- iterator &operator--() noexcept;
252
- iterator operator--(int) noexcept;
253
-
254
- iterator &operator+=(difference_type) noexcept;
255
- iterator &operator-=(difference_type) noexcept;
256
- iterator operator+(difference_type) const noexcept;
257
- friend inline iterator operator+(difference_type lhs, iterator rhs) noexcept {
258
- return rhs + lhs;
259
- }
260
- iterator operator-(difference_type) const noexcept;
261
- difference_type operator-(const iterator &) const noexcept;
262
-
263
- bool operator==(const iterator &) const noexcept;
264
- bool operator!=(const iterator &) const noexcept;
265
- bool operator<(const iterator &) const noexcept;
266
- bool operator<=(const iterator &) const noexcept;
267
- bool operator>(const iterator &) const noexcept;
268
- bool operator>=(const iterator &) const noexcept;
269
-
270
- private:
271
- friend class Slice;
272
- void *pos;
273
- std::size_t stride;
274
- };
275
-
276
- #if __cplusplus >= 202002L
277
- static_assert(std::ranges::contiguous_range<rust::Slice<const uint8_t>>);
278
- static_assert(std::contiguous_iterator<rust::Slice<const uint8_t>::iterator>);
279
- #endif
280
-
281
- template <typename T>
282
- Slice<T>::Slice() noexcept {
283
- sliceInit(this, reinterpret_cast<void *>(align_of<T>()), 0);
284
- }
285
-
286
- template <typename T>
287
- Slice<T>::Slice(T *s, std::size_t count) noexcept {
288
- assert(s != nullptr || count == 0);
289
- sliceInit(this,
290
- s == nullptr && count == 0
291
- ? reinterpret_cast<void *>(align_of<T>())
292
- : const_cast<typename std::remove_const<T>::type *>(s),
293
- count);
294
- }
295
-
296
- template <typename T>
297
- T *Slice<T>::data() const noexcept {
298
- return reinterpret_cast<T *>(slicePtr(this));
299
- }
300
-
301
- template <typename T>
302
- std::size_t Slice<T>::size() const noexcept {
303
- return sliceLen(this);
304
- }
305
-
306
- template <typename T>
307
- std::size_t Slice<T>::length() const noexcept {
308
- return this->size();
309
- }
310
-
311
- template <typename T>
312
- bool Slice<T>::empty() const noexcept {
313
- return this->size() == 0;
314
- }
315
-
316
- template <typename T>
317
- T &Slice<T>::operator[](std::size_t n) const noexcept {
318
- assert(n < this->size());
319
- auto ptr = static_cast<char *>(slicePtr(this)) + size_of<T>() * n;
320
- return *reinterpret_cast<T *>(ptr);
321
- }
322
-
323
- template <typename T>
324
- T &Slice<T>::at(std::size_t n) const {
325
- if (n >= this->size()) {
326
- panic<std::out_of_range>("rust::Slice index out of range");
327
- }
328
- return (*this)[n];
329
- }
330
-
331
- template <typename T>
332
- T &Slice<T>::front() const noexcept {
333
- assert(!this->empty());
334
- return (*this)[0];
335
- }
336
-
337
- template <typename T>
338
- T &Slice<T>::back() const noexcept {
339
- assert(!this->empty());
340
- return (*this)[this->size() - 1];
341
- }
342
-
343
- template <typename T>
344
- typename Slice<T>::iterator::reference
345
- Slice<T>::iterator::operator*() const noexcept {
346
- return *static_cast<T *>(this->pos);
347
- }
348
-
349
- template <typename T>
350
- typename Slice<T>::iterator::pointer
351
- Slice<T>::iterator::operator->() const noexcept {
352
- return static_cast<T *>(this->pos);
353
- }
354
-
355
- template <typename T>
356
- typename Slice<T>::iterator::reference Slice<T>::iterator::operator[](
357
- typename Slice<T>::iterator::difference_type n) const noexcept {
358
- auto ptr = static_cast<char *>(this->pos) + this->stride * n;
359
- return *reinterpret_cast<T *>(ptr);
360
- }
361
-
362
- template <typename T>
363
- typename Slice<T>::iterator &Slice<T>::iterator::operator++() noexcept {
364
- this->pos = static_cast<char *>(this->pos) + this->stride;
365
- return *this;
366
- }
367
-
368
- template <typename T>
369
- typename Slice<T>::iterator Slice<T>::iterator::operator++(int) noexcept {
370
- auto ret = iterator(*this);
371
- this->pos = static_cast<char *>(this->pos) + this->stride;
372
- return ret;
373
- }
374
-
375
- template <typename T>
376
- typename Slice<T>::iterator &Slice<T>::iterator::operator--() noexcept {
377
- this->pos = static_cast<char *>(this->pos) - this->stride;
378
- return *this;
379
- }
380
-
381
- template <typename T>
382
- typename Slice<T>::iterator Slice<T>::iterator::operator--(int) noexcept {
383
- auto ret = iterator(*this);
384
- this->pos = static_cast<char *>(this->pos) - this->stride;
385
- return ret;
386
- }
387
-
388
- template <typename T>
389
- typename Slice<T>::iterator &Slice<T>::iterator::operator+=(
390
- typename Slice<T>::iterator::difference_type n) noexcept {
391
- this->pos = static_cast<char *>(this->pos) + this->stride * n;
392
- return *this;
393
- }
394
-
395
- template <typename T>
396
- typename Slice<T>::iterator &Slice<T>::iterator::operator-=(
397
- typename Slice<T>::iterator::difference_type n) noexcept {
398
- this->pos = static_cast<char *>(this->pos) - this->stride * n;
399
- return *this;
400
- }
401
-
402
- template <typename T>
403
- typename Slice<T>::iterator Slice<T>::iterator::operator+(
404
- typename Slice<T>::iterator::difference_type n) const noexcept {
405
- auto ret = iterator(*this);
406
- ret.pos = static_cast<char *>(this->pos) + this->stride * n;
407
- return ret;
408
- }
409
-
410
- template <typename T>
411
- typename Slice<T>::iterator Slice<T>::iterator::operator-(
412
- typename Slice<T>::iterator::difference_type n) const noexcept {
413
- auto ret = iterator(*this);
414
- ret.pos = static_cast<char *>(this->pos) - this->stride * n;
415
- return ret;
416
- }
417
-
418
- template <typename T>
419
- typename Slice<T>::iterator::difference_type
420
- Slice<T>::iterator::operator-(const iterator &other) const noexcept {
421
- auto diff = std::distance(static_cast<char *>(other.pos),
422
- static_cast<char *>(this->pos));
423
- return diff / static_cast<typename Slice<T>::iterator::difference_type>(
424
- this->stride);
425
- }
426
-
427
- template <typename T>
428
- bool Slice<T>::iterator::operator==(const iterator &other) const noexcept {
429
- return this->pos == other.pos;
430
- }
431
-
432
- template <typename T>
433
- bool Slice<T>::iterator::operator!=(const iterator &other) const noexcept {
434
- return this->pos != other.pos;
435
- }
436
-
437
- template <typename T>
438
- bool Slice<T>::iterator::operator<(const iterator &other) const noexcept {
439
- return this->pos < other.pos;
440
- }
441
-
442
- template <typename T>
443
- bool Slice<T>::iterator::operator<=(const iterator &other) const noexcept {
444
- return this->pos <= other.pos;
445
- }
446
-
447
- template <typename T>
448
- bool Slice<T>::iterator::operator>(const iterator &other) const noexcept {
449
- return this->pos > other.pos;
450
- }
451
-
452
- template <typename T>
453
- bool Slice<T>::iterator::operator>=(const iterator &other) const noexcept {
454
- return this->pos >= other.pos;
455
- }
456
-
457
- template <typename T>
458
- typename Slice<T>::iterator Slice<T>::begin() const noexcept {
459
- iterator it;
460
- it.pos = slicePtr(this);
461
- it.stride = size_of<T>();
462
- return it;
463
- }
464
-
465
- template <typename T>
466
- typename Slice<T>::iterator Slice<T>::end() const noexcept {
467
- iterator it = this->begin();
468
- it.pos = static_cast<char *>(it.pos) + it.stride * this->size();
469
- return it;
470
- }
471
-
472
- template <typename T>
473
- void Slice<T>::swap(Slice &rhs) noexcept {
474
- std::swap(*this, rhs);
475
- }
476
- #endif // CXXBRIDGE1_RUST_SLICE
477
-
478
- #ifndef CXXBRIDGE1_RUST_BITCOPY_T
479
- #define CXXBRIDGE1_RUST_BITCOPY_T
480
- struct unsafe_bitcopy_t final {
481
- explicit unsafe_bitcopy_t() = default;
482
- };
483
- #endif // CXXBRIDGE1_RUST_BITCOPY_T
484
-
485
- #ifndef CXXBRIDGE1_RUST_VEC
486
- #define CXXBRIDGE1_RUST_VEC
487
- template <typename T>
488
- class Vec final {
489
- public:
490
- using value_type = T;
491
-
492
- Vec() noexcept;
493
- Vec(std::initializer_list<T>);
494
- Vec(const Vec &);
495
- Vec(Vec &&) noexcept;
496
- ~Vec() noexcept;
497
-
498
- Vec &operator=(Vec &&) & noexcept;
499
- Vec &operator=(const Vec &) &;
500
-
501
- std::size_t size() const noexcept;
502
- bool empty() const noexcept;
503
- const T *data() const noexcept;
504
- T *data() noexcept;
505
- std::size_t capacity() const noexcept;
506
-
507
- const T &operator[](std::size_t n) const noexcept;
508
- const T &at(std::size_t n) const;
509
- const T &front() const noexcept;
510
- const T &back() const noexcept;
511
-
512
- T &operator[](std::size_t n) noexcept;
513
- T &at(std::size_t n);
514
- T &front() noexcept;
515
- T &back() noexcept;
516
-
517
- void reserve(std::size_t new_cap);
518
- void push_back(const T &value);
519
- void push_back(T &&value);
520
- template <typename... Args>
521
- void emplace_back(Args &&...args);
522
- void truncate(std::size_t len);
523
- void clear();
524
-
525
- using iterator = typename Slice<T>::iterator;
526
- iterator begin() noexcept;
527
- iterator end() noexcept;
528
-
529
- using const_iterator = typename Slice<const T>::iterator;
530
- const_iterator begin() const noexcept;
531
- const_iterator end() const noexcept;
532
- const_iterator cbegin() const noexcept;
533
- const_iterator cend() const noexcept;
534
-
535
- void swap(Vec &) noexcept;
536
-
537
- Vec(unsafe_bitcopy_t, const Vec &) noexcept;
538
-
539
- private:
540
- void reserve_total(std::size_t new_cap) noexcept;
541
- void set_len(std::size_t len) noexcept;
542
- void drop() noexcept;
543
-
544
- friend void swap(Vec &lhs, Vec &rhs) noexcept { lhs.swap(rhs); }
545
-
546
- std::array<std::uintptr_t, 3> repr;
547
- };
548
-
549
- template <typename T>
550
- Vec<T>::Vec(std::initializer_list<T> init) : Vec{} {
551
- this->reserve_total(init.size());
552
- std::move(init.begin(), init.end(), std::back_inserter(*this));
553
- }
554
-
555
- template <typename T>
556
- Vec<T>::Vec(const Vec &other) : Vec() {
557
- this->reserve_total(other.size());
558
- std::copy(other.begin(), other.end(), std::back_inserter(*this));
559
- }
560
-
561
- template <typename T>
562
- Vec<T>::Vec(Vec &&other) noexcept : repr(other.repr) {
563
- new (&other) Vec();
564
- }
565
-
566
- template <typename T>
567
- Vec<T>::~Vec() noexcept {
568
- this->drop();
569
- }
570
-
571
- template <typename T>
572
- Vec<T> &Vec<T>::operator=(Vec &&other) & noexcept {
573
- this->drop();
574
- this->repr = other.repr;
575
- new (&other) Vec();
576
- return *this;
577
- }
578
-
579
- template <typename T>
580
- Vec<T> &Vec<T>::operator=(const Vec &other) & {
581
- if (this != &other) {
582
- this->drop();
583
- new (this) Vec(other);
584
- }
585
- return *this;
586
- }
587
-
588
- template <typename T>
589
- bool Vec<T>::empty() const noexcept {
590
- return this->size() == 0;
591
- }
592
-
593
- template <typename T>
594
- T *Vec<T>::data() noexcept {
595
- return const_cast<T *>(const_cast<const Vec<T> *>(this)->data());
596
- }
597
-
598
- template <typename T>
599
- const T &Vec<T>::operator[](std::size_t n) const noexcept {
600
- assert(n < this->size());
601
- auto data = reinterpret_cast<const char *>(this->data());
602
- return *reinterpret_cast<const T *>(data + n * size_of<T>());
603
- }
604
-
605
- template <typename T>
606
- const T &Vec<T>::at(std::size_t n) const {
607
- if (n >= this->size()) {
608
- panic<std::out_of_range>("rust::Vec index out of range");
609
- }
610
- return (*this)[n];
611
- }
612
-
613
- template <typename T>
614
- const T &Vec<T>::front() const noexcept {
615
- assert(!this->empty());
616
- return (*this)[0];
617
- }
618
-
619
- template <typename T>
620
- const T &Vec<T>::back() const noexcept {
621
- assert(!this->empty());
622
- return (*this)[this->size() - 1];
623
- }
624
-
625
- template <typename T>
626
- T &Vec<T>::operator[](std::size_t n) noexcept {
627
- assert(n < this->size());
628
- auto data = reinterpret_cast<char *>(this->data());
629
- return *reinterpret_cast<T *>(data + n * size_of<T>());
630
- }
631
-
632
- template <typename T>
633
- T &Vec<T>::at(std::size_t n) {
634
- if (n >= this->size()) {
635
- panic<std::out_of_range>("rust::Vec index out of range");
636
- }
637
- return (*this)[n];
638
- }
639
-
640
- template <typename T>
641
- T &Vec<T>::front() noexcept {
642
- assert(!this->empty());
643
- return (*this)[0];
644
- }
645
-
646
- template <typename T>
647
- T &Vec<T>::back() noexcept {
648
- assert(!this->empty());
649
- return (*this)[this->size() - 1];
650
- }
651
-
652
- template <typename T>
653
- void Vec<T>::reserve(std::size_t new_cap) {
654
- this->reserve_total(new_cap);
655
- }
656
-
657
- template <typename T>
658
- void Vec<T>::push_back(const T &value) {
659
- this->emplace_back(value);
660
- }
661
-
662
- template <typename T>
663
- void Vec<T>::push_back(T &&value) {
664
- this->emplace_back(std::move(value));
665
- }
666
-
667
- template <typename T>
668
- template <typename... Args>
669
- void Vec<T>::emplace_back(Args &&...args) {
670
- auto size = this->size();
671
- this->reserve_total(size + 1);
672
- ::new (reinterpret_cast<T *>(reinterpret_cast<char *>(this->data()) +
673
- size * size_of<T>()))
674
- T(std::forward<Args>(args)...);
675
- this->set_len(size + 1);
676
- }
677
-
678
- template <typename T>
679
- void Vec<T>::clear() {
680
- this->truncate(0);
681
- }
682
-
683
- template <typename T>
684
- typename Vec<T>::iterator Vec<T>::begin() noexcept {
685
- return Slice<T>(this->data(), this->size()).begin();
686
- }
687
-
688
- template <typename T>
689
- typename Vec<T>::iterator Vec<T>::end() noexcept {
690
- return Slice<T>(this->data(), this->size()).end();
691
- }
692
-
693
- template <typename T>
694
- typename Vec<T>::const_iterator Vec<T>::begin() const noexcept {
695
- return this->cbegin();
696
- }
697
-
698
- template <typename T>
699
- typename Vec<T>::const_iterator Vec<T>::end() const noexcept {
700
- return this->cend();
701
- }
702
-
703
- template <typename T>
704
- typename Vec<T>::const_iterator Vec<T>::cbegin() const noexcept {
705
- return Slice<const T>(this->data(), this->size()).begin();
706
- }
707
-
708
- template <typename T>
709
- typename Vec<T>::const_iterator Vec<T>::cend() const noexcept {
710
- return Slice<const T>(this->data(), this->size()).end();
711
- }
712
-
713
- template <typename T>
714
- void Vec<T>::swap(Vec &rhs) noexcept {
715
- using std::swap;
716
- swap(this->repr, rhs.repr);
717
- }
718
-
719
- template <typename T>
720
- Vec<T>::Vec(unsafe_bitcopy_t, const Vec &bits) noexcept : repr(bits.repr) {}
721
- #endif // CXXBRIDGE1_RUST_VEC
722
-
723
- #ifndef CXXBRIDGE1_IS_COMPLETE
724
- #define CXXBRIDGE1_IS_COMPLETE
725
- namespace detail {
726
- namespace {
727
- template <typename T, typename = std::size_t>
728
- struct is_complete : std::false_type {};
729
- template <typename T>
730
- struct is_complete<T, decltype(sizeof(T))> : std::true_type {};
731
- } // namespace
732
- } // namespace detail
733
- #endif // CXXBRIDGE1_IS_COMPLETE
734
-
735
- #ifndef CXXBRIDGE1_LAYOUT
736
- #define CXXBRIDGE1_LAYOUT
737
- class layout {
738
- template <typename T>
739
- friend std::size_t size_of();
740
- template <typename T>
741
- friend std::size_t align_of();
742
- template <typename T>
743
- static typename std::enable_if<std::is_base_of<Opaque, T>::value,
744
- std::size_t>::type
745
- do_size_of() {
746
- return T::layout::size();
747
- }
748
- template <typename T>
749
- static typename std::enable_if<!std::is_base_of<Opaque, T>::value,
750
- std::size_t>::type
751
- do_size_of() {
752
- return sizeof(T);
753
- }
754
- template <typename T>
755
- static
756
- typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type
757
- size_of() {
758
- return do_size_of<T>();
759
- }
760
- template <typename T>
761
- static typename std::enable_if<std::is_base_of<Opaque, T>::value,
762
- std::size_t>::type
763
- do_align_of() {
764
- return T::layout::align();
765
- }
766
- template <typename T>
767
- static typename std::enable_if<!std::is_base_of<Opaque, T>::value,
768
- std::size_t>::type
769
- do_align_of() {
770
- return alignof(T);
771
- }
772
- template <typename T>
773
- static
774
- typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type
775
- align_of() {
776
- return do_align_of<T>();
777
- }
778
- };
779
-
780
- template <typename T>
781
- std::size_t size_of() {
782
- return layout::size_of<T>();
783
- }
784
-
785
- template <typename T>
786
- std::size_t align_of() {
787
- return layout::align_of<T>();
788
- }
789
- #endif // CXXBRIDGE1_LAYOUT
790
- } // namespace cxxbridge1
791
- } // namespace rust
792
-
793
- #if __cplusplus >= 201402L
794
- #define CXX_DEFAULT_VALUE(value) = value
795
- #else
796
- #define CXX_DEFAULT_VALUE(value)
797
- #endif
798
-
799
- namespace bark_cxx {
800
- struct CxxBalance;
801
- struct ConfigOpts;
802
- struct CreateOpts;
803
- struct SendManyOutput;
804
- enum class RefreshModeType : ::std::uint8_t;
805
- struct RefreshOpts;
806
- }
807
-
808
- namespace bark_cxx {
809
- #ifndef CXXBRIDGE1_STRUCT_bark_cxx$CxxBalance
810
- #define CXXBRIDGE1_STRUCT_bark_cxx$CxxBalance
811
- struct CxxBalance final {
812
- ::std::uint64_t onchain CXX_DEFAULT_VALUE(0);
813
- ::std::uint64_t offchain CXX_DEFAULT_VALUE(0);
814
- ::std::uint64_t pending_exit CXX_DEFAULT_VALUE(0);
815
-
816
- using IsRelocatable = ::std::true_type;
817
- };
818
- #endif // CXXBRIDGE1_STRUCT_bark_cxx$CxxBalance
819
-
820
- #ifndef CXXBRIDGE1_STRUCT_bark_cxx$ConfigOpts
821
- #define CXXBRIDGE1_STRUCT_bark_cxx$ConfigOpts
822
- struct ConfigOpts final {
823
- ::rust::String asp;
824
- ::rust::String esplora;
825
- ::rust::String bitcoind;
826
- ::rust::String bitcoind_cookie;
827
- ::rust::String bitcoind_user;
828
- ::rust::String bitcoind_pass;
829
- ::std::uint32_t vtxo_refresh_expiry_threshold CXX_DEFAULT_VALUE(0);
830
- ::std::uint64_t fallback_fee_rate CXX_DEFAULT_VALUE(0);
831
-
832
- using IsRelocatable = ::std::true_type;
833
- };
834
- #endif // CXXBRIDGE1_STRUCT_bark_cxx$ConfigOpts
835
-
836
- #ifndef CXXBRIDGE1_STRUCT_bark_cxx$CreateOpts
837
- #define CXXBRIDGE1_STRUCT_bark_cxx$CreateOpts
838
- struct CreateOpts final {
839
- bool regtest CXX_DEFAULT_VALUE(false);
840
- bool signet CXX_DEFAULT_VALUE(false);
841
- bool bitcoin CXX_DEFAULT_VALUE(false);
842
- ::rust::String mnemonic;
843
- ::std::uint32_t birthday_height CXX_DEFAULT_VALUE(0);
844
- ::bark_cxx::ConfigOpts config;
845
-
846
- using IsRelocatable = ::std::true_type;
847
- };
848
- #endif // CXXBRIDGE1_STRUCT_bark_cxx$CreateOpts
849
-
850
- #ifndef CXXBRIDGE1_STRUCT_bark_cxx$SendManyOutput
851
- #define CXXBRIDGE1_STRUCT_bark_cxx$SendManyOutput
852
- struct SendManyOutput final {
853
- ::rust::String destination;
854
- ::std::uint64_t amount_sat CXX_DEFAULT_VALUE(0);
855
-
856
- using IsRelocatable = ::std::true_type;
857
- };
858
- #endif // CXXBRIDGE1_STRUCT_bark_cxx$SendManyOutput
859
-
860
- #ifndef CXXBRIDGE1_ENUM_bark_cxx$RefreshModeType
861
- #define CXXBRIDGE1_ENUM_bark_cxx$RefreshModeType
862
- enum class RefreshModeType : ::std::uint8_t {
863
- DefaultThreshold = 0,
864
- ThresholdBlocks = 1,
865
- ThresholdHours = 2,
866
- Counterparty = 3,
867
- All = 4,
868
- Specific = 5,
869
- };
870
- #endif // CXXBRIDGE1_ENUM_bark_cxx$RefreshModeType
871
-
872
- #ifndef CXXBRIDGE1_STRUCT_bark_cxx$RefreshOpts
873
- #define CXXBRIDGE1_STRUCT_bark_cxx$RefreshOpts
874
- struct RefreshOpts final {
875
- ::bark_cxx::RefreshModeType mode_type;
876
- ::std::uint32_t threshold_value CXX_DEFAULT_VALUE(0);
877
- ::rust::Vec<::rust::String> specific_vtxo_ids;
878
-
879
- using IsRelocatable = ::std::true_type;
880
- };
881
- #endif // CXXBRIDGE1_STRUCT_bark_cxx$RefreshOpts
882
-
883
- void init_logger() noexcept;
884
-
885
- ::rust::String create_mnemonic();
886
-
887
- bool is_wallet_loaded() noexcept;
888
-
889
- void close_wallet();
890
-
891
- ::rust::String get_onchain_address();
892
-
893
- ::bark_cxx::CxxBalance get_balance(bool no_sync);
894
-
895
- ::rust::String get_onchain_utxos(bool no_sync);
896
-
897
- ::rust::String get_vtxo_pubkey(::std::uint32_t index);
898
-
899
- ::rust::String get_vtxos(bool no_sync);
900
-
901
- ::rust::String bolt11_invoice(::std::uint64_t amount_msat);
902
-
903
- void claim_bolt11_payment(::rust::Str bolt11);
904
-
905
- void load_wallet(::rust::Str datadir, ::bark_cxx::CreateOpts opts);
906
-
907
- ::rust::String send_onchain(::rust::Str destination, ::std::uint64_t amount_sat, bool no_sync);
908
-
909
- ::rust::String drain_onchain(::rust::Str destination, bool no_sync);
910
-
911
- ::rust::String send_many_onchain(::rust::Vec<::bark_cxx::SendManyOutput> outputs, bool no_sync);
912
-
913
- ::rust::String refresh_vtxos(::bark_cxx::RefreshOpts opts, bool no_sync);
914
-
915
- ::rust::String board_amount(::std::uint64_t amount_sat, bool no_sync);
916
-
917
- ::rust::String board_all(bool no_sync);
918
-
919
- ::rust::String send_payment(::rust::Str destination, ::std::uint64_t amount_sat, ::rust::Str comment, bool no_sync);
920
-
921
- ::rust::String send_round_onchain(::rust::Str destination, ::std::uint64_t amount_sat, bool no_sync);
922
-
923
- ::rust::String offboard_specific(::rust::Vec<::rust::String> vtxo_ids, ::rust::Str destination_address, bool no_sync);
924
-
925
- ::rust::String offboard_all(::rust::Str destination_address, bool no_sync);
926
-
927
- ::rust::String start_exit_for_vtxos(::rust::Vec<::rust::String> vtxo_ids);
928
-
929
- ::rust::String start_exit_for_entire_wallet();
930
-
931
- ::rust::String exit_progress_once();
932
- } // namespace bark_cxx