From 5d69c140ba9504d737a75e9d616afa6322383931 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 13 Jun 2025 11:44:21 +0200 Subject: [PATCH 1/3] remove workspace --- Cargo.toml | 3 - generate-binding.sh | 18 +- Cargo.lock => uniffi-bindgen-cs/Cargo.lock | 376 ++------------------- 3 files changed, 32 insertions(+), 365 deletions(-) delete mode 100644 Cargo.toml rename Cargo.lock => uniffi-bindgen-cs/Cargo.lock (69%) diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 365d2e2..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,3 +0,0 @@ -[workspace] -resolver = "2" -members = ["uniffi-bindgen-cs", "servicepoint-binding-uniffi"] \ No newline at end of file diff --git a/generate-binding.sh b/generate-binding.sh index fffdd7f..7bffc8d 100755 --- a/generate-binding.sh +++ b/generate-binding.sh @@ -2,14 +2,18 @@ set -e SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +UNIFFI_BINDING_PATH="$(realpath "$SCRIPT_PATH"/servicepoint-binding-uniffi)" +UNIFFI_BINDGEN_CS_PATH="$(realpath "$SCRIPT_PATH"/uniffi-bindgen-cs)" -cd "$SCRIPT_PATH" -cargo build --release - -TARGET_PATH="$(realpath "$SCRIPT_PATH"/target/release)" -SERVICEPOINT_SO="$TARGET_PATH/libservicepoint_binding_uniffi.so" +cargo build --release --manifest-path="$UNIFFI_BINDING_PATH"/Cargo.toml +SERVICEPOINT_SO="$(realpath "$UNIFFI_BINDING_PATH"/target/release/libservicepoint_binding_uniffi.so)" echo "Source: $SERVICEPOINT_SO" -echo "Output: $LIBRARIES_PATH" -"$TARGET_PATH/uniffi-bindgen-cs" --library "$SERVICEPOINT_SO" --out-dir "$SCRIPT_PATH/ServicePoint" +cargo build --manifest-path="$UNIFFI_BINDGEN_CS_PATH"/Cargo.toml +UNIFFI_BINDGEN_CS="$UNIFFI_BINDGEN_CS_PATH"/target/debug/uniffi-bindgen-cs + +# cd is needed because in library mode, Cargo.toml is read from the current directory +cd $UNIFFI_BINDING_PATH + +$UNIFFI_BINDGEN_CS "$SERVICEPOINT_SO" --library --out-dir "$SCRIPT_PATH/ServicePoint" --no-format diff --git a/Cargo.lock b/uniffi-bindgen-cs/Cargo.lock similarity index 69% rename from Cargo.lock rename to uniffi-bindgen-cs/Cargo.lock index fdb4daf..3b2dcc0 100644 --- a/Cargo.lock +++ b/uniffi-bindgen-cs/Cargo.lock @@ -1,12 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 - -[[package]] -name = "adler2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +version = 4 [[package]] name = "anyhow" @@ -50,7 +44,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.101", + "syn 2.0.103", ] [[package]] @@ -67,7 +61,7 @@ dependencies = [ "rustc-hash", "serde", "serde_derive", - "syn 2.0.101", + "syn 2.0.103", ] [[package]] @@ -123,69 +117,23 @@ dependencies = [ "serde", ] -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "bytes" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" -[[package]] -name = "bzip2" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49ecfb22d906f800d4fe833b6282cf4dc1c298f5057ca0b5445e5c209735ca47" -dependencies = [ - "bzip2-sys", -] - -[[package]] -name = "bzip2-sys" -version = "0.1.13+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14" -dependencies = [ - "cc", - "pkg-config", -] - [[package]] name = "camino" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +checksum = "0da45bc31171d8d6960122e222a67740df867c1dd53b4d51caa297084c185cab" dependencies = [ "serde", ] @@ -210,26 +158,9 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", ] -[[package]] -name = "cc" -version = "1.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8691782945451c1c383942c4874dbe63814f61cb57ef773cda2972682b7bb3c0" -dependencies = [ - "jobserver", - "libc", - "shlex", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - [[package]] name = "clap" version = "3.2.25" @@ -237,7 +168,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", - "bitflags 1.3.2", + "bitflags", "clap_derive", "clap_lex", "indexmap", @@ -269,15 +200,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "crc32fast" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" -dependencies = [ - "cfg-if", -] - [[package]] name = "extend" version = "1.2.0" @@ -286,17 +208,7 @@ checksum = "311a6d2f1f9d60bff73d2c78a0af97ed27f79672f15c238192a5bbb64db56d00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", -] - -[[package]] -name = "flate2" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" -dependencies = [ - "crc32fast", - "miniz_oxide", + "syn 2.0.103", ] [[package]] @@ -308,24 +220,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "getrandom" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" -dependencies = [ - "cfg-if", - "libc", - "r-efi", - "wasi", -] - [[package]] name = "glob" version = "0.3.2" @@ -386,16 +280,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" -[[package]] -name = "jobserver" -version = "0.1.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" -dependencies = [ - "getrandom", - "libc", -] - [[package]] name = "libc" version = "0.2.172" @@ -410,9 +294,9 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "mime" @@ -436,15 +320,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" -dependencies = [ - "adler2", -] - [[package]] name = "nom" version = "7.1.3" @@ -479,12 +354,6 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" -[[package]] -name = "pkg-config" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" - [[package]] name = "plain" version = "0.2.3" @@ -533,28 +402,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rust-lzma" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d62915608f6cee1d7f2fc00f28b4f058ff79d6e4ec3c2fe0006b09b52437c84" -dependencies = [ - "pkg-config", - "vcpkg", -] - [[package]] name = "rustc-hash" version = "2.1.1" @@ -584,7 +431,7 @@ checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.103", ] [[package]] @@ -613,7 +460,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.103", ] [[package]] @@ -628,37 +475,6 @@ dependencies = [ "serde", ] -[[package]] -name = "servicepoint" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6bd5cfa49c73aeecb344680ffbf697abf73e0563a441b93b9723ae43867500f" -dependencies = [ - "bitvec", - "bzip2", - "flate2", - "log", - "once_cell", - "rust-lzma", - "thiserror 2.0.12", - "zstd", -] - -[[package]] -name = "servicepoint_binding_uniffi" -version = "0.13.1" -dependencies = [ - "servicepoint", - "thiserror 2.0.12", - "uniffi", -] - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "siphasher" version = "0.3.11" @@ -671,12 +487,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -696,21 +506,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.101" +version = "2.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "e4307e30089d6fd6aff212f2da3a1f9e32f3223b1f010fb09b7c95f90f3ca1e8" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "termcolor" version = "1.4.1" @@ -737,16 +541,7 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.69", -] - -[[package]] -name = "thiserror" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" -dependencies = [ - "thiserror-impl 2.0.12", + "thiserror-impl", ] [[package]] @@ -757,18 +552,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", + "syn 2.0.103", ] [[package]] @@ -800,23 +584,9 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-width" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" - -[[package]] -name = "uniffi" -version = "0.28.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cb08c58c7ed7033150132febe696bef553f891b1ede57424b40d87a89e3c170" -dependencies = [ - "anyhow", - "cargo_metadata", - "uniffi_bindgen", - "uniffi_build", - "uniffi_core", - "uniffi_macros", -] +checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" [[package]] name = "uniffi-bindgen-cs" @@ -871,17 +641,6 @@ dependencies = [ "uniffi_udl", ] -[[package]] -name = "uniffi_build" -version = "0.28.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7cf32576e08104b7dc2a6a5d815f37616e66c6866c2a639fe16e6d2286b75b" -dependencies = [ - "anyhow", - "camino", - "uniffi_bindgen", -] - [[package]] name = "uniffi_checksum_derive" version = "0.28.3" @@ -889,39 +648,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "802d2051a700e3ec894c79f80d2705b69d85844dafbbe5d1a92776f8f48b563a" dependencies = [ "quote", - "syn 2.0.101", -] - -[[package]] -name = "uniffi_core" -version = "0.28.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc7687007d2546c454d8ae609b105daceb88175477dac280707ad6d95bcd6f1f" -dependencies = [ - "anyhow", - "bytes", - "log", - "once_cell", - "paste", - "static_assertions", -] - -[[package]] -name = "uniffi_macros" -version = "0.28.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12c65a5b12ec544ef136693af8759fb9d11aefce740fb76916721e876639033b" -dependencies = [ - "bincode", - "camino", - "fs-err", - "once_cell", - "proc-macro2", - "quote", - "serde", - "syn 2.0.101", - "toml", - "uniffi_meta", + "syn 2.0.103", ] [[package]] @@ -962,27 +689,12 @@ dependencies = [ "weedle2", ] -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "wasi" -version = "0.14.2+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" -dependencies = [ - "wit-bindgen-rt", -] - [[package]] name = "weedle2" version = "5.0.0" @@ -1098,55 +810,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.9" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9fb597c990f03753e08d3c29efbfcf2019a003b4bf4ba19225c158e1549f0f3" +checksum = "74c7b26e3480b707944fc872477815d29a8e429d2f93a1ce000f5fa84a15cbcd" dependencies = [ "memchr", ] - -[[package]] -name = "wit-bindgen-rt" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" -dependencies = [ - "bitflags 2.9.0", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zstd" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "7.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" -dependencies = [ - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.15+zstd.1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb81183ddd97d0c74cedf1d50d85c8d08c1b8b68ee863bdee9e706eedba1a237" -dependencies = [ - "cc", - "pkg-config", -] From 08bc35db294f366db1f09e67f6968257bfb23d04 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 13 Jun 2025 11:44:44 +0200 Subject: [PATCH 2/3] update to nixos 25.05 --- flake.lock | 8 ++++---- flake.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 6106b67..f51971e 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1746183838, - "narHash": "sha256-kwaaguGkAqTZ1oK0yXeQ3ayYjs8u/W7eEfrFpFfIDFA=", + "lastModified": 1749494155, + "narHash": "sha256-FG4DEYBpROupu758beabUk9lhrblSf5hnv84v1TLqMc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "bf3287dac860542719fe7554e21e686108716879", + "rev": "88331c17ba434359491e8d5889cce872464052c2", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-24.11", + "ref": "nixos-25.05", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 2b8da61..b59d1d6 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "Flake for the servicepoint library."; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; }; outputs = From 13a34e83d75043267f48fec99c7782469f835ce4 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 13 Jun 2025 11:48:40 +0200 Subject: [PATCH 3/3] update to wip uniffi binding --- ServicePoint.Example/Program.cs | 3 +- ServicePoint/servicepoint_binding_uniffi.cs | 650 +++++++++++++++++++- servicepoint-binding-uniffi | 2 +- 3 files changed, 637 insertions(+), 18 deletions(-) diff --git a/ServicePoint.Example/Program.cs b/ServicePoint.Example/Program.cs index d767851..624bba5 100644 --- a/ServicePoint.Example/Program.cs +++ b/ServicePoint.Example/Program.cs @@ -1,8 +1,7 @@ using System.Threading; using ServicePoint; -// TODO: replace with new Connection("127.0.0.1:2342") to send to a real display -var connection = Connection.NewFake(); +var connection = new Connection("127.0.0.1:2342"); connection.Send(Command.Clear()); connection.Send(Command.Brightness(5)); diff --git a/ServicePoint/servicepoint_binding_uniffi.cs b/ServicePoint/servicepoint_binding_uniffi.cs index 6609351..622d21d 100644 --- a/ServicePoint/servicepoint_binding_uniffi.cs +++ b/ServicePoint/servicepoint_binding_uniffi.cs @@ -15,6 +15,8 @@ using System.Linq; using System.Runtime.InteropServices; using System.Threading; namespace ServicePoint; +using Brightness = Byte; +using FfiConverterTypeBrightness = FfiConverterUInt8; @@ -816,6 +818,22 @@ static class _UniFFILib { + + + + + + + + + + + + + + + + @@ -936,6 +954,18 @@ static class _UniFFILib { public static extern ulong uniffi_servicepoint_binding_uniffi_fn_method_bitmap_width(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr uniffi_servicepoint_binding_uniffi_fn_clone_bitmaplegacycommand(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern void uniffi_servicepoint_binding_uniffi_fn_free_bitmaplegacycommand(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr uniffi_servicepoint_binding_uniffi_fn_constructor_bitmaplegacycommand_new(ref UniffiRustCallStatus _uniffi_out_err + ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr uniffi_servicepoint_binding_uniffi_fn_clone_brightnessgrid(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err ); @@ -1052,6 +1082,18 @@ static class _UniFFILib { public static extern ulong uniffi_servicepoint_binding_uniffi_fn_method_chargrid_width(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr uniffi_servicepoint_binding_uniffi_fn_clone_clearcommand(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern void uniffi_servicepoint_binding_uniffi_fn_free_clearcommand(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr uniffi_servicepoint_binding_uniffi_fn_constructor_clearcommand_new(ref UniffiRustCallStatus _uniffi_out_err + ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr uniffi_servicepoint_binding_uniffi_fn_clone_command(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err ); @@ -1172,6 +1214,30 @@ static class _UniFFILib { public static extern ulong uniffi_servicepoint_binding_uniffi_fn_method_cp437grid_width(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr uniffi_servicepoint_binding_uniffi_fn_clone_fadeoutcommand(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern void uniffi_servicepoint_binding_uniffi_fn_free_fadeoutcommand(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr uniffi_servicepoint_binding_uniffi_fn_constructor_fadeoutcommand_new(ref UniffiRustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr uniffi_servicepoint_binding_uniffi_fn_clone_hardresetcommand(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern void uniffi_servicepoint_binding_uniffi_fn_free_hardresetcommand(IntPtr @ptr,ref UniffiRustCallStatus _uniffi_out_err + ); + + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr uniffi_servicepoint_binding_uniffi_fn_constructor_hardresetcommand_new(ref UniffiRustCallStatus _uniffi_out_err + ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] public static extern RustBuffer uniffi_servicepoint_binding_uniffi_fn_func_get_constants(ref UniffiRustCallStatus _uniffi_out_err ); @@ -1600,6 +1666,10 @@ static class _UniFFILib { public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_bitmap_new_max_sized( ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_bitmaplegacycommand_new( + ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_brightnessgrid_clone( ); @@ -1624,6 +1694,10 @@ static class _UniFFILib { public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_chargrid_new( ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_clearcommand_new( + ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_command_bitmap_linear( ); @@ -1680,6 +1754,14 @@ static class _UniFFILib { public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_new( ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_fadeoutcommand_new( + ); + + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] + public static extern ushort uniffi_servicepoint_binding_uniffi_checksum_constructor_hardresetcommand_new( + ); + [DllImport("servicepoint_binding_uniffi", CallingConvention = CallingConvention.Cdecl)] public static extern uint ffi_servicepoint_binding_uniffi_uniffi_contract_version( ); @@ -1792,14 +1874,14 @@ static class _UniFFILib { } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_fill(); - if (checksum != 47185) { - throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_fill` checksum `47185`, library returned `{checksum}`"); + if (checksum != 46387) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_fill` checksum `46387`, library returned `{checksum}`"); } } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_get(); - if (checksum != 39844) { - throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_get` checksum `39844`, library returned `{checksum}`"); + if (checksum != 47112) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_get` checksum `47112`, library returned `{checksum}`"); } } { @@ -1810,8 +1892,8 @@ static class _UniFFILib { } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_set(); - if (checksum != 24064) { - throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_set` checksum `24064`, library returned `{checksum}`"); + if (checksum != 27525) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_method_brightnessgrid_set` checksum `27525`, library returned `{checksum}`"); } } { @@ -1994,6 +2076,12 @@ static class _UniFFILib { throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_bitmap_new_max_sized` checksum `47687`, library returned `{checksum}`"); } } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_bitmaplegacycommand_new(); + if (checksum != 44315) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_bitmaplegacycommand_new` checksum `44315`, library returned `{checksum}`"); + } + } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_brightnessgrid_clone(); if (checksum != 56444) { @@ -2030,6 +2118,12 @@ static class _UniFFILib { throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_chargrid_new` checksum `2094`, library returned `{checksum}`"); } } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_clearcommand_new(); + if (checksum != 340) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_clearcommand_new` checksum `340`, library returned `{checksum}`"); + } + } { var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_command_bitmap_linear(); if (checksum != 62752) { @@ -2114,6 +2208,18 @@ static class _UniFFILib { throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_cp437grid_new` checksum `8874`, library returned `{checksum}`"); } } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_fadeoutcommand_new(); + if (checksum != 9933) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_fadeoutcommand_new` checksum `9933`, library returned `{checksum}`"); + } + } + { + var checksum = _UniFFILib.uniffi_servicepoint_binding_uniffi_checksum_constructor_hardresetcommand_new(); + if (checksum != 65216) { + throw new UniffiContractChecksumException($"ServicePoint: uniffi bindings expected function `uniffi_servicepoint_binding_uniffi_checksum_constructor_hardresetcommand_new` checksum `65216`, library returned `{checksum}`"); + } + } } } @@ -2680,13 +2786,139 @@ class FfiConverterTypeBitmap: FfiConverter { +public interface IBitmapLegacyCommand { +} +public class BitmapLegacyCommand : IBitmapLegacyCommand, IDisposable { + protected IntPtr pointer; + private int _wasDestroyed = 0; + private long _callCounter = 1; + + public BitmapLegacyCommand(IntPtr pointer) { + this.pointer = pointer; + } + + ~BitmapLegacyCommand() { + Destroy(); + } + public BitmapLegacyCommand() : + this( + _UniffiHelpers.RustCall( (ref UniffiRustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_constructor_bitmaplegacycommand_new( ref _status) +)) {} + + protected void FreeRustArcPtr() { + _UniffiHelpers.RustCall((ref UniffiRustCallStatus status) => { + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_free_bitmaplegacycommand(this.pointer, ref status); + }); + } + + protected IntPtr CloneRustArcPtr() { + return _UniffiHelpers.RustCall((ref UniffiRustCallStatus status) => { + return _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_clone_bitmaplegacycommand(this.pointer, ref status); + }); + } + + public void Destroy() + { + // Only allow a single call to this method. + if (Interlocked.CompareExchange(ref _wasDestroyed, 1, 0) == 0) + { + // This decrement always matches the initial count of 1 given at creation time. + if (Interlocked.Decrement(ref _callCounter) == 0) + { + FreeRustArcPtr(); + } + } + } + + public void Dispose() + { + Destroy(); + GC.SuppressFinalize(this); // Suppress finalization to avoid unnecessary GC overhead. + } + + private void IncrementCallCounter() + { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + long count; + do + { + count = Interlocked.Read(ref _callCounter); + if (count == 0L) throw new System.ObjectDisposedException(String.Format("'{0}' object has already been destroyed", this.GetType().Name)); + if (count == long.MaxValue) throw new System.OverflowException(String.Format("'{0}' call counter would overflow", this.GetType().Name)); + + } while (Interlocked.CompareExchange(ref _callCounter, count + 1, count) != count); + } + + private void DecrementCallCounter() + { + // This decrement always matches the increment we performed above. + if (Interlocked.Decrement(ref _callCounter) == 0) { + FreeRustArcPtr(); + } + } + + internal void CallWithPointer(Action action) + { + IncrementCallCounter(); + try { + action(CloneRustArcPtr()); + } + finally { + DecrementCallCounter(); + } + } + + internal T CallWithPointer(Func func) + { + IncrementCallCounter(); + try { + return func(CloneRustArcPtr()); + } + finally { + DecrementCallCounter(); + } + } + + + + +} +class FfiConverterTypeBitmapLegacyCommand: FfiConverter { + public static FfiConverterTypeBitmapLegacyCommand INSTANCE = new FfiConverterTypeBitmapLegacyCommand(); + + + public override IntPtr Lower(BitmapLegacyCommand value) { + return value.CallWithPointer(thisPtr => thisPtr); + } + + public override BitmapLegacyCommand Lift(IntPtr value) { + return new BitmapLegacyCommand(value); + } + + public override BitmapLegacyCommand Read(BigEndianStream stream) { + return Lift(new IntPtr(stream.ReadLong())); + } + + public override int AllocationSize(BitmapLegacyCommand value) { + return 8; + } + + public override void Write(BitmapLegacyCommand value, BigEndianStream stream) { + stream.WriteLong(Lower(value).ToInt64()); + } +} + + + public interface IBrightnessGrid { byte[] CopyRaw(); bool Equals(BrightnessGrid @other); - void Fill(byte @value); - byte Get(ulong @x, ulong @y); + void Fill(Brightness @value); + Brightness Get(ulong @x, ulong @y); ulong Height(); - void Set(ulong @x, ulong @y, byte @value); + void Set(ulong @x, ulong @y, Brightness @value); ulong Width(); } public class BrightnessGrid : IBrightnessGrid, IDisposable { @@ -2799,17 +3031,17 @@ public class BrightnessGrid : IBrightnessGrid, IDisposable { } - public void Fill(byte @value) { + public void Fill(Brightness @value) { CallWithPointer(thisPtr => _UniffiHelpers.RustCall( (ref UniffiRustCallStatus _status) => - _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_fill(thisPtr, FfiConverterUInt8.INSTANCE.Lower(@value), ref _status) + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_fill(thisPtr, FfiConverterTypeBrightness.INSTANCE.Lower(@value), ref _status) )); } - public byte Get(ulong @x, ulong @y) { - return CallWithPointer(thisPtr => FfiConverterUInt8.INSTANCE.Lift( + public Brightness Get(ulong @x, ulong @y) { + return CallWithPointer(thisPtr => FfiConverterTypeBrightness.INSTANCE.Lift( _UniffiHelpers.RustCall( (ref UniffiRustCallStatus _status) => _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_get(thisPtr, FfiConverterUInt64.INSTANCE.Lower(@x), FfiConverterUInt64.INSTANCE.Lower(@y), ref _status) ))); @@ -2824,10 +3056,10 @@ public class BrightnessGrid : IBrightnessGrid, IDisposable { } - public void Set(ulong @x, ulong @y, byte @value) { + public void Set(ulong @x, ulong @y, Brightness @value) { CallWithPointer(thisPtr => _UniffiHelpers.RustCall( (ref UniffiRustCallStatus _status) => - _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_set(thisPtr, FfiConverterUInt64.INSTANCE.Lower(@x), FfiConverterUInt64.INSTANCE.Lower(@y), FfiConverterUInt8.INSTANCE.Lower(@value), ref _status) + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_method_brightnessgrid_set(thisPtr, FfiConverterUInt64.INSTANCE.Lower(@x), FfiConverterUInt64.INSTANCE.Lower(@y), FfiConverterTypeBrightness.INSTANCE.Lower(@value), ref _status) )); } @@ -3151,6 +3383,132 @@ class FfiConverterTypeCharGrid: FfiConverter { +public interface IClearCommand { +} +public class ClearCommand : IClearCommand, IDisposable { + protected IntPtr pointer; + private int _wasDestroyed = 0; + private long _callCounter = 1; + + public ClearCommand(IntPtr pointer) { + this.pointer = pointer; + } + + ~ClearCommand() { + Destroy(); + } + public ClearCommand() : + this( + _UniffiHelpers.RustCall( (ref UniffiRustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_constructor_clearcommand_new( ref _status) +)) {} + + protected void FreeRustArcPtr() { + _UniffiHelpers.RustCall((ref UniffiRustCallStatus status) => { + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_free_clearcommand(this.pointer, ref status); + }); + } + + protected IntPtr CloneRustArcPtr() { + return _UniffiHelpers.RustCall((ref UniffiRustCallStatus status) => { + return _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_clone_clearcommand(this.pointer, ref status); + }); + } + + public void Destroy() + { + // Only allow a single call to this method. + if (Interlocked.CompareExchange(ref _wasDestroyed, 1, 0) == 0) + { + // This decrement always matches the initial count of 1 given at creation time. + if (Interlocked.Decrement(ref _callCounter) == 0) + { + FreeRustArcPtr(); + } + } + } + + public void Dispose() + { + Destroy(); + GC.SuppressFinalize(this); // Suppress finalization to avoid unnecessary GC overhead. + } + + private void IncrementCallCounter() + { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + long count; + do + { + count = Interlocked.Read(ref _callCounter); + if (count == 0L) throw new System.ObjectDisposedException(String.Format("'{0}' object has already been destroyed", this.GetType().Name)); + if (count == long.MaxValue) throw new System.OverflowException(String.Format("'{0}' call counter would overflow", this.GetType().Name)); + + } while (Interlocked.CompareExchange(ref _callCounter, count + 1, count) != count); + } + + private void DecrementCallCounter() + { + // This decrement always matches the increment we performed above. + if (Interlocked.Decrement(ref _callCounter) == 0) { + FreeRustArcPtr(); + } + } + + internal void CallWithPointer(Action action) + { + IncrementCallCounter(); + try { + action(CloneRustArcPtr()); + } + finally { + DecrementCallCounter(); + } + } + + internal T CallWithPointer(Func func) + { + IncrementCallCounter(); + try { + return func(CloneRustArcPtr()); + } + finally { + DecrementCallCounter(); + } + } + + + + +} +class FfiConverterTypeClearCommand: FfiConverter { + public static FfiConverterTypeClearCommand INSTANCE = new FfiConverterTypeClearCommand(); + + + public override IntPtr Lower(ClearCommand value) { + return value.CallWithPointer(thisPtr => thisPtr); + } + + public override ClearCommand Lift(IntPtr value) { + return new ClearCommand(value); + } + + public override ClearCommand Read(BigEndianStream stream) { + return Lift(new IntPtr(stream.ReadLong())); + } + + public override int AllocationSize(ClearCommand value) { + return 8; + } + + public override void Write(ClearCommand value, BigEndianStream stream) { + stream.WriteLong(Lower(value).ToInt64()); + } +} + + + public interface ICommand { bool Equals(Command @other); } @@ -3706,6 +4064,258 @@ class FfiConverterTypeCp437Grid: FfiConverter { +public interface IFadeOutCommand { +} +public class FadeOutCommand : IFadeOutCommand, IDisposable { + protected IntPtr pointer; + private int _wasDestroyed = 0; + private long _callCounter = 1; + + public FadeOutCommand(IntPtr pointer) { + this.pointer = pointer; + } + + ~FadeOutCommand() { + Destroy(); + } + public FadeOutCommand() : + this( + _UniffiHelpers.RustCall( (ref UniffiRustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_constructor_fadeoutcommand_new( ref _status) +)) {} + + protected void FreeRustArcPtr() { + _UniffiHelpers.RustCall((ref UniffiRustCallStatus status) => { + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_free_fadeoutcommand(this.pointer, ref status); + }); + } + + protected IntPtr CloneRustArcPtr() { + return _UniffiHelpers.RustCall((ref UniffiRustCallStatus status) => { + return _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_clone_fadeoutcommand(this.pointer, ref status); + }); + } + + public void Destroy() + { + // Only allow a single call to this method. + if (Interlocked.CompareExchange(ref _wasDestroyed, 1, 0) == 0) + { + // This decrement always matches the initial count of 1 given at creation time. + if (Interlocked.Decrement(ref _callCounter) == 0) + { + FreeRustArcPtr(); + } + } + } + + public void Dispose() + { + Destroy(); + GC.SuppressFinalize(this); // Suppress finalization to avoid unnecessary GC overhead. + } + + private void IncrementCallCounter() + { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + long count; + do + { + count = Interlocked.Read(ref _callCounter); + if (count == 0L) throw new System.ObjectDisposedException(String.Format("'{0}' object has already been destroyed", this.GetType().Name)); + if (count == long.MaxValue) throw new System.OverflowException(String.Format("'{0}' call counter would overflow", this.GetType().Name)); + + } while (Interlocked.CompareExchange(ref _callCounter, count + 1, count) != count); + } + + private void DecrementCallCounter() + { + // This decrement always matches the increment we performed above. + if (Interlocked.Decrement(ref _callCounter) == 0) { + FreeRustArcPtr(); + } + } + + internal void CallWithPointer(Action action) + { + IncrementCallCounter(); + try { + action(CloneRustArcPtr()); + } + finally { + DecrementCallCounter(); + } + } + + internal T CallWithPointer(Func func) + { + IncrementCallCounter(); + try { + return func(CloneRustArcPtr()); + } + finally { + DecrementCallCounter(); + } + } + + + + +} +class FfiConverterTypeFadeOutCommand: FfiConverter { + public static FfiConverterTypeFadeOutCommand INSTANCE = new FfiConverterTypeFadeOutCommand(); + + + public override IntPtr Lower(FadeOutCommand value) { + return value.CallWithPointer(thisPtr => thisPtr); + } + + public override FadeOutCommand Lift(IntPtr value) { + return new FadeOutCommand(value); + } + + public override FadeOutCommand Read(BigEndianStream stream) { + return Lift(new IntPtr(stream.ReadLong())); + } + + public override int AllocationSize(FadeOutCommand value) { + return 8; + } + + public override void Write(FadeOutCommand value, BigEndianStream stream) { + stream.WriteLong(Lower(value).ToInt64()); + } +} + + + +public interface IHardResetCommand { +} +public class HardResetCommand : IHardResetCommand, IDisposable { + protected IntPtr pointer; + private int _wasDestroyed = 0; + private long _callCounter = 1; + + public HardResetCommand(IntPtr pointer) { + this.pointer = pointer; + } + + ~HardResetCommand() { + Destroy(); + } + public HardResetCommand() : + this( + _UniffiHelpers.RustCall( (ref UniffiRustCallStatus _status) => + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_constructor_hardresetcommand_new( ref _status) +)) {} + + protected void FreeRustArcPtr() { + _UniffiHelpers.RustCall((ref UniffiRustCallStatus status) => { + _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_free_hardresetcommand(this.pointer, ref status); + }); + } + + protected IntPtr CloneRustArcPtr() { + return _UniffiHelpers.RustCall((ref UniffiRustCallStatus status) => { + return _UniFFILib.uniffi_servicepoint_binding_uniffi_fn_clone_hardresetcommand(this.pointer, ref status); + }); + } + + public void Destroy() + { + // Only allow a single call to this method. + if (Interlocked.CompareExchange(ref _wasDestroyed, 1, 0) == 0) + { + // This decrement always matches the initial count of 1 given at creation time. + if (Interlocked.Decrement(ref _callCounter) == 0) + { + FreeRustArcPtr(); + } + } + } + + public void Dispose() + { + Destroy(); + GC.SuppressFinalize(this); // Suppress finalization to avoid unnecessary GC overhead. + } + + private void IncrementCallCounter() + { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + long count; + do + { + count = Interlocked.Read(ref _callCounter); + if (count == 0L) throw new System.ObjectDisposedException(String.Format("'{0}' object has already been destroyed", this.GetType().Name)); + if (count == long.MaxValue) throw new System.OverflowException(String.Format("'{0}' call counter would overflow", this.GetType().Name)); + + } while (Interlocked.CompareExchange(ref _callCounter, count + 1, count) != count); + } + + private void DecrementCallCounter() + { + // This decrement always matches the increment we performed above. + if (Interlocked.Decrement(ref _callCounter) == 0) { + FreeRustArcPtr(); + } + } + + internal void CallWithPointer(Action action) + { + IncrementCallCounter(); + try { + action(CloneRustArcPtr()); + } + finally { + DecrementCallCounter(); + } + } + + internal T CallWithPointer(Func func) + { + IncrementCallCounter(); + try { + return func(CloneRustArcPtr()); + } + finally { + DecrementCallCounter(); + } + } + + + + +} +class FfiConverterTypeHardResetCommand: FfiConverter { + public static FfiConverterTypeHardResetCommand INSTANCE = new FfiConverterTypeHardResetCommand(); + + + public override IntPtr Lower(HardResetCommand value) { + return value.CallWithPointer(thisPtr => thisPtr); + } + + public override HardResetCommand Lift(IntPtr value) { + return new HardResetCommand(value); + } + + public override HardResetCommand Read(BigEndianStream stream) { + return Lift(new IntPtr(stream.ReadLong())); + } + + public override int AllocationSize(HardResetCommand value) { + return 8; + } + + public override void Write(HardResetCommand value, BigEndianStream stream) { + stream.WriteLong(Lower(value).ToInt64()); + } +} + + + public record Constants ( ulong @tileSize, ulong @tileWidth, @@ -4056,6 +4666,16 @@ class FfiConverterTypeServicePointError : FfiConverterRustBuffer