diff --git a/README.md b/README.md index a4e2836..903a519 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # servicepoint +[![crates.io](https://img.shields.io/crates/v/servicepoint.svg)](https://crates.io/crates/servicepoint) +[![Crates.io Total Downloads](https://img.shields.io/crates/d/servicepoint)](https://crates.io/crates/servicepoint) +[![docs.rs](https://img.shields.io/docsrs/servicepoint)](https://docs.rs/servicepoint/latest/servicepoint/) +[![GPLv3 licensed](https://img.shields.io/crates/l/servicepoint)](../../LICENSE) + In [CCCB](https://berlin.ccc.de/), there is a big pixel matrix hanging on the wall. It is called "Service Point Display" or "Airport Display". This repository contains a library for parsing, encoding and sending packets to this display via UDP in multiple @@ -7,20 +12,20 @@ programming languages. Take a look at the contained crates for language specific information: -| Language | Readme | -|-----------|---------------------------------------------------------------------| -| Rust | [servicepoint](crates/servicepoint/README.md) | -| C / C++ | [servicepoint_binding_c](crates/servicepoint_binding_c/README.md) | -| .NET (C#) | [servicepoint_binding_cs](crates/servicepoint_binding_cs/README.md) | +| Crate | Languages | Readme | +|-----------------------------|-----------------------------------|-------------------------------------------------------------------------| +| servicepoint | Rust | [servicepoint](crates/servicepoint/README.md) | +| servicepoint_binding_c | C / C++ | [servicepoint_binding_c](crates/servicepoint_binding_c/README.md) | +| servicepoint_binding_uniffi | C# / Python / Go / Kotlin / Swift | [servicepoint_binding_cs](crates/servicepoint_binding_uniffi/README.md) | ## Projects using the library - screen simulator (rust): [servicepoint-simulator](https://github.com/kaesaecracker/servicepoint-simulator) - A bunch of projects (C): [arfst23/ServicePoint](https://github.com/arfst23/ServicePoint), including - - a CLI tool to display image files on the display or use the display as a TTY - - a BSD games robots clone - - a split-flap-display simulator - - animations that play on the display + - a CLI tool to display image files on the display or use the display as a TTY + - a BSD games robots clone + - a split-flap-display simulator + - animations that play on the display - tanks game (C#): [servicepoint-tanks](https://github.com/kaesaecracker/cccb-tanks-cs) - cellular automata slideshow (rust): [servicepoint-life](https://github.com/kaesaecracker/servicepoint-life) diff --git a/crates/servicepoint_binding_uniffi/README.md b/crates/servicepoint_binding_uniffi/README.md new file mode 100644 index 0000000..b71c35d --- /dev/null +++ b/crates/servicepoint_binding_uniffi/README.md @@ -0,0 +1,90 @@ +# ServicePoint + +In [CCCB](https://berlin.ccc.de/), there is a big pixel matrix hanging on the wall. It is called "Service Point +Display" or "Airport Display". + +This crate contains bindings for multiple programming languages, enabling non-rust-developers to use the library. + +Also take a look at the main project [README](https://github.com/cccb/servicepoint/blob/main/README.md) for more +information. + +## Note on stability + +This library is still in early development. +You can absolutely use it, and it works, but expect minor breaking changes with every version bump. + +## Notes on differences to rust library + +- Performance will not be as good as the rust version: + - most objects are reference counted. + - objects with mutating methods will also have a MRSW lock +- You will not get rust backtraces in release builds of the native code +- Panic messages will work (PanicException) + +## Supported languages + +| Language | Support level | Notes | +|-----------|---------------|-------------------------------------------------------------------------------------------------| +| .NET (C#) | Full | see dedicated section | +| Ruby | Working | LD_LIBRARY_PATH has to be set, see example project | +| Python | Tested once | Required project file not included. The shared library will be loaded from the script location. | +| Go | untested | | +| Kotlin | untested | | +| Swift | untested | | + +## Installation + +Including this repository as a submodule and building from source is the recommended way of using the library. + +```bash +git submodule add https://github.com/cccb/servicepoint.git +git commit -m "add servicepoint submodule" +``` + +Run `generate-bindings.sh` to regenerate all bindings. This will also build `libservicepoint.so` (or equivalent on your +platform). + +For languages not fully supported, there will be no project file for the library, just the naked source file(s). +If you successfully use a language, please open an issue or PR to add the missing ones. + +## .NET (C#) + +This is the best supported language. + +F# is not tested. If there are usability or functionality problems, please open an issue. + +Currently, the project file is hard-coded for Linux and will need tweaks for other platforms (e.g. `.dylib` instead of `.so`). + +You do not have to compile or copy the rust crate manually, as building `ServicePoint.csproj` also builds it. + +### Example + +```csharp +using System.Threading; +using ServicePoint; + +var connection = new Connection("127.0.0.1:2342"); +connection.Send(Command.Clear()); + +connection.Send(Command.Brightness(5)); + +var pixels = Bitmap.NewMaxSized(); +for (ulong offset = 0; offset < ulong.MaxValue; offset++) +{ + pixels.Fill(false); + + for (ulong y = 0; y < pixels.Height(); y++) + pixels.Set((y + offset) % pixels.Width(), y, true); + + connection.Send(Command.BitmapLinearWin(0, 0, pixels)); + Thread.Sleep(14); +} +``` + +A full example including project files is available as part of this crate. + +### Why is there no NuGet-Package? + +NuGet packages are not a good way to distribute native +binaries ([relevant issue](https://github.com/dotnet/sdk/issues/33845)). +Because of that, there is no NuGet package you can use directly. diff --git a/crates/servicepoint_binding_uniffi/generate-bindings.sh b/crates/servicepoint_binding_uniffi/generate-bindings.sh index 5b0866d..bfb571c 100755 --- a/crates/servicepoint_binding_uniffi/generate-bindings.sh +++ b/crates/servicepoint_binding_uniffi/generate-bindings.sh @@ -19,6 +19,6 @@ COMMON_ARGS="--library $SERVICEPOINT_SO" ${BINDGEN} generate $COMMON_ARGS --language python --out-dir "$LIBRARIES_PATH/python" ${BINDGEN} generate $COMMON_ARGS --language kotlin --out-dir "$LIBRARIES_PATH/kotlin" ${BINDGEN} generate $COMMON_ARGS --language swift --out-dir "$LIBRARIES_PATH/swift" -${BINDGEN} generate $COMMON_ARGS --language ruby --out-dir "$LIBRARIES_PATH/ruby" +${BINDGEN} generate $COMMON_ARGS --language ruby --out-dir "$LIBRARIES_PATH/ruby/lib" ${BINDGEN_CS} $COMMON_ARGS --out-dir "$LIBRARIES_PATH/csharp/ServicePoint" ${BINDGEN_GO} $COMMON_ARGS --out-dir "$LIBRARIES_PATH/go/" diff --git a/crates/servicepoint_binding_uniffi/libraries/.gitignore b/crates/servicepoint_binding_uniffi/libraries/.gitignore new file mode 100644 index 0000000..a875c72 --- /dev/null +++ b/crates/servicepoint_binding_uniffi/libraries/.gitignore @@ -0,0 +1,4 @@ +go +kotlin +python +swift \ No newline at end of file diff --git a/crates/servicepoint_binding_uniffi/libraries/ruby/example/Gemfile b/crates/servicepoint_binding_uniffi/libraries/ruby/example/Gemfile new file mode 100644 index 0000000..f44ed21 --- /dev/null +++ b/crates/servicepoint_binding_uniffi/libraries/ruby/example/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'servicepoint', path: '..' diff --git a/crates/servicepoint_binding_uniffi/libraries/ruby/example/Gemfile.lock b/crates/servicepoint_binding_uniffi/libraries/ruby/example/Gemfile.lock new file mode 100644 index 0000000..2b6d5f7 --- /dev/null +++ b/crates/servicepoint_binding_uniffi/libraries/ruby/example/Gemfile.lock @@ -0,0 +1,19 @@ +PATH + remote: .. + specs: + servicepoint (0.0.0) + ffi + +GEM + remote: https://rubygems.org/ + specs: + ffi (1.17.0-x86_64-linux-gnu) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + servicepoint! + +BUNDLED WITH + 2.3.27 diff --git a/crates/servicepoint_binding_uniffi/libraries/ruby/example/example.rb b/crates/servicepoint_binding_uniffi/libraries/ruby/example/example.rb new file mode 100644 index 0000000..8d212f2 --- /dev/null +++ b/crates/servicepoint_binding_uniffi/libraries/ruby/example/example.rb @@ -0,0 +1,25 @@ +require_relative "../lib/servicepoint_binding_uniffi" + +include ServicepointBindingUniffi + +connection = Connection.new("172.23.42.29:2342") + +pixels = Bitmap.new_max_sized +x_offset = 0 +loop do + + pixels.fill(false) + + (0..((pixels.height) -1)).each do |y| + pixels.set((y + x_offset) % pixels.width, y, true); + end + + command = Command.bitmap_linear_win(0, 0, pixels, CompressionCode::UNCOMPRESSED) + + connection.send(command) + sleep 0.0005 + + x_offset += 1 +end + + diff --git a/crates/servicepoint_binding_uniffi/libraries/ruby/example/example.sh b/crates/servicepoint_binding_uniffi/libraries/ruby/example/example.sh new file mode 100755 index 0000000..25ed29e --- /dev/null +++ b/crates/servicepoint_binding_uniffi/libraries/ruby/example/example.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +LD_LIBRARY_PATH="../../../../../target/release:$LD_LIBRARY_PATH" ruby example.rb diff --git a/crates/servicepoint_binding_uniffi/libraries/ruby/lib/servicepoint_binding_uniffi.rb b/crates/servicepoint_binding_uniffi/libraries/ruby/lib/servicepoint_binding_uniffi.rb new file mode 100644 index 0000000..b66f128 --- /dev/null +++ b/crates/servicepoint_binding_uniffi/libraries/ruby/lib/servicepoint_binding_uniffi.rb @@ -0,0 +1,1897 @@ +# This file was autogenerated by some hot garbage in the `uniffi` crate. +# Trust me, you don't want to mess with it! + +# Common helper code. +# +# Ideally this would live in a separate .rb file where it can be unittested etc +# in isolation, and perhaps even published as a re-useable package. +# +# However, it's important that the details of how this helper code works (e.g. the +# way that different builtin types are passed across the FFI) exactly match what's +# expected by the rust code on the other side of the interface. In practice right +# now that means coming from the exact some version of `uniffi` that was used to +# compile the rust component. The easiest way to ensure this is to bundle the Ruby +# helpers directly inline like we're doing here. + +require 'ffi' + + +module ServicepointBindingUniffi + def self.uniffi_in_range(i, type_name, min, max) + raise TypeError, "no implicit conversion of #{i} into Integer" unless i.respond_to?(:to_int) + i = i.to_int + raise RangeError, "#{type_name} requires #{min} <= value < #{max}" unless (min <= i && i < max) + i +end + +def self.uniffi_utf8(v) + raise TypeError, "no implicit conversion of #{v} into String" unless v.respond_to?(:to_str) + v = v.to_str.encode(Encoding::UTF_8) + raise Encoding::InvalidByteSequenceError, "not a valid UTF-8 encoded string" unless v.valid_encoding? + v +end + +def self.uniffi_bytes(v) + raise TypeError, "no implicit conversion of #{v} into String" unless v.respond_to?(:to_str) + v.to_str +end + + class RustBuffer < FFI::Struct + layout :capacity, :int32, + :len, :int32, + :data, :pointer + + def self.alloc(size) + return ServicepointBindingUniffi.rust_call(:ffi_servicepoint_binding_uniffi_rustbuffer_alloc, size) + end + + def self.reserve(rbuf, additional) + return ServicepointBindingUniffi.rust_call(:ffi_servicepoint_binding_uniffi_rustbuffer_reserve, rbuf, additional) + end + + def free + ServicepointBindingUniffi.rust_call(:ffi_servicepoint_binding_uniffi_rustbuffer_free, self) + end + + def capacity + self[:capacity] + end + + def len + self[:len] + end + + def len=(value) + self[:len] = value + end + + def data + self[:data] + end + + def to_s + "RustBuffer(capacity=#{capacity}, len=#{len}, data=#{data.read_bytes len})" + end + + # The allocated buffer will be automatically freed if an error occurs, ensuring that + # we don't accidentally leak it. + def self.allocWithBuilder + builder = RustBufferBuilder.new + + begin + yield builder + rescue => e + builder.discard + raise e + end + end + + # The RustBuffer will be freed once the context-manager exits, ensuring that we don't + # leak it even if an error occurs. + def consumeWithStream + stream = RustBufferStream.new self + + yield stream + + raise RuntimeError, 'junk data left in buffer after consuming' if stream.remaining != 0 + ensure + free + end# The primitive String type. + + def self.allocFromString(value) + RustBuffer.allocWithBuilder do |builder| + builder.write value.encode('utf-8') + return builder.finalize + end + end + + def consumeIntoString + consumeWithStream do |stream| + return stream.read(stream.remaining).force_encoding(Encoding::UTF_8) + end + end + + # The primitive Bytes type. + + def self.allocFromBytes(value) + RustBuffer.allocWithBuilder do |builder| + builder.write_Bytes(value) + return builder.finalize + end + end + + def consumeIntoBytes + consumeWithStream do |stream| + return stream.readBytes + end + end + + + + # The Enum type CompressionCode. + + def self.alloc_from_TypeCompressionCode(v) + RustBuffer.allocWithBuilder do |builder| + builder.write_TypeCompressionCode(v) + return builder.finalize + end + end + + def consumeIntoTypeCompressionCode + consumeWithStream do |stream| + return stream.readTypeCompressionCode + end + end + + + + + +end + +module UniFFILib + class ForeignBytes < FFI::Struct + layout :len, :int32, + :data, :pointer + + def len + self[:len] + end + + def data + self[:data] + end + + def to_s + "ForeignBytes(len=#{len}, data=#{data.read_bytes(len)})" + end + end +end + +private_constant :UniFFILib + +# Helper for structured reading of values from a RustBuffer. +class RustBufferStream + + def initialize(rbuf) + @rbuf = rbuf + @offset = 0 + end + + def remaining + @rbuf.len - @offset + end + + def read(size) + raise InternalError, 'read past end of rust buffer' if @offset + size > @rbuf.len + + data = @rbuf.data.get_bytes @offset, size + + @offset += size + + data + end + + def readU8 + unpack_from 1, 'c' + end + + def readU64 + unpack_from 8, 'Q>' + end + + def readBool + v = unpack_from 1, 'c' + + return false if v == 0 + return true if v == 1 + + raise InternalError, 'Unexpected byte for Boolean type' + end + + def readString + size = unpack_from 4, 'l>' + + raise InternalError, 'Unexpected negative string length' if size.negative? + + read(size).force_encoding(Encoding::UTF_8) + end + + def readBytes + size = unpack_from 4, 'l>' + + raise InternalError, 'Unexpected negative byte string length' if size.negative? + + read(size).force_encoding(Encoding::BINARY) + end + + # The Object type BitVec. + + def readTypeBitVec + pointer = FFI::Pointer.new unpack_from 8, 'Q>' + return BitVec._uniffi_allocate(pointer) + end + + # The Object type Bitmap. + + def readTypeBitmap + pointer = FFI::Pointer.new unpack_from 8, 'Q>' + return Bitmap._uniffi_allocate(pointer) + end + + # The Object type BrightnessGrid. + + def readTypeBrightnessGrid + pointer = FFI::Pointer.new unpack_from 8, 'Q>' + return BrightnessGrid._uniffi_allocate(pointer) + end + + # The Object type CharGrid. + + def readTypeCharGrid + pointer = FFI::Pointer.new unpack_from 8, 'Q>' + return CharGrid._uniffi_allocate(pointer) + end + + # The Object type Command. + + def readTypeCommand + pointer = FFI::Pointer.new unpack_from 8, 'Q>' + return Command._uniffi_allocate(pointer) + end + + # The Object type Connection. + + def readTypeConnection + pointer = FFI::Pointer.new unpack_from 8, 'Q>' + return Connection._uniffi_allocate(pointer) + end + + # The Object type Cp437Grid. + + def readTypeCp437Grid + pointer = FFI::Pointer.new unpack_from 8, 'Q>' + return Cp437Grid._uniffi_allocate(pointer) + end + + + + + + # The Error type CharGridError + + def readTypeCharGridError + variant = unpack_from 4, 'l>' + + if variant == 1 + return CharGridError::StringNotOneChar.new( + readString() + ) + end + if variant == 2 + return CharGridError::InvalidSeriesLength.new( + readU64(), + readU64() + ) + end + if variant == 3 + return CharGridError::OutOfBounds.new( + readU64(), + readU64() + ) + end + + raise InternalError, 'Unexpected variant tag for TypeCharGridError' + end + + + + + # The Enum type CompressionCode. + + def readTypeCompressionCode + variant = unpack_from 4, 'l>' + + if variant == 1 + return CompressionCode::UNCOMPRESSED + end + if variant == 2 + return CompressionCode::ZLIB + end + if variant == 3 + return CompressionCode::BZIP2 + end + if variant == 4 + return CompressionCode::LZMA + end + if variant == 5 + return CompressionCode::ZSTD + end + + raise InternalError, 'Unexpected variant tag for TypeCompressionCode' + end + + + + + + + + # The Error type ServicePointError + + def readTypeServicePointError + variant = unpack_from 4, 'l>' + + if variant == 1 + return ServicePointError::IoError.new( + readString() + ) + end + if variant == 2 + return ServicePointError::InvalidBrightness.new( + readU8() + ) + end + + raise InternalError, 'Unexpected variant tag for TypeServicePointError' + end + + + + + def unpack_from(size, format) + raise InternalError, 'read past end of rust buffer' if @offset + size > @rbuf.len + + value = @rbuf.data.get_bytes(@offset, size).unpack format + + @offset += size + + # TODO: verify this + raise 'more than one element!!!' if value.size > 1 + + value[0] + end +end + +private_constant :RustBufferStream + +# Helper for structured writing of values into a RustBuffer. +class RustBufferBuilder + def initialize + @rust_buf = RustBuffer.alloc 16 + @rust_buf.len = 0 + end + + def finalize + rbuf = @rust_buf + + @rust_buf = nil + + rbuf + end + + def discard + return if @rust_buf.nil? + + rbuf = finalize + rbuf.free + end + + def write(value) + reserve(value.bytes.size) do + @rust_buf.data.put_array_of_char @rust_buf.len, value.bytes + end + end + + def write_U8(v) + v = ServicepointBindingUniffi::uniffi_in_range(v, "u8", 0, 2**8) + pack_into(1, 'c', v) + end + + def write_U64(v) + v = ServicepointBindingUniffi::uniffi_in_range(v, "u64", 0, 2**64) + pack_into(8, 'Q>', v) + end + + def write_Bool(v) + pack_into(1, 'c', v ? 1 : 0) + end + + def write_String(v) + v = ServicepointBindingUniffi::uniffi_utf8(v) + pack_into 4, 'l>', v.bytes.size + write v + end + + def write_Bytes(v) + v = ServicepointBindingUniffi::uniffi_bytes(v) + pack_into 4, 'l>', v.bytes.size + write v + end + + # The Object type BitVec. + + def write_TypeBitVec(obj) + pointer = BitVec._uniffi_lower obj + pack_into(8, 'Q>', pointer.address) + end + + # The Object type Bitmap. + + def write_TypeBitmap(obj) + pointer = Bitmap._uniffi_lower obj + pack_into(8, 'Q>', pointer.address) + end + + # The Object type BrightnessGrid. + + def write_TypeBrightnessGrid(obj) + pointer = BrightnessGrid._uniffi_lower obj + pack_into(8, 'Q>', pointer.address) + end + + # The Object type CharGrid. + + def write_TypeCharGrid(obj) + pointer = CharGrid._uniffi_lower obj + pack_into(8, 'Q>', pointer.address) + end + + # The Object type Command. + + def write_TypeCommand(obj) + pointer = Command._uniffi_lower obj + pack_into(8, 'Q>', pointer.address) + end + + # The Object type Connection. + + def write_TypeConnection(obj) + pointer = Connection._uniffi_lower obj + pack_into(8, 'Q>', pointer.address) + end + + # The Object type Cp437Grid. + + def write_TypeCp437Grid(obj) + pointer = Cp437Grid._uniffi_lower obj + pack_into(8, 'Q>', pointer.address) + end + + + + # The Enum type CompressionCode. + + def write_TypeCompressionCode(v) + pack_into(4, 'l>', v) + end + + + + + + + private + + def reserve(num_bytes) + if @rust_buf.len + num_bytes > @rust_buf.capacity + @rust_buf = RustBuffer.reserve(@rust_buf, num_bytes) + end + + yield + + @rust_buf.len += num_bytes + end + + def pack_into(size, format, value) + reserve(size) do + @rust_buf.data.put_array_of_char @rust_buf.len, [value].pack(format).bytes + end + end +end + +private_constant :RustBufferBuilder + + # Error definitions + class RustCallStatus < FFI::Struct + layout :code, :int8, + :error_buf, RustBuffer + + def code + self[:code] + end + + def error_buf + self[:error_buf] + end + + def to_s + "RustCallStatus(code=#{self[:code]})" + end +end + +# These match the values from the uniffi::rustcalls module +CALL_SUCCESS = 0 +CALL_ERROR = 1 +CALL_PANIC = 2 + + +module CharGridError + class StringNotOneChar < StandardError + def initialize(value) + @value = value + super() + end + + attr_reader :value + + + def to_s + "#{self.class.name}(value=#{@value.inspect})" + end + end + class InvalidSeriesLength < StandardError + def initialize(actual, expected) + @actual = actual + @expected = expected + super() + end + + attr_reader :actual, :expected + + + def to_s + "#{self.class.name}(actual=#{@actual.inspect}, expected=#{@expected.inspect})" + end + end + class OutOfBounds < StandardError + def initialize(index, size) + @index = index + @size = size + super() + end + + attr_reader :index, :size + + + def to_s + "#{self.class.name}(index=#{@index.inspect}, size=#{@size.inspect})" + end + end + +end + + + + +module ServicePointError + class IoError < StandardError + def initialize(error) + @error = error + super() + end + + attr_reader :error + + + def to_s + "#{self.class.name}(error=#{@error.inspect})" + end + end + class InvalidBrightness < StandardError + def initialize(value) + @value = value + super() + end + + attr_reader :value + + + def to_s + "#{self.class.name}(value=#{@value.inspect})" + end + end + +end + + +# Map error modules to the RustBuffer method name that reads them +ERROR_MODULE_TO_READER_METHOD = { + + CharGridError => :readTypeCharGridError, + + + + ServicePointError => :readTypeServicePointError, + +} + +private_constant :ERROR_MODULE_TO_READER_METHOD, :CALL_SUCCESS, :CALL_ERROR, :CALL_PANIC, + :RustCallStatus + +def self.consume_buffer_into_error(error_module, rust_buffer) + rust_buffer.consumeWithStream do |stream| + reader_method = ERROR_MODULE_TO_READER_METHOD[error_module] + return stream.send(reader_method) + end +end + +class InternalError < StandardError +end + +def self.rust_call(fn_name, *args) + # Call a rust function + rust_call_with_error(nil, fn_name, *args) +end + +def self.rust_call_with_error(error_module, fn_name, *args) + # Call a rust function and handle errors + # + # Use this when the rust function returns a Result<>. error_module must be the error_module that corresponds to that Result. + + + # Note: RustCallStatus.new zeroes out the struct, which is exactly what we + # want to pass to Rust (code=0, error_buf=RustBuffer(len=0, capacity=0, + # data=NULL)) + status = RustCallStatus.new + args << status + + result = UniFFILib.public_send(fn_name, *args) + + case status.code + when CALL_SUCCESS + result + when CALL_ERROR + if error_module.nil? + status.error_buf.free + raise InternalError, "CALL_ERROR with no error_module set" + else + raise consume_buffer_into_error(error_module, status.error_buf) + end + when CALL_PANIC + # When the rust code sees a panic, it tries to construct a RustBuffer + # with the message. But if that code panics, then it just sends back + # an empty buffer. + if status.error_buf.len > 0 + raise InternalError, status.error_buf.consumeIntoString() + else + raise InternalError, "Rust panic" + end + else + raise InternalError, "Unknown call status: #{status.code}" + end +end + +private_class_method :consume_buffer_into_error + + # This is how we find and load the dynamic library provided by the component. +# For now we just look it up by name. +module UniFFILib + extend FFI::Library + + + ffi_lib 'servicepoint_binding_uniffi' + + + attach_function :uniffi_servicepoint_binding_uniffi_fn_free_bitvec, + [:pointer, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_bitvec_clone, + [:pointer, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_bitvec_load, + [RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_bitvec_new, + [:uint64, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitvec_copy_raw, + [:pointer, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitvec_equals, + [:pointer, :pointer, RustCallStatus.by_ref], + :int8 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitvec_fill, + [:pointer, :int8, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitvec_get, + [:pointer, :uint64, RustCallStatus.by_ref], + :int8 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitvec_len, + [:pointer, RustCallStatus.by_ref], + :uint64 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitvec_set, + [:pointer, :uint64, :int8, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_free_bitmap, + [:pointer, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_bitmap_clone, + [:pointer, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_bitmap_load, + [:uint64, :uint64, RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_bitmap_new, + [:uint64, :uint64, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_bitmap_new_max_sized, + [RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitmap_copy_raw, + [:pointer, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitmap_equals, + [:pointer, :pointer, RustCallStatus.by_ref], + :int8 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitmap_fill, + [:pointer, :int8, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitmap_get, + [:pointer, :uint64, :uint64, RustCallStatus.by_ref], + :int8 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitmap_height, + [:pointer, RustCallStatus.by_ref], + :uint64 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitmap_set, + [:pointer, :uint64, :uint64, :int8, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_bitmap_width, + [:pointer, RustCallStatus.by_ref], + :uint64 + attach_function :uniffi_servicepoint_binding_uniffi_fn_free_brightnessgrid, + [:pointer, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_brightnessgrid_clone, + [:pointer, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_brightnessgrid_load, + [:uint64, :uint64, RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_brightnessgrid_new, + [:uint64, :uint64, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_copy_raw, + [:pointer, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_equals, + [:pointer, :pointer, RustCallStatus.by_ref], + :int8 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_fill, + [:pointer, :uint8, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_get, + [:pointer, :uint64, :uint64, RustCallStatus.by_ref], + :uint8 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_height, + [:pointer, RustCallStatus.by_ref], + :uint64 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_set, + [:pointer, :uint64, :uint64, :uint8, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_width, + [:pointer, RustCallStatus.by_ref], + :uint64 + attach_function :uniffi_servicepoint_binding_uniffi_fn_free_chargrid, + [:pointer, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_chargrid_clone, + [:pointer, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_chargrid_load, + [RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_chargrid_new, + [:uint64, :uint64, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_as_string, + [:pointer, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_equals, + [:pointer, :pointer, RustCallStatus.by_ref], + :int8 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_fill, + [:pointer, RustBuffer.by_value, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_get, + [:pointer, :uint64, :uint64, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_get_col, + [:pointer, :uint64, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_get_row, + [:pointer, :uint64, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_height, + [:pointer, RustCallStatus.by_ref], + :uint64 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_set, + [:pointer, :uint64, :uint64, RustBuffer.by_value, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_set_col, + [:pointer, :uint64, RustBuffer.by_value, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_set_row, + [:pointer, :uint64, RustBuffer.by_value, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_to_cp437, + [:pointer, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_chargrid_width, + [:pointer, RustCallStatus.by_ref], + :uint64 + attach_function :uniffi_servicepoint_binding_uniffi_fn_free_command, + [:pointer, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_bitmap_linear, + [:uint64, :pointer, RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_bitmap_linear_and, + [:uint64, :pointer, RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_bitmap_linear_or, + [:uint64, :pointer, RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_bitmap_linear_win, + [:uint64, :uint64, :pointer, RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_bitmap_linear_xor, + [:uint64, :pointer, RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_brightness, + [:uint8, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_char_brightness, + [:uint64, :uint64, :pointer, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_clear, + [RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_clone, + [:pointer, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_cp437_data, + [:uint64, :uint64, :pointer, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_fade_out, + [RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset, + [RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_command_equals, + [:pointer, :pointer, RustCallStatus.by_ref], + :int8 + attach_function :uniffi_servicepoint_binding_uniffi_fn_free_connection, + [:pointer, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_connection_new, + [RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_connection_new_fake, + [RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_connection_send, + [:pointer, :pointer, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_free_cp437grid, + [:pointer, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_clone, + [:pointer, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_load, + [:uint64, :uint64, RustBuffer.by_value, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_new, + [:uint64, :uint64, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_copy_raw, + [:pointer, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_equals, + [:pointer, :pointer, RustCallStatus.by_ref], + :int8 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_fill, + [:pointer, :uint8, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_get, + [:pointer, :uint64, :uint64, RustCallStatus.by_ref], + :uint8 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_height, + [:pointer, RustCallStatus.by_ref], + :uint64 + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_set, + [:pointer, :uint64, :uint64, :uint8, RustCallStatus.by_ref], + :void + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_to_utf8, + [:pointer, RustCallStatus.by_ref], + :pointer + attach_function :uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_width, + [:pointer, RustCallStatus.by_ref], + :uint64 + attach_function :ffi_servicepoint_binding_uniffi_rustbuffer_alloc, + [:int32, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :ffi_servicepoint_binding_uniffi_rustbuffer_from_bytes, + [ForeignBytes, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :ffi_servicepoint_binding_uniffi_rustbuffer_free, + [RustBuffer.by_value, RustCallStatus.by_ref], + :void + attach_function :ffi_servicepoint_binding_uniffi_rustbuffer_reserve, + [RustBuffer.by_value, :int32, RustCallStatus.by_ref], + RustBuffer.by_value + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_copy_raw, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_equals, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_fill, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_get, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_len, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitvec_set, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_copy_raw, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_equals, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_fill, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_get, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_height, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_set, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_bitmap_width, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_copy_raw, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_equals, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_fill, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_get, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_height, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_set, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_width, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_as_string, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_equals, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_fill, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_get, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_get_col, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_get_row, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_height, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_set, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_set_col, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_set_row, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_to_cp437, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_chargrid_width, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_command_equals, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_connection_send, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_copy_raw, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_equals, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_fill, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_get, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_height, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_set, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_to_utf8, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_method_cp437grid_width, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_bitvec_clone, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_bitvec_load, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_bitvec_new, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_bitmap_clone, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_bitmap_load, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_bitmap_new, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_bitmap_new_max_sized, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_brightnessgrid_clone, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_brightnessgrid_load, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_brightnessgrid_new, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_chargrid_clone, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_chargrid_load, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_chargrid_new, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_bitmap_linear, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_bitmap_linear_and, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_bitmap_linear_or, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_bitmap_linear_win, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_bitmap_linear_xor, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_brightness, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_char_brightness, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_clear, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_clone, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_cp437_data, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_fade_out, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_command_hard_reset, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_connection_new_fake, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_clone, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_load, + [RustCallStatus.by_ref], + :uint16 + attach_function :uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_new, + [RustCallStatus.by_ref], + :uint16 + attach_function :ffi_servicepoint_binding_uniffi_uniffi_contract_version, + [RustCallStatus.by_ref], + :uint32 + +end + + # Public interface members begin here. + + + + + + +class CompressionCode + UNCOMPRESSED = 1 + ZLIB = 2 + BZIP2 = 3 + LZMA = 4 + ZSTD = 5 + +end + + + + + + + + + class BitVec + + # A private helper for initializing instances of the class from a raw pointer, + # bypassing any initialization logic and ensuring they are GC'd properly. + def self._uniffi_allocate(pointer) + pointer.autorelease = false + inst = allocate + inst.instance_variable_set :@pointer, pointer + ObjectSpace.define_finalizer(inst, _uniffi_define_finalizer_by_pointer(pointer, inst.object_id)) + return inst + end + + # A private helper for registering an object finalizer. + # N.B. it's important that this does not capture a reference + # to the actual instance, only its underlying pointer. + def self._uniffi_define_finalizer_by_pointer(pointer, object_id) + Proc.new do |_id| + ServicepointBindingUniffi.rust_call( + :uniffi_servicepoint_binding_uniffi_fn_free_bitvec, + pointer + ) + end + end + + # A private helper for lowering instances into a raw pointer. + # This does an explicit typecheck, because accidentally lowering a different type of + # object in a place where this type is expected, could lead to memory unsafety. + def self._uniffi_lower(inst) + if not inst.is_a? self + raise TypeError.new "Expected a BitVec instance, got #{inst}" + end + return inst.instance_variable_get :@pointer + end + def initialize(size) + size = ServicepointBindingUniffi::uniffi_in_range(size, "u64", 0, 2**64) + pointer = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_bitvec_new,size) + @pointer = pointer + ObjectSpace.define_finalizer(self, self.class._uniffi_define_finalizer_by_pointer(pointer, self.object_id)) + end + + def self.clone(other) + other = other + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_bitvec_clone,(BitVec._uniffi_lower other))) + end + def self.load(data) + data = ServicepointBindingUniffi::uniffi_bytes(data) + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_bitvec_load,RustBuffer.allocFromBytes(data))) + end + + + def copy_raw() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitvec_copy_raw,@pointer,) + return result.consumeIntoBytes + end + def equals(other) + other = other + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitvec_equals,@pointer,(BitVec._uniffi_lower other)) + return 1 == result + end + def fill(value) + value = value ? true : false + ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitvec_fill,@pointer,(value ? 1 : 0)) + end + + def get(index) + index = ServicepointBindingUniffi::uniffi_in_range(index, "u64", 0, 2**64) + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitvec_get,@pointer,index) + return 1 == result + end + def len() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitvec_len,@pointer,) + return result.to_i + end + def set(index, value) + index = ServicepointBindingUniffi::uniffi_in_range(index, "u64", 0, 2**64) + value = value ? true : false + ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitvec_set,@pointer,index,(value ? 1 : 0)) + end + + +end + + class Bitmap + + # A private helper for initializing instances of the class from a raw pointer, + # bypassing any initialization logic and ensuring they are GC'd properly. + def self._uniffi_allocate(pointer) + pointer.autorelease = false + inst = allocate + inst.instance_variable_set :@pointer, pointer + ObjectSpace.define_finalizer(inst, _uniffi_define_finalizer_by_pointer(pointer, inst.object_id)) + return inst + end + + # A private helper for registering an object finalizer. + # N.B. it's important that this does not capture a reference + # to the actual instance, only its underlying pointer. + def self._uniffi_define_finalizer_by_pointer(pointer, object_id) + Proc.new do |_id| + ServicepointBindingUniffi.rust_call( + :uniffi_servicepoint_binding_uniffi_fn_free_bitmap, + pointer + ) + end + end + + # A private helper for lowering instances into a raw pointer. + # This does an explicit typecheck, because accidentally lowering a different type of + # object in a place where this type is expected, could lead to memory unsafety. + def self._uniffi_lower(inst) + if not inst.is_a? self + raise TypeError.new "Expected a Bitmap instance, got #{inst}" + end + return inst.instance_variable_get :@pointer + end + def initialize(width, height) + width = ServicepointBindingUniffi::uniffi_in_range(width, "u64", 0, 2**64) + height = ServicepointBindingUniffi::uniffi_in_range(height, "u64", 0, 2**64) + pointer = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_bitmap_new,width,height) + @pointer = pointer + ObjectSpace.define_finalizer(self, self.class._uniffi_define_finalizer_by_pointer(pointer, self.object_id)) + end + + def self.clone(other) + other = other + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_bitmap_clone,(Bitmap._uniffi_lower other))) + end + def self.load(width, height, data) + width = ServicepointBindingUniffi::uniffi_in_range(width, "u64", 0, 2**64) + height = ServicepointBindingUniffi::uniffi_in_range(height, "u64", 0, 2**64) + data = ServicepointBindingUniffi::uniffi_bytes(data) + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_bitmap_load,width,height,RustBuffer.allocFromBytes(data))) + end + def self.new_max_sized() + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_bitmap_new_max_sized,)) + end + + + def copy_raw() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitmap_copy_raw,@pointer,) + return result.consumeIntoBytes + end + def equals(other) + other = other + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitmap_equals,@pointer,(Bitmap._uniffi_lower other)) + return 1 == result + end + def fill(value) + value = value ? true : false + ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitmap_fill,@pointer,(value ? 1 : 0)) + end + + def get(x, y) + x = ServicepointBindingUniffi::uniffi_in_range(x, "u64", 0, 2**64) + y = ServicepointBindingUniffi::uniffi_in_range(y, "u64", 0, 2**64) + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitmap_get,@pointer,x,y) + return 1 == result + end + def height() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitmap_height,@pointer,) + return result.to_i + end + def set(x, y, value) + x = ServicepointBindingUniffi::uniffi_in_range(x, "u64", 0, 2**64) + y = ServicepointBindingUniffi::uniffi_in_range(y, "u64", 0, 2**64) + value = value ? true : false + ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitmap_set,@pointer,x,y,(value ? 1 : 0)) + end + + def width() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_bitmap_width,@pointer,) + return result.to_i + end + +end + + class BrightnessGrid + + # A private helper for initializing instances of the class from a raw pointer, + # bypassing any initialization logic and ensuring they are GC'd properly. + def self._uniffi_allocate(pointer) + pointer.autorelease = false + inst = allocate + inst.instance_variable_set :@pointer, pointer + ObjectSpace.define_finalizer(inst, _uniffi_define_finalizer_by_pointer(pointer, inst.object_id)) + return inst + end + + # A private helper for registering an object finalizer. + # N.B. it's important that this does not capture a reference + # to the actual instance, only its underlying pointer. + def self._uniffi_define_finalizer_by_pointer(pointer, object_id) + Proc.new do |_id| + ServicepointBindingUniffi.rust_call( + :uniffi_servicepoint_binding_uniffi_fn_free_brightnessgrid, + pointer + ) + end + end + + # A private helper for lowering instances into a raw pointer. + # This does an explicit typecheck, because accidentally lowering a different type of + # object in a place where this type is expected, could lead to memory unsafety. + def self._uniffi_lower(inst) + if not inst.is_a? self + raise TypeError.new "Expected a BrightnessGrid instance, got #{inst}" + end + return inst.instance_variable_get :@pointer + end + def initialize(width, height) + width = ServicepointBindingUniffi::uniffi_in_range(width, "u64", 0, 2**64) + height = ServicepointBindingUniffi::uniffi_in_range(height, "u64", 0, 2**64) + pointer = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_brightnessgrid_new,width,height) + @pointer = pointer + ObjectSpace.define_finalizer(self, self.class._uniffi_define_finalizer_by_pointer(pointer, self.object_id)) + end + + def self.clone(other) + other = other + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_brightnessgrid_clone,(BrightnessGrid._uniffi_lower other))) + end + def self.load(width, height, data) + width = ServicepointBindingUniffi::uniffi_in_range(width, "u64", 0, 2**64) + height = ServicepointBindingUniffi::uniffi_in_range(height, "u64", 0, 2**64) + data = ServicepointBindingUniffi::uniffi_bytes(data) + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_brightnessgrid_load,width,height,RustBuffer.allocFromBytes(data))) + end + + + def copy_raw() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_copy_raw,@pointer,) + return result.consumeIntoBytes + end + def equals(other) + other = other + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_equals,@pointer,(BrightnessGrid._uniffi_lower other)) + return 1 == result + end + def fill(value) + value = ServicepointBindingUniffi::uniffi_in_range(value, "u8", 0, 2**8) + ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_fill,@pointer,value) + end + + def get(x, y) + x = ServicepointBindingUniffi::uniffi_in_range(x, "u64", 0, 2**64) + y = ServicepointBindingUniffi::uniffi_in_range(y, "u64", 0, 2**64) + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_get,@pointer,x,y) + return result.to_i + end + def height() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_height,@pointer,) + return result.to_i + end + def set(x, y, value) + x = ServicepointBindingUniffi::uniffi_in_range(x, "u64", 0, 2**64) + y = ServicepointBindingUniffi::uniffi_in_range(y, "u64", 0, 2**64) + value = ServicepointBindingUniffi::uniffi_in_range(value, "u8", 0, 2**8) + ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_set,@pointer,x,y,value) + end + + def width() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_width,@pointer,) + return result.to_i + end + +end + + class CharGrid + + # A private helper for initializing instances of the class from a raw pointer, + # bypassing any initialization logic and ensuring they are GC'd properly. + def self._uniffi_allocate(pointer) + pointer.autorelease = false + inst = allocate + inst.instance_variable_set :@pointer, pointer + ObjectSpace.define_finalizer(inst, _uniffi_define_finalizer_by_pointer(pointer, inst.object_id)) + return inst + end + + # A private helper for registering an object finalizer. + # N.B. it's important that this does not capture a reference + # to the actual instance, only its underlying pointer. + def self._uniffi_define_finalizer_by_pointer(pointer, object_id) + Proc.new do |_id| + ServicepointBindingUniffi.rust_call( + :uniffi_servicepoint_binding_uniffi_fn_free_chargrid, + pointer + ) + end + end + + # A private helper for lowering instances into a raw pointer. + # This does an explicit typecheck, because accidentally lowering a different type of + # object in a place where this type is expected, could lead to memory unsafety. + def self._uniffi_lower(inst) + if not inst.is_a? self + raise TypeError.new "Expected a CharGrid instance, got #{inst}" + end + return inst.instance_variable_get :@pointer + end + def initialize(width, height) + width = ServicepointBindingUniffi::uniffi_in_range(width, "u64", 0, 2**64) + height = ServicepointBindingUniffi::uniffi_in_range(height, "u64", 0, 2**64) + pointer = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_chargrid_new,width,height) + @pointer = pointer + ObjectSpace.define_finalizer(self, self.class._uniffi_define_finalizer_by_pointer(pointer, self.object_id)) + end + + def self.clone(other) + other = other + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_chargrid_clone,(CharGrid._uniffi_lower other))) + end + def self.load(data) + data = ServicepointBindingUniffi::uniffi_utf8(data) + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_chargrid_load,RustBuffer.allocFromString(data))) + end + + + def as_string() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_as_string,@pointer,) + return result.consumeIntoString + end + def equals(other) + other = other + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_equals,@pointer,(CharGrid._uniffi_lower other)) + return 1 == result + end + def fill(value) + value = ServicepointBindingUniffi::uniffi_utf8(value) + ServicepointBindingUniffi.rust_call_with_error(CharGridError,:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_fill,@pointer,RustBuffer.allocFromString(value)) + end + + def get(x, y) + x = ServicepointBindingUniffi::uniffi_in_range(x, "u64", 0, 2**64) + y = ServicepointBindingUniffi::uniffi_in_range(y, "u64", 0, 2**64) + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_get,@pointer,x,y) + return result.consumeIntoString + end + def get_col(x) + x = ServicepointBindingUniffi::uniffi_in_range(x, "u64", 0, 2**64) + result = ServicepointBindingUniffi.rust_call_with_error(CharGridError,:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_get_col,@pointer,x) + return result.consumeIntoString + end + def get_row(y) + y = ServicepointBindingUniffi::uniffi_in_range(y, "u64", 0, 2**64) + result = ServicepointBindingUniffi.rust_call_with_error(CharGridError,:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_get_row,@pointer,y) + return result.consumeIntoString + end + def height() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_height,@pointer,) + return result.to_i + end + def set(x, y, value) + x = ServicepointBindingUniffi::uniffi_in_range(x, "u64", 0, 2**64) + y = ServicepointBindingUniffi::uniffi_in_range(y, "u64", 0, 2**64) + value = ServicepointBindingUniffi::uniffi_utf8(value) + ServicepointBindingUniffi.rust_call_with_error(CharGridError,:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_set,@pointer,x,y,RustBuffer.allocFromString(value)) + end + + def set_col(x, col) + x = ServicepointBindingUniffi::uniffi_in_range(x, "u64", 0, 2**64) + col = ServicepointBindingUniffi::uniffi_utf8(col) + ServicepointBindingUniffi.rust_call_with_error(CharGridError,:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_set_col,@pointer,x,RustBuffer.allocFromString(col)) + end + + def set_row(y, row) + y = ServicepointBindingUniffi::uniffi_in_range(y, "u64", 0, 2**64) + row = ServicepointBindingUniffi::uniffi_utf8(row) + ServicepointBindingUniffi.rust_call_with_error(CharGridError,:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_set_row,@pointer,y,RustBuffer.allocFromString(row)) + end + + def to_cp437() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_to_cp437,@pointer,) + return Cp437Grid._uniffi_allocate(result) + end + def width() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_chargrid_width,@pointer,) + return result.to_i + end + +end + + class Command + + # A private helper for initializing instances of the class from a raw pointer, + # bypassing any initialization logic and ensuring they are GC'd properly. + def self._uniffi_allocate(pointer) + pointer.autorelease = false + inst = allocate + inst.instance_variable_set :@pointer, pointer + ObjectSpace.define_finalizer(inst, _uniffi_define_finalizer_by_pointer(pointer, inst.object_id)) + return inst + end + + # A private helper for registering an object finalizer. + # N.B. it's important that this does not capture a reference + # to the actual instance, only its underlying pointer. + def self._uniffi_define_finalizer_by_pointer(pointer, object_id) + Proc.new do |_id| + ServicepointBindingUniffi.rust_call( + :uniffi_servicepoint_binding_uniffi_fn_free_command, + pointer + ) + end + end + + # A private helper for lowering instances into a raw pointer. + # This does an explicit typecheck, because accidentally lowering a different type of + # object in a place where this type is expected, could lead to memory unsafety. + def self._uniffi_lower(inst) + if not inst.is_a? self + raise TypeError.new "Expected a Command instance, got #{inst}" + end + return inst.instance_variable_get :@pointer + end + + def self.bitmap_linear(offset, bitmap, compression) + offset = ServicepointBindingUniffi::uniffi_in_range(offset, "u64", 0, 2**64) + bitmap = bitmap + compression = compression + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_bitmap_linear,offset,(BitVec._uniffi_lower bitmap),RustBuffer.alloc_from_TypeCompressionCode(compression))) + end + def self.bitmap_linear_and(offset, bitmap, compression) + offset = ServicepointBindingUniffi::uniffi_in_range(offset, "u64", 0, 2**64) + bitmap = bitmap + compression = compression + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_bitmap_linear_and,offset,(BitVec._uniffi_lower bitmap),RustBuffer.alloc_from_TypeCompressionCode(compression))) + end + def self.bitmap_linear_or(offset, bitmap, compression) + offset = ServicepointBindingUniffi::uniffi_in_range(offset, "u64", 0, 2**64) + bitmap = bitmap + compression = compression + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_bitmap_linear_or,offset,(BitVec._uniffi_lower bitmap),RustBuffer.alloc_from_TypeCompressionCode(compression))) + end + def self.bitmap_linear_win(offset_x, offset_y, bitmap, compression) + offset_x = ServicepointBindingUniffi::uniffi_in_range(offset_x, "u64", 0, 2**64) + offset_y = ServicepointBindingUniffi::uniffi_in_range(offset_y, "u64", 0, 2**64) + bitmap = bitmap + compression = compression + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_bitmap_linear_win,offset_x,offset_y,(Bitmap._uniffi_lower bitmap),RustBuffer.alloc_from_TypeCompressionCode(compression))) + end + def self.bitmap_linear_xor(offset, bitmap, compression) + offset = ServicepointBindingUniffi::uniffi_in_range(offset, "u64", 0, 2**64) + bitmap = bitmap + compression = compression + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_bitmap_linear_xor,offset,(BitVec._uniffi_lower bitmap),RustBuffer.alloc_from_TypeCompressionCode(compression))) + end + def self.brightness(brightness) + brightness = ServicepointBindingUniffi::uniffi_in_range(brightness, "u8", 0, 2**8) + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call_with_error(ServicePointError,:uniffi_servicepoint_binding_uniffi_fn_constructor_command_brightness,brightness)) + end + def self.char_brightness(offset_x, offset_y, grid) + offset_x = ServicepointBindingUniffi::uniffi_in_range(offset_x, "u64", 0, 2**64) + offset_y = ServicepointBindingUniffi::uniffi_in_range(offset_y, "u64", 0, 2**64) + grid = grid + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_char_brightness,offset_x,offset_y,(BrightnessGrid._uniffi_lower grid))) + end + def self.clear() + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_clear,)) + end + def self.clone(other) + other = other + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_clone,(Command._uniffi_lower other))) + end + def self.cp437_data(offset_x, offset_y, grid) + offset_x = ServicepointBindingUniffi::uniffi_in_range(offset_x, "u64", 0, 2**64) + offset_y = ServicepointBindingUniffi::uniffi_in_range(offset_y, "u64", 0, 2**64) + grid = grid + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_cp437_data,offset_x,offset_y,(Cp437Grid._uniffi_lower grid))) + end + def self.fade_out() + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_fade_out,)) + end + def self.hard_reset() + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_command_hard_reset,)) + end + + + def equals(other) + other = other + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_command_equals,@pointer,(Command._uniffi_lower other)) + return 1 == result + end + +end + + class Connection + + # A private helper for initializing instances of the class from a raw pointer, + # bypassing any initialization logic and ensuring they are GC'd properly. + def self._uniffi_allocate(pointer) + pointer.autorelease = false + inst = allocate + inst.instance_variable_set :@pointer, pointer + ObjectSpace.define_finalizer(inst, _uniffi_define_finalizer_by_pointer(pointer, inst.object_id)) + return inst + end + + # A private helper for registering an object finalizer. + # N.B. it's important that this does not capture a reference + # to the actual instance, only its underlying pointer. + def self._uniffi_define_finalizer_by_pointer(pointer, object_id) + Proc.new do |_id| + ServicepointBindingUniffi.rust_call( + :uniffi_servicepoint_binding_uniffi_fn_free_connection, + pointer + ) + end + end + + # A private helper for lowering instances into a raw pointer. + # This does an explicit typecheck, because accidentally lowering a different type of + # object in a place where this type is expected, could lead to memory unsafety. + def self._uniffi_lower(inst) + if not inst.is_a? self + raise TypeError.new "Expected a Connection instance, got #{inst}" + end + return inst.instance_variable_get :@pointer + end + def initialize(host) + host = ServicepointBindingUniffi::uniffi_utf8(host) + pointer = ServicepointBindingUniffi.rust_call_with_error(ServicePointError,:uniffi_servicepoint_binding_uniffi_fn_constructor_connection_new,RustBuffer.allocFromString(host)) + @pointer = pointer + ObjectSpace.define_finalizer(self, self.class._uniffi_define_finalizer_by_pointer(pointer, self.object_id)) + end + + def self.new_fake() + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_connection_new_fake,)) + end + + + def send(command) + command = command + ServicepointBindingUniffi.rust_call_with_error(ServicePointError,:uniffi_servicepoint_binding_uniffi_fn_method_connection_send,@pointer,(Command._uniffi_lower command)) + end + + +end + + class Cp437Grid + + # A private helper for initializing instances of the class from a raw pointer, + # bypassing any initialization logic and ensuring they are GC'd properly. + def self._uniffi_allocate(pointer) + pointer.autorelease = false + inst = allocate + inst.instance_variable_set :@pointer, pointer + ObjectSpace.define_finalizer(inst, _uniffi_define_finalizer_by_pointer(pointer, inst.object_id)) + return inst + end + + # A private helper for registering an object finalizer. + # N.B. it's important that this does not capture a reference + # to the actual instance, only its underlying pointer. + def self._uniffi_define_finalizer_by_pointer(pointer, object_id) + Proc.new do |_id| + ServicepointBindingUniffi.rust_call( + :uniffi_servicepoint_binding_uniffi_fn_free_cp437grid, + pointer + ) + end + end + + # A private helper for lowering instances into a raw pointer. + # This does an explicit typecheck, because accidentally lowering a different type of + # object in a place where this type is expected, could lead to memory unsafety. + def self._uniffi_lower(inst) + if not inst.is_a? self + raise TypeError.new "Expected a Cp437Grid instance, got #{inst}" + end + return inst.instance_variable_get :@pointer + end + def initialize(width, height) + width = ServicepointBindingUniffi::uniffi_in_range(width, "u64", 0, 2**64) + height = ServicepointBindingUniffi::uniffi_in_range(height, "u64", 0, 2**64) + pointer = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_new,width,height) + @pointer = pointer + ObjectSpace.define_finalizer(self, self.class._uniffi_define_finalizer_by_pointer(pointer, self.object_id)) + end + + def self.clone(other) + other = other + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_clone,(Cp437Grid._uniffi_lower other))) + end + def self.load(width, height, data) + width = ServicepointBindingUniffi::uniffi_in_range(width, "u64", 0, 2**64) + height = ServicepointBindingUniffi::uniffi_in_range(height, "u64", 0, 2**64) + data = ServicepointBindingUniffi::uniffi_bytes(data) + # Call the (fallible) function before creating any half-baked object instances. + # Lightly yucky way to bypass the usual "initialize" logic + # and just create a new instance with the required pointer. + return _uniffi_allocate(ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_constructor_cp437grid_load,width,height,RustBuffer.allocFromBytes(data))) + end + + + def copy_raw() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_copy_raw,@pointer,) + return result.consumeIntoBytes + end + def equals(other) + other = other + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_equals,@pointer,(Cp437Grid._uniffi_lower other)) + return 1 == result + end + def fill(value) + value = ServicepointBindingUniffi::uniffi_in_range(value, "u8", 0, 2**8) + ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_fill,@pointer,value) + end + + def get(x, y) + x = ServicepointBindingUniffi::uniffi_in_range(x, "u64", 0, 2**64) + y = ServicepointBindingUniffi::uniffi_in_range(y, "u64", 0, 2**64) + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_get,@pointer,x,y) + return result.to_i + end + def height() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_height,@pointer,) + return result.to_i + end + def set(x, y, value) + x = ServicepointBindingUniffi::uniffi_in_range(x, "u64", 0, 2**64) + y = ServicepointBindingUniffi::uniffi_in_range(y, "u64", 0, 2**64) + value = ServicepointBindingUniffi::uniffi_in_range(value, "u8", 0, 2**8) + ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_set,@pointer,x,y,value) + end + + def to_utf8() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_to_utf8,@pointer,) + return CharGrid._uniffi_allocate(result) + end + def width() + result = ServicepointBindingUniffi.rust_call(:uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_width,@pointer,) + return result.to_i + end + +end + +end + diff --git a/crates/servicepoint_binding_uniffi/libraries/ruby/servicepoint.gemspec b/crates/servicepoint_binding_uniffi/libraries/ruby/servicepoint.gemspec new file mode 100644 index 0000000..412482f --- /dev/null +++ b/crates/servicepoint_binding_uniffi/libraries/ruby/servicepoint.gemspec @@ -0,0 +1,13 @@ +Gem::Specification.new do |s| + s.name = "servicepoint" + s.version = "0.0.0" + s.summary = "" + s.description = "" + s.authors = ["kaesaecracker"] + s.email = "" + s.files = ["lib/servicepoint_binding_uniffi.rb"] + s.homepage = + "https://rubygems.org/gems/hola" + s.license = "MIT" + s.add_dependency 'ffi' +end diff --git a/flake.nix b/flake.nix index 0d70b7c..5ead28d 100644 --- a/flake.nix +++ b/flake.nix @@ -69,10 +69,10 @@ strictDeps = true; buildInputs = buildInputs; overrideMain = old: { - preConfigure = '' - cargo_build_options="$cargo_build_options --example ${example}" - ''; - }; + preConfigure = '' + cargo_build_options="$cargo_build_options --example ${example}" + ''; + }; }; makePackage = package: @@ -117,16 +117,19 @@ clippy cargo-expand cargo-tarpaulin - gcc - gnumake - dotnet-sdk_8 ]; }; in { default = pkgs.mkShell rec { inputsFrom = [ self.packages.${system}.servicepoint ]; - packages = [ rust-toolchain ]; + packages = with pkgs; [ + rust-toolchain + ruby + dotnet-sdk_8 + gcc + gnumake + ]; LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (builtins.concatMap (d: d.buildInputs) inputsFrom)}"; RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; };