chordsketch 0.4.0 → 0.6.0

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.
@@ -14,7 +14,7 @@
14
14
  # helpers directly inline like we're doing here.
15
15
 
16
16
  require 'ffi'
17
-
17
+ require 'set'
18
18
 
19
19
  module Chordsketch
20
20
  def self.uniffi_in_range(i, type_name, min, max)
@@ -36,21 +36,64 @@ def self.uniffi_bytes(v)
36
36
  v.to_str
37
37
  end
38
38
 
39
+ # Callback return codes
40
+ UNIFFI_CALLBACK_SUCCESS = 0
41
+ UNIFFI_CALLBACK_ERROR = 1
42
+ UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2
43
+
44
+ # Call a method on a callback interface object, catching and reporting errors
45
+ # to Rust via the call_status.
46
+ # If error_type is provided, known errors of that type are reported as UNIFFI_CALLBACK_ERROR;
47
+ # all other errors are reported as UNIFFI_CALLBACK_UNEXPECTED_ERROR.
48
+ def self.uniffi_trait_interface_call(call_status, make_call, write_return_value, error_type = nil, lower_error = nil)
49
+ begin
50
+ write_return_value.call make_call.call
51
+ rescue StandardError => e
52
+ buf = if !error_type.nil? && uniffi_is_error_type?(e, error_type)
53
+ call_status[:code] = UNIFFI_CALLBACK_ERROR
54
+ lower_error.call e
55
+ else
56
+ call_status[:code] = UNIFFI_CALLBACK_UNEXPECTED_ERROR
57
+ RustBuffer.alloc_from_string(e.inspect)
58
+ end
59
+
60
+ error_buf = call_status[:error_buf]
61
+ error_buf[:capacity] = buf[:capacity]
62
+ error_buf[:len] = buf[:len]
63
+ error_buf[:data] = buf[:data]
64
+ end
65
+ end
66
+
67
+ # Check if an exception is a variant of the given error type.
68
+ # Error types in Ruby are either modules (non-flat enums) or classes (flat enums),
69
+ # with variant classes as constant within them.
70
+ def self.uniffi_is_error_type?(e, error_type)
71
+ # Object-as-error: error_type is a class itself (e.g. MyError < StandardError)
72
+ if error_type.is_a?(Class) && e.is_a?(error_type)
73
+ return true
74
+ end
75
+
76
+ # Enum error: error_type is a module with class constants for each variant
77
+ error_type.constants.any? do |c|
78
+ klass = error_type.const_get c
79
+ klass.is_a?(Class) && e.is_a?(klass)
80
+ end
81
+ end
39
82
  class RustBuffer < FFI::Struct
40
83
  layout :capacity, :uint64,
41
84
  :len, :uint64,
42
85
  :data, :pointer
43
86
 
44
87
  def self.alloc(size)
45
- return Chordsketch.rust_call(:ffi_chordsketch_ffi_rustbuffer_alloc, size)
88
+ return ::Chordsketch.rust_call(:ffi_chordsketch_ffi_rustbuffer_alloc, size)
46
89
  end
47
90
 
48
91
  def self.reserve(rbuf, additional)
49
- return Chordsketch.rust_call(:ffi_chordsketch_ffi_rustbuffer_reserve, rbuf, additional)
92
+ return ::Chordsketch.rust_call(:ffi_chordsketch_ffi_rustbuffer_reserve, rbuf, additional)
50
93
  end
51
94
 
52
95
  def free
53
- Chordsketch.rust_call(:ffi_chordsketch_ffi_rustbuffer_free, self)
96
+ ::Chordsketch.rust_call(:ffi_chordsketch_ffi_rustbuffer_free, self)
54
97
  end
55
98
 
56
99
  def capacity
@@ -98,14 +141,14 @@ end
98
141
  free
99
142
  end# The primitive String type.
100
143
 
101
- def self.allocFromString(value)
144
+ def self.alloc_from_string(value)
102
145
  RustBuffer.allocWithBuilder do |builder|
103
146
  builder.write value.encode('utf-8')
104
147
  return builder.finalize
105
148
  end
106
149
  end
107
150
 
108
- def consumeIntoString
151
+ def consume_into_string
109
152
  consumeWithStream do |stream|
110
153
  return stream.read(stream.remaining).force_encoding(Encoding::UTF_8)
111
154
  end
@@ -113,16 +156,36 @@ end
113
156
 
114
157
  # The primitive Bytes type.
115
158
 
116
- def self.allocFromBytes(value)
159
+ def self.alloc_from_bytes(value)
160
+ RustBuffer.allocWithBuilder do |builder|
161
+ builder.write_bytes(value)
162
+ return builder.finalize
163
+ end
164
+ end
165
+
166
+ def consume_into_bytes
167
+ consumeWithStream do |stream|
168
+ return stream.read_bytes
169
+ end
170
+ end
171
+
172
+ # The Record type ChordDefine.
173
+
174
+ def self.check_lower_TypeChordDefine(v)
175
+
176
+
177
+ end
178
+
179
+ def self.alloc_from_TypeChordDefine(v)
117
180
  RustBuffer.allocWithBuilder do |builder|
118
- builder.write_Bytes(value)
181
+ builder.write_TypeChordDefine(v)
119
182
  return builder.finalize
120
183
  end
121
184
  end
122
185
 
123
- def consumeIntoBytes
186
+ def consume_into_TypeChordDefine
124
187
  consumeWithStream do |stream|
125
- return stream.readBytes
188
+ return stream.read_TypeChordDefine
126
189
  end
127
190
  end
128
191
 
@@ -140,9 +203,9 @@ end
140
203
  end
141
204
  end
142
205
 
143
- def consumeIntoTypeConversionWithWarnings
206
+ def consume_into_TypeConversionWithWarnings
144
207
  consumeWithStream do |stream|
145
- return stream.readTypeConversionWithWarnings
208
+ return stream.read_TypeConversionWithWarnings
146
209
  end
147
210
  end
148
211
 
@@ -160,9 +223,31 @@ end
160
223
  end
161
224
  end
162
225
 
163
- def consumeIntoTypePdfRenderWithWarnings
226
+ def consume_into_TypePdfRenderWithWarnings
227
+ consumeWithStream do |stream|
228
+ return stream.read_TypePdfRenderWithWarnings
229
+ end
230
+ end
231
+
232
+ # The Record type StaffNote.
233
+
234
+ def self.check_lower_TypeStaffNote(v)
235
+
236
+
237
+
238
+
239
+ end
240
+
241
+ def self.alloc_from_TypeStaffNote(v)
242
+ RustBuffer.allocWithBuilder do |builder|
243
+ builder.write_TypeStaffNote(v)
244
+ return builder.finalize
245
+ end
246
+ end
247
+
248
+ def consume_into_TypeStaffNote
164
249
  consumeWithStream do |stream|
165
- return stream.readTypePdfRenderWithWarnings
250
+ return stream.read_TypeStaffNote
166
251
  end
167
252
  end
168
253
 
@@ -180,9 +265,9 @@ end
180
265
  end
181
266
  end
182
267
 
183
- def consumeIntoTypeTextRenderWithWarnings
268
+ def consume_into_TypeTextRenderWithWarnings
184
269
  consumeWithStream do |stream|
185
- return stream.readTypeTextRenderWithWarnings
270
+ return stream.read_TypeTextRenderWithWarnings
186
271
  end
187
272
  end
188
273
 
@@ -201,18 +286,32 @@ end
201
286
  end
202
287
  end
203
288
 
204
- def consumeIntoTypeValidationError
289
+ def consume_into_TypeValidationError
205
290
  consumeWithStream do |stream|
206
- return stream.readTypeValidationError
291
+ return stream.read_TypeValidationError
292
+ end
293
+ end
294
+
295
+ # Error enum - generate alloc_from for callback error serialization
296
+ def self.alloc_from_TypeChordSketchError(v)
297
+ RustBuffer.allocWithBuilder do |builder|
298
+ builder.write_TypeChordSketchError(v)
299
+ return builder.finalize
207
300
  end
208
301
  end
209
302
 
303
+ # Enum used as error - generate consume_into_ for use as a return value
304
+ def consume_into_TypeChordSketchError
305
+ consumeWithStream do |stream|
306
+ return stream.read_TypeChordSketchError
307
+ end
308
+ end
210
309
 
211
310
 
212
311
  # The Optional<T> type for i8.
213
312
 
214
313
  def self.check_lower_Optionali8(v)
215
- if not v.nil?
314
+ if !v.nil?
216
315
 
217
316
  end
218
317
  end
@@ -224,16 +323,16 @@ end
224
323
  end
225
324
  end
226
325
 
227
- def consumeIntoOptionali8
326
+ def consume_into_Optionali8
228
327
  consumeWithStream do |stream|
229
- return stream.readOptionali8
328
+ return stream.read_Optionali8
230
329
  end
231
330
  end
232
331
 
233
332
  # The Optional<T> type for string.
234
333
 
235
334
  def self.check_lower_Optionalstring(v)
236
- if not v.nil?
335
+ if !v.nil?
237
336
 
238
337
  end
239
338
  end
@@ -245,9 +344,72 @@ end
245
344
  end
246
345
  end
247
346
 
248
- def consumeIntoOptionalstring
347
+ def consume_into_Optionalstring
348
+ consumeWithStream do |stream|
349
+ return stream.read_Optionalstring
350
+ end
351
+ end
352
+
353
+ # The Optional<T> type for Sequenceu8.
354
+
355
+ def self.check_lower_OptionalSequenceu8(v)
356
+ if !v.nil?
357
+ RustBuffer.check_lower_Sequenceu8(v)
358
+ end
359
+ end
360
+
361
+ def self.alloc_from_OptionalSequenceu8(v)
362
+ RustBuffer.allocWithBuilder do |builder|
363
+ builder.write_OptionalSequenceu8(v)
364
+ return builder.finalize()
365
+ end
366
+ end
367
+
368
+ def consume_into_OptionalSequenceu8
369
+ consumeWithStream do |stream|
370
+ return stream.read_OptionalSequenceu8
371
+ end
372
+ end
373
+
374
+ # The Optional<T> type for SequenceTypeStaffNote.
375
+
376
+ def self.check_lower_OptionalSequenceTypeStaffNote(v)
377
+ if !v.nil?
378
+ RustBuffer.check_lower_SequenceTypeStaffNote(v)
379
+ end
380
+ end
381
+
382
+ def self.alloc_from_OptionalSequenceTypeStaffNote(v)
383
+ RustBuffer.allocWithBuilder do |builder|
384
+ builder.write_OptionalSequenceTypeStaffNote(v)
385
+ return builder.finalize()
386
+ end
387
+ end
388
+
389
+ def consume_into_OptionalSequenceTypeStaffNote
390
+ consumeWithStream do |stream|
391
+ return stream.read_OptionalSequenceTypeStaffNote
392
+ end
393
+ end
394
+
395
+ # The Sequence<T> type for u8.
396
+
397
+ def self.check_lower_Sequenceu8(v)
398
+ v.each do |item|
399
+
400
+ end
401
+ end
402
+
403
+ def self.alloc_from_Sequenceu8(v)
404
+ RustBuffer.allocWithBuilder do |builder|
405
+ builder.write_Sequenceu8(v)
406
+ return builder.finalize()
407
+ end
408
+ end
409
+
410
+ def consume_into_Sequenceu8
249
411
  consumeWithStream do |stream|
250
- return stream.readOptionalstring
412
+ return stream.read_Sequenceu8
251
413
  end
252
414
  end
253
415
 
@@ -266,9 +428,51 @@ end
266
428
  end
267
429
  end
268
430
 
269
- def consumeIntoSequencestring
431
+ def consume_into_Sequencestring
432
+ consumeWithStream do |stream|
433
+ return stream.read_Sequencestring
434
+ end
435
+ end
436
+
437
+ # The Sequence<T> type for TypeChordDefine.
438
+
439
+ def self.check_lower_SequenceTypeChordDefine(v)
440
+ v.each do |item|
441
+ RustBuffer.check_lower_TypeChordDefine(item)
442
+ end
443
+ end
444
+
445
+ def self.alloc_from_SequenceTypeChordDefine(v)
446
+ RustBuffer.allocWithBuilder do |builder|
447
+ builder.write_SequenceTypeChordDefine(v)
448
+ return builder.finalize()
449
+ end
450
+ end
451
+
452
+ def consume_into_SequenceTypeChordDefine
453
+ consumeWithStream do |stream|
454
+ return stream.read_SequenceTypeChordDefine
455
+ end
456
+ end
457
+
458
+ # The Sequence<T> type for TypeStaffNote.
459
+
460
+ def self.check_lower_SequenceTypeStaffNote(v)
461
+ v.each do |item|
462
+ RustBuffer.check_lower_TypeStaffNote(item)
463
+ end
464
+ end
465
+
466
+ def self.alloc_from_SequenceTypeStaffNote(v)
467
+ RustBuffer.allocWithBuilder do |builder|
468
+ builder.write_SequenceTypeStaffNote(v)
469
+ return builder.finalize()
470
+ end
471
+ end
472
+
473
+ def consume_into_SequenceTypeStaffNote
270
474
  consumeWithStream do |stream|
271
- return stream.readSequencestring
475
+ return stream.read_SequenceTypeStaffNote
272
476
  end
273
477
  end
274
478
 
@@ -287,9 +491,9 @@ end
287
491
  end
288
492
  end
289
493
 
290
- def consumeIntoSequenceTypeValidationError
494
+ def consume_into_SequenceTypeValidationError
291
495
  consumeWithStream do |stream|
292
- return stream.readSequenceTypeValidationError
496
+ return stream.read_SequenceTypeValidationError
293
497
  end
294
498
  end
295
499
 
@@ -339,15 +543,19 @@ class RustBufferStream
339
543
  data
340
544
  end
341
545
 
342
- def readI8
546
+ def read_u8
547
+ unpack_from 1, 'c'
548
+ end
549
+
550
+ def read_i8
343
551
  unpack_from 1, 'c'
344
552
  end
345
553
 
346
- def readU32
554
+ def read_u32
347
555
  unpack_from 4, 'L>'
348
556
  end
349
557
 
350
- def readString
558
+ def read_string
351
559
  size = unpack_from 4, 'l>'
352
560
 
353
561
  raise InternalError, 'Unexpected negative string length' if size.negative?
@@ -355,7 +563,7 @@ class RustBufferStream
355
563
  read(size).force_encoding(Encoding::UTF_8)
356
564
  end
357
565
 
358
- def readBytes
566
+ def read_bytes
359
567
  size = unpack_from 4, 'l>'
360
568
 
361
569
  raise InternalError, 'Unexpected negative byte string length' if size.negative?
@@ -363,40 +571,60 @@ class RustBufferStream
363
571
  read(size).force_encoding(Encoding::BINARY)
364
572
  end
365
573
 
574
+ # The Record type ChordDefine.
575
+
576
+ def read_TypeChordDefine
577
+ ChordDefine.new(
578
+ name: read_string,
579
+ raw: read_string
580
+ )
581
+ end
582
+
366
583
  # The Record type ConversionWithWarnings.
367
584
 
368
- def readTypeConversionWithWarnings
585
+ def read_TypeConversionWithWarnings
369
586
  ConversionWithWarnings.new(
370
- output: readString,
371
- warnings: readSequencestring
587
+ output: read_string,
588
+ warnings: read_Sequencestring
372
589
  )
373
590
  end
374
591
 
375
592
  # The Record type PdfRenderWithWarnings.
376
593
 
377
- def readTypePdfRenderWithWarnings
594
+ def read_TypePdfRenderWithWarnings
378
595
  PdfRenderWithWarnings.new(
379
- output: readBytes,
380
- warnings: readSequencestring
596
+ output: read_bytes,
597
+ warnings: read_Sequencestring
598
+ )
599
+ end
600
+
601
+ # The Record type StaffNote.
602
+
603
+ def read_TypeStaffNote
604
+ StaffNote.new(
605
+ letter: read_string,
606
+ accidental: read_i8,
607
+ octave: read_i8,
608
+ midi: read_u8
381
609
  )
382
610
  end
383
611
 
384
612
  # The Record type TextRenderWithWarnings.
385
613
 
386
- def readTypeTextRenderWithWarnings
614
+ def read_TypeTextRenderWithWarnings
387
615
  TextRenderWithWarnings.new(
388
- output: readString,
389
- warnings: readSequencestring
616
+ output: read_string,
617
+ warnings: read_Sequencestring
390
618
  )
391
619
  end
392
620
 
393
621
  # The Record type ValidationError.
394
622
 
395
- def readTypeValidationError
623
+ def read_TypeValidationError
396
624
  ValidationError.new(
397
- line: readU32,
398
- column: readU32,
399
- message: readString
625
+ line: read_u32,
626
+ column: read_u32,
627
+ message: read_string
400
628
  )
401
629
  end
402
630
 
@@ -406,7 +634,7 @@ class RustBufferStream
406
634
 
407
635
  # The Error type ChordSketchError
408
636
 
409
- def readTypeChordSketchError
637
+ def read_TypeChordSketchError
410
638
  variant = unpack_from 4, 'l>'
411
639
 
412
640
  if variant == 1
@@ -414,12 +642,12 @@ class RustBufferStream
414
642
  end
415
643
  if variant == 2
416
644
  return ChordSketchError::InvalidConfig.new(
417
- readString()
645
+ reason: read_string()
418
646
  )
419
647
  end
420
648
  if variant == 3
421
649
  return ChordSketchError::ConversionFailed.new(
422
- readString()
650
+ reason: read_string()
423
651
  )
424
652
  end
425
653
 
@@ -427,37 +655,117 @@ class RustBufferStream
427
655
  end
428
656
 
429
657
 
658
+
430
659
  # The Optional<T> type for i8.
431
660
 
432
- def readOptionali8
661
+ def read_Optionali8
433
662
  flag = unpack_from 1, 'c'
434
663
 
435
664
  if flag == 0
436
665
  return nil
437
666
  elsif flag == 1
438
- return readI8
667
+ return read_i8
439
668
  else
440
669
  raise InternalError, 'Unexpected flag byte for Optionali8'
441
670
  end
442
671
  end
443
672
 
673
+
444
674
  # The Optional<T> type for string.
445
675
 
446
- def readOptionalstring
676
+ def read_Optionalstring
447
677
  flag = unpack_from 1, 'c'
448
678
 
449
679
  if flag == 0
450
680
  return nil
451
681
  elsif flag == 1
452
- return readString
682
+ return read_string
453
683
  else
454
684
  raise InternalError, 'Unexpected flag byte for Optionalstring'
455
685
  end
456
686
  end
457
687
 
688
+
689
+ # The Optional<T> type for Sequenceu8.
690
+
691
+ def read_OptionalSequenceu8
692
+ flag = unpack_from 1, 'c'
693
+
694
+ if flag == 0
695
+ return nil
696
+ elsif flag == 1
697
+ return read_Sequenceu8
698
+ else
699
+ raise InternalError, 'Unexpected flag byte for OptionalSequenceu8'
700
+ end
701
+ end
702
+
703
+
704
+ # The Optional<T> type for SequenceTypeStaffNote.
705
+
706
+ def read_OptionalSequenceTypeStaffNote
707
+ flag = unpack_from 1, 'c'
708
+
709
+ if flag == 0
710
+ return nil
711
+ elsif flag == 1
712
+ return read_SequenceTypeStaffNote
713
+ else
714
+ raise InternalError, 'Unexpected flag byte for OptionalSequenceTypeStaffNote'
715
+ end
716
+ end
717
+
718
+ # The Sequence<T> type for u8.
719
+
720
+ def read_Sequenceu8
721
+ count = unpack_from 4, 'l>'
722
+
723
+ raise InternalError, 'Unexpected negative sequence length' if count.negative?
724
+
725
+ items = []
726
+
727
+ count.times do
728
+ items.append read_u8
729
+ end
730
+
731
+ items
732
+ end
733
+
458
734
  # The Sequence<T> type for string.
459
735
 
460
- def readSequencestring
736
+ def read_Sequencestring
737
+ count = unpack_from 4, 'l>'
738
+
739
+ raise InternalError, 'Unexpected negative sequence length' if count.negative?
740
+
741
+ items = []
742
+
743
+ count.times do
744
+ items.append read_string
745
+ end
746
+
747
+ items
748
+ end
749
+
750
+ # The Sequence<T> type for TypeChordDefine.
751
+
752
+ def read_SequenceTypeChordDefine
753
+ count = unpack_from 4, 'l>'
754
+
755
+ raise InternalError, 'Unexpected negative sequence length' if count.negative?
756
+
757
+ items = []
758
+
759
+ count.times do
760
+ items.append read_TypeChordDefine
761
+ end
762
+
763
+ items
764
+ end
765
+
766
+ # The Sequence<T> type for TypeStaffNote.
767
+
768
+ def read_SequenceTypeStaffNote
461
769
  count = unpack_from 4, 'l>'
462
770
 
463
771
  raise InternalError, 'Unexpected negative sequence length' if count.negative?
@@ -465,7 +773,7 @@ class RustBufferStream
465
773
  items = []
466
774
 
467
775
  count.times do
468
- items.append readString
776
+ items.append read_TypeStaffNote
469
777
  end
470
778
 
471
779
  items
@@ -473,7 +781,7 @@ class RustBufferStream
473
781
 
474
782
  # The Sequence<T> type for TypeValidationError.
475
783
 
476
- def readSequenceTypeValidationError
784
+ def read_SequenceTypeValidationError
477
785
  count = unpack_from 4, 'l>'
478
786
 
479
787
  raise InternalError, 'Unexpected negative sequence length' if count.negative?
@@ -481,7 +789,7 @@ class RustBufferStream
481
789
  items = []
482
790
 
483
791
  count.times do
484
- items.append readTypeValidationError
792
+ items.append read_TypeValidationError
485
793
  end
486
794
 
487
795
  items
@@ -533,57 +841,96 @@ class RustBufferBuilder
533
841
  end
534
842
  end
535
843
 
536
- def write_I8(v)
537
- v = Chordsketch::uniffi_in_range(v, "i8", -2**7, 2**7)
844
+ def write_u8(v)
845
+ v = ::Chordsketch::uniffi_in_range(v, "u8", 0, 2**8)
538
846
  pack_into(1, 'c', v)
539
847
  end
540
848
 
541
- def write_U32(v)
542
- v = Chordsketch::uniffi_in_range(v, "u32", 0, 2**32)
849
+ def write_i8(v)
850
+ v = ::Chordsketch::uniffi_in_range(v, "i8", -2**7, 2**7)
851
+ pack_into(1, 'c', v)
852
+ end
853
+
854
+ def write_u32(v)
855
+ v = ::Chordsketch::uniffi_in_range(v, "u32", 0, 2**32)
543
856
  pack_into(4, 'L>', v)
544
857
  end
545
858
 
546
- def write_String(v)
547
- v = Chordsketch::uniffi_utf8(v)
859
+ def write_string(v)
860
+ v = ::Chordsketch::uniffi_utf8(v)
548
861
  pack_into 4, 'l>', v.bytes.size
549
862
  write v
550
863
  end
551
864
 
552
- def write_Bytes(v)
553
- v = Chordsketch::uniffi_bytes(v)
865
+ def write_bytes(v)
866
+ v = ::Chordsketch::uniffi_bytes(v)
554
867
  pack_into 4, 'l>', v.bytes.size
555
868
  write v
556
869
  end
557
870
 
871
+ # The Record type ChordDefine.
872
+
873
+ def write_TypeChordDefine(v)
874
+ self.write_string(v.name)
875
+ self.write_string(v.raw)
876
+ end
877
+
558
878
  # The Record type ConversionWithWarnings.
559
879
 
560
880
  def write_TypeConversionWithWarnings(v)
561
- self.write_String(v.output)
881
+ self.write_string(v.output)
562
882
  self.write_Sequencestring(v.warnings)
563
883
  end
564
884
 
565
885
  # The Record type PdfRenderWithWarnings.
566
886
 
567
887
  def write_TypePdfRenderWithWarnings(v)
568
- self.write_Bytes(v.output)
888
+ self.write_bytes(v.output)
569
889
  self.write_Sequencestring(v.warnings)
570
890
  end
571
891
 
892
+ # The Record type StaffNote.
893
+
894
+ def write_TypeStaffNote(v)
895
+ self.write_string(v.letter)
896
+ self.write_i8(v.accidental)
897
+ self.write_i8(v.octave)
898
+ self.write_u8(v.midi)
899
+ end
900
+
572
901
  # The Record type TextRenderWithWarnings.
573
902
 
574
903
  def write_TypeTextRenderWithWarnings(v)
575
- self.write_String(v.output)
904
+ self.write_string(v.output)
576
905
  self.write_Sequencestring(v.warnings)
577
906
  end
578
907
 
579
908
  # The Record type ValidationError.
580
909
 
581
910
  def write_TypeValidationError(v)
582
- self.write_U32(v.line)
583
- self.write_U32(v.column)
584
- self.write_String(v.message)
911
+ self.write_u32(v.line)
912
+ self.write_u32(v.column)
913
+ self.write_string(v.message)
585
914
  end
586
915
 
916
+ # The Error type ChordSketchError - write for callback error returns.
917
+
918
+ def write_TypeChordSketchError(v)
919
+ if v.is_a?(ChordSketchError::NoSongsFound)
920
+ pack_into 4, 'l>', 1
921
+ return
922
+ end
923
+ if v.is_a?(ChordSketchError::InvalidConfig)
924
+ pack_into 4, 'l>', 2
925
+ self.write_string(v.reason)
926
+ return
927
+ end
928
+ if v.is_a?(ChordSketchError::ConversionFailed)
929
+ pack_into 4, 'l>', 3
930
+ self.write_string(v.reason)
931
+ return
932
+ end
933
+ end
587
934
 
588
935
 
589
936
  # The Optional<T> type for i8.
@@ -593,7 +940,7 @@ class RustBufferBuilder
593
940
  pack_into(1, 'c', 0)
594
941
  else
595
942
  pack_into(1, 'c', 1)
596
- self.write_I8(v)
943
+ self.write_i8(v)
597
944
  end
598
945
  end
599
946
 
@@ -604,7 +951,39 @@ class RustBufferBuilder
604
951
  pack_into(1, 'c', 0)
605
952
  else
606
953
  pack_into(1, 'c', 1)
607
- self.write_String(v)
954
+ self.write_string(v)
955
+ end
956
+ end
957
+
958
+ # The Optional<T> type for Sequenceu8.
959
+
960
+ def write_OptionalSequenceu8(v)
961
+ if v.nil?
962
+ pack_into(1, 'c', 0)
963
+ else
964
+ pack_into(1, 'c', 1)
965
+ self.write_Sequenceu8(v)
966
+ end
967
+ end
968
+
969
+ # The Optional<T> type for SequenceTypeStaffNote.
970
+
971
+ def write_OptionalSequenceTypeStaffNote(v)
972
+ if v.nil?
973
+ pack_into(1, 'c', 0)
974
+ else
975
+ pack_into(1, 'c', 1)
976
+ self.write_SequenceTypeStaffNote(v)
977
+ end
978
+ end
979
+
980
+ # The Sequence<T> type for u8.
981
+
982
+ def write_Sequenceu8(items)
983
+ pack_into(4, 'l>', items.size)
984
+
985
+ items.each do |item|
986
+ self.write_u8(item)
608
987
  end
609
988
  end
610
989
 
@@ -614,7 +993,27 @@ class RustBufferBuilder
614
993
  pack_into(4, 'l>', items.size)
615
994
 
616
995
  items.each do |item|
617
- self.write_String(item)
996
+ self.write_string(item)
997
+ end
998
+ end
999
+
1000
+ # The Sequence<T> type for TypeChordDefine.
1001
+
1002
+ def write_SequenceTypeChordDefine(items)
1003
+ pack_into(4, 'l>', items.size)
1004
+
1005
+ items.each do |item|
1006
+ self.write_TypeChordDefine(item)
1007
+ end
1008
+ end
1009
+
1010
+ # The Sequence<T> type for TypeStaffNote.
1011
+
1012
+ def write_SequenceTypeStaffNote(items)
1013
+ pack_into(4, 'l>', items.size)
1014
+
1015
+ items.each do |item|
1016
+ self.write_TypeStaffNote(item)
618
1017
  end
619
1018
  end
620
1019
 
@@ -678,37 +1077,48 @@ CALL_PANIC = 2
678
1077
  module ChordSketchError
679
1078
  class NoSongsFound < StandardError
680
1079
  def initialize()
1080
+
681
1081
  super()
682
- end
1082
+ end
1083
+
683
1084
 
684
1085
  def to_s
685
- "#{self.class.name}()"
1086
+ "#{self.class.name}()"
1087
+
686
1088
  end
687
1089
  end
688
1090
  class InvalidConfig < StandardError
689
- def initialize(reason)
1091
+ def initialize(reason:)
1092
+
690
1093
  @reason = reason
1094
+
691
1095
  super()
692
- end
1096
+ end
1097
+
693
1098
 
694
1099
  attr_reader :reason
695
1100
 
696
1101
 
697
1102
  def to_s
698
- "#{self.class.name}(reason=#{@reason.inspect})"
1103
+ "#{self.class.name}(reason=#{@reason.inspect})"
1104
+
699
1105
  end
700
1106
  end
701
1107
  class ConversionFailed < StandardError
702
- def initialize(reason)
1108
+ def initialize(reason:)
1109
+
703
1110
  @reason = reason
1111
+
704
1112
  super()
705
- end
1113
+ end
1114
+
706
1115
 
707
1116
  attr_reader :reason
708
1117
 
709
1118
 
710
1119
  def to_s
711
- "#{self.class.name}(reason=#{@reason.inspect})"
1120
+ "#{self.class.name}(reason=#{@reason.inspect})"
1121
+
712
1122
  end
713
1123
  end
714
1124
 
@@ -717,9 +1127,7 @@ end
717
1127
 
718
1128
  # Map error modules to the RustBuffer method name that reads them
719
1129
  ERROR_MODULE_TO_READER_METHOD = {
720
-
721
- ChordSketchError => :readTypeChordSketchError,
722
-
1130
+ ChordSketchError => :read_TypeChordSketchError,
723
1131
  }
724
1132
 
725
1133
  private_constant :ERROR_MODULE_TO_READER_METHOD, :CALL_SUCCESS, :CALL_ERROR, :CALL_PANIC,
@@ -727,7 +1135,8 @@ private_constant :ERROR_MODULE_TO_READER_METHOD, :CALL_SUCCESS, :CALL_ERROR, :CA
727
1135
 
728
1136
  def self.consume_buffer_into_error(error_module, rust_buffer)
729
1137
  rust_buffer.consumeWithStream do |stream|
730
- reader_method = ERROR_MODULE_TO_READER_METHOD[error_module]
1138
+ reader_method = ERROR_MODULE_TO_READER_METHOD[error_module] ||
1139
+ ERROR_MODULE_TO_READER_METHOD[error_module.name&.split('::')&.last]
731
1140
  return stream.send(reader_method)
732
1141
  end
733
1142
  end
@@ -769,7 +1178,7 @@ def self.rust_call_with_error(error_module, fn_name, *args)
769
1178
  # with the message. But if that code panics, then it just sends back
770
1179
  # an empty buffer.
771
1180
  if status.error_buf.len > 0
772
- raise InternalError, status.error_buf.consumeIntoString()
1181
+ raise InternalError, status.error_buf.consume_into_string
773
1182
  else
774
1183
  raise InternalError, "Rust panic"
775
1184
  end
@@ -789,148 +1198,628 @@ module UniFFILib
789
1198
  ffi_lib Chordsketch::NATIVE_LIB_PATH
790
1199
 
791
1200
 
792
- attach_function :uniffi_chordsketch_ffi_fn_func_chord_diagram_svg,
793
- [RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
1201
+ # Define FFI callback types and structs (vtables, etc.)
1202
+
1203
+ callback :RustFutureContinuationCallback,
1204
+ [:uint64, :int8, ],
1205
+ :void
1206
+
1207
+ callback :ForeignFutureDroppedCallback,
1208
+ [:uint64, ],
1209
+ :void
1210
+
1211
+ callback :CallbackInterfaceFree,
1212
+ [:uint64, ],
1213
+ :void
1214
+
1215
+ callback :CallbackInterfaceClone,
1216
+ [:uint64, ],
1217
+ :uint64
1218
+
1219
+ class ForeignFutureDroppedCallbackStruct < FFI::Struct
1220
+ layout(
1221
+ :handle, :uint64,
1222
+ :free, :ForeignFutureDroppedCallback
1223
+ )
1224
+ end
1225
+
1226
+ class ForeignFutureResultU8 < FFI::Struct
1227
+ layout(
1228
+ :return_value, :uint8,
1229
+ :call_status, RustCallStatus
1230
+ )
1231
+ end
1232
+
1233
+ callback :ForeignFutureCompleteU8,
1234
+ [:uint64, ForeignFutureResultU8.by_value, ],
1235
+ :void
1236
+
1237
+ class ForeignFutureResultI8 < FFI::Struct
1238
+ layout(
1239
+ :return_value, :int8,
1240
+ :call_status, RustCallStatus
1241
+ )
1242
+ end
1243
+
1244
+ callback :ForeignFutureCompleteI8,
1245
+ [:uint64, ForeignFutureResultI8.by_value, ],
1246
+ :void
1247
+
1248
+ class ForeignFutureResultU16 < FFI::Struct
1249
+ layout(
1250
+ :return_value, :uint16,
1251
+ :call_status, RustCallStatus
1252
+ )
1253
+ end
1254
+
1255
+ callback :ForeignFutureCompleteU16,
1256
+ [:uint64, ForeignFutureResultU16.by_value, ],
1257
+ :void
1258
+
1259
+ class ForeignFutureResultI16 < FFI::Struct
1260
+ layout(
1261
+ :return_value, :int16,
1262
+ :call_status, RustCallStatus
1263
+ )
1264
+ end
1265
+
1266
+ callback :ForeignFutureCompleteI16,
1267
+ [:uint64, ForeignFutureResultI16.by_value, ],
1268
+ :void
1269
+
1270
+ class ForeignFutureResultU32 < FFI::Struct
1271
+ layout(
1272
+ :return_value, :uint32,
1273
+ :call_status, RustCallStatus
1274
+ )
1275
+ end
1276
+
1277
+ callback :ForeignFutureCompleteU32,
1278
+ [:uint64, ForeignFutureResultU32.by_value, ],
1279
+ :void
1280
+
1281
+ class ForeignFutureResultI32 < FFI::Struct
1282
+ layout(
1283
+ :return_value, :int32,
1284
+ :call_status, RustCallStatus
1285
+ )
1286
+ end
1287
+
1288
+ callback :ForeignFutureCompleteI32,
1289
+ [:uint64, ForeignFutureResultI32.by_value, ],
1290
+ :void
1291
+
1292
+ class ForeignFutureResultU64 < FFI::Struct
1293
+ layout(
1294
+ :return_value, :uint64,
1295
+ :call_status, RustCallStatus
1296
+ )
1297
+ end
1298
+
1299
+ callback :ForeignFutureCompleteU64,
1300
+ [:uint64, ForeignFutureResultU64.by_value, ],
1301
+ :void
1302
+
1303
+ class ForeignFutureResultI64 < FFI::Struct
1304
+ layout(
1305
+ :return_value, :int64,
1306
+ :call_status, RustCallStatus
1307
+ )
1308
+ end
1309
+
1310
+ callback :ForeignFutureCompleteI64,
1311
+ [:uint64, ForeignFutureResultI64.by_value, ],
1312
+ :void
1313
+
1314
+ class ForeignFutureResultF32 < FFI::Struct
1315
+ layout(
1316
+ :return_value, :float,
1317
+ :call_status, RustCallStatus
1318
+ )
1319
+ end
1320
+
1321
+ callback :ForeignFutureCompleteF32,
1322
+ [:uint64, ForeignFutureResultF32.by_value, ],
1323
+ :void
1324
+
1325
+ class ForeignFutureResultF64 < FFI::Struct
1326
+ layout(
1327
+ :return_value, :double,
1328
+ :call_status, RustCallStatus
1329
+ )
1330
+ end
1331
+
1332
+ callback :ForeignFutureCompleteF64,
1333
+ [:uint64, ForeignFutureResultF64.by_value, ],
1334
+ :void
1335
+
1336
+ class ForeignFutureResultRustBuffer < FFI::Struct
1337
+ layout(
1338
+ :return_value, RustBuffer.by_value,
1339
+ :call_status, RustCallStatus
1340
+ )
1341
+ end
1342
+
1343
+ callback :ForeignFutureCompleteRustBuffer,
1344
+ [:uint64, ForeignFutureResultRustBuffer.by_value, ],
1345
+ :void
1346
+
1347
+ class ForeignFutureResultVoid < FFI::Struct
1348
+ layout(
1349
+ :call_status, RustCallStatus
1350
+ )
1351
+ end
1352
+
1353
+ callback :ForeignFutureCompleteVoid,
1354
+ [:uint64, ForeignFutureResultVoid.by_value, ],
1355
+ :void
1356
+
1357
+ attach_function :uniffi_chordsketch_ffi_fn_func_chord_diagram_svg,
1358
+ [RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
794
1359
  RustBuffer.by_value
1360
+
1361
+ attach_function :uniffi_chordsketch_ffi_fn_func_chord_diagram_svg_with_defines,
1362
+ [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
1363
+ RustBuffer.by_value
1364
+
1365
+ attach_function :uniffi_chordsketch_ffi_fn_func_chord_diagram_svg_with_defines_orientation,
1366
+ [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
1367
+ RustBuffer.by_value
1368
+
1369
+ attach_function :uniffi_chordsketch_ffi_fn_func_chord_diagram_svg_with_orientation,
1370
+ [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
1371
+ RustBuffer.by_value
1372
+
1373
+ attach_function :uniffi_chordsketch_ffi_fn_func_chord_pitches,
1374
+ [RustBuffer.by_value, RustCallStatus.by_ref],
1375
+ RustBuffer.by_value
1376
+
1377
+ attach_function :uniffi_chordsketch_ffi_fn_func_chord_staff_notes,
1378
+ [RustBuffer.by_value, RustCallStatus.by_ref],
1379
+ RustBuffer.by_value
1380
+
795
1381
  attach_function :uniffi_chordsketch_ffi_fn_func_convert_chordpro_to_irealb,
796
1382
  [RustBuffer.by_value, RustCallStatus.by_ref],
797
1383
  RustBuffer.by_value
1384
+
798
1385
  attach_function :uniffi_chordsketch_ffi_fn_func_convert_irealb_to_chordpro_text,
799
1386
  [RustBuffer.by_value, RustCallStatus.by_ref],
800
1387
  RustBuffer.by_value
1388
+
1389
+ attach_function :uniffi_chordsketch_ffi_fn_func_diagram_pitches,
1390
+ [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
1391
+ RustBuffer.by_value
1392
+
1393
+ attach_function :uniffi_chordsketch_ffi_fn_func_key_scale_pitches,
1394
+ [RustBuffer.by_value, RustCallStatus.by_ref],
1395
+ RustBuffer.by_value
1396
+
1397
+ attach_function :uniffi_chordsketch_ffi_fn_func_key_tonic_triad,
1398
+ [RustBuffer.by_value, RustCallStatus.by_ref],
1399
+ RustBuffer.by_value
1400
+
801
1401
  attach_function :uniffi_chordsketch_ffi_fn_func_parse_and_render_html,
802
1402
  [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
803
1403
  RustBuffer.by_value
1404
+
804
1405
  attach_function :uniffi_chordsketch_ffi_fn_func_parse_and_render_html_body,
805
1406
  [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
806
1407
  RustBuffer.by_value
1408
+
807
1409
  attach_function :uniffi_chordsketch_ffi_fn_func_parse_and_render_html_body_with_warnings,
808
1410
  [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
809
1411
  RustBuffer.by_value
1412
+
810
1413
  attach_function :uniffi_chordsketch_ffi_fn_func_parse_and_render_html_with_warnings,
811
1414
  [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
812
1415
  RustBuffer.by_value
1416
+
813
1417
  attach_function :uniffi_chordsketch_ffi_fn_func_parse_and_render_pdf,
814
1418
  [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
815
1419
  RustBuffer.by_value
1420
+
816
1421
  attach_function :uniffi_chordsketch_ffi_fn_func_parse_and_render_pdf_with_warnings,
817
1422
  [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
818
1423
  RustBuffer.by_value
1424
+
819
1425
  attach_function :uniffi_chordsketch_ffi_fn_func_parse_and_render_text,
820
1426
  [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
821
1427
  RustBuffer.by_value
1428
+
822
1429
  attach_function :uniffi_chordsketch_ffi_fn_func_parse_and_render_text_with_warnings,
823
1430
  [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
824
1431
  RustBuffer.by_value
1432
+
825
1433
  attach_function :uniffi_chordsketch_ffi_fn_func_parse_irealb,
826
1434
  [RustBuffer.by_value, RustCallStatus.by_ref],
827
1435
  RustBuffer.by_value
1436
+
828
1437
  attach_function :uniffi_chordsketch_ffi_fn_func_render_html_css,
829
1438
  [RustCallStatus.by_ref],
830
1439
  RustBuffer.by_value
1440
+
831
1441
  attach_function :uniffi_chordsketch_ffi_fn_func_render_html_css_with_config_json,
832
1442
  [RustBuffer.by_value, RustCallStatus.by_ref],
833
1443
  RustBuffer.by_value
1444
+
834
1445
  attach_function :uniffi_chordsketch_ffi_fn_func_render_ireal_pdf,
835
1446
  [RustBuffer.by_value, RustCallStatus.by_ref],
836
1447
  RustBuffer.by_value
1448
+
837
1449
  attach_function :uniffi_chordsketch_ffi_fn_func_render_ireal_png,
838
1450
  [RustBuffer.by_value, RustCallStatus.by_ref],
839
1451
  RustBuffer.by_value
1452
+
840
1453
  attach_function :uniffi_chordsketch_ffi_fn_func_render_ireal_svg,
841
1454
  [RustBuffer.by_value, RustCallStatus.by_ref],
842
1455
  RustBuffer.by_value
1456
+
843
1457
  attach_function :uniffi_chordsketch_ffi_fn_func_serialize_irealb,
844
1458
  [RustBuffer.by_value, RustCallStatus.by_ref],
845
1459
  RustBuffer.by_value
1460
+
846
1461
  attach_function :uniffi_chordsketch_ffi_fn_func_validate,
847
1462
  [RustBuffer.by_value, RustCallStatus.by_ref],
848
1463
  RustBuffer.by_value
1464
+
849
1465
  attach_function :uniffi_chordsketch_ffi_fn_func_version,
850
1466
  [RustCallStatus.by_ref],
851
1467
  RustBuffer.by_value
1468
+
852
1469
  attach_function :ffi_chordsketch_ffi_rustbuffer_alloc,
853
1470
  [:uint64, RustCallStatus.by_ref],
854
1471
  RustBuffer.by_value
1472
+
855
1473
  attach_function :ffi_chordsketch_ffi_rustbuffer_from_bytes,
856
1474
  [ForeignBytes, RustCallStatus.by_ref],
857
1475
  RustBuffer.by_value
1476
+
858
1477
  attach_function :ffi_chordsketch_ffi_rustbuffer_free,
859
1478
  [RustBuffer.by_value, RustCallStatus.by_ref],
860
1479
  :void
1480
+
861
1481
  attach_function :ffi_chordsketch_ffi_rustbuffer_reserve,
862
1482
  [RustBuffer.by_value, :uint64, RustCallStatus.by_ref],
863
1483
  RustBuffer.by_value
1484
+
1485
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_u8,
1486
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1487
+ :void
1488
+
1489
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_u8,
1490
+ [:uint64, ],
1491
+ :void
1492
+
1493
+ attach_function :ffi_chordsketch_ffi_rust_future_free_u8,
1494
+ [:uint64, ],
1495
+ :void
1496
+
1497
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_u8,
1498
+ [:uint64, RustCallStatus.by_ref],
1499
+ :uint8
1500
+
1501
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_i8,
1502
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1503
+ :void
1504
+
1505
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_i8,
1506
+ [:uint64, ],
1507
+ :void
1508
+
1509
+ attach_function :ffi_chordsketch_ffi_rust_future_free_i8,
1510
+ [:uint64, ],
1511
+ :void
1512
+
1513
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_i8,
1514
+ [:uint64, RustCallStatus.by_ref],
1515
+ :int8
1516
+
1517
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_u16,
1518
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1519
+ :void
1520
+
1521
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_u16,
1522
+ [:uint64, ],
1523
+ :void
1524
+
1525
+ attach_function :ffi_chordsketch_ffi_rust_future_free_u16,
1526
+ [:uint64, ],
1527
+ :void
1528
+
1529
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_u16,
1530
+ [:uint64, RustCallStatus.by_ref],
1531
+ :uint16
1532
+
1533
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_i16,
1534
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1535
+ :void
1536
+
1537
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_i16,
1538
+ [:uint64, ],
1539
+ :void
1540
+
1541
+ attach_function :ffi_chordsketch_ffi_rust_future_free_i16,
1542
+ [:uint64, ],
1543
+ :void
1544
+
1545
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_i16,
1546
+ [:uint64, RustCallStatus.by_ref],
1547
+ :int16
1548
+
1549
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_u32,
1550
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1551
+ :void
1552
+
1553
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_u32,
1554
+ [:uint64, ],
1555
+ :void
1556
+
1557
+ attach_function :ffi_chordsketch_ffi_rust_future_free_u32,
1558
+ [:uint64, ],
1559
+ :void
1560
+
1561
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_u32,
1562
+ [:uint64, RustCallStatus.by_ref],
1563
+ :uint32
1564
+
1565
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_i32,
1566
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1567
+ :void
1568
+
1569
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_i32,
1570
+ [:uint64, ],
1571
+ :void
1572
+
1573
+ attach_function :ffi_chordsketch_ffi_rust_future_free_i32,
1574
+ [:uint64, ],
1575
+ :void
1576
+
1577
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_i32,
1578
+ [:uint64, RustCallStatus.by_ref],
1579
+ :int32
1580
+
1581
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_u64,
1582
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1583
+ :void
1584
+
1585
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_u64,
1586
+ [:uint64, ],
1587
+ :void
1588
+
1589
+ attach_function :ffi_chordsketch_ffi_rust_future_free_u64,
1590
+ [:uint64, ],
1591
+ :void
1592
+
1593
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_u64,
1594
+ [:uint64, RustCallStatus.by_ref],
1595
+ :uint64
1596
+
1597
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_i64,
1598
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1599
+ :void
1600
+
1601
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_i64,
1602
+ [:uint64, ],
1603
+ :void
1604
+
1605
+ attach_function :ffi_chordsketch_ffi_rust_future_free_i64,
1606
+ [:uint64, ],
1607
+ :void
1608
+
1609
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_i64,
1610
+ [:uint64, RustCallStatus.by_ref],
1611
+ :int64
1612
+
1613
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_f32,
1614
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1615
+ :void
1616
+
1617
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_f32,
1618
+ [:uint64, ],
1619
+ :void
1620
+
1621
+ attach_function :ffi_chordsketch_ffi_rust_future_free_f32,
1622
+ [:uint64, ],
1623
+ :void
1624
+
1625
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_f32,
1626
+ [:uint64, RustCallStatus.by_ref],
1627
+ :float
1628
+
1629
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_f64,
1630
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1631
+ :void
1632
+
1633
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_f64,
1634
+ [:uint64, ],
1635
+ :void
1636
+
1637
+ attach_function :ffi_chordsketch_ffi_rust_future_free_f64,
1638
+ [:uint64, ],
1639
+ :void
1640
+
1641
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_f64,
1642
+ [:uint64, RustCallStatus.by_ref],
1643
+ :double
1644
+
1645
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_rust_buffer,
1646
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1647
+ :void
1648
+
1649
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_rust_buffer,
1650
+ [:uint64, ],
1651
+ :void
1652
+
1653
+ attach_function :ffi_chordsketch_ffi_rust_future_free_rust_buffer,
1654
+ [:uint64, ],
1655
+ :void
1656
+
1657
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_rust_buffer,
1658
+ [:uint64, RustCallStatus.by_ref],
1659
+ RustBuffer.by_value
1660
+
1661
+ attach_function :ffi_chordsketch_ffi_rust_future_poll_void,
1662
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1663
+ :void
1664
+
1665
+ attach_function :ffi_chordsketch_ffi_rust_future_cancel_void,
1666
+ [:uint64, ],
1667
+ :void
1668
+
1669
+ attach_function :ffi_chordsketch_ffi_rust_future_free_void,
1670
+ [:uint64, ],
1671
+ :void
1672
+
1673
+ attach_function :ffi_chordsketch_ffi_rust_future_complete_void,
1674
+ [:uint64, RustCallStatus.by_ref],
1675
+ :void
1676
+
864
1677
  attach_function :uniffi_chordsketch_ffi_checksum_func_chord_diagram_svg,
865
- [RustCallStatus.by_ref],
1678
+ [],
866
1679
  :uint16
1680
+
1681
+ attach_function :uniffi_chordsketch_ffi_checksum_func_chord_diagram_svg_with_defines,
1682
+ [],
1683
+ :uint16
1684
+
1685
+ attach_function :uniffi_chordsketch_ffi_checksum_func_chord_diagram_svg_with_defines_orientation,
1686
+ [],
1687
+ :uint16
1688
+
1689
+ attach_function :uniffi_chordsketch_ffi_checksum_func_chord_diagram_svg_with_orientation,
1690
+ [],
1691
+ :uint16
1692
+
1693
+ attach_function :uniffi_chordsketch_ffi_checksum_func_chord_pitches,
1694
+ [],
1695
+ :uint16
1696
+
1697
+ attach_function :uniffi_chordsketch_ffi_checksum_func_chord_staff_notes,
1698
+ [],
1699
+ :uint16
1700
+
867
1701
  attach_function :uniffi_chordsketch_ffi_checksum_func_convert_chordpro_to_irealb,
868
- [RustCallStatus.by_ref],
1702
+ [],
869
1703
  :uint16
1704
+
870
1705
  attach_function :uniffi_chordsketch_ffi_checksum_func_convert_irealb_to_chordpro_text,
871
- [RustCallStatus.by_ref],
1706
+ [],
1707
+ :uint16
1708
+
1709
+ attach_function :uniffi_chordsketch_ffi_checksum_func_diagram_pitches,
1710
+ [],
1711
+ :uint16
1712
+
1713
+ attach_function :uniffi_chordsketch_ffi_checksum_func_key_scale_pitches,
1714
+ [],
1715
+ :uint16
1716
+
1717
+ attach_function :uniffi_chordsketch_ffi_checksum_func_key_tonic_triad,
1718
+ [],
872
1719
  :uint16
1720
+
873
1721
  attach_function :uniffi_chordsketch_ffi_checksum_func_parse_and_render_html,
874
- [RustCallStatus.by_ref],
1722
+ [],
875
1723
  :uint16
1724
+
876
1725
  attach_function :uniffi_chordsketch_ffi_checksum_func_parse_and_render_html_body,
877
- [RustCallStatus.by_ref],
1726
+ [],
878
1727
  :uint16
1728
+
879
1729
  attach_function :uniffi_chordsketch_ffi_checksum_func_parse_and_render_html_body_with_warnings,
880
- [RustCallStatus.by_ref],
1730
+ [],
881
1731
  :uint16
1732
+
882
1733
  attach_function :uniffi_chordsketch_ffi_checksum_func_parse_and_render_html_with_warnings,
883
- [RustCallStatus.by_ref],
1734
+ [],
884
1735
  :uint16
1736
+
885
1737
  attach_function :uniffi_chordsketch_ffi_checksum_func_parse_and_render_pdf,
886
- [RustCallStatus.by_ref],
1738
+ [],
887
1739
  :uint16
1740
+
888
1741
  attach_function :uniffi_chordsketch_ffi_checksum_func_parse_and_render_pdf_with_warnings,
889
- [RustCallStatus.by_ref],
1742
+ [],
890
1743
  :uint16
1744
+
891
1745
  attach_function :uniffi_chordsketch_ffi_checksum_func_parse_and_render_text,
892
- [RustCallStatus.by_ref],
1746
+ [],
893
1747
  :uint16
1748
+
894
1749
  attach_function :uniffi_chordsketch_ffi_checksum_func_parse_and_render_text_with_warnings,
895
- [RustCallStatus.by_ref],
1750
+ [],
896
1751
  :uint16
1752
+
897
1753
  attach_function :uniffi_chordsketch_ffi_checksum_func_parse_irealb,
898
- [RustCallStatus.by_ref],
1754
+ [],
899
1755
  :uint16
1756
+
900
1757
  attach_function :uniffi_chordsketch_ffi_checksum_func_render_html_css,
901
- [RustCallStatus.by_ref],
1758
+ [],
902
1759
  :uint16
1760
+
903
1761
  attach_function :uniffi_chordsketch_ffi_checksum_func_render_html_css_with_config_json,
904
- [RustCallStatus.by_ref],
1762
+ [],
905
1763
  :uint16
1764
+
906
1765
  attach_function :uniffi_chordsketch_ffi_checksum_func_render_ireal_pdf,
907
- [RustCallStatus.by_ref],
1766
+ [],
908
1767
  :uint16
1768
+
909
1769
  attach_function :uniffi_chordsketch_ffi_checksum_func_render_ireal_png,
910
- [RustCallStatus.by_ref],
1770
+ [],
911
1771
  :uint16
1772
+
912
1773
  attach_function :uniffi_chordsketch_ffi_checksum_func_render_ireal_svg,
913
- [RustCallStatus.by_ref],
1774
+ [],
914
1775
  :uint16
1776
+
915
1777
  attach_function :uniffi_chordsketch_ffi_checksum_func_serialize_irealb,
916
- [RustCallStatus.by_ref],
1778
+ [],
917
1779
  :uint16
1780
+
918
1781
  attach_function :uniffi_chordsketch_ffi_checksum_func_validate,
919
- [RustCallStatus.by_ref],
1782
+ [],
920
1783
  :uint16
1784
+
921
1785
  attach_function :uniffi_chordsketch_ffi_checksum_func_version,
922
- [RustCallStatus.by_ref],
1786
+ [],
923
1787
  :uint16
1788
+
924
1789
  attach_function :ffi_chordsketch_ffi_uniffi_contract_version,
925
- [RustCallStatus.by_ref],
1790
+ [],
926
1791
  :uint32
927
1792
 
928
1793
  end
929
1794
 
1795
+ # Custom type definitions.
1796
+
930
1797
  # Public interface members begin here.
931
1798
 
932
1799
 
933
1800
 
1801
+ # Record type ChordDefine
1802
+ class ChordDefine
1803
+ attr_reader :name, :raw
1804
+
1805
+ def initialize(name:, raw:)
1806
+ @name = name
1807
+ @raw = raw
1808
+ end
1809
+
1810
+ def ==(other)
1811
+ if @name != other.name
1812
+ return false
1813
+ end
1814
+ if @raw != other.raw
1815
+ return false
1816
+ end
1817
+
1818
+ true
1819
+ end
1820
+
1821
+ end
1822
+
934
1823
  # Record type ConversionWithWarnings
935
1824
  class ConversionWithWarnings
936
1825
  attr_reader :output, :warnings
@@ -950,6 +1839,7 @@ class ConversionWithWarnings
950
1839
 
951
1840
  true
952
1841
  end
1842
+
953
1843
  end
954
1844
 
955
1845
  # Record type PdfRenderWithWarnings
@@ -971,6 +1861,37 @@ class PdfRenderWithWarnings
971
1861
 
972
1862
  true
973
1863
  end
1864
+
1865
+ end
1866
+
1867
+ # Record type StaffNote
1868
+ class StaffNote
1869
+ attr_reader :letter, :accidental, :octave, :midi
1870
+
1871
+ def initialize(letter:, accidental:, octave:, midi:)
1872
+ @letter = letter
1873
+ @accidental = accidental
1874
+ @octave = octave
1875
+ @midi = midi
1876
+ end
1877
+
1878
+ def ==(other)
1879
+ if @letter != other.letter
1880
+ return false
1881
+ end
1882
+ if @accidental != other.accidental
1883
+ return false
1884
+ end
1885
+ if @octave != other.octave
1886
+ return false
1887
+ end
1888
+ if @midi != other.midi
1889
+ return false
1890
+ end
1891
+
1892
+ true
1893
+ end
1894
+
974
1895
  end
975
1896
 
976
1897
  # Record type TextRenderWithWarnings
@@ -992,6 +1913,7 @@ class TextRenderWithWarnings
992
1913
 
993
1914
  true
994
1915
  end
1916
+
995
1917
  end
996
1918
 
997
1919
  # Record type ValidationError
@@ -1017,6 +1939,7 @@ class ValidationError
1017
1939
 
1018
1940
  true
1019
1941
  end
1942
+
1020
1943
  end
1021
1944
 
1022
1945
 
@@ -1024,14 +1947,95 @@ end
1024
1947
 
1025
1948
 
1026
1949
  def self.chord_diagram_svg(chord, instrument)
1027
- chord = Chordsketch::uniffi_utf8(chord)
1950
+ chord = ::Chordsketch::uniffi_utf8(chord)
1951
+
1952
+
1953
+ instrument = ::Chordsketch::uniffi_utf8(instrument)
1954
+
1955
+
1956
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_chord_diagram_svg,RustBuffer.alloc_from_string(chord),RustBuffer.alloc_from_string(instrument))
1957
+ return result.consume_into_Optionalstring
1958
+ end
1959
+
1960
+
1961
+
1962
+
1963
+
1964
+ def self.chord_diagram_svg_with_defines(chord, instrument, defines)
1965
+ chord = ::Chordsketch::uniffi_utf8(chord)
1966
+
1967
+
1968
+ instrument = ::Chordsketch::uniffi_utf8(instrument)
1969
+
1970
+
1971
+ defines = defines
1972
+ RustBuffer.check_lower_SequenceTypeChordDefine(defines)
1973
+
1974
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_chord_diagram_svg_with_defines,RustBuffer.alloc_from_string(chord),RustBuffer.alloc_from_string(instrument),RustBuffer.alloc_from_SequenceTypeChordDefine(defines))
1975
+ return result.consume_into_Optionalstring
1976
+ end
1977
+
1978
+
1979
+
1980
+
1981
+
1982
+ def self.chord_diagram_svg_with_defines_orientation(chord, instrument, defines, orientation)
1983
+ chord = ::Chordsketch::uniffi_utf8(chord)
1984
+
1985
+
1986
+ instrument = ::Chordsketch::uniffi_utf8(instrument)
1987
+
1988
+
1989
+ defines = defines
1990
+ RustBuffer.check_lower_SequenceTypeChordDefine(defines)
1991
+
1992
+ orientation = (orientation ? ::Chordsketch::uniffi_utf8(orientation) : nil)
1993
+ RustBuffer.check_lower_Optionalstring(orientation)
1994
+
1995
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_chord_diagram_svg_with_defines_orientation,RustBuffer.alloc_from_string(chord),RustBuffer.alloc_from_string(instrument),RustBuffer.alloc_from_SequenceTypeChordDefine(defines),RustBuffer.alloc_from_Optionalstring(orientation))
1996
+ return result.consume_into_Optionalstring
1997
+ end
1998
+
1999
+
2000
+
2001
+
2002
+
2003
+ def self.chord_diagram_svg_with_orientation(chord, instrument, orientation)
2004
+ chord = ::Chordsketch::uniffi_utf8(chord)
2005
+
1028
2006
 
2007
+ instrument = ::Chordsketch::uniffi_utf8(instrument)
1029
2008
 
1030
- instrument = Chordsketch::uniffi_utf8(instrument)
1031
2009
 
2010
+ orientation = (orientation ? ::Chordsketch::uniffi_utf8(orientation) : nil)
2011
+ RustBuffer.check_lower_Optionalstring(orientation)
1032
2012
 
1033
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_chord_diagram_svg,RustBuffer.allocFromString(chord),RustBuffer.allocFromString(instrument))
1034
- return result.consumeIntoOptionalstring
2013
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_chord_diagram_svg_with_orientation,RustBuffer.alloc_from_string(chord),RustBuffer.alloc_from_string(instrument),RustBuffer.alloc_from_Optionalstring(orientation))
2014
+ return result.consume_into_Optionalstring
2015
+ end
2016
+
2017
+
2018
+
2019
+
2020
+
2021
+ def self.chord_pitches(chord)
2022
+ chord = ::Chordsketch::uniffi_utf8(chord)
2023
+
2024
+
2025
+ result = ::Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_chord_pitches,RustBuffer.alloc_from_string(chord))
2026
+ return result.consume_into_OptionalSequenceu8
2027
+ end
2028
+
2029
+
2030
+
2031
+
2032
+
2033
+ def self.chord_staff_notes(chord)
2034
+ chord = ::Chordsketch::uniffi_utf8(chord)
2035
+
2036
+
2037
+ result = ::Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_chord_staff_notes,RustBuffer.alloc_from_string(chord))
2038
+ return result.consume_into_OptionalSequenceTypeStaffNote
1035
2039
  end
1036
2040
 
1037
2041
 
@@ -1039,11 +2043,11 @@ end
1039
2043
 
1040
2044
 
1041
2045
  def self.convert_chordpro_to_irealb(input)
1042
- input = Chordsketch::uniffi_utf8(input)
2046
+ input = ::Chordsketch::uniffi_utf8(input)
1043
2047
 
1044
2048
 
1045
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_convert_chordpro_to_irealb,RustBuffer.allocFromString(input))
1046
- return result.consumeIntoTypeConversionWithWarnings
2049
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_convert_chordpro_to_irealb,RustBuffer.alloc_from_string(input))
2050
+ return result.consume_into_TypeConversionWithWarnings
1047
2051
  end
1048
2052
 
1049
2053
 
@@ -1051,11 +2055,53 @@ end
1051
2055
 
1052
2056
 
1053
2057
  def self.convert_irealb_to_chordpro_text(input)
1054
- input = Chordsketch::uniffi_utf8(input)
2058
+ input = ::Chordsketch::uniffi_utf8(input)
1055
2059
 
1056
2060
 
1057
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_convert_irealb_to_chordpro_text,RustBuffer.allocFromString(input))
1058
- return result.consumeIntoTypeConversionWithWarnings
2061
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_convert_irealb_to_chordpro_text,RustBuffer.alloc_from_string(input))
2062
+ return result.consume_into_TypeConversionWithWarnings
2063
+ end
2064
+
2065
+
2066
+
2067
+
2068
+
2069
+ def self.diagram_pitches(chord, instrument, defines)
2070
+ chord = ::Chordsketch::uniffi_utf8(chord)
2071
+
2072
+
2073
+ instrument = ::Chordsketch::uniffi_utf8(instrument)
2074
+
2075
+
2076
+ defines = defines
2077
+ RustBuffer.check_lower_SequenceTypeChordDefine(defines)
2078
+
2079
+ result = ::Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_diagram_pitches,RustBuffer.alloc_from_string(chord),RustBuffer.alloc_from_string(instrument),RustBuffer.alloc_from_SequenceTypeChordDefine(defines))
2080
+ return result.consume_into_OptionalSequenceu8
2081
+ end
2082
+
2083
+
2084
+
2085
+
2086
+
2087
+ def self.key_scale_pitches(key)
2088
+ key = ::Chordsketch::uniffi_utf8(key)
2089
+
2090
+
2091
+ result = ::Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_key_scale_pitches,RustBuffer.alloc_from_string(key))
2092
+ return result.consume_into_OptionalSequenceu8
2093
+ end
2094
+
2095
+
2096
+
2097
+
2098
+
2099
+ def self.key_tonic_triad(key)
2100
+ key = ::Chordsketch::uniffi_utf8(key)
2101
+
2102
+
2103
+ result = ::Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_key_tonic_triad,RustBuffer.alloc_from_string(key))
2104
+ return result.consume_into_OptionalSequenceu8
1059
2105
  end
1060
2106
 
1061
2107
 
@@ -1063,17 +2109,17 @@ end
1063
2109
 
1064
2110
 
1065
2111
  def self.parse_and_render_html(input, config_json, transpose)
1066
- input = Chordsketch::uniffi_utf8(input)
2112
+ input = ::Chordsketch::uniffi_utf8(input)
1067
2113
 
1068
2114
 
1069
- config_json = (config_json ? Chordsketch::uniffi_utf8(config_json) : nil)
2115
+ config_json = (config_json ? ::Chordsketch::uniffi_utf8(config_json) : nil)
1070
2116
  RustBuffer.check_lower_Optionalstring(config_json)
1071
2117
 
1072
- transpose = (transpose ? Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
2118
+ transpose = (transpose ? ::Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
1073
2119
  RustBuffer.check_lower_Optionali8(transpose)
1074
2120
 
1075
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_html,RustBuffer.allocFromString(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
1076
- return result.consumeIntoString
2121
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_html,RustBuffer.alloc_from_string(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
2122
+ return result.consume_into_string
1077
2123
  end
1078
2124
 
1079
2125
 
@@ -1081,17 +2127,17 @@ end
1081
2127
 
1082
2128
 
1083
2129
  def self.parse_and_render_html_body(input, config_json, transpose)
1084
- input = Chordsketch::uniffi_utf8(input)
2130
+ input = ::Chordsketch::uniffi_utf8(input)
1085
2131
 
1086
2132
 
1087
- config_json = (config_json ? Chordsketch::uniffi_utf8(config_json) : nil)
2133
+ config_json = (config_json ? ::Chordsketch::uniffi_utf8(config_json) : nil)
1088
2134
  RustBuffer.check_lower_Optionalstring(config_json)
1089
2135
 
1090
- transpose = (transpose ? Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
2136
+ transpose = (transpose ? ::Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
1091
2137
  RustBuffer.check_lower_Optionali8(transpose)
1092
2138
 
1093
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_html_body,RustBuffer.allocFromString(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
1094
- return result.consumeIntoString
2139
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_html_body,RustBuffer.alloc_from_string(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
2140
+ return result.consume_into_string
1095
2141
  end
1096
2142
 
1097
2143
 
@@ -1099,17 +2145,17 @@ end
1099
2145
 
1100
2146
 
1101
2147
  def self.parse_and_render_html_body_with_warnings(input, config_json, transpose)
1102
- input = Chordsketch::uniffi_utf8(input)
2148
+ input = ::Chordsketch::uniffi_utf8(input)
1103
2149
 
1104
2150
 
1105
- config_json = (config_json ? Chordsketch::uniffi_utf8(config_json) : nil)
2151
+ config_json = (config_json ? ::Chordsketch::uniffi_utf8(config_json) : nil)
1106
2152
  RustBuffer.check_lower_Optionalstring(config_json)
1107
2153
 
1108
- transpose = (transpose ? Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
2154
+ transpose = (transpose ? ::Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
1109
2155
  RustBuffer.check_lower_Optionali8(transpose)
1110
2156
 
1111
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_html_body_with_warnings,RustBuffer.allocFromString(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
1112
- return result.consumeIntoTypeTextRenderWithWarnings
2157
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_html_body_with_warnings,RustBuffer.alloc_from_string(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
2158
+ return result.consume_into_TypeTextRenderWithWarnings
1113
2159
  end
1114
2160
 
1115
2161
 
@@ -1117,17 +2163,17 @@ end
1117
2163
 
1118
2164
 
1119
2165
  def self.parse_and_render_html_with_warnings(input, config_json, transpose)
1120
- input = Chordsketch::uniffi_utf8(input)
2166
+ input = ::Chordsketch::uniffi_utf8(input)
1121
2167
 
1122
2168
 
1123
- config_json = (config_json ? Chordsketch::uniffi_utf8(config_json) : nil)
2169
+ config_json = (config_json ? ::Chordsketch::uniffi_utf8(config_json) : nil)
1124
2170
  RustBuffer.check_lower_Optionalstring(config_json)
1125
2171
 
1126
- transpose = (transpose ? Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
2172
+ transpose = (transpose ? ::Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
1127
2173
  RustBuffer.check_lower_Optionali8(transpose)
1128
2174
 
1129
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_html_with_warnings,RustBuffer.allocFromString(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
1130
- return result.consumeIntoTypeTextRenderWithWarnings
2175
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_html_with_warnings,RustBuffer.alloc_from_string(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
2176
+ return result.consume_into_TypeTextRenderWithWarnings
1131
2177
  end
1132
2178
 
1133
2179
 
@@ -1135,17 +2181,17 @@ end
1135
2181
 
1136
2182
 
1137
2183
  def self.parse_and_render_pdf(input, config_json, transpose)
1138
- input = Chordsketch::uniffi_utf8(input)
2184
+ input = ::Chordsketch::uniffi_utf8(input)
1139
2185
 
1140
2186
 
1141
- config_json = (config_json ? Chordsketch::uniffi_utf8(config_json) : nil)
2187
+ config_json = (config_json ? ::Chordsketch::uniffi_utf8(config_json) : nil)
1142
2188
  RustBuffer.check_lower_Optionalstring(config_json)
1143
2189
 
1144
- transpose = (transpose ? Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
2190
+ transpose = (transpose ? ::Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
1145
2191
  RustBuffer.check_lower_Optionali8(transpose)
1146
2192
 
1147
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_pdf,RustBuffer.allocFromString(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
1148
- return result.consumeIntoBytes
2193
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_pdf,RustBuffer.alloc_from_string(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
2194
+ return result.consume_into_bytes
1149
2195
  end
1150
2196
 
1151
2197
 
@@ -1153,17 +2199,17 @@ end
1153
2199
 
1154
2200
 
1155
2201
  def self.parse_and_render_pdf_with_warnings(input, config_json, transpose)
1156
- input = Chordsketch::uniffi_utf8(input)
2202
+ input = ::Chordsketch::uniffi_utf8(input)
1157
2203
 
1158
2204
 
1159
- config_json = (config_json ? Chordsketch::uniffi_utf8(config_json) : nil)
2205
+ config_json = (config_json ? ::Chordsketch::uniffi_utf8(config_json) : nil)
1160
2206
  RustBuffer.check_lower_Optionalstring(config_json)
1161
2207
 
1162
- transpose = (transpose ? Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
2208
+ transpose = (transpose ? ::Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
1163
2209
  RustBuffer.check_lower_Optionali8(transpose)
1164
2210
 
1165
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_pdf_with_warnings,RustBuffer.allocFromString(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
1166
- return result.consumeIntoTypePdfRenderWithWarnings
2211
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_pdf_with_warnings,RustBuffer.alloc_from_string(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
2212
+ return result.consume_into_TypePdfRenderWithWarnings
1167
2213
  end
1168
2214
 
1169
2215
 
@@ -1171,17 +2217,17 @@ end
1171
2217
 
1172
2218
 
1173
2219
  def self.parse_and_render_text(input, config_json, transpose)
1174
- input = Chordsketch::uniffi_utf8(input)
2220
+ input = ::Chordsketch::uniffi_utf8(input)
1175
2221
 
1176
2222
 
1177
- config_json = (config_json ? Chordsketch::uniffi_utf8(config_json) : nil)
2223
+ config_json = (config_json ? ::Chordsketch::uniffi_utf8(config_json) : nil)
1178
2224
  RustBuffer.check_lower_Optionalstring(config_json)
1179
2225
 
1180
- transpose = (transpose ? Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
2226
+ transpose = (transpose ? ::Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
1181
2227
  RustBuffer.check_lower_Optionali8(transpose)
1182
2228
 
1183
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_text,RustBuffer.allocFromString(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
1184
- return result.consumeIntoString
2229
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_text,RustBuffer.alloc_from_string(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
2230
+ return result.consume_into_string
1185
2231
  end
1186
2232
 
1187
2233
 
@@ -1189,17 +2235,17 @@ end
1189
2235
 
1190
2236
 
1191
2237
  def self.parse_and_render_text_with_warnings(input, config_json, transpose)
1192
- input = Chordsketch::uniffi_utf8(input)
2238
+ input = ::Chordsketch::uniffi_utf8(input)
1193
2239
 
1194
2240
 
1195
- config_json = (config_json ? Chordsketch::uniffi_utf8(config_json) : nil)
2241
+ config_json = (config_json ? ::Chordsketch::uniffi_utf8(config_json) : nil)
1196
2242
  RustBuffer.check_lower_Optionalstring(config_json)
1197
2243
 
1198
- transpose = (transpose ? Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
2244
+ transpose = (transpose ? ::Chordsketch::uniffi_in_range(transpose, "i8", -2**7, 2**7) : nil)
1199
2245
  RustBuffer.check_lower_Optionali8(transpose)
1200
2246
 
1201
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_text_with_warnings,RustBuffer.allocFromString(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
1202
- return result.consumeIntoTypeTextRenderWithWarnings
2247
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_and_render_text_with_warnings,RustBuffer.alloc_from_string(input),RustBuffer.alloc_from_Optionalstring(config_json),RustBuffer.alloc_from_Optionali8(transpose))
2248
+ return result.consume_into_TypeTextRenderWithWarnings
1203
2249
  end
1204
2250
 
1205
2251
 
@@ -1207,11 +2253,11 @@ end
1207
2253
 
1208
2254
 
1209
2255
  def self.parse_irealb(input)
1210
- input = Chordsketch::uniffi_utf8(input)
2256
+ input = ::Chordsketch::uniffi_utf8(input)
1211
2257
 
1212
2258
 
1213
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_irealb,RustBuffer.allocFromString(input))
1214
- return result.consumeIntoString
2259
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_parse_irealb,RustBuffer.alloc_from_string(input))
2260
+ return result.consume_into_string
1215
2261
  end
1216
2262
 
1217
2263
 
@@ -1219,8 +2265,8 @@ end
1219
2265
 
1220
2266
 
1221
2267
  def self.render_html_css()
1222
- result = Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_render_html_css,)
1223
- return result.consumeIntoString
2268
+ result = ::Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_render_html_css,)
2269
+ return result.consume_into_string
1224
2270
  end
1225
2271
 
1226
2272
 
@@ -1228,11 +2274,11 @@ end
1228
2274
 
1229
2275
 
1230
2276
  def self.render_html_css_with_config_json(config_json)
1231
- config_json = (config_json ? Chordsketch::uniffi_utf8(config_json) : nil)
2277
+ config_json = (config_json ? ::Chordsketch::uniffi_utf8(config_json) : nil)
1232
2278
  RustBuffer.check_lower_Optionalstring(config_json)
1233
2279
 
1234
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_render_html_css_with_config_json,RustBuffer.alloc_from_Optionalstring(config_json))
1235
- return result.consumeIntoString
2280
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_render_html_css_with_config_json,RustBuffer.alloc_from_Optionalstring(config_json))
2281
+ return result.consume_into_string
1236
2282
  end
1237
2283
 
1238
2284
 
@@ -1240,11 +2286,11 @@ end
1240
2286
 
1241
2287
 
1242
2288
  def self.render_ireal_pdf(input)
1243
- input = Chordsketch::uniffi_utf8(input)
2289
+ input = ::Chordsketch::uniffi_utf8(input)
1244
2290
 
1245
2291
 
1246
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_render_ireal_pdf,RustBuffer.allocFromString(input))
1247
- return result.consumeIntoBytes
2292
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_render_ireal_pdf,RustBuffer.alloc_from_string(input))
2293
+ return result.consume_into_bytes
1248
2294
  end
1249
2295
 
1250
2296
 
@@ -1252,11 +2298,11 @@ end
1252
2298
 
1253
2299
 
1254
2300
  def self.render_ireal_png(input)
1255
- input = Chordsketch::uniffi_utf8(input)
2301
+ input = ::Chordsketch::uniffi_utf8(input)
1256
2302
 
1257
2303
 
1258
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_render_ireal_png,RustBuffer.allocFromString(input))
1259
- return result.consumeIntoBytes
2304
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_render_ireal_png,RustBuffer.alloc_from_string(input))
2305
+ return result.consume_into_bytes
1260
2306
  end
1261
2307
 
1262
2308
 
@@ -1264,11 +2310,11 @@ end
1264
2310
 
1265
2311
 
1266
2312
  def self.render_ireal_svg(input)
1267
- input = Chordsketch::uniffi_utf8(input)
2313
+ input = ::Chordsketch::uniffi_utf8(input)
1268
2314
 
1269
2315
 
1270
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_render_ireal_svg,RustBuffer.allocFromString(input))
1271
- return result.consumeIntoString
2316
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_render_ireal_svg,RustBuffer.alloc_from_string(input))
2317
+ return result.consume_into_string
1272
2318
  end
1273
2319
 
1274
2320
 
@@ -1276,11 +2322,11 @@ end
1276
2322
 
1277
2323
 
1278
2324
  def self.serialize_irealb(input)
1279
- input = Chordsketch::uniffi_utf8(input)
2325
+ input = ::Chordsketch::uniffi_utf8(input)
1280
2326
 
1281
2327
 
1282
- result = Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_serialize_irealb,RustBuffer.allocFromString(input))
1283
- return result.consumeIntoString
2328
+ result = ::Chordsketch.rust_call_with_error(ChordSketchError,:uniffi_chordsketch_ffi_fn_func_serialize_irealb,RustBuffer.alloc_from_string(input))
2329
+ return result.consume_into_string
1284
2330
  end
1285
2331
 
1286
2332
 
@@ -1288,11 +2334,11 @@ end
1288
2334
 
1289
2335
 
1290
2336
  def self.validate(input)
1291
- input = Chordsketch::uniffi_utf8(input)
2337
+ input = ::Chordsketch::uniffi_utf8(input)
1292
2338
 
1293
2339
 
1294
- result = Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_validate,RustBuffer.allocFromString(input))
1295
- return result.consumeIntoSequenceTypeValidationError
2340
+ result = ::Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_validate,RustBuffer.alloc_from_string(input))
2341
+ return result.consume_into_SequenceTypeValidationError
1296
2342
  end
1297
2343
 
1298
2344
 
@@ -1300,13 +2346,15 @@ end
1300
2346
 
1301
2347
 
1302
2348
  def self.version()
1303
- result = Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_version,)
1304
- return result.consumeIntoString
2349
+ result = ::Chordsketch.rust_call(:uniffi_chordsketch_ffi_fn_func_version,)
2350
+ return result.consume_into_string
1305
2351
  end
1306
2352
 
1307
2353
 
1308
2354
 
1309
2355
 
1310
2356
 
2357
+
2358
+
1311
2359
  end
1312
2360