llmtrim 0.5.0-x86_64-linux → 0.6.0-x86_64-linux

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d2e301e24e9662b07fdfbe23173c9484fdca41eaeb42c181aa3f7a29e256988
4
- data.tar.gz: 8ab5ef43f57d2653299b5900b7ac1c8e46312729710ba7d5b4c0c117c4be5876
3
+ metadata.gz: 5173a07ebbc309c7874ccc3f98cec214c045cbc16a80656de03541a2cd0cbce5
4
+ data.tar.gz: c052c591279898c45f14c7abcf6028966f58b0f9e82c5656723f0b2eb9fc2217
5
5
  SHA512:
6
- metadata.gz: 3159228c3ea53491077c1c9f9207e7af254db11d88e78f164332b648029ce33ffa9cfa602a549dafd0abd3b4d049db90dd786e84d34ed622b87402d568ff2945
7
- data.tar.gz: 22c6651c3067f4640f72c01bbe769a0d1df0e408e1e6ee6312b8de31cf51debfdc28483979bcc22ce50ff7fe15f95c999084e46a4672c0b9d14ef3536750f828
6
+ metadata.gz: fb9af7cfe197be47bbc91ce29124d2b3c7ec4b5bf852eb21b6f1267bfdf36e1671096e91c7c8610dddf5c06b16113f9b1271d205ce806a0c600e0918a7947230
7
+ data.tar.gz: e7b6f0a245c6549e644f18b4e02ea0243e913f1c35b3e00df3a7f9a8f3834760b11ea3857678ccea8fa17ce0bb679dad45f18e495de890beca1939cc2cb9ce23
Binary file
@@ -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 LlmtrimFfi
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 LlmtrimFfi.rust_call(:ffi_llmtrim_ffi_rustbuffer_alloc, size)
88
+ return ::LlmtrimFfi.rust_call(:ffi_llmtrim_ffi_rustbuffer_alloc, size)
46
89
  end
47
90
 
48
91
  def self.reserve(rbuf, additional)
49
- return LlmtrimFfi.rust_call(:ffi_llmtrim_ffi_rustbuffer_reserve, rbuf, additional)
92
+ return ::LlmtrimFfi.rust_call(:ffi_llmtrim_ffi_rustbuffer_reserve, rbuf, additional)
50
93
  end
51
94
 
52
95
  def free
53
- LlmtrimFfi.rust_call(:ffi_llmtrim_ffi_rustbuffer_free, self)
96
+ ::LlmtrimFfi.rust_call(:ffi_llmtrim_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
@@ -133,9 +176,9 @@ end
133
176
  end
134
177
  end
135
178
 
136
- def consumeIntoTypeCompressOutput
179
+ def consume_into_TypeCompressOutput
137
180
  consumeWithStream do |stream|
138
- return stream.readTypeCompressOutput
181
+ return stream.read_TypeCompressOutput
139
182
  end
140
183
  end
141
184
 
@@ -156,12 +199,26 @@ end
156
199
  end
157
200
  end
158
201
 
159
- def consumeIntoTypeStageReport
202
+ def consume_into_TypeStageReport
160
203
  consumeWithStream do |stream|
161
- return stream.readTypeStageReport
204
+ return stream.read_TypeStageReport
205
+ end
206
+ end
207
+
208
+ # Error enum - generate alloc_from for callback error serialization
209
+ def self.alloc_from_TypeLlmtrimError(v)
210
+ RustBuffer.allocWithBuilder do |builder|
211
+ builder.write_TypeLlmtrimError(v)
212
+ return builder.finalize
162
213
  end
163
214
  end
164
215
 
216
+ # Enum used as error - generate consume_into_ for use as a return value
217
+ def consume_into_TypeLlmtrimError
218
+ consumeWithStream do |stream|
219
+ return stream.read_TypeLlmtrimError
220
+ end
221
+ end
165
222
 
166
223
 
167
224
  # The Enum type Provider.
@@ -176,9 +233,9 @@ end
176
233
  end
177
234
  end
178
235
 
179
- def consumeIntoTypeProvider
236
+ def consume_into_TypeProvider
180
237
  consumeWithStream do |stream|
181
- return stream.readTypeProvider
238
+ return stream.read_TypeProvider
182
239
  end
183
240
  end
184
241
 
@@ -186,7 +243,7 @@ end
186
243
  # The Optional<T> type for string.
187
244
 
188
245
  def self.check_lower_Optionalstring(v)
189
- if not v.nil?
246
+ if !v.nil?
190
247
 
191
248
  end
192
249
  end
@@ -198,16 +255,16 @@ end
198
255
  end
199
256
  end
200
257
 
201
- def consumeIntoOptionalstring
258
+ def consume_into_Optionalstring
202
259
  consumeWithStream do |stream|
203
- return stream.readOptionalstring
260
+ return stream.read_Optionalstring
204
261
  end
205
262
  end
206
263
 
207
264
  # The Optional<T> type for TypeProvider.
208
265
 
209
266
  def self.check_lower_OptionalTypeProvider(v)
210
- if not v.nil?
267
+ if !v.nil?
211
268
  RustBuffer.check_lower_TypeProvider(v)
212
269
  end
213
270
  end
@@ -219,9 +276,9 @@ end
219
276
  end
220
277
  end
221
278
 
222
- def consumeIntoOptionalTypeProvider
279
+ def consume_into_OptionalTypeProvider
223
280
  consumeWithStream do |stream|
224
- return stream.readOptionalTypeProvider
281
+ return stream.read_OptionalTypeProvider
225
282
  end
226
283
  end
227
284
 
@@ -240,9 +297,9 @@ end
240
297
  end
241
298
  end
242
299
 
243
- def consumeIntoSequenceTypeStageReport
300
+ def consume_into_SequenceTypeStageReport
244
301
  consumeWithStream do |stream|
245
- return stream.readSequenceTypeStageReport
302
+ return stream.read_SequenceTypeStageReport
246
303
  end
247
304
  end
248
305
 
@@ -292,11 +349,11 @@ class RustBufferStream
292
349
  data
293
350
  end
294
351
 
295
- def readU64
352
+ def read_u64
296
353
  unpack_from 8, 'Q>'
297
354
  end
298
355
 
299
- def readBool
356
+ def read_bool
300
357
  v = unpack_from 1, 'c'
301
358
 
302
359
  return false if v == 0
@@ -305,7 +362,7 @@ class RustBufferStream
305
362
  raise InternalError, 'Unexpected byte for Boolean type'
306
363
  end
307
364
 
308
- def readString
365
+ def read_string
309
366
  size = unpack_from 4, 'l>'
310
367
 
311
368
  raise InternalError, 'Unexpected negative string length' if size.negative?
@@ -315,30 +372,30 @@ class RustBufferStream
315
372
 
316
373
  # The Record type CompressOutput.
317
374
 
318
- def readTypeCompressOutput
375
+ def read_TypeCompressOutput
319
376
  CompressOutput.new(
320
- request_json: readString,
321
- provider: readString,
322
- model: readOptionalstring,
323
- tokenizer_label: readString,
324
- tokenizer_exact: readBool,
325
- input_tokens_before: readU64,
326
- input_tokens_after: readU64,
327
- frozen_input_tokens: readU64,
328
- output_shaped: readBool,
329
- stages: readSequenceTypeStageReport
377
+ request_json: read_string,
378
+ provider: read_string,
379
+ model: read_Optionalstring,
380
+ tokenizer_label: read_string,
381
+ tokenizer_exact: read_bool,
382
+ input_tokens_before: read_u64,
383
+ input_tokens_after: read_u64,
384
+ frozen_input_tokens: read_u64,
385
+ output_shaped: read_bool,
386
+ stages: read_SequenceTypeStageReport
330
387
  )
331
388
  end
332
389
 
333
390
  # The Record type StageReport.
334
391
 
335
- def readTypeStageReport
392
+ def read_TypeStageReport
336
393
  StageReport.new(
337
- name: readString,
338
- applied: readBool,
339
- tokens_before: readU64,
340
- tokens_after: readU64,
341
- note: readOptionalstring
394
+ name: read_string,
395
+ applied: read_bool,
396
+ tokens_before: read_u64,
397
+ tokens_after: read_u64,
398
+ note: read_Optionalstring
342
399
  )
343
400
  end
344
401
 
@@ -348,17 +405,17 @@ class RustBufferStream
348
405
 
349
406
  # The Error type LlmtrimError
350
407
 
351
- def readTypeLlmtrimError
408
+ def read_TypeLlmtrimError
352
409
  variant = unpack_from 4, 'l>'
353
410
 
354
411
  if variant == 1
355
412
  return LlmtrimError::Compress.new(
356
- readString()
413
+ detail: read_string()
357
414
  )
358
415
  end
359
416
  if variant == 2
360
417
  return LlmtrimError::UnknownPreset.new(
361
- readString()
418
+ name: read_string()
362
419
  )
363
420
  end
364
421
 
@@ -370,7 +427,7 @@ class RustBufferStream
370
427
 
371
428
  # The Enum type Provider.
372
429
 
373
- def readTypeProvider
430
+ def read_TypeProvider
374
431
  variant = unpack_from 4, 'l>'
375
432
 
376
433
  if variant == 1
@@ -388,29 +445,31 @@ class RustBufferStream
388
445
 
389
446
 
390
447
 
448
+
391
449
  # The Optional<T> type for string.
392
450
 
393
- def readOptionalstring
451
+ def read_Optionalstring
394
452
  flag = unpack_from 1, 'c'
395
453
 
396
454
  if flag == 0
397
455
  return nil
398
456
  elsif flag == 1
399
- return readString
457
+ return read_string
400
458
  else
401
459
  raise InternalError, 'Unexpected flag byte for Optionalstring'
402
460
  end
403
461
  end
404
462
 
463
+
405
464
  # The Optional<T> type for TypeProvider.
406
465
 
407
- def readOptionalTypeProvider
466
+ def read_OptionalTypeProvider
408
467
  flag = unpack_from 1, 'c'
409
468
 
410
469
  if flag == 0
411
470
  return nil
412
471
  elsif flag == 1
413
- return readTypeProvider
472
+ return read_TypeProvider
414
473
  else
415
474
  raise InternalError, 'Unexpected flag byte for OptionalTypeProvider'
416
475
  end
@@ -418,7 +477,7 @@ class RustBufferStream
418
477
 
419
478
  # The Sequence<T> type for TypeStageReport.
420
479
 
421
- def readSequenceTypeStageReport
480
+ def read_SequenceTypeStageReport
422
481
  count = unpack_from 4, 'l>'
423
482
 
424
483
  raise InternalError, 'Unexpected negative sequence length' if count.negative?
@@ -426,7 +485,7 @@ class RustBufferStream
426
485
  items = []
427
486
 
428
487
  count.times do
429
- items.append readTypeStageReport
488
+ items.append read_TypeStageReport
430
489
  end
431
490
 
432
491
  items
@@ -478,17 +537,17 @@ class RustBufferBuilder
478
537
  end
479
538
  end
480
539
 
481
- def write_U64(v)
482
- v = LlmtrimFfi::uniffi_in_range(v, "u64", 0, 2**64)
540
+ def write_u64(v)
541
+ v = ::LlmtrimFfi::uniffi_in_range(v, "u64", 0, 2**64)
483
542
  pack_into(8, 'Q>', v)
484
543
  end
485
544
 
486
- def write_Bool(v)
545
+ def write_bool(v)
487
546
  pack_into(1, 'c', v ? 1 : 0)
488
547
  end
489
548
 
490
- def write_String(v)
491
- v = LlmtrimFfi::uniffi_utf8(v)
549
+ def write_string(v)
550
+ v = ::LlmtrimFfi::uniffi_utf8(v)
492
551
  pack_into 4, 'l>', v.bytes.size
493
552
  write v
494
553
  end
@@ -496,36 +555,58 @@ class RustBufferBuilder
496
555
  # The Record type CompressOutput.
497
556
 
498
557
  def write_TypeCompressOutput(v)
499
- self.write_String(v.request_json)
500
- self.write_String(v.provider)
558
+ self.write_string(v.request_json)
559
+ self.write_string(v.provider)
501
560
  self.write_Optionalstring(v.model)
502
- self.write_String(v.tokenizer_label)
503
- self.write_Bool(v.tokenizer_exact)
504
- self.write_U64(v.input_tokens_before)
505
- self.write_U64(v.input_tokens_after)
506
- self.write_U64(v.frozen_input_tokens)
507
- self.write_Bool(v.output_shaped)
561
+ self.write_string(v.tokenizer_label)
562
+ self.write_bool(v.tokenizer_exact)
563
+ self.write_u64(v.input_tokens_before)
564
+ self.write_u64(v.input_tokens_after)
565
+ self.write_u64(v.frozen_input_tokens)
566
+ self.write_bool(v.output_shaped)
508
567
  self.write_SequenceTypeStageReport(v.stages)
509
568
  end
510
569
 
511
570
  # The Record type StageReport.
512
571
 
513
572
  def write_TypeStageReport(v)
514
- self.write_String(v.name)
515
- self.write_Bool(v.applied)
516
- self.write_U64(v.tokens_before)
517
- self.write_U64(v.tokens_after)
573
+ self.write_string(v.name)
574
+ self.write_bool(v.applied)
575
+ self.write_u64(v.tokens_before)
576
+ self.write_u64(v.tokens_after)
518
577
  self.write_Optionalstring(v.note)
519
578
  end
520
579
 
580
+ # The Error type LlmtrimError - write for callback error returns.
581
+
582
+ def write_TypeLlmtrimError(v)
583
+ if v.is_a?(LlmtrimError::Compress)
584
+ pack_into 4, 'l>', 1
585
+ self.write_string(v.detail)
586
+ return
587
+ end
588
+ if v.is_a?(LlmtrimError::UnknownPreset)
589
+ pack_into 4, 'l>', 2
590
+ self.write_string(v.name)
591
+ return
592
+ end
593
+ end
521
594
 
522
595
 
523
596
  # The Enum type Provider.
524
597
 
525
598
  def write_TypeProvider(v)
526
- pack_into(4, 'l>', v)
599
+ if v == Provider::OPEN_AI
600
+ pack_into(4, 'l>', 1)
601
+ end
602
+ if v == Provider::ANTHROPIC
603
+ pack_into(4, 'l>', 2)
604
+ end
605
+ if v == Provider::GOOGLE
606
+ pack_into(4, 'l>', 3)
607
+ end
527
608
  end
528
-
609
+
529
610
 
530
611
  # The Optional<T> type for string.
531
612
 
@@ -534,7 +615,7 @@ class RustBufferBuilder
534
615
  pack_into(1, 'c', 0)
535
616
  else
536
617
  pack_into(1, 'c', 1)
537
- self.write_String(v)
618
+ self.write_string(v)
538
619
  end
539
620
  end
540
621
 
@@ -608,29 +689,37 @@ CALL_PANIC = 2
608
689
 
609
690
  module LlmtrimError
610
691
  class Compress < StandardError
611
- def initialize(detail)
692
+ def initialize(detail:)
693
+
612
694
  @detail = detail
695
+
613
696
  super()
614
- end
697
+ end
698
+
615
699
 
616
700
  attr_reader :detail
617
701
 
618
702
 
619
703
  def to_s
620
- "#{self.class.name}(detail=#{@detail.inspect})"
704
+ "#{self.class.name}(detail=#{@detail.inspect})"
705
+
621
706
  end
622
707
  end
623
708
  class UnknownPreset < StandardError
624
- def initialize(name)
709
+ def initialize(name:)
710
+
625
711
  @name = name
712
+
626
713
  super()
627
- end
714
+ end
715
+
628
716
 
629
717
  attr_reader :name
630
718
 
631
719
 
632
720
  def to_s
633
- "#{self.class.name}(name=#{@name.inspect})"
721
+ "#{self.class.name}(name=#{@name.inspect})"
722
+
634
723
  end
635
724
  end
636
725
 
@@ -640,10 +729,7 @@ end
640
729
 
641
730
  # Map error modules to the RustBuffer method name that reads them
642
731
  ERROR_MODULE_TO_READER_METHOD = {
643
-
644
- LlmtrimError => :readTypeLlmtrimError,
645
-
646
-
732
+ LlmtrimError => :read_TypeLlmtrimError,
647
733
  }
648
734
 
649
735
  private_constant :ERROR_MODULE_TO_READER_METHOD, :CALL_SUCCESS, :CALL_ERROR, :CALL_PANIC,
@@ -651,7 +737,8 @@ private_constant :ERROR_MODULE_TO_READER_METHOD, :CALL_SUCCESS, :CALL_ERROR, :CA
651
737
 
652
738
  def self.consume_buffer_into_error(error_module, rust_buffer)
653
739
  rust_buffer.consumeWithStream do |stream|
654
- reader_method = ERROR_MODULE_TO_READER_METHOD[error_module]
740
+ reader_method = ERROR_MODULE_TO_READER_METHOD[error_module] ||
741
+ ERROR_MODULE_TO_READER_METHOD[error_module.name&.split('::')&.last]
655
742
  return stream.send(reader_method)
656
743
  end
657
744
  end
@@ -693,7 +780,7 @@ def self.rust_call_with_error(error_module, fn_name, *args)
693
780
  # with the message. But if that code panics, then it just sends back
694
781
  # an empty buffer.
695
782
  if status.error_buf.len > 0
696
- raise InternalError, status.error_buf.consumeIntoString()
783
+ raise InternalError, status.error_buf.consume_into_string
697
784
  else
698
785
  raise InternalError, "Rust panic"
699
786
  end
@@ -713,30 +800,386 @@ module UniFFILib
713
800
  ffi_lib File.expand_path('libllmtrim_ffi.so', __dir__)
714
801
 
715
802
 
803
+ # Define FFI callback types and structs (vtables, etc.)
804
+
805
+ callback :RustFutureContinuationCallback,
806
+ [:uint64, :int8, ],
807
+ :void
808
+
809
+ callback :ForeignFutureDroppedCallback,
810
+ [:uint64, ],
811
+ :void
812
+
813
+ callback :CallbackInterfaceFree,
814
+ [:uint64, ],
815
+ :void
816
+
817
+ callback :CallbackInterfaceClone,
818
+ [:uint64, ],
819
+ :uint64
820
+
821
+ class ForeignFutureDroppedCallbackStruct < FFI::Struct
822
+ layout(
823
+ :handle, :uint64,
824
+ :free, :ForeignFutureDroppedCallback
825
+ )
826
+ end
827
+
828
+ class ForeignFutureResultU8 < FFI::Struct
829
+ layout(
830
+ :return_value, :uint8,
831
+ :call_status, RustCallStatus
832
+ )
833
+ end
834
+
835
+ callback :ForeignFutureCompleteU8,
836
+ [:uint64, ForeignFutureResultU8.by_value, ],
837
+ :void
838
+
839
+ class ForeignFutureResultI8 < FFI::Struct
840
+ layout(
841
+ :return_value, :int8,
842
+ :call_status, RustCallStatus
843
+ )
844
+ end
845
+
846
+ callback :ForeignFutureCompleteI8,
847
+ [:uint64, ForeignFutureResultI8.by_value, ],
848
+ :void
849
+
850
+ class ForeignFutureResultU16 < FFI::Struct
851
+ layout(
852
+ :return_value, :uint16,
853
+ :call_status, RustCallStatus
854
+ )
855
+ end
856
+
857
+ callback :ForeignFutureCompleteU16,
858
+ [:uint64, ForeignFutureResultU16.by_value, ],
859
+ :void
860
+
861
+ class ForeignFutureResultI16 < FFI::Struct
862
+ layout(
863
+ :return_value, :int16,
864
+ :call_status, RustCallStatus
865
+ )
866
+ end
867
+
868
+ callback :ForeignFutureCompleteI16,
869
+ [:uint64, ForeignFutureResultI16.by_value, ],
870
+ :void
871
+
872
+ class ForeignFutureResultU32 < FFI::Struct
873
+ layout(
874
+ :return_value, :uint32,
875
+ :call_status, RustCallStatus
876
+ )
877
+ end
878
+
879
+ callback :ForeignFutureCompleteU32,
880
+ [:uint64, ForeignFutureResultU32.by_value, ],
881
+ :void
882
+
883
+ class ForeignFutureResultI32 < FFI::Struct
884
+ layout(
885
+ :return_value, :int32,
886
+ :call_status, RustCallStatus
887
+ )
888
+ end
889
+
890
+ callback :ForeignFutureCompleteI32,
891
+ [:uint64, ForeignFutureResultI32.by_value, ],
892
+ :void
893
+
894
+ class ForeignFutureResultU64 < FFI::Struct
895
+ layout(
896
+ :return_value, :uint64,
897
+ :call_status, RustCallStatus
898
+ )
899
+ end
900
+
901
+ callback :ForeignFutureCompleteU64,
902
+ [:uint64, ForeignFutureResultU64.by_value, ],
903
+ :void
904
+
905
+ class ForeignFutureResultI64 < FFI::Struct
906
+ layout(
907
+ :return_value, :int64,
908
+ :call_status, RustCallStatus
909
+ )
910
+ end
911
+
912
+ callback :ForeignFutureCompleteI64,
913
+ [:uint64, ForeignFutureResultI64.by_value, ],
914
+ :void
915
+
916
+ class ForeignFutureResultF32 < FFI::Struct
917
+ layout(
918
+ :return_value, :float,
919
+ :call_status, RustCallStatus
920
+ )
921
+ end
922
+
923
+ callback :ForeignFutureCompleteF32,
924
+ [:uint64, ForeignFutureResultF32.by_value, ],
925
+ :void
926
+
927
+ class ForeignFutureResultF64 < FFI::Struct
928
+ layout(
929
+ :return_value, :double,
930
+ :call_status, RustCallStatus
931
+ )
932
+ end
933
+
934
+ callback :ForeignFutureCompleteF64,
935
+ [:uint64, ForeignFutureResultF64.by_value, ],
936
+ :void
937
+
938
+ class ForeignFutureResultRustBuffer < FFI::Struct
939
+ layout(
940
+ :return_value, RustBuffer.by_value,
941
+ :call_status, RustCallStatus
942
+ )
943
+ end
944
+
945
+ callback :ForeignFutureCompleteRustBuffer,
946
+ [:uint64, ForeignFutureResultRustBuffer.by_value, ],
947
+ :void
948
+
949
+ class ForeignFutureResultVoid < FFI::Struct
950
+ layout(
951
+ :call_status, RustCallStatus
952
+ )
953
+ end
954
+
955
+ callback :ForeignFutureCompleteVoid,
956
+ [:uint64, ForeignFutureResultVoid.by_value, ],
957
+ :void
958
+
716
959
  attach_function :uniffi_llmtrim_ffi_fn_func_compress,
717
960
  [RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
718
961
  RustBuffer.by_value
962
+
719
963
  attach_function :ffi_llmtrim_ffi_rustbuffer_alloc,
720
964
  [:uint64, RustCallStatus.by_ref],
721
965
  RustBuffer.by_value
966
+
722
967
  attach_function :ffi_llmtrim_ffi_rustbuffer_from_bytes,
723
968
  [ForeignBytes, RustCallStatus.by_ref],
724
969
  RustBuffer.by_value
970
+
725
971
  attach_function :ffi_llmtrim_ffi_rustbuffer_free,
726
972
  [RustBuffer.by_value, RustCallStatus.by_ref],
727
973
  :void
974
+
728
975
  attach_function :ffi_llmtrim_ffi_rustbuffer_reserve,
729
976
  [RustBuffer.by_value, :uint64, RustCallStatus.by_ref],
730
977
  RustBuffer.by_value
978
+
979
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_u8,
980
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
981
+ :void
982
+
983
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_u8,
984
+ [:uint64, ],
985
+ :void
986
+
987
+ attach_function :ffi_llmtrim_ffi_rust_future_free_u8,
988
+ [:uint64, ],
989
+ :void
990
+
991
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_u8,
992
+ [:uint64, RustCallStatus.by_ref],
993
+ :uint8
994
+
995
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_i8,
996
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
997
+ :void
998
+
999
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_i8,
1000
+ [:uint64, ],
1001
+ :void
1002
+
1003
+ attach_function :ffi_llmtrim_ffi_rust_future_free_i8,
1004
+ [:uint64, ],
1005
+ :void
1006
+
1007
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_i8,
1008
+ [:uint64, RustCallStatus.by_ref],
1009
+ :int8
1010
+
1011
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_u16,
1012
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1013
+ :void
1014
+
1015
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_u16,
1016
+ [:uint64, ],
1017
+ :void
1018
+
1019
+ attach_function :ffi_llmtrim_ffi_rust_future_free_u16,
1020
+ [:uint64, ],
1021
+ :void
1022
+
1023
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_u16,
1024
+ [:uint64, RustCallStatus.by_ref],
1025
+ :uint16
1026
+
1027
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_i16,
1028
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1029
+ :void
1030
+
1031
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_i16,
1032
+ [:uint64, ],
1033
+ :void
1034
+
1035
+ attach_function :ffi_llmtrim_ffi_rust_future_free_i16,
1036
+ [:uint64, ],
1037
+ :void
1038
+
1039
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_i16,
1040
+ [:uint64, RustCallStatus.by_ref],
1041
+ :int16
1042
+
1043
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_u32,
1044
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1045
+ :void
1046
+
1047
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_u32,
1048
+ [:uint64, ],
1049
+ :void
1050
+
1051
+ attach_function :ffi_llmtrim_ffi_rust_future_free_u32,
1052
+ [:uint64, ],
1053
+ :void
1054
+
1055
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_u32,
1056
+ [:uint64, RustCallStatus.by_ref],
1057
+ :uint32
1058
+
1059
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_i32,
1060
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1061
+ :void
1062
+
1063
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_i32,
1064
+ [:uint64, ],
1065
+ :void
1066
+
1067
+ attach_function :ffi_llmtrim_ffi_rust_future_free_i32,
1068
+ [:uint64, ],
1069
+ :void
1070
+
1071
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_i32,
1072
+ [:uint64, RustCallStatus.by_ref],
1073
+ :int32
1074
+
1075
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_u64,
1076
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1077
+ :void
1078
+
1079
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_u64,
1080
+ [:uint64, ],
1081
+ :void
1082
+
1083
+ attach_function :ffi_llmtrim_ffi_rust_future_free_u64,
1084
+ [:uint64, ],
1085
+ :void
1086
+
1087
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_u64,
1088
+ [:uint64, RustCallStatus.by_ref],
1089
+ :uint64
1090
+
1091
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_i64,
1092
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1093
+ :void
1094
+
1095
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_i64,
1096
+ [:uint64, ],
1097
+ :void
1098
+
1099
+ attach_function :ffi_llmtrim_ffi_rust_future_free_i64,
1100
+ [:uint64, ],
1101
+ :void
1102
+
1103
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_i64,
1104
+ [:uint64, RustCallStatus.by_ref],
1105
+ :int64
1106
+
1107
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_f32,
1108
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1109
+ :void
1110
+
1111
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_f32,
1112
+ [:uint64, ],
1113
+ :void
1114
+
1115
+ attach_function :ffi_llmtrim_ffi_rust_future_free_f32,
1116
+ [:uint64, ],
1117
+ :void
1118
+
1119
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_f32,
1120
+ [:uint64, RustCallStatus.by_ref],
1121
+ :float
1122
+
1123
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_f64,
1124
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1125
+ :void
1126
+
1127
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_f64,
1128
+ [:uint64, ],
1129
+ :void
1130
+
1131
+ attach_function :ffi_llmtrim_ffi_rust_future_free_f64,
1132
+ [:uint64, ],
1133
+ :void
1134
+
1135
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_f64,
1136
+ [:uint64, RustCallStatus.by_ref],
1137
+ :double
1138
+
1139
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_rust_buffer,
1140
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1141
+ :void
1142
+
1143
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_rust_buffer,
1144
+ [:uint64, ],
1145
+ :void
1146
+
1147
+ attach_function :ffi_llmtrim_ffi_rust_future_free_rust_buffer,
1148
+ [:uint64, ],
1149
+ :void
1150
+
1151
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_rust_buffer,
1152
+ [:uint64, RustCallStatus.by_ref],
1153
+ RustBuffer.by_value
1154
+
1155
+ attach_function :ffi_llmtrim_ffi_rust_future_poll_void,
1156
+ [:uint64, :RustFutureContinuationCallback, :uint64, ],
1157
+ :void
1158
+
1159
+ attach_function :ffi_llmtrim_ffi_rust_future_cancel_void,
1160
+ [:uint64, ],
1161
+ :void
1162
+
1163
+ attach_function :ffi_llmtrim_ffi_rust_future_free_void,
1164
+ [:uint64, ],
1165
+ :void
1166
+
1167
+ attach_function :ffi_llmtrim_ffi_rust_future_complete_void,
1168
+ [:uint64, RustCallStatus.by_ref],
1169
+ :void
1170
+
731
1171
  attach_function :uniffi_llmtrim_ffi_checksum_func_compress,
732
- [RustCallStatus.by_ref],
1172
+ [],
733
1173
  :uint16
1174
+
734
1175
  attach_function :ffi_llmtrim_ffi_uniffi_contract_version,
735
- [RustCallStatus.by_ref],
1176
+ [],
736
1177
  :uint32
737
1178
 
738
1179
  end
739
1180
 
1181
+ # Custom type definitions.
1182
+
740
1183
  # Public interface members begin here.
741
1184
 
742
1185
 
@@ -745,9 +1188,9 @@ end
745
1188
 
746
1189
 
747
1190
  class Provider
748
- OPEN_AI = 1
749
- ANTHROPIC = 2
750
- GOOGLE = 3
1191
+ OPEN_AI = 0
1192
+ ANTHROPIC = 1
1193
+ GOOGLE = 2
751
1194
 
752
1195
  end
753
1196
 
@@ -804,6 +1247,7 @@ class CompressOutput
804
1247
 
805
1248
  true
806
1249
  end
1250
+
807
1251
  end
808
1252
 
809
1253
  # Record type StageReport
@@ -837,6 +1281,7 @@ class StageReport
837
1281
 
838
1282
  true
839
1283
  end
1284
+
840
1285
  end
841
1286
 
842
1287
 
@@ -844,22 +1289,24 @@ end
844
1289
 
845
1290
 
846
1291
  def self.compress(input, provider, preset)
847
- input = LlmtrimFfi::uniffi_utf8(input)
1292
+ input = ::LlmtrimFfi::uniffi_utf8(input)
848
1293
 
849
1294
 
850
1295
  provider = (provider ? provider : nil)
851
1296
  RustBuffer.check_lower_OptionalTypeProvider(provider)
852
1297
 
853
- preset = (preset ? LlmtrimFfi::uniffi_utf8(preset) : nil)
1298
+ preset = (preset ? ::LlmtrimFfi::uniffi_utf8(preset) : nil)
854
1299
  RustBuffer.check_lower_Optionalstring(preset)
855
1300
 
856
- result = LlmtrimFfi.rust_call_with_error(LlmtrimError,:uniffi_llmtrim_ffi_fn_func_compress,RustBuffer.allocFromString(input),RustBuffer.alloc_from_OptionalTypeProvider(provider),RustBuffer.alloc_from_Optionalstring(preset))
857
- return result.consumeIntoTypeCompressOutput
1301
+ result = ::LlmtrimFfi.rust_call_with_error(LlmtrimError,:uniffi_llmtrim_ffi_fn_func_compress,RustBuffer.alloc_from_string(input),RustBuffer.alloc_from_OptionalTypeProvider(provider),RustBuffer.alloc_from_Optionalstring(preset))
1302
+ return result.consume_into_TypeCompressOutput
858
1303
  end
859
1304
 
860
1305
 
861
1306
 
862
1307
 
863
1308
 
1309
+
1310
+
864
1311
  end
865
1312
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llmtrim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - François Kiene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-29 00:00:00.000000000 Z
11
+ date: 2026-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi