diff --git a/.vscode/settings.json b/.vscode/settings.json index 8f170fb8..deee6912 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,12 @@ { "rust-analyzer.check.command": "clippy", -} + "dart.vmAdditionalArgs": [ + "--enable-experiment=native-assets" + ], + // Seperate target directory for cargo check from build directory to avoid + // bloking each other and cache invalidation + "rust-analyzer.checkOnSave.extraArgs": [ + "--target-dir", + "${workspaceFolder}/target/check" + ], +} \ No newline at end of file diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 59fd4bf7..09da2a6f 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -38,12 +38,57 @@ dependencies = [ "memchr", ] +[[package]] +name = "allo-isolate" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b6d794345b06592d0ebeed8e477e41b71e5a0a49df4fc0e4184d5938b99509" +dependencies = [ + "anyhow", + "atomic", + "backtrace", + "chrono", +] + [[package]] name = "allocator-api2" version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_log-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937" + +[[package]] +name = "android_logger" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f" +dependencies = [ + "android_log-sys", + "env_logger", + "log", + "once_cell", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "0.6.14" @@ -98,6 +143,9 @@ name = "anyhow" version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +dependencies = [ + "backtrace", +] [[package]] name = "arc-swap" @@ -105,6 +153,23 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" +[[package]] +name = "atomic" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -135,7 +200,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools", + "itertools 0.12.1", "lazy_static", "lazycell", "log", @@ -161,6 +226,15 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "bstr" version = "1.9.1" @@ -172,6 +246,18 @@ dependencies = [ "serde", ] +[[package]] +name = "build-target" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "832133bbabbbaa9fbdba793456a2827627a7d2b8fb96032fa1e7666d7895832b" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + [[package]] name = "bytemuck" version = "1.16.3" @@ -192,12 +278,77 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +[[package]] +name = "camino" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", +] + +[[package]] +name = "cargo_toml" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "802b755090e39835a4b0440fb0bbee0df7495a8b337f63db21e616f7821c7e8c" +dependencies = [ + "serde", + "toml 0.8.15", +] + +[[package]] +name = "cbindgen" +version = "0.24.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b922faaf31122819ec80c4047cc684c6979a087366c069611e33649bf98e18d" +dependencies = [ + "heck 0.4.1", + "indexmap 1.9.3", + "log", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 1.0.109", + "tempfile", + "toml 0.5.11", +] + [[package]] name = "cc" version = "1.1.6" @@ -219,6 +370,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.52.6", +] + [[package]] name = "clang-sys" version = "1.8.1" @@ -258,7 +423,7 @@ version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.72", @@ -309,6 +474,61 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +[[package]] +name = "colored" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f741c91823341bebf717d4c71bda820630ce065443b58bd1b7451af008355" +dependencies = [ + "is-terminal", + "lazy_static", + "winapi", +] + +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.52.0", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "convert_case" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.4.2" @@ -318,6 +538,31 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "darling" version = "0.20.10" @@ -353,6 +598,61 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "dart-sys-fork" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "933dafff26172b719bb9695dd3715a1e7792f62dcdc8a5d4c740db7e0fedee8b" +dependencies = [ + "cc", +] + +[[package]] +name = "dart_vdd" +version = "0.1.0" +dependencies = [ + "chrono", + "driver-ipc", + "flutter_rust_bridge", + "flutter_rust_bridge_codegen", + "tokio", + "tokio-stream", +] + +[[package]] +name = "dashmap" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" +dependencies = [ + "cfg-if", + "num_cpus", +] + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "delegate-attr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51aac4c99b2e6775164b412ea33ae8441b2fde2dbf05a20bc0052a63d08c475b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "deranged" version = "0.3.11" @@ -362,6 +662,17 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive_builder" version = "0.20.0" @@ -393,6 +704,16 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "driver-ipc" version = "0.1.0" @@ -436,6 +757,44 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "enum-iterator" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fd242f399be1da0a5354aa462d57b4ab2b4ee0683cc552f7c007d2d12d36e94" +dependencies = [ + "enum-iterator-derive", +] + +[[package]] +name = "enum-iterator-derive" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "enum_dispatch" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" +dependencies = [ + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "env_filter" version = "0.1.2" @@ -445,6 +804,16 @@ dependencies = [ "log", ] +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "log", + "regex", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -483,6 +852,17 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +[[package]] +name = "fern" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee" +dependencies = [ + "chrono", + "colored", + "log", +] + [[package]] name = "filetime" version = "0.2.23" @@ -505,6 +885,93 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "flutter_rust_bridge" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db18c05aac3922abfe24282af9128947d2b27856f3d6a4f30888bffa976855a" +dependencies = [ + "allo-isolate", + "android_logger", + "anyhow", + "build-target", + "bytemuck", + "byteorder", + "chrono", + "console_error_panic_hook", + "dart-sys-fork", + "delegate-attr", + "flutter_rust_bridge_macros", + "futures", + "js-sys", + "lazy_static", + "oslog", + "threadpool", + "tokio", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "flutter_rust_bridge_codegen" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f5719e3d9b52f30bad8b704087ebb32a6b11fedb4cb6afe77330aded5424185" +dependencies = [ + "anyhow", + "atty", + "cargo_metadata", + "cargo_toml", + "cbindgen", + "chrono", + "clap", + "convert_case", + "derivative", + "enum-iterator", + "enum_dispatch", + "fern", + "glob", + "hex", + "include_dir", + "indicatif", + "indicatif-log-bridge", + "itertools 0.10.5", + "lazy_static", + "log", + "notify", + "notify-debouncer-mini", + "paste", + "pathdiff", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "serde_yaml", + "serial_test", + "sha1", + "strum", + "strum_macros", + "syn 2.0.72", + "tempfile", + "toml 0.5.11", + "topological-sort", +] + +[[package]] +name = "flutter_rust_bridge_macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83de8013ddf893c420794e8a722f941eeca7f4939b46434282d66b676a0997c" +dependencies = [ + "hex", + "md-5", + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "fnv" version = "1.0.7" @@ -520,18 +987,114 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fsevent-sys" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" +dependencies = [ + "libc", +] + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + [[package]] name = "futures-core" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "futures-sink" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getset" version = "0.1.2" @@ -771,7 +1334,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ddf80e16f3c19ac06ce415a38b8591993d3f73aede049cb561becb5b3a8e242" dependencies = [ "gix-hash", - "hashbrown", + "hashbrown 0.14.5", "parking_lot", ] @@ -794,7 +1357,7 @@ dependencies = [ "gix-traverse", "gix-utils", "gix-validate", - "hashbrown", + "hashbrown 0.14.5", "itoa", "libc", "memmap2", @@ -1063,6 +1626,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.14.5" @@ -1073,18 +1642,39 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "home" version = "0.5.9" @@ -1094,6 +1684,29 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core 0.52.0", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1110,12 +1723,41 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "include_dir" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" +dependencies = [ + "include_dir_macros", +] + +[[package]] +name = "include_dir_macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "indenter" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + [[package]] name = "indexmap" version = "2.2.6" @@ -1123,7 +1765,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.14.5", +] + +[[package]] +name = "indicatif" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + +[[package]] +name = "indicatif-log-bridge" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2963046f28a204e3e3fd7e754fd90a6235da05b5378f24707ff0ec9513725ce3" +dependencies = [ + "indicatif", + "log", ] [[package]] @@ -1132,11 +1797,60 @@ version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" +[[package]] +name = "inotify" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +dependencies = [ + "bitflags 1.3.2", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" +dependencies = [ + "libc", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "is-terminal" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] [[package]] name = "itertools" @@ -1159,6 +1873,35 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57d8bde02bbf44a562cf068a8ff4a68842df387e302a03a4de4a57fcf82ec377" +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "kqueue" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" +dependencies = [ + "bitflags 1.3.2", + "libc", +] + [[package]] name = "lazy_format" version = "2.0.3" @@ -1193,6 +1936,12 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1215,6 +1964,16 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + [[package]] name = "memchr" version = "2.7.4" @@ -1254,13 +2013,25 @@ dependencies = [ "adler", ] +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.48.0", +] + [[package]] name = "mio" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", @@ -1276,12 +2047,61 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "notify" +version = "6.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" +dependencies = [ + "bitflags 2.6.0", + "crossbeam-channel", + "filetime", + "fsevent-sys", + "inotify", + "kqueue", + "libc", + "log", + "mio 0.8.11", + "walkdir", + "windows-sys 0.48.0", +] + +[[package]] +name = "notify-debouncer-mini" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d40b221972a1fc5ef4d858a2f671fb34c75983eb385463dff3780eeff6a9d43" +dependencies = [ + "crossbeam-channel", + "log", + "notify", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.9", + "libc", +] + [[package]] name = "num_threads" version = "0.1.7" @@ -1291,6 +2111,12 @@ dependencies = [ "libc", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.32.2" @@ -1306,6 +2132,17 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "oslog" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8343ce955f18e7e68c0207dd0ea776ec453035685395ababd2ea651c569728b3" +dependencies = [ + "cc", + "dashmap 4.0.2", + "log", +] + [[package]] name = "owo-colors" version = "3.5.0" @@ -1347,6 +2184,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1359,6 +2202,12 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "portable-atomic" version = "1.7.0" @@ -1476,7 +2325,7 @@ version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "pyo3-build-config", "quote", @@ -1591,6 +2440,15 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +dependencies = [ + "serde", +] + [[package]] name = "serde" version = "1.0.206" @@ -1632,6 +2490,54 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +dependencies = [ + "indexmap 1.9.3", + "ryu", + "serde", + "yaml-rust", +] + +[[package]] +name = "serial_test" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e56dd856803e253c8f298af3f4d7eb0ae5e23a737252cd90bb4f3b435033b2d" +dependencies = [ + "dashmap 5.5.3", + "futures", + "lazy_static", + "log", + "parking_lot", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha1_smol" version = "1.0.1" @@ -1672,6 +2578,15 @@ dependencies = [ "libc", ] +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.13.2" @@ -1694,6 +2609,25 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + [[package]] name = "syn" version = "1.0.109" @@ -1764,6 +2698,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "time" version = "0.3.36" @@ -1821,7 +2764,7 @@ dependencies = [ "backtrace", "bytes", "libc", - "mio", + "mio 1.0.1", "pin-project-lite", "socket2", "tokio-macros", @@ -1882,7 +2825,19 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "toml" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.16", ] [[package]] @@ -1900,13 +2855,32 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", "winnow 0.5.40", ] +[[package]] +name = "toml_edit" +version = "0.22.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" +dependencies = [ + "indexmap 2.2.6", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.15", +] + +[[package]] +name = "topological-sort" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" + [[package]] name = "tracing" version = "0.1.40" @@ -1948,6 +2922,12 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + [[package]] name = "unicode-bidi" version = "0.3.15" @@ -1975,6 +2955,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + [[package]] name = "unindent" version = "0.2.3" @@ -2120,6 +3106,72 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.72", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + [[package]] name = "wdf-umdf" version = "0.1.0" @@ -2140,6 +3192,16 @@ dependencies = [ "winreg", ] +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "which" version = "4.4.2" @@ -2158,6 +3220,22 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + [[package]] name = "winapi-util" version = "0.1.8" @@ -2167,13 +3245,28 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows" version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" dependencies = [ - "windows-core", + "windows-core 0.58.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ "windows-targets 0.52.6", ] @@ -2428,6 +3521,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "zerocopy" version = "0.7.35" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 54165a07..bb381c20 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -8,6 +8,7 @@ members = [ "driver-logger", "virtual-display-driver-cli", "bindings/python", + "bindings/dart/rust", "vdd-user-session-service", ] diff --git a/rust/bindings/dart/.gitignore b/rust/bindings/dart/.gitignore new file mode 100644 index 00000000..3cceda55 --- /dev/null +++ b/rust/bindings/dart/.gitignore @@ -0,0 +1,7 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/guides/libraries/private-files#pubspeclock. +pubspec.lock diff --git a/rust/bindings/dart/CHANGELOG.md b/rust/bindings/dart/CHANGELOG.md new file mode 100644 index 00000000..a0712a79 --- /dev/null +++ b/rust/bindings/dart/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.1.0 + +- Initial version. diff --git a/rust/bindings/dart/Makefile.toml b/rust/bindings/dart/Makefile.toml new file mode 100644 index 00000000..5b867c5c --- /dev/null +++ b/rust/bindings/dart/Makefile.toml @@ -0,0 +1,17 @@ +[tasks.generate] +install_crate = "flutter_rust_bridge_codegen@^2.2.0" +script = ''' + flutter_rust_bridge_codegen generate + ''' + +[tasks.generate-watch] +install_crate = "flutter_rust_bridge_codegen@^2.2.0" +script = ''' + flutter_rust_bridge_codegen generate --watch + ''' + +[tasks.test] +clear = true +script = ''' + dart --enable-experiment=native-assets test + ''' diff --git a/rust/bindings/dart/README.md b/rust/bindings/dart/README.md new file mode 100644 index 00000000..60265bdb --- /dev/null +++ b/rust/bindings/dart/README.md @@ -0,0 +1,200 @@ +Control +[`virtual-display-rs`](https://github.com/MolotovCherry/virtual-display-rs) +using Dart, to create and manage virtual monitors on Windows. + +`virtual-display-rs` uses windows named pipes to connect to the driver. + +> Note: This package uses [native +> assets](https://github.com/dart-lang/sdk/issues/50565), which are not yet +> stable. To use this package, you must enable it using +> `--enable-experiment=native-assets` as the first flag on every dart command, +> or, when using flutter, enable it in the flutter config using `flutter config +> --enable-native-assets`. + +## Features + +- Add/Remove/Change virtual monitors +- Add/Remove/Change monitor resolutions and framerate +- Persist driver state across restarts +- Get continues state updates from the driver, no matter why it changed + +## Getting started + +1. [Install the driver](https://github.com/MolotovCherry/virtual-display-rs?tab=readme-ov-file#how-to-install) +2. Install Rust using [rustup](https://www.rust-lang.org/learn/get-started) +3. Add dependency to `pubspec.yaml`: + +```yaml +dependencies: + vdd: + git: + url: https://github.com/MolotovCherry/virtual-display-rs.git + ref: master + path: rust/bindings/dart +``` + +## Usage + +Import the relevant packages: + +```dart +import 'package:vdd/vdd.dart' as vdd; + +// Imports all errors, that might be thrown by dart_vdd +import 'package:vdd/errors.dart' as vdd; +``` + +### Initialization + +Before using the driver, `vdd` must be initialized: + +```dart +await vdd.init(); +``` + +There are two clients with a different level of abstraction. + +### `Client` + +This client does not manage its own state. + +```dart +// Connect to driver using the default named pipe +final client = await vdd.Client.connect(); + +// Listen to all state changes +client.receiveEvents().listen((monitors) { + print("Driver state changed: $monitors"); +}); + +final monitors = [ + vdd.Monitor( + id: 0, + enabled: true, + modes: [ + vdd.Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60, 120]), + ), + ], + ), +]; + +// Override driver state with new monitor +await client.notify(monitors: monitors); + +// Make this state persistent across restarts +await vdd.Client.persist(monitors: monitors); +``` + +### `DriverClient` + +This client manages its own state, separate from the driver. This state might +become stale. To refresh it, call `DriverClient.refreshState`. To apply state +changes to the driver, call `DriverClient.notify`. + +```dart +// Connect to the driver, using the default pipe name +final client = await vdd.DriverClient.connect(); + +// Listen to all state changes +client.receiveEvents().listen((monitors) async { + print("Driver state changed: $monitors"); + + // Refresh local state when driver state changes + await client.refreshState(); +}); + +print("Current driver state: ${client.state}"); + +// Get a free id for a new monitor +final monitorId = client.newId()!; + +// Add a new monitor +client.add( + monitor: vdd.Monitor( + id: monitorId, + enabled: true, + modes: [ + vdd.Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60, 120]), + ), + ], + ), +); + +// Apply changes to the driver +await client.notify(); + +// Make changes persistent across restarts +await client.persist(); +``` + +## Testing + +`vdd` provides a mock server, simulating the driver on the other end of the +named pipe. + +Additionally, import `package:vdd/test.dart` to get access to the mock server. + +```dart +import 'package:vdd/vdd.dart' as vdd; +import 'package:vdd/test.dart' as vdd; +``` + +```dart +setUpAll(() async { + await vdd.init(); +}); + +test('test', () async { + // Pass in a unique pipe name + final server = await vdd.MockServer.create(pipeName: "my_pipe_name"); + final client = await vdd.Client.connect(pipeName: server.pipeName); + + // Use the client + await client.notify(...); + + // Pump the server, to handle exactly one request + await server.pump(); + + expect(server.state, ...); + + await server.setState(...); + + expect(client.requestState(), ...); +}); +``` + +For more examples, see the +[tests](https://github.com/MolotovCherry/virtual-display-rs/tree/master/rust/bindings/dart/test/vdd_test.dart) +in `test/`. + +## Maintaining + +To regenerate bindings, run: + +```bash +cargo make generate +``` + +or + +```bash +cargo make generate-watch +``` + +To run unit tests, run: + +```bash +cargo make test +``` + +To run examples, run: + +```bash +dart --enable-experiment=native-assets run example/.dart +``` \ No newline at end of file diff --git a/rust/bindings/dart/analysis_options.yaml b/rust/bindings/dart/analysis_options.yaml new file mode 100644 index 00000000..dee8927a --- /dev/null +++ b/rust/bindings/dart/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/rust/bindings/dart/build.dart b/rust/bindings/dart/build.dart new file mode 100644 index 00000000..b5ac33e8 --- /dev/null +++ b/rust/bindings/dart/build.dart @@ -0,0 +1,44 @@ +import 'dart:io'; + +import 'package:flutter_rust_bridge/src/cli/run_command.dart'; +import 'package:native_assets_cli/native_assets_cli.dart'; + +void main(List args) async { + await build(args, (config, output) async { + final rustRoot = config.packageRoot.resolve('rust'); + + final rustFlags = Platform.environment['RUSTFLAGS']; + + await runCommand( + 'cargo', + [ + 'build', + '--release', + '--artifact-dir', + config.outputDirectory.toFilePath(), + '-Z', + 'unstable-options', + ], + pwd: rustRoot.toFilePath(), + printCommandInStderr: true, + env: { + if (rustFlags != null) 'RUSTFLAGS': rustFlags, + }, + ); + + output.addDependencies(await Directory.fromUri(rustRoot) + .list(recursive: true) + .where((f) => f is File) + .map((e) => e.uri) + .toList()); + + output.addAsset(NativeCodeAsset( + package: "vdd", + linkMode: DynamicLoadingBundled(), + name: "vdd_lib", + os: OS.windows, + architecture: Architecture.current, + file: config.outputDirectory.resolve('dart_vdd.dll'), + )); + }); +} diff --git a/rust/bindings/dart/example/client_example.dart b/rust/bindings/dart/example/client_example.dart new file mode 100644 index 00000000..0faf25fa --- /dev/null +++ b/rust/bindings/dart/example/client_example.dart @@ -0,0 +1,53 @@ +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:vdd/errors.dart' as vdd; +import 'package:vdd/vdd.dart' as vdd; + +void main(List args) async { + await vdd.init(); + + // Connect to driver using the default named pipe + final client = await vdd.Client.connect(); + + try { + print("Current state: ${await client.requestState()}"); + } on vdd.RequestError catch (e) { + print("Did you forget to install the driver?\n$e"); + return; + } + + // Listen to all state changes + client.receiveEvents().listen((monitors) { + print("Driver state changed: $monitors"); + }); + + final monitors = [ + vdd.Monitor( + id: 0, + enabled: true, + modes: [ + vdd.Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60, 120]), + ), + ], + ), + ]; + + // Override driver state with new monitor + await client.notify(monitors: monitors); + + // Make this state persistent across restarts + await vdd.Client.persist(monitors: monitors); + + await Future.delayed(Duration(seconds: 5)); + + // Remove all monitors + await client.removeAll(); + + await vdd.Client.persist(monitors: []); + + exit(0); +} diff --git a/rust/bindings/dart/example/driver_client_example.dart b/rust/bindings/dart/example/driver_client_example.dart new file mode 100644 index 00000000..6148f0b3 --- /dev/null +++ b/rust/bindings/dart/example/driver_client_example.dart @@ -0,0 +1,70 @@ +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:vdd/errors.dart' as vdd; +import 'package:vdd/vdd.dart' as vdd; + +void main(List args) async { + await vdd.init(); + + try { + // Connect to the driver, using the default pipe name + final client = await vdd.DriverClient.connect(); + + // Listen to all state changes + client.receiveEvents().listen((monitors) async { + print("Driver state changed: $monitors"); + + // Refresh local state when driver state changes + await client.refreshState(); + }); + + print("Current driver state: ${client.state}"); + + // Get a free id for a new monitor + final monitorId = client.newId()!; + + // Add a new monitor + client.add( + monitor: vdd.Monitor( + id: monitorId, + enabled: true, + modes: [ + vdd.Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60, 120]), + ), + ], + ), + ); + + client.addMode( + id: monitorId, + mode: vdd.Mode( + width: 2560, + height: 1440, + refreshRates: Uint32List.fromList([60, 120]), + ), + ); + + // Apply changes to the driver + await client.notify(); + + // Make changes persistent across restarts + await client.persist(); + + await Future.delayed(Duration(seconds: 5)); + + // Remove all monitors + client.removeAll(); + + await client.notify(); + + await client.persist(); + } on vdd.InitError catch (e) { + print("Did you forget to install the driver?\n$e"); + } + + exit(0); +} diff --git a/rust/bindings/dart/flutter_rust_bridge.yaml b/rust/bindings/dart/flutter_rust_bridge.yaml new file mode 100644 index 00000000..55a44fc4 --- /dev/null +++ b/rust/bindings/dart/flutter_rust_bridge.yaml @@ -0,0 +1,3 @@ +rust_input: crate::api # Space-separated list of rust modules +dart_output: lib/src/generated # Directory +web: false diff --git a/rust/bindings/dart/lib/errors.dart b/rust/bindings/dart/lib/errors.dart new file mode 100644 index 00000000..ade1d974 --- /dev/null +++ b/rust/bindings/dart/lib/errors.dart @@ -0,0 +1,30 @@ +export 'src/generated/api/client.dart' + show + ConnectionError, + ConnectionError_Failed, + PersistError, + PersistError_Open, + PersistError_Serialize, + PersistError_Set, + ReceiveError, + RequestError, + RequestError_Receive, + RequestError_Send, + RequestError_Timeout, + SendError, + SendError_PipeBroken; + +export 'src/generated/api/driver_client.dart' + show + AddModeError, + AddModeError_ModeExists, + AddModeError_MonitorNotFound, + AddModeError_RefreshRateExists, + DuplicateError, + DuplicateError_Monitor, + DuplicateError_Mode, + DuplicateError_RefreshRate, + InitError, + InitError_Connect, + InitError_RequestState, + MonitorNotFoundError; diff --git a/rust/bindings/dart/lib/src/generated/api.dart b/rust/bindings/dart/lib/src/generated/api.dart new file mode 100644 index 00000000..71a25cfe --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/api.dart @@ -0,0 +1,28 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.2.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import 'frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:freezed_annotation/freezed_annotation.dart' hide protected; +part 'api.freezed.dart'; + +@freezed +class Mode with _$Mode { + const factory Mode({ + required int width, + required int height, + required Uint32List refreshRates, + }) = _Mode; +} + +@freezed +class Monitor with _$Monitor { + const factory Monitor({ + required int id, + String? name, + required bool enabled, + required List modes, + }) = _Monitor; +} diff --git a/rust/bindings/dart/lib/src/generated/api.freezed.dart b/rust/bindings/dart/lib/src/generated/api.freezed.dart new file mode 100644 index 00000000..738dd064 --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/api.freezed.dart @@ -0,0 +1,365 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'api.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$Mode { + int get width => throw _privateConstructorUsedError; + int get height => throw _privateConstructorUsedError; + Uint32List get refreshRates => throw _privateConstructorUsedError; + + /// Create a copy of Mode + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ModeCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ModeCopyWith<$Res> { + factory $ModeCopyWith(Mode value, $Res Function(Mode) then) = + _$ModeCopyWithImpl<$Res, Mode>; + @useResult + $Res call({int width, int height, Uint32List refreshRates}); +} + +/// @nodoc +class _$ModeCopyWithImpl<$Res, $Val extends Mode> + implements $ModeCopyWith<$Res> { + _$ModeCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Mode + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? width = null, + Object? height = null, + Object? refreshRates = null, + }) { + return _then(_value.copyWith( + width: null == width + ? _value.width + : width // ignore: cast_nullable_to_non_nullable + as int, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as int, + refreshRates: null == refreshRates + ? _value.refreshRates + : refreshRates // ignore: cast_nullable_to_non_nullable + as Uint32List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ModeImplCopyWith<$Res> implements $ModeCopyWith<$Res> { + factory _$$ModeImplCopyWith( + _$ModeImpl value, $Res Function(_$ModeImpl) then) = + __$$ModeImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({int width, int height, Uint32List refreshRates}); +} + +/// @nodoc +class __$$ModeImplCopyWithImpl<$Res> + extends _$ModeCopyWithImpl<$Res, _$ModeImpl> + implements _$$ModeImplCopyWith<$Res> { + __$$ModeImplCopyWithImpl(_$ModeImpl _value, $Res Function(_$ModeImpl) _then) + : super(_value, _then); + + /// Create a copy of Mode + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? width = null, + Object? height = null, + Object? refreshRates = null, + }) { + return _then(_$ModeImpl( + width: null == width + ? _value.width + : width // ignore: cast_nullable_to_non_nullable + as int, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as int, + refreshRates: null == refreshRates + ? _value.refreshRates + : refreshRates // ignore: cast_nullable_to_non_nullable + as Uint32List, + )); + } +} + +/// @nodoc + +class _$ModeImpl implements _Mode { + const _$ModeImpl( + {required this.width, required this.height, required this.refreshRates}); + + @override + final int width; + @override + final int height; + @override + final Uint32List refreshRates; + + @override + String toString() { + return 'Mode(width: $width, height: $height, refreshRates: $refreshRates)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ModeImpl && + (identical(other.width, width) || other.width == width) && + (identical(other.height, height) || other.height == height) && + const DeepCollectionEquality() + .equals(other.refreshRates, refreshRates)); + } + + @override + int get hashCode => Object.hash(runtimeType, width, height, + const DeepCollectionEquality().hash(refreshRates)); + + /// Create a copy of Mode + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ModeImplCopyWith<_$ModeImpl> get copyWith => + __$$ModeImplCopyWithImpl<_$ModeImpl>(this, _$identity); +} + +abstract class _Mode implements Mode { + const factory _Mode( + {required final int width, + required final int height, + required final Uint32List refreshRates}) = _$ModeImpl; + + @override + int get width; + @override + int get height; + @override + Uint32List get refreshRates; + + /// Create a copy of Mode + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ModeImplCopyWith<_$ModeImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$Monitor { + int get id => throw _privateConstructorUsedError; + String? get name => throw _privateConstructorUsedError; + bool get enabled => throw _privateConstructorUsedError; + List get modes => throw _privateConstructorUsedError; + + /// Create a copy of Monitor + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $MonitorCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MonitorCopyWith<$Res> { + factory $MonitorCopyWith(Monitor value, $Res Function(Monitor) then) = + _$MonitorCopyWithImpl<$Res, Monitor>; + @useResult + $Res call({int id, String? name, bool enabled, List modes}); +} + +/// @nodoc +class _$MonitorCopyWithImpl<$Res, $Val extends Monitor> + implements $MonitorCopyWith<$Res> { + _$MonitorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Monitor + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = freezed, + Object? enabled = null, + Object? modes = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + modes: null == modes + ? _value.modes + : modes // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MonitorImplCopyWith<$Res> implements $MonitorCopyWith<$Res> { + factory _$$MonitorImplCopyWith( + _$MonitorImpl value, $Res Function(_$MonitorImpl) then) = + __$$MonitorImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({int id, String? name, bool enabled, List modes}); +} + +/// @nodoc +class __$$MonitorImplCopyWithImpl<$Res> + extends _$MonitorCopyWithImpl<$Res, _$MonitorImpl> + implements _$$MonitorImplCopyWith<$Res> { + __$$MonitorImplCopyWithImpl( + _$MonitorImpl _value, $Res Function(_$MonitorImpl) _then) + : super(_value, _then); + + /// Create a copy of Monitor + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = freezed, + Object? enabled = null, + Object? modes = null, + }) { + return _then(_$MonitorImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + modes: null == modes + ? _value._modes + : modes // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc + +class _$MonitorImpl implements _Monitor { + const _$MonitorImpl( + {required this.id, + this.name, + required this.enabled, + required final List modes}) + : _modes = modes; + + @override + final int id; + @override + final String? name; + @override + final bool enabled; + final List _modes; + @override + List get modes { + if (_modes is EqualUnmodifiableListView) return _modes; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_modes); + } + + @override + String toString() { + return 'Monitor(id: $id, name: $name, enabled: $enabled, modes: $modes)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MonitorImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name) && + (identical(other.enabled, enabled) || other.enabled == enabled) && + const DeepCollectionEquality().equals(other._modes, _modes)); + } + + @override + int get hashCode => Object.hash(runtimeType, id, name, enabled, + const DeepCollectionEquality().hash(_modes)); + + /// Create a copy of Monitor + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$MonitorImplCopyWith<_$MonitorImpl> get copyWith => + __$$MonitorImplCopyWithImpl<_$MonitorImpl>(this, _$identity); +} + +abstract class _Monitor implements Monitor { + const factory _Monitor( + {required final int id, + final String? name, + required final bool enabled, + required final List modes}) = _$MonitorImpl; + + @override + int get id; + @override + String? get name; + @override + bool get enabled; + @override + List get modes; + + /// Create a copy of Monitor + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$MonitorImplCopyWith<_$MonitorImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/rust/bindings/dart/lib/src/generated/api/client.dart b/rust/bindings/dart/lib/src/generated/api/client.dart new file mode 100644 index 00000000..9c7957a4 --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/api/client.dart @@ -0,0 +1,154 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.2.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../api.dart'; +import '../frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:freezed_annotation/freezed_annotation.dart' hide protected; +part 'client.freezed.dart'; + +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `from`, `from`, `from`, `from`, `from` + +// Rust type: RustOpaqueMoi> +abstract class Client implements RustOpaqueInterface { + /// Connect to the driver. + /// + /// You can optionally specify the name of the named pipe to connect to. The + /// default value is "virtualdisplaydriver". + static Future connect({String? pipeName}) => + RustLib.instance.api.crateApiClientClientConnect(pipeName: pipeName); + + /// Send new state to the driver. + Future notify({required List monitors}); + + /// Write `monitors` to the registry for current user. + /// + /// Next time the driver is started, it will load this state from the + /// registry. This might be after a reboot or a driver restart. + static Future persist({required List monitors}) => + RustLib.instance.api.crateApiClientClientPersist(monitors: monitors); + + /// Receive continuous events from the driver. + /// + /// Only new events after calling this method are received. + /// + /// May be called multiple times. + Stream> receiveEvents(); + + /// Remove all monitors with the specified IDs. + Future remove({required List ids}); + + /// Remove all monitors. + Future removeAll(); + + /// Request the current state of the driver. + /// + /// Throws [RequestError.timeout] if the driver does not respond within 5 + /// seconds. + Future> requestState(); +} + +@freezed +sealed class ConnectionError with _$ConnectionError implements FrbException { + const ConnectionError._(); + + const factory ConnectionError.failed({ + required String message, + }) = ConnectionError_Failed; + + @override + String toString() => switch (this) { + ConnectionError_Failed(:final message) => + 'Failed to open pipe: $message', + }; +} + +@freezed +sealed class PersistError with _$PersistError implements FrbException { + const PersistError._(); + + const factory PersistError.open({ + required String message, + }) = PersistError_Open; + const factory PersistError.set_({ + required String message, + }) = PersistError_Set; + const factory PersistError.serialize({ + required String message, + }) = PersistError_Serialize; + + @override + String toString() => switch (this) { + PersistError_Open(:final message) => + 'Failed to open registry key: $message', + PersistError_Set(:final message) => + 'Failed to set registry key: $message', + PersistError_Serialize(:final message) => + 'Failed to serialize data: $message', + }; +} + +class ReceiveError implements FrbException { + final String message; + + const ReceiveError({ + required this.message, + }); + + @override + String toString() => switch (this) { + ReceiveError(:final message) => 'Failed to receive event: $message', + }; + + @override + int get hashCode => message.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is ReceiveError && + runtimeType == other.runtimeType && + message == other.message; +} + +@freezed +sealed class RequestError with _$RequestError implements FrbException { + const RequestError._(); + + const factory RequestError.send({ + required String message, + }) = RequestError_Send; + const factory RequestError.receive({ + required String message, + }) = RequestError_Receive; + const factory RequestError.timeout({ + required Duration duration, + }) = RequestError_Timeout; + + @override + String toString() => switch (this) { + RequestError_Send(:final message) => + 'Failed to send message (pipe broken): $message', + RequestError_Receive(:final message) => + 'Failed to receive message (pipe broken): $message', + RequestError_Timeout(:final duration) => + 'Did not get a response in time ($duration)', + }; +} + +@freezed +sealed class SendError with _$SendError implements FrbException { + const SendError._(); + + const factory SendError.pipeBroken({ + required String message, + }) = SendError_PipeBroken; + + @override + String toString() => switch (this) { + SendError_PipeBroken(:final message) => + 'Failed to send message (pipe broken): $message', + }; +} diff --git a/rust/bindings/dart/lib/src/generated/api/client.freezed.dart b/rust/bindings/dart/lib/src/generated/api/client.freezed.dart new file mode 100644 index 00000000..36b6764b --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/api/client.freezed.dart @@ -0,0 +1,1485 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'client.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$ConnectionError { + String get message => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(String message) failed, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? failed, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? failed, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(ConnectionError_Failed value) failed, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ConnectionError_Failed value)? failed, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ConnectionError_Failed value)? failed, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + + /// Create a copy of ConnectionError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ConnectionErrorCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ConnectionErrorCopyWith<$Res> { + factory $ConnectionErrorCopyWith( + ConnectionError value, $Res Function(ConnectionError) then) = + _$ConnectionErrorCopyWithImpl<$Res, ConnectionError>; + @useResult + $Res call({String message}); +} + +/// @nodoc +class _$ConnectionErrorCopyWithImpl<$Res, $Val extends ConnectionError> + implements $ConnectionErrorCopyWith<$Res> { + _$ConnectionErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ConnectionError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_value.copyWith( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ConnectionError_FailedImplCopyWith<$Res> + implements $ConnectionErrorCopyWith<$Res> { + factory _$$ConnectionError_FailedImplCopyWith( + _$ConnectionError_FailedImpl value, + $Res Function(_$ConnectionError_FailedImpl) then) = + __$$ConnectionError_FailedImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$ConnectionError_FailedImplCopyWithImpl<$Res> + extends _$ConnectionErrorCopyWithImpl<$Res, _$ConnectionError_FailedImpl> + implements _$$ConnectionError_FailedImplCopyWith<$Res> { + __$$ConnectionError_FailedImplCopyWithImpl( + _$ConnectionError_FailedImpl _value, + $Res Function(_$ConnectionError_FailedImpl) _then) + : super(_value, _then); + + /// Create a copy of ConnectionError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$ConnectionError_FailedImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$ConnectionError_FailedImpl extends ConnectionError_Failed { + const _$ConnectionError_FailedImpl({required this.message}) : super._(); + + @override + final String message; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ConnectionError_FailedImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + /// Create a copy of ConnectionError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ConnectionError_FailedImplCopyWith<_$ConnectionError_FailedImpl> + get copyWith => __$$ConnectionError_FailedImplCopyWithImpl< + _$ConnectionError_FailedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) failed, + }) { + return failed(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? failed, + }) { + return failed?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? failed, + required TResult orElse(), + }) { + if (failed != null) { + return failed(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ConnectionError_Failed value) failed, + }) { + return failed(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ConnectionError_Failed value)? failed, + }) { + return failed?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ConnectionError_Failed value)? failed, + required TResult orElse(), + }) { + if (failed != null) { + return failed(this); + } + return orElse(); + } +} + +abstract class ConnectionError_Failed extends ConnectionError { + const factory ConnectionError_Failed({required final String message}) = + _$ConnectionError_FailedImpl; + const ConnectionError_Failed._() : super._(); + + @override + String get message; + + /// Create a copy of ConnectionError + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ConnectionError_FailedImplCopyWith<_$ConnectionError_FailedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$PersistError { + String get message => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(String message) open, + required TResult Function(String message) set_, + required TResult Function(String message) serialize, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? open, + TResult? Function(String message)? set_, + TResult? Function(String message)? serialize, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? open, + TResult Function(String message)? set_, + TResult Function(String message)? serialize, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(PersistError_Open value) open, + required TResult Function(PersistError_Set value) set_, + required TResult Function(PersistError_Serialize value) serialize, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PersistError_Open value)? open, + TResult? Function(PersistError_Set value)? set_, + TResult? Function(PersistError_Serialize value)? serialize, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PersistError_Open value)? open, + TResult Function(PersistError_Set value)? set_, + TResult Function(PersistError_Serialize value)? serialize, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PersistErrorCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PersistErrorCopyWith<$Res> { + factory $PersistErrorCopyWith( + PersistError value, $Res Function(PersistError) then) = + _$PersistErrorCopyWithImpl<$Res, PersistError>; + @useResult + $Res call({String message}); +} + +/// @nodoc +class _$PersistErrorCopyWithImpl<$Res, $Val extends PersistError> + implements $PersistErrorCopyWith<$Res> { + _$PersistErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_value.copyWith( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PersistError_OpenImplCopyWith<$Res> + implements $PersistErrorCopyWith<$Res> { + factory _$$PersistError_OpenImplCopyWith(_$PersistError_OpenImpl value, + $Res Function(_$PersistError_OpenImpl) then) = + __$$PersistError_OpenImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$PersistError_OpenImplCopyWithImpl<$Res> + extends _$PersistErrorCopyWithImpl<$Res, _$PersistError_OpenImpl> + implements _$$PersistError_OpenImplCopyWith<$Res> { + __$$PersistError_OpenImplCopyWithImpl(_$PersistError_OpenImpl _value, + $Res Function(_$PersistError_OpenImpl) _then) + : super(_value, _then); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$PersistError_OpenImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PersistError_OpenImpl extends PersistError_Open { + const _$PersistError_OpenImpl({required this.message}) : super._(); + + @override + final String message; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PersistError_OpenImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PersistError_OpenImplCopyWith<_$PersistError_OpenImpl> get copyWith => + __$$PersistError_OpenImplCopyWithImpl<_$PersistError_OpenImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) open, + required TResult Function(String message) set_, + required TResult Function(String message) serialize, + }) { + return open(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? open, + TResult? Function(String message)? set_, + TResult? Function(String message)? serialize, + }) { + return open?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? open, + TResult Function(String message)? set_, + TResult Function(String message)? serialize, + required TResult orElse(), + }) { + if (open != null) { + return open(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(PersistError_Open value) open, + required TResult Function(PersistError_Set value) set_, + required TResult Function(PersistError_Serialize value) serialize, + }) { + return open(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PersistError_Open value)? open, + TResult? Function(PersistError_Set value)? set_, + TResult? Function(PersistError_Serialize value)? serialize, + }) { + return open?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PersistError_Open value)? open, + TResult Function(PersistError_Set value)? set_, + TResult Function(PersistError_Serialize value)? serialize, + required TResult orElse(), + }) { + if (open != null) { + return open(this); + } + return orElse(); + } +} + +abstract class PersistError_Open extends PersistError { + const factory PersistError_Open({required final String message}) = + _$PersistError_OpenImpl; + const PersistError_Open._() : super._(); + + @override + String get message; + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PersistError_OpenImplCopyWith<_$PersistError_OpenImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PersistError_SetImplCopyWith<$Res> + implements $PersistErrorCopyWith<$Res> { + factory _$$PersistError_SetImplCopyWith(_$PersistError_SetImpl value, + $Res Function(_$PersistError_SetImpl) then) = + __$$PersistError_SetImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$PersistError_SetImplCopyWithImpl<$Res> + extends _$PersistErrorCopyWithImpl<$Res, _$PersistError_SetImpl> + implements _$$PersistError_SetImplCopyWith<$Res> { + __$$PersistError_SetImplCopyWithImpl(_$PersistError_SetImpl _value, + $Res Function(_$PersistError_SetImpl) _then) + : super(_value, _then); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$PersistError_SetImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PersistError_SetImpl extends PersistError_Set { + const _$PersistError_SetImpl({required this.message}) : super._(); + + @override + final String message; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PersistError_SetImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PersistError_SetImplCopyWith<_$PersistError_SetImpl> get copyWith => + __$$PersistError_SetImplCopyWithImpl<_$PersistError_SetImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) open, + required TResult Function(String message) set_, + required TResult Function(String message) serialize, + }) { + return set_(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? open, + TResult? Function(String message)? set_, + TResult? Function(String message)? serialize, + }) { + return set_?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? open, + TResult Function(String message)? set_, + TResult Function(String message)? serialize, + required TResult orElse(), + }) { + if (set_ != null) { + return set_(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(PersistError_Open value) open, + required TResult Function(PersistError_Set value) set_, + required TResult Function(PersistError_Serialize value) serialize, + }) { + return set_(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PersistError_Open value)? open, + TResult? Function(PersistError_Set value)? set_, + TResult? Function(PersistError_Serialize value)? serialize, + }) { + return set_?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PersistError_Open value)? open, + TResult Function(PersistError_Set value)? set_, + TResult Function(PersistError_Serialize value)? serialize, + required TResult orElse(), + }) { + if (set_ != null) { + return set_(this); + } + return orElse(); + } +} + +abstract class PersistError_Set extends PersistError { + const factory PersistError_Set({required final String message}) = + _$PersistError_SetImpl; + const PersistError_Set._() : super._(); + + @override + String get message; + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PersistError_SetImplCopyWith<_$PersistError_SetImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PersistError_SerializeImplCopyWith<$Res> + implements $PersistErrorCopyWith<$Res> { + factory _$$PersistError_SerializeImplCopyWith( + _$PersistError_SerializeImpl value, + $Res Function(_$PersistError_SerializeImpl) then) = + __$$PersistError_SerializeImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$PersistError_SerializeImplCopyWithImpl<$Res> + extends _$PersistErrorCopyWithImpl<$Res, _$PersistError_SerializeImpl> + implements _$$PersistError_SerializeImplCopyWith<$Res> { + __$$PersistError_SerializeImplCopyWithImpl( + _$PersistError_SerializeImpl _value, + $Res Function(_$PersistError_SerializeImpl) _then) + : super(_value, _then); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$PersistError_SerializeImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PersistError_SerializeImpl extends PersistError_Serialize { + const _$PersistError_SerializeImpl({required this.message}) : super._(); + + @override + final String message; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PersistError_SerializeImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PersistError_SerializeImplCopyWith<_$PersistError_SerializeImpl> + get copyWith => __$$PersistError_SerializeImplCopyWithImpl< + _$PersistError_SerializeImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) open, + required TResult Function(String message) set_, + required TResult Function(String message) serialize, + }) { + return serialize(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? open, + TResult? Function(String message)? set_, + TResult? Function(String message)? serialize, + }) { + return serialize?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? open, + TResult Function(String message)? set_, + TResult Function(String message)? serialize, + required TResult orElse(), + }) { + if (serialize != null) { + return serialize(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(PersistError_Open value) open, + required TResult Function(PersistError_Set value) set_, + required TResult Function(PersistError_Serialize value) serialize, + }) { + return serialize(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PersistError_Open value)? open, + TResult? Function(PersistError_Set value)? set_, + TResult? Function(PersistError_Serialize value)? serialize, + }) { + return serialize?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PersistError_Open value)? open, + TResult Function(PersistError_Set value)? set_, + TResult Function(PersistError_Serialize value)? serialize, + required TResult orElse(), + }) { + if (serialize != null) { + return serialize(this); + } + return orElse(); + } +} + +abstract class PersistError_Serialize extends PersistError { + const factory PersistError_Serialize({required final String message}) = + _$PersistError_SerializeImpl; + const PersistError_Serialize._() : super._(); + + @override + String get message; + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PersistError_SerializeImplCopyWith<_$PersistError_SerializeImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$RequestError { + @optionalTypeArgs + TResult when({ + required TResult Function(String message) send, + required TResult Function(String message) receive, + required TResult Function(Duration duration) timeout, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? send, + TResult? Function(String message)? receive, + TResult? Function(Duration duration)? timeout, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? send, + TResult Function(String message)? receive, + TResult Function(Duration duration)? timeout, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(RequestError_Send value) send, + required TResult Function(RequestError_Receive value) receive, + required TResult Function(RequestError_Timeout value) timeout, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RequestError_Send value)? send, + TResult? Function(RequestError_Receive value)? receive, + TResult? Function(RequestError_Timeout value)? timeout, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RequestError_Send value)? send, + TResult Function(RequestError_Receive value)? receive, + TResult Function(RequestError_Timeout value)? timeout, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $RequestErrorCopyWith<$Res> { + factory $RequestErrorCopyWith( + RequestError value, $Res Function(RequestError) then) = + _$RequestErrorCopyWithImpl<$Res, RequestError>; +} + +/// @nodoc +class _$RequestErrorCopyWithImpl<$Res, $Val extends RequestError> + implements $RequestErrorCopyWith<$Res> { + _$RequestErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of RequestError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$RequestError_SendImplCopyWith<$Res> { + factory _$$RequestError_SendImplCopyWith(_$RequestError_SendImpl value, + $Res Function(_$RequestError_SendImpl) then) = + __$$RequestError_SendImplCopyWithImpl<$Res>; + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$RequestError_SendImplCopyWithImpl<$Res> + extends _$RequestErrorCopyWithImpl<$Res, _$RequestError_SendImpl> + implements _$$RequestError_SendImplCopyWith<$Res> { + __$$RequestError_SendImplCopyWithImpl(_$RequestError_SendImpl _value, + $Res Function(_$RequestError_SendImpl) _then) + : super(_value, _then); + + /// Create a copy of RequestError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$RequestError_SendImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$RequestError_SendImpl extends RequestError_Send { + const _$RequestError_SendImpl({required this.message}) : super._(); + + @override + final String message; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RequestError_SendImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + /// Create a copy of RequestError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RequestError_SendImplCopyWith<_$RequestError_SendImpl> get copyWith => + __$$RequestError_SendImplCopyWithImpl<_$RequestError_SendImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) send, + required TResult Function(String message) receive, + required TResult Function(Duration duration) timeout, + }) { + return send(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? send, + TResult? Function(String message)? receive, + TResult? Function(Duration duration)? timeout, + }) { + return send?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? send, + TResult Function(String message)? receive, + TResult Function(Duration duration)? timeout, + required TResult orElse(), + }) { + if (send != null) { + return send(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RequestError_Send value) send, + required TResult Function(RequestError_Receive value) receive, + required TResult Function(RequestError_Timeout value) timeout, + }) { + return send(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RequestError_Send value)? send, + TResult? Function(RequestError_Receive value)? receive, + TResult? Function(RequestError_Timeout value)? timeout, + }) { + return send?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RequestError_Send value)? send, + TResult Function(RequestError_Receive value)? receive, + TResult Function(RequestError_Timeout value)? timeout, + required TResult orElse(), + }) { + if (send != null) { + return send(this); + } + return orElse(); + } +} + +abstract class RequestError_Send extends RequestError { + const factory RequestError_Send({required final String message}) = + _$RequestError_SendImpl; + const RequestError_Send._() : super._(); + + String get message; + + /// Create a copy of RequestError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RequestError_SendImplCopyWith<_$RequestError_SendImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$RequestError_ReceiveImplCopyWith<$Res> { + factory _$$RequestError_ReceiveImplCopyWith(_$RequestError_ReceiveImpl value, + $Res Function(_$RequestError_ReceiveImpl) then) = + __$$RequestError_ReceiveImplCopyWithImpl<$Res>; + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$RequestError_ReceiveImplCopyWithImpl<$Res> + extends _$RequestErrorCopyWithImpl<$Res, _$RequestError_ReceiveImpl> + implements _$$RequestError_ReceiveImplCopyWith<$Res> { + __$$RequestError_ReceiveImplCopyWithImpl(_$RequestError_ReceiveImpl _value, + $Res Function(_$RequestError_ReceiveImpl) _then) + : super(_value, _then); + + /// Create a copy of RequestError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$RequestError_ReceiveImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$RequestError_ReceiveImpl extends RequestError_Receive { + const _$RequestError_ReceiveImpl({required this.message}) : super._(); + + @override + final String message; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RequestError_ReceiveImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + /// Create a copy of RequestError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RequestError_ReceiveImplCopyWith<_$RequestError_ReceiveImpl> + get copyWith => + __$$RequestError_ReceiveImplCopyWithImpl<_$RequestError_ReceiveImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) send, + required TResult Function(String message) receive, + required TResult Function(Duration duration) timeout, + }) { + return receive(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? send, + TResult? Function(String message)? receive, + TResult? Function(Duration duration)? timeout, + }) { + return receive?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? send, + TResult Function(String message)? receive, + TResult Function(Duration duration)? timeout, + required TResult orElse(), + }) { + if (receive != null) { + return receive(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RequestError_Send value) send, + required TResult Function(RequestError_Receive value) receive, + required TResult Function(RequestError_Timeout value) timeout, + }) { + return receive(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RequestError_Send value)? send, + TResult? Function(RequestError_Receive value)? receive, + TResult? Function(RequestError_Timeout value)? timeout, + }) { + return receive?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RequestError_Send value)? send, + TResult Function(RequestError_Receive value)? receive, + TResult Function(RequestError_Timeout value)? timeout, + required TResult orElse(), + }) { + if (receive != null) { + return receive(this); + } + return orElse(); + } +} + +abstract class RequestError_Receive extends RequestError { + const factory RequestError_Receive({required final String message}) = + _$RequestError_ReceiveImpl; + const RequestError_Receive._() : super._(); + + String get message; + + /// Create a copy of RequestError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RequestError_ReceiveImplCopyWith<_$RequestError_ReceiveImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$RequestError_TimeoutImplCopyWith<$Res> { + factory _$$RequestError_TimeoutImplCopyWith(_$RequestError_TimeoutImpl value, + $Res Function(_$RequestError_TimeoutImpl) then) = + __$$RequestError_TimeoutImplCopyWithImpl<$Res>; + @useResult + $Res call({Duration duration}); +} + +/// @nodoc +class __$$RequestError_TimeoutImplCopyWithImpl<$Res> + extends _$RequestErrorCopyWithImpl<$Res, _$RequestError_TimeoutImpl> + implements _$$RequestError_TimeoutImplCopyWith<$Res> { + __$$RequestError_TimeoutImplCopyWithImpl(_$RequestError_TimeoutImpl _value, + $Res Function(_$RequestError_TimeoutImpl) _then) + : super(_value, _then); + + /// Create a copy of RequestError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? duration = null, + }) { + return _then(_$RequestError_TimeoutImpl( + duration: null == duration + ? _value.duration + : duration // ignore: cast_nullable_to_non_nullable + as Duration, + )); + } +} + +/// @nodoc + +class _$RequestError_TimeoutImpl extends RequestError_Timeout { + const _$RequestError_TimeoutImpl({required this.duration}) : super._(); + + @override + final Duration duration; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RequestError_TimeoutImpl && + (identical(other.duration, duration) || + other.duration == duration)); + } + + @override + int get hashCode => Object.hash(runtimeType, duration); + + /// Create a copy of RequestError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RequestError_TimeoutImplCopyWith<_$RequestError_TimeoutImpl> + get copyWith => + __$$RequestError_TimeoutImplCopyWithImpl<_$RequestError_TimeoutImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) send, + required TResult Function(String message) receive, + required TResult Function(Duration duration) timeout, + }) { + return timeout(duration); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? send, + TResult? Function(String message)? receive, + TResult? Function(Duration duration)? timeout, + }) { + return timeout?.call(duration); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? send, + TResult Function(String message)? receive, + TResult Function(Duration duration)? timeout, + required TResult orElse(), + }) { + if (timeout != null) { + return timeout(duration); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RequestError_Send value) send, + required TResult Function(RequestError_Receive value) receive, + required TResult Function(RequestError_Timeout value) timeout, + }) { + return timeout(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RequestError_Send value)? send, + TResult? Function(RequestError_Receive value)? receive, + TResult? Function(RequestError_Timeout value)? timeout, + }) { + return timeout?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RequestError_Send value)? send, + TResult Function(RequestError_Receive value)? receive, + TResult Function(RequestError_Timeout value)? timeout, + required TResult orElse(), + }) { + if (timeout != null) { + return timeout(this); + } + return orElse(); + } +} + +abstract class RequestError_Timeout extends RequestError { + const factory RequestError_Timeout({required final Duration duration}) = + _$RequestError_TimeoutImpl; + const RequestError_Timeout._() : super._(); + + Duration get duration; + + /// Create a copy of RequestError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RequestError_TimeoutImplCopyWith<_$RequestError_TimeoutImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$SendError { + String get message => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(String message) pipeBroken, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? pipeBroken, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? pipeBroken, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(SendError_PipeBroken value) pipeBroken, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SendError_PipeBroken value)? pipeBroken, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SendError_PipeBroken value)? pipeBroken, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + + /// Create a copy of SendError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SendErrorCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SendErrorCopyWith<$Res> { + factory $SendErrorCopyWith(SendError value, $Res Function(SendError) then) = + _$SendErrorCopyWithImpl<$Res, SendError>; + @useResult + $Res call({String message}); +} + +/// @nodoc +class _$SendErrorCopyWithImpl<$Res, $Val extends SendError> + implements $SendErrorCopyWith<$Res> { + _$SendErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SendError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_value.copyWith( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$SendError_PipeBrokenImplCopyWith<$Res> + implements $SendErrorCopyWith<$Res> { + factory _$$SendError_PipeBrokenImplCopyWith(_$SendError_PipeBrokenImpl value, + $Res Function(_$SendError_PipeBrokenImpl) then) = + __$$SendError_PipeBrokenImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$SendError_PipeBrokenImplCopyWithImpl<$Res> + extends _$SendErrorCopyWithImpl<$Res, _$SendError_PipeBrokenImpl> + implements _$$SendError_PipeBrokenImplCopyWith<$Res> { + __$$SendError_PipeBrokenImplCopyWithImpl(_$SendError_PipeBrokenImpl _value, + $Res Function(_$SendError_PipeBrokenImpl) _then) + : super(_value, _then); + + /// Create a copy of SendError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$SendError_PipeBrokenImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$SendError_PipeBrokenImpl extends SendError_PipeBroken { + const _$SendError_PipeBrokenImpl({required this.message}) : super._(); + + @override + final String message; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SendError_PipeBrokenImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + /// Create a copy of SendError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SendError_PipeBrokenImplCopyWith<_$SendError_PipeBrokenImpl> + get copyWith => + __$$SendError_PipeBrokenImplCopyWithImpl<_$SendError_PipeBrokenImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) pipeBroken, + }) { + return pipeBroken(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? pipeBroken, + }) { + return pipeBroken?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? pipeBroken, + required TResult orElse(), + }) { + if (pipeBroken != null) { + return pipeBroken(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SendError_PipeBroken value) pipeBroken, + }) { + return pipeBroken(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SendError_PipeBroken value)? pipeBroken, + }) { + return pipeBroken?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SendError_PipeBroken value)? pipeBroken, + required TResult orElse(), + }) { + if (pipeBroken != null) { + return pipeBroken(this); + } + return orElse(); + } +} + +abstract class SendError_PipeBroken extends SendError { + const factory SendError_PipeBroken({required final String message}) = + _$SendError_PipeBrokenImpl; + const SendError_PipeBroken._() : super._(); + + @override + String get message; + + /// Create a copy of SendError + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SendError_PipeBrokenImplCopyWith<_$SendError_PipeBrokenImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/rust/bindings/dart/lib/src/generated/api/driver_client.dart b/rust/bindings/dart/lib/src/generated/api/driver_client.dart new file mode 100644 index 00000000..9e2e6310 --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/api/driver_client.dart @@ -0,0 +1,260 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.2.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../api.dart'; +import '../frb_generated.dart'; +import 'client.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:freezed_annotation/freezed_annotation.dart' hide protected; +part 'driver_client.freezed.dart'; + +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `from`, `from`, `from`, `from` + +// Rust type: RustOpaqueMoi> +abstract class DriverClient implements RustOpaqueInterface { + /// Add a new monitor. + /// + /// Returns an error if a monitor with this ID already exists, or if the + /// monitor is invalid. A monitor is invalid if it has duplicate modes, or + /// if any of its modes has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void add({required Monitor monitor}); + + /// Add a mode to the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist, or if the mode already + /// exists on that monitor, or if the mode is invalid. A mode is invalid if + /// it has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void addMode({required int id, required Mode mode}); + + /// Connect to driver on pipe with default name. + /// + /// You can optionally specify the name of the named pipe to connect to. The + /// default name is "virtualdisplaydriver" + static Future connect({String? pipeName}) => + RustLib.instance.api + .crateApiDriverClientDriverClientConnect(pipeName: pipeName); + + /// Find the monitor with the given ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + Monitor? findMonitor({required int id}); + + /// Get the closest available free ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + /// + /// Note: Duplicate monitors are ignored when send to the Driver using + /// [DriverClient.notify]. + int? newId({int? preferredId}); + + /// Send the current client state to the driver. + /// + /// State changes of the client are not automatically sent to the driver. + /// You must manually call this method to send changes to the driver. + Future notify(); + + /// Write client state to the registry for current user. + /// + /// Next time the driver is started, it will load this state from the + /// registry. This might be after a reboot or a driver restart. + Future persist(); + + /// Returns a stream of continuous events from the driver. + /// + /// This stream will always reflect the real state of the driver, regardless + /// of who changed its state. This means, if it is changed by another + /// process, this stream will still be updated. + Stream> receiveEvents(); + + /// Manually synchronize with the driver. + Future> refreshState(); + + /// Remove monitors by id. + /// + /// Silently skips IDs that do not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void remove({required List ids}); + + /// Remove all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + void removeAll(); + + /// Remove a mode from the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist. If the mode does not + /// exist, it is silently skipped. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void removeMode({required int id, required (int, int) resolution}); + + /// Replace an existing monitor. The monitor is identified by its ID. + /// + /// Throws [MonitorNotFoundError] if the monitor does not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void replaceMonitor({required Monitor monitor}); + + /// Set enabled state of all monitors with the given IDs. + /// + /// Silently skips incorrect IDs. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void setEnabled({required List ids, required bool enabled}); + + /// Replace all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + void setMonitors({required List monitors}); + + /// Get the current monitor state stored inside this client. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + List get state; +} + +@freezed +sealed class AddModeError with _$AddModeError implements FrbException { + const AddModeError._(); + + const factory AddModeError.monitorNotFound({ + required int id, + }) = AddModeError_MonitorNotFound; + const factory AddModeError.modeExists({ + required int monitorId, + required int width, + required int height, + }) = AddModeError_ModeExists; + const factory AddModeError.refreshRateExists({ + required int monitorId, + required int width, + required int height, + required int refreshRate, + }) = AddModeError_RefreshRateExists; + + @override + String toString() => switch (this) { + AddModeError_MonitorNotFound(:final id) => + 'Monitor with id $id not found', + AddModeError_ModeExists( + :final monitorId, + :final width, + :final height + ) => + 'Mode ${width}x$height already exists on monitor $monitorId', + AddModeError_RefreshRateExists( + :final monitorId, + :final width, + :final height, + :final refreshRate + ) => + 'Refresh rate $refreshRate already exists on mode ${width}x$height on monitor $monitorId', + }; +} + +@freezed +sealed class DuplicateError with _$DuplicateError implements FrbException { + const DuplicateError._(); + + const factory DuplicateError.monitor({ + required int id, + }) = DuplicateError_Monitor; + const factory DuplicateError.mode({ + required int monitorId, + required int width, + required int height, + }) = DuplicateError_Mode; + const factory DuplicateError.refreshRate({ + required int monitorId, + required int width, + required int height, + required int refreshRate, + }) = DuplicateError_RefreshRate; + + @override + String toString() => switch (this) { + DuplicateError_Monitor(:final id) => + 'Monitor with id $id already exists', + DuplicateError_Mode(:final monitorId, :final width, :final height) => + 'Mode ${width}x$height already exists on monitor $monitorId', + DuplicateError_RefreshRate( + :final monitorId, + :final width, + :final height, + :final refreshRate + ) => + 'Refresh rate $refreshRate already exists on mode ${width}x$height on monitor $monitorId', + }; +} + +@freezed +sealed class InitError with _$InitError implements FrbException { + const InitError._(); + + const factory InitError.connect({ + required ConnectionError inner, + }) = InitError_Connect; + const factory InitError.requestState({ + required RequestError inner, + }) = InitError_RequestState; + + @override + String toString() => 'Failed to initialize DriverClient: $inner'; +} + +class MonitorNotFoundError implements FrbException { + final int id; + + const MonitorNotFoundError({ + required this.id, + }); + + @override + String toString() => 'Monitor with id $id not found'; + + @override + int get hashCode => id.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is MonitorNotFoundError && + runtimeType == other.runtimeType && + id == other.id; +} diff --git a/rust/bindings/dart/lib/src/generated/api/driver_client.freezed.dart b/rust/bindings/dart/lib/src/generated/api/driver_client.freezed.dart new file mode 100644 index 00000000..3cadf900 --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/api/driver_client.freezed.dart @@ -0,0 +1,1562 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'driver_client.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$AddModeError { + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitorNotFound, + required TResult Function(int monitorId, int width, int height) modeExists, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRateExists, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitorNotFound, + TResult? Function(int monitorId, int width, int height)? modeExists, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitorNotFound, + TResult Function(int monitorId, int width, int height)? modeExists, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(AddModeError_MonitorNotFound value) + monitorNotFound, + required TResult Function(AddModeError_ModeExists value) modeExists, + required TResult Function(AddModeError_RefreshRateExists value) + refreshRateExists, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult? Function(AddModeError_ModeExists value)? modeExists, + TResult? Function(AddModeError_RefreshRateExists value)? refreshRateExists, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult Function(AddModeError_ModeExists value)? modeExists, + TResult Function(AddModeError_RefreshRateExists value)? refreshRateExists, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AddModeErrorCopyWith<$Res> { + factory $AddModeErrorCopyWith( + AddModeError value, $Res Function(AddModeError) then) = + _$AddModeErrorCopyWithImpl<$Res, AddModeError>; +} + +/// @nodoc +class _$AddModeErrorCopyWithImpl<$Res, $Val extends AddModeError> + implements $AddModeErrorCopyWith<$Res> { + _$AddModeErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$AddModeError_MonitorNotFoundImplCopyWith<$Res> { + factory _$$AddModeError_MonitorNotFoundImplCopyWith( + _$AddModeError_MonitorNotFoundImpl value, + $Res Function(_$AddModeError_MonitorNotFoundImpl) then) = + __$$AddModeError_MonitorNotFoundImplCopyWithImpl<$Res>; + @useResult + $Res call({int id}); +} + +/// @nodoc +class __$$AddModeError_MonitorNotFoundImplCopyWithImpl<$Res> + extends _$AddModeErrorCopyWithImpl<$Res, _$AddModeError_MonitorNotFoundImpl> + implements _$$AddModeError_MonitorNotFoundImplCopyWith<$Res> { + __$$AddModeError_MonitorNotFoundImplCopyWithImpl( + _$AddModeError_MonitorNotFoundImpl _value, + $Res Function(_$AddModeError_MonitorNotFoundImpl) _then) + : super(_value, _then); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + }) { + return _then(_$AddModeError_MonitorNotFoundImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$AddModeError_MonitorNotFoundImpl extends AddModeError_MonitorNotFound { + const _$AddModeError_MonitorNotFoundImpl({required this.id}) : super._(); + + @override + final int id; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddModeError_MonitorNotFoundImpl && + (identical(other.id, id) || other.id == id)); + } + + @override + int get hashCode => Object.hash(runtimeType, id); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$AddModeError_MonitorNotFoundImplCopyWith< + _$AddModeError_MonitorNotFoundImpl> + get copyWith => __$$AddModeError_MonitorNotFoundImplCopyWithImpl< + _$AddModeError_MonitorNotFoundImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitorNotFound, + required TResult Function(int monitorId, int width, int height) modeExists, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRateExists, + }) { + return monitorNotFound(id); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitorNotFound, + TResult? Function(int monitorId, int width, int height)? modeExists, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + }) { + return monitorNotFound?.call(id); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitorNotFound, + TResult Function(int monitorId, int width, int height)? modeExists, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + required TResult orElse(), + }) { + if (monitorNotFound != null) { + return monitorNotFound(id); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AddModeError_MonitorNotFound value) + monitorNotFound, + required TResult Function(AddModeError_ModeExists value) modeExists, + required TResult Function(AddModeError_RefreshRateExists value) + refreshRateExists, + }) { + return monitorNotFound(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult? Function(AddModeError_ModeExists value)? modeExists, + TResult? Function(AddModeError_RefreshRateExists value)? refreshRateExists, + }) { + return monitorNotFound?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult Function(AddModeError_ModeExists value)? modeExists, + TResult Function(AddModeError_RefreshRateExists value)? refreshRateExists, + required TResult orElse(), + }) { + if (monitorNotFound != null) { + return monitorNotFound(this); + } + return orElse(); + } +} + +abstract class AddModeError_MonitorNotFound extends AddModeError { + const factory AddModeError_MonitorNotFound({required final int id}) = + _$AddModeError_MonitorNotFoundImpl; + const AddModeError_MonitorNotFound._() : super._(); + + int get id; + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$AddModeError_MonitorNotFoundImplCopyWith< + _$AddModeError_MonitorNotFoundImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AddModeError_ModeExistsImplCopyWith<$Res> { + factory _$$AddModeError_ModeExistsImplCopyWith( + _$AddModeError_ModeExistsImpl value, + $Res Function(_$AddModeError_ModeExistsImpl) then) = + __$$AddModeError_ModeExistsImplCopyWithImpl<$Res>; + @useResult + $Res call({int monitorId, int width, int height}); +} + +/// @nodoc +class __$$AddModeError_ModeExistsImplCopyWithImpl<$Res> + extends _$AddModeErrorCopyWithImpl<$Res, _$AddModeError_ModeExistsImpl> + implements _$$AddModeError_ModeExistsImplCopyWith<$Res> { + __$$AddModeError_ModeExistsImplCopyWithImpl( + _$AddModeError_ModeExistsImpl _value, + $Res Function(_$AddModeError_ModeExistsImpl) _then) + : super(_value, _then); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? monitorId = null, + Object? width = null, + Object? height = null, + }) { + return _then(_$AddModeError_ModeExistsImpl( + monitorId: null == monitorId + ? _value.monitorId + : monitorId // ignore: cast_nullable_to_non_nullable + as int, + width: null == width + ? _value.width + : width // ignore: cast_nullable_to_non_nullable + as int, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$AddModeError_ModeExistsImpl extends AddModeError_ModeExists { + const _$AddModeError_ModeExistsImpl( + {required this.monitorId, required this.width, required this.height}) + : super._(); + + @override + final int monitorId; + @override + final int width; + @override + final int height; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddModeError_ModeExistsImpl && + (identical(other.monitorId, monitorId) || + other.monitorId == monitorId) && + (identical(other.width, width) || other.width == width) && + (identical(other.height, height) || other.height == height)); + } + + @override + int get hashCode => Object.hash(runtimeType, monitorId, width, height); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$AddModeError_ModeExistsImplCopyWith<_$AddModeError_ModeExistsImpl> + get copyWith => __$$AddModeError_ModeExistsImplCopyWithImpl< + _$AddModeError_ModeExistsImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitorNotFound, + required TResult Function(int monitorId, int width, int height) modeExists, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRateExists, + }) { + return modeExists(monitorId, width, height); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitorNotFound, + TResult? Function(int monitorId, int width, int height)? modeExists, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + }) { + return modeExists?.call(monitorId, width, height); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitorNotFound, + TResult Function(int monitorId, int width, int height)? modeExists, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + required TResult orElse(), + }) { + if (modeExists != null) { + return modeExists(monitorId, width, height); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AddModeError_MonitorNotFound value) + monitorNotFound, + required TResult Function(AddModeError_ModeExists value) modeExists, + required TResult Function(AddModeError_RefreshRateExists value) + refreshRateExists, + }) { + return modeExists(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult? Function(AddModeError_ModeExists value)? modeExists, + TResult? Function(AddModeError_RefreshRateExists value)? refreshRateExists, + }) { + return modeExists?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult Function(AddModeError_ModeExists value)? modeExists, + TResult Function(AddModeError_RefreshRateExists value)? refreshRateExists, + required TResult orElse(), + }) { + if (modeExists != null) { + return modeExists(this); + } + return orElse(); + } +} + +abstract class AddModeError_ModeExists extends AddModeError { + const factory AddModeError_ModeExists( + {required final int monitorId, + required final int width, + required final int height}) = _$AddModeError_ModeExistsImpl; + const AddModeError_ModeExists._() : super._(); + + int get monitorId; + int get width; + int get height; + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$AddModeError_ModeExistsImplCopyWith<_$AddModeError_ModeExistsImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AddModeError_RefreshRateExistsImplCopyWith<$Res> { + factory _$$AddModeError_RefreshRateExistsImplCopyWith( + _$AddModeError_RefreshRateExistsImpl value, + $Res Function(_$AddModeError_RefreshRateExistsImpl) then) = + __$$AddModeError_RefreshRateExistsImplCopyWithImpl<$Res>; + @useResult + $Res call({int monitorId, int width, int height, int refreshRate}); +} + +/// @nodoc +class __$$AddModeError_RefreshRateExistsImplCopyWithImpl<$Res> + extends _$AddModeErrorCopyWithImpl<$Res, + _$AddModeError_RefreshRateExistsImpl> + implements _$$AddModeError_RefreshRateExistsImplCopyWith<$Res> { + __$$AddModeError_RefreshRateExistsImplCopyWithImpl( + _$AddModeError_RefreshRateExistsImpl _value, + $Res Function(_$AddModeError_RefreshRateExistsImpl) _then) + : super(_value, _then); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? monitorId = null, + Object? width = null, + Object? height = null, + Object? refreshRate = null, + }) { + return _then(_$AddModeError_RefreshRateExistsImpl( + monitorId: null == monitorId + ? _value.monitorId + : monitorId // ignore: cast_nullable_to_non_nullable + as int, + width: null == width + ? _value.width + : width // ignore: cast_nullable_to_non_nullable + as int, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as int, + refreshRate: null == refreshRate + ? _value.refreshRate + : refreshRate // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$AddModeError_RefreshRateExistsImpl + extends AddModeError_RefreshRateExists { + const _$AddModeError_RefreshRateExistsImpl( + {required this.monitorId, + required this.width, + required this.height, + required this.refreshRate}) + : super._(); + + @override + final int monitorId; + @override + final int width; + @override + final int height; + @override + final int refreshRate; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddModeError_RefreshRateExistsImpl && + (identical(other.monitorId, monitorId) || + other.monitorId == monitorId) && + (identical(other.width, width) || other.width == width) && + (identical(other.height, height) || other.height == height) && + (identical(other.refreshRate, refreshRate) || + other.refreshRate == refreshRate)); + } + + @override + int get hashCode => + Object.hash(runtimeType, monitorId, width, height, refreshRate); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$AddModeError_RefreshRateExistsImplCopyWith< + _$AddModeError_RefreshRateExistsImpl> + get copyWith => __$$AddModeError_RefreshRateExistsImplCopyWithImpl< + _$AddModeError_RefreshRateExistsImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitorNotFound, + required TResult Function(int monitorId, int width, int height) modeExists, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRateExists, + }) { + return refreshRateExists(monitorId, width, height, refreshRate); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitorNotFound, + TResult? Function(int monitorId, int width, int height)? modeExists, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + }) { + return refreshRateExists?.call(monitorId, width, height, refreshRate); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitorNotFound, + TResult Function(int monitorId, int width, int height)? modeExists, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + required TResult orElse(), + }) { + if (refreshRateExists != null) { + return refreshRateExists(monitorId, width, height, refreshRate); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AddModeError_MonitorNotFound value) + monitorNotFound, + required TResult Function(AddModeError_ModeExists value) modeExists, + required TResult Function(AddModeError_RefreshRateExists value) + refreshRateExists, + }) { + return refreshRateExists(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult? Function(AddModeError_ModeExists value)? modeExists, + TResult? Function(AddModeError_RefreshRateExists value)? refreshRateExists, + }) { + return refreshRateExists?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult Function(AddModeError_ModeExists value)? modeExists, + TResult Function(AddModeError_RefreshRateExists value)? refreshRateExists, + required TResult orElse(), + }) { + if (refreshRateExists != null) { + return refreshRateExists(this); + } + return orElse(); + } +} + +abstract class AddModeError_RefreshRateExists extends AddModeError { + const factory AddModeError_RefreshRateExists( + {required final int monitorId, + required final int width, + required final int height, + required final int refreshRate}) = _$AddModeError_RefreshRateExistsImpl; + const AddModeError_RefreshRateExists._() : super._(); + + int get monitorId; + int get width; + int get height; + int get refreshRate; + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$AddModeError_RefreshRateExistsImplCopyWith< + _$AddModeError_RefreshRateExistsImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$DuplicateError { + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitor, + required TResult Function(int monitorId, int width, int height) mode, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRate, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitor, + TResult? Function(int monitorId, int width, int height)? mode, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitor, + TResult Function(int monitorId, int width, int height)? mode, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(DuplicateError_Monitor value) monitor, + required TResult Function(DuplicateError_Mode value) mode, + required TResult Function(DuplicateError_RefreshRate value) refreshRate, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DuplicateError_Monitor value)? monitor, + TResult? Function(DuplicateError_Mode value)? mode, + TResult? Function(DuplicateError_RefreshRate value)? refreshRate, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DuplicateError_Monitor value)? monitor, + TResult Function(DuplicateError_Mode value)? mode, + TResult Function(DuplicateError_RefreshRate value)? refreshRate, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DuplicateErrorCopyWith<$Res> { + factory $DuplicateErrorCopyWith( + DuplicateError value, $Res Function(DuplicateError) then) = + _$DuplicateErrorCopyWithImpl<$Res, DuplicateError>; +} + +/// @nodoc +class _$DuplicateErrorCopyWithImpl<$Res, $Val extends DuplicateError> + implements $DuplicateErrorCopyWith<$Res> { + _$DuplicateErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$DuplicateError_MonitorImplCopyWith<$Res> { + factory _$$DuplicateError_MonitorImplCopyWith( + _$DuplicateError_MonitorImpl value, + $Res Function(_$DuplicateError_MonitorImpl) then) = + __$$DuplicateError_MonitorImplCopyWithImpl<$Res>; + @useResult + $Res call({int id}); +} + +/// @nodoc +class __$$DuplicateError_MonitorImplCopyWithImpl<$Res> + extends _$DuplicateErrorCopyWithImpl<$Res, _$DuplicateError_MonitorImpl> + implements _$$DuplicateError_MonitorImplCopyWith<$Res> { + __$$DuplicateError_MonitorImplCopyWithImpl( + _$DuplicateError_MonitorImpl _value, + $Res Function(_$DuplicateError_MonitorImpl) _then) + : super(_value, _then); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + }) { + return _then(_$DuplicateError_MonitorImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$DuplicateError_MonitorImpl extends DuplicateError_Monitor { + const _$DuplicateError_MonitorImpl({required this.id}) : super._(); + + @override + final int id; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DuplicateError_MonitorImpl && + (identical(other.id, id) || other.id == id)); + } + + @override + int get hashCode => Object.hash(runtimeType, id); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DuplicateError_MonitorImplCopyWith<_$DuplicateError_MonitorImpl> + get copyWith => __$$DuplicateError_MonitorImplCopyWithImpl< + _$DuplicateError_MonitorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitor, + required TResult Function(int monitorId, int width, int height) mode, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRate, + }) { + return monitor(id); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitor, + TResult? Function(int monitorId, int width, int height)? mode, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + }) { + return monitor?.call(id); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitor, + TResult Function(int monitorId, int width, int height)? mode, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + required TResult orElse(), + }) { + if (monitor != null) { + return monitor(id); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(DuplicateError_Monitor value) monitor, + required TResult Function(DuplicateError_Mode value) mode, + required TResult Function(DuplicateError_RefreshRate value) refreshRate, + }) { + return monitor(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DuplicateError_Monitor value)? monitor, + TResult? Function(DuplicateError_Mode value)? mode, + TResult? Function(DuplicateError_RefreshRate value)? refreshRate, + }) { + return monitor?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DuplicateError_Monitor value)? monitor, + TResult Function(DuplicateError_Mode value)? mode, + TResult Function(DuplicateError_RefreshRate value)? refreshRate, + required TResult orElse(), + }) { + if (monitor != null) { + return monitor(this); + } + return orElse(); + } +} + +abstract class DuplicateError_Monitor extends DuplicateError { + const factory DuplicateError_Monitor({required final int id}) = + _$DuplicateError_MonitorImpl; + const DuplicateError_Monitor._() : super._(); + + int get id; + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DuplicateError_MonitorImplCopyWith<_$DuplicateError_MonitorImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$DuplicateError_ModeImplCopyWith<$Res> { + factory _$$DuplicateError_ModeImplCopyWith(_$DuplicateError_ModeImpl value, + $Res Function(_$DuplicateError_ModeImpl) then) = + __$$DuplicateError_ModeImplCopyWithImpl<$Res>; + @useResult + $Res call({int monitorId, int width, int height}); +} + +/// @nodoc +class __$$DuplicateError_ModeImplCopyWithImpl<$Res> + extends _$DuplicateErrorCopyWithImpl<$Res, _$DuplicateError_ModeImpl> + implements _$$DuplicateError_ModeImplCopyWith<$Res> { + __$$DuplicateError_ModeImplCopyWithImpl(_$DuplicateError_ModeImpl _value, + $Res Function(_$DuplicateError_ModeImpl) _then) + : super(_value, _then); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? monitorId = null, + Object? width = null, + Object? height = null, + }) { + return _then(_$DuplicateError_ModeImpl( + monitorId: null == monitorId + ? _value.monitorId + : monitorId // ignore: cast_nullable_to_non_nullable + as int, + width: null == width + ? _value.width + : width // ignore: cast_nullable_to_non_nullable + as int, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$DuplicateError_ModeImpl extends DuplicateError_Mode { + const _$DuplicateError_ModeImpl( + {required this.monitorId, required this.width, required this.height}) + : super._(); + + @override + final int monitorId; + @override + final int width; + @override + final int height; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DuplicateError_ModeImpl && + (identical(other.monitorId, monitorId) || + other.monitorId == monitorId) && + (identical(other.width, width) || other.width == width) && + (identical(other.height, height) || other.height == height)); + } + + @override + int get hashCode => Object.hash(runtimeType, monitorId, width, height); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DuplicateError_ModeImplCopyWith<_$DuplicateError_ModeImpl> get copyWith => + __$$DuplicateError_ModeImplCopyWithImpl<_$DuplicateError_ModeImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitor, + required TResult Function(int monitorId, int width, int height) mode, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRate, + }) { + return mode(monitorId, width, height); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitor, + TResult? Function(int monitorId, int width, int height)? mode, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + }) { + return mode?.call(monitorId, width, height); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitor, + TResult Function(int monitorId, int width, int height)? mode, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + required TResult orElse(), + }) { + if (mode != null) { + return mode(monitorId, width, height); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(DuplicateError_Monitor value) monitor, + required TResult Function(DuplicateError_Mode value) mode, + required TResult Function(DuplicateError_RefreshRate value) refreshRate, + }) { + return mode(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DuplicateError_Monitor value)? monitor, + TResult? Function(DuplicateError_Mode value)? mode, + TResult? Function(DuplicateError_RefreshRate value)? refreshRate, + }) { + return mode?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DuplicateError_Monitor value)? monitor, + TResult Function(DuplicateError_Mode value)? mode, + TResult Function(DuplicateError_RefreshRate value)? refreshRate, + required TResult orElse(), + }) { + if (mode != null) { + return mode(this); + } + return orElse(); + } +} + +abstract class DuplicateError_Mode extends DuplicateError { + const factory DuplicateError_Mode( + {required final int monitorId, + required final int width, + required final int height}) = _$DuplicateError_ModeImpl; + const DuplicateError_Mode._() : super._(); + + int get monitorId; + int get width; + int get height; + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DuplicateError_ModeImplCopyWith<_$DuplicateError_ModeImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$DuplicateError_RefreshRateImplCopyWith<$Res> { + factory _$$DuplicateError_RefreshRateImplCopyWith( + _$DuplicateError_RefreshRateImpl value, + $Res Function(_$DuplicateError_RefreshRateImpl) then) = + __$$DuplicateError_RefreshRateImplCopyWithImpl<$Res>; + @useResult + $Res call({int monitorId, int width, int height, int refreshRate}); +} + +/// @nodoc +class __$$DuplicateError_RefreshRateImplCopyWithImpl<$Res> + extends _$DuplicateErrorCopyWithImpl<$Res, _$DuplicateError_RefreshRateImpl> + implements _$$DuplicateError_RefreshRateImplCopyWith<$Res> { + __$$DuplicateError_RefreshRateImplCopyWithImpl( + _$DuplicateError_RefreshRateImpl _value, + $Res Function(_$DuplicateError_RefreshRateImpl) _then) + : super(_value, _then); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? monitorId = null, + Object? width = null, + Object? height = null, + Object? refreshRate = null, + }) { + return _then(_$DuplicateError_RefreshRateImpl( + monitorId: null == monitorId + ? _value.monitorId + : monitorId // ignore: cast_nullable_to_non_nullable + as int, + width: null == width + ? _value.width + : width // ignore: cast_nullable_to_non_nullable + as int, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as int, + refreshRate: null == refreshRate + ? _value.refreshRate + : refreshRate // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$DuplicateError_RefreshRateImpl extends DuplicateError_RefreshRate { + const _$DuplicateError_RefreshRateImpl( + {required this.monitorId, + required this.width, + required this.height, + required this.refreshRate}) + : super._(); + + @override + final int monitorId; + @override + final int width; + @override + final int height; + @override + final int refreshRate; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DuplicateError_RefreshRateImpl && + (identical(other.monitorId, monitorId) || + other.monitorId == monitorId) && + (identical(other.width, width) || other.width == width) && + (identical(other.height, height) || other.height == height) && + (identical(other.refreshRate, refreshRate) || + other.refreshRate == refreshRate)); + } + + @override + int get hashCode => + Object.hash(runtimeType, monitorId, width, height, refreshRate); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DuplicateError_RefreshRateImplCopyWith<_$DuplicateError_RefreshRateImpl> + get copyWith => __$$DuplicateError_RefreshRateImplCopyWithImpl< + _$DuplicateError_RefreshRateImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitor, + required TResult Function(int monitorId, int width, int height) mode, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRate, + }) { + return refreshRate(monitorId, width, height, this.refreshRate); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitor, + TResult? Function(int monitorId, int width, int height)? mode, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + }) { + return refreshRate?.call(monitorId, width, height, this.refreshRate); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitor, + TResult Function(int monitorId, int width, int height)? mode, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + required TResult orElse(), + }) { + if (refreshRate != null) { + return refreshRate(monitorId, width, height, this.refreshRate); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(DuplicateError_Monitor value) monitor, + required TResult Function(DuplicateError_Mode value) mode, + required TResult Function(DuplicateError_RefreshRate value) refreshRate, + }) { + return refreshRate(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DuplicateError_Monitor value)? monitor, + TResult? Function(DuplicateError_Mode value)? mode, + TResult? Function(DuplicateError_RefreshRate value)? refreshRate, + }) { + return refreshRate?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DuplicateError_Monitor value)? monitor, + TResult Function(DuplicateError_Mode value)? mode, + TResult Function(DuplicateError_RefreshRate value)? refreshRate, + required TResult orElse(), + }) { + if (refreshRate != null) { + return refreshRate(this); + } + return orElse(); + } +} + +abstract class DuplicateError_RefreshRate extends DuplicateError { + const factory DuplicateError_RefreshRate( + {required final int monitorId, + required final int width, + required final int height, + required final int refreshRate}) = _$DuplicateError_RefreshRateImpl; + const DuplicateError_RefreshRate._() : super._(); + + int get monitorId; + int get width; + int get height; + int get refreshRate; + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DuplicateError_RefreshRateImplCopyWith<_$DuplicateError_RefreshRateImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$InitError { + FrbException get inner => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(ConnectionError inner) connect, + required TResult Function(RequestError inner) requestState, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ConnectionError inner)? connect, + TResult? Function(RequestError inner)? requestState, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ConnectionError inner)? connect, + TResult Function(RequestError inner)? requestState, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(InitError_Connect value) connect, + required TResult Function(InitError_RequestState value) requestState, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(InitError_Connect value)? connect, + TResult? Function(InitError_RequestState value)? requestState, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(InitError_Connect value)? connect, + TResult Function(InitError_RequestState value)? requestState, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $InitErrorCopyWith<$Res> { + factory $InitErrorCopyWith(InitError value, $Res Function(InitError) then) = + _$InitErrorCopyWithImpl<$Res, InitError>; +} + +/// @nodoc +class _$InitErrorCopyWithImpl<$Res, $Val extends InitError> + implements $InitErrorCopyWith<$Res> { + _$InitErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$InitError_ConnectImplCopyWith<$Res> { + factory _$$InitError_ConnectImplCopyWith(_$InitError_ConnectImpl value, + $Res Function(_$InitError_ConnectImpl) then) = + __$$InitError_ConnectImplCopyWithImpl<$Res>; + @useResult + $Res call({ConnectionError inner}); + + $ConnectionErrorCopyWith<$Res> get inner; +} + +/// @nodoc +class __$$InitError_ConnectImplCopyWithImpl<$Res> + extends _$InitErrorCopyWithImpl<$Res, _$InitError_ConnectImpl> + implements _$$InitError_ConnectImplCopyWith<$Res> { + __$$InitError_ConnectImplCopyWithImpl(_$InitError_ConnectImpl _value, + $Res Function(_$InitError_ConnectImpl) _then) + : super(_value, _then); + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? inner = null, + }) { + return _then(_$InitError_ConnectImpl( + inner: null == inner + ? _value.inner + : inner // ignore: cast_nullable_to_non_nullable + as ConnectionError, + )); + } + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ConnectionErrorCopyWith<$Res> get inner { + return $ConnectionErrorCopyWith<$Res>(_value.inner, (value) { + return _then(_value.copyWith(inner: value)); + }); + } +} + +/// @nodoc + +class _$InitError_ConnectImpl extends InitError_Connect { + const _$InitError_ConnectImpl({required this.inner}) : super._(); + + @override + final ConnectionError inner; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$InitError_ConnectImpl && + (identical(other.inner, inner) || other.inner == inner)); + } + + @override + int get hashCode => Object.hash(runtimeType, inner); + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$InitError_ConnectImplCopyWith<_$InitError_ConnectImpl> get copyWith => + __$$InitError_ConnectImplCopyWithImpl<_$InitError_ConnectImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ConnectionError inner) connect, + required TResult Function(RequestError inner) requestState, + }) { + return connect(inner); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ConnectionError inner)? connect, + TResult? Function(RequestError inner)? requestState, + }) { + return connect?.call(inner); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ConnectionError inner)? connect, + TResult Function(RequestError inner)? requestState, + required TResult orElse(), + }) { + if (connect != null) { + return connect(inner); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(InitError_Connect value) connect, + required TResult Function(InitError_RequestState value) requestState, + }) { + return connect(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(InitError_Connect value)? connect, + TResult? Function(InitError_RequestState value)? requestState, + }) { + return connect?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(InitError_Connect value)? connect, + TResult Function(InitError_RequestState value)? requestState, + required TResult orElse(), + }) { + if (connect != null) { + return connect(this); + } + return orElse(); + } +} + +abstract class InitError_Connect extends InitError { + const factory InitError_Connect({required final ConnectionError inner}) = + _$InitError_ConnectImpl; + const InitError_Connect._() : super._(); + + @override + ConnectionError get inner; + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$InitError_ConnectImplCopyWith<_$InitError_ConnectImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$InitError_RequestStateImplCopyWith<$Res> { + factory _$$InitError_RequestStateImplCopyWith( + _$InitError_RequestStateImpl value, + $Res Function(_$InitError_RequestStateImpl) then) = + __$$InitError_RequestStateImplCopyWithImpl<$Res>; + @useResult + $Res call({RequestError inner}); + + $RequestErrorCopyWith<$Res> get inner; +} + +/// @nodoc +class __$$InitError_RequestStateImplCopyWithImpl<$Res> + extends _$InitErrorCopyWithImpl<$Res, _$InitError_RequestStateImpl> + implements _$$InitError_RequestStateImplCopyWith<$Res> { + __$$InitError_RequestStateImplCopyWithImpl( + _$InitError_RequestStateImpl _value, + $Res Function(_$InitError_RequestStateImpl) _then) + : super(_value, _then); + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? inner = null, + }) { + return _then(_$InitError_RequestStateImpl( + inner: null == inner + ? _value.inner + : inner // ignore: cast_nullable_to_non_nullable + as RequestError, + )); + } + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $RequestErrorCopyWith<$Res> get inner { + return $RequestErrorCopyWith<$Res>(_value.inner, (value) { + return _then(_value.copyWith(inner: value)); + }); + } +} + +/// @nodoc + +class _$InitError_RequestStateImpl extends InitError_RequestState { + const _$InitError_RequestStateImpl({required this.inner}) : super._(); + + @override + final RequestError inner; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$InitError_RequestStateImpl && + (identical(other.inner, inner) || other.inner == inner)); + } + + @override + int get hashCode => Object.hash(runtimeType, inner); + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$InitError_RequestStateImplCopyWith<_$InitError_RequestStateImpl> + get copyWith => __$$InitError_RequestStateImplCopyWithImpl< + _$InitError_RequestStateImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ConnectionError inner) connect, + required TResult Function(RequestError inner) requestState, + }) { + return requestState(inner); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ConnectionError inner)? connect, + TResult? Function(RequestError inner)? requestState, + }) { + return requestState?.call(inner); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ConnectionError inner)? connect, + TResult Function(RequestError inner)? requestState, + required TResult orElse(), + }) { + if (requestState != null) { + return requestState(inner); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(InitError_Connect value) connect, + required TResult Function(InitError_RequestState value) requestState, + }) { + return requestState(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(InitError_Connect value)? connect, + TResult? Function(InitError_RequestState value)? requestState, + }) { + return requestState?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(InitError_Connect value)? connect, + TResult Function(InitError_RequestState value)? requestState, + required TResult orElse(), + }) { + if (requestState != null) { + return requestState(this); + } + return orElse(); + } +} + +abstract class InitError_RequestState extends InitError { + const factory InitError_RequestState({required final RequestError inner}) = + _$InitError_RequestStateImpl; + const InitError_RequestState._() : super._(); + + @override + RequestError get inner; + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$InitError_RequestStateImplCopyWith<_$InitError_RequestStateImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/rust/bindings/dart/lib/src/generated/api/mock.dart b/rust/bindings/dart/lib/src/generated/api/mock.dart new file mode 100644 index 00000000..69d1a38d --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/api/mock.dart @@ -0,0 +1,22 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.2.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../api.dart'; +import '../frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + +// Rust type: RustOpaqueMoi> +abstract class MockServer implements RustOpaqueInterface { + static Future create({required String pipeName}) => + RustLib.instance.api.crateApiMockMockServerCreate(pipeName: pipeName); + + String get pipeName; + + Future pump(); + + Future setState({required List state}); + + List get state; +} diff --git a/rust/bindings/dart/lib/src/generated/frb_generated.dart b/rust/bindings/dart/lib/src/generated/frb_generated.dart new file mode 100644 index 00000000..83ecbeb3 --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/frb_generated.dart @@ -0,0 +1,2602 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.2.0. + +// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field + +import 'api.dart'; +import 'api/client.dart'; +import 'api/driver_client.dart'; +import 'api/mock.dart'; +import 'dart:async'; +import 'dart:convert'; +import 'frb_generated.dart'; +import 'frb_generated.io.dart' + if (dart.library.js_interop) 'frb_generated.web.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + +/// Main entrypoint of the Rust API +class RustLib extends BaseEntrypoint { + @internal + static final instance = RustLib._(); + + RustLib._(); + + /// Initialize flutter_rust_bridge + static Future init({ + RustLibApi? api, + BaseHandler? handler, + ExternalLibrary? externalLibrary, + }) async { + await instance.initImpl( + api: api, + handler: handler, + externalLibrary: externalLibrary, + ); + } + + /// Dispose flutter_rust_bridge + /// + /// The call to this function is optional, since flutter_rust_bridge (and everything else) + /// is automatically disposed when the app stops. + static void dispose() => instance.disposeImpl(); + + @override + ApiImplConstructor get apiImplConstructor => + RustLibApiImpl.new; + + @override + WireConstructor get wireConstructor => + RustLibWire.fromExternalLibrary; + + @override + Future executeRustInitializers() async {} + + @override + ExternalLibraryLoaderConfig get defaultExternalLibraryLoaderConfig => + kDefaultExternalLibraryLoaderConfig; + + @override + String get codegenVersion => '2.2.0'; + + @override + int get rustContentHash => -527967754; + + static const kDefaultExternalLibraryLoaderConfig = + ExternalLibraryLoaderConfig( + stem: 'dart_vdd', + ioDirectory: 'rust/target/release/', + webPrefix: 'pkg/', + ); +} + +abstract class RustLibApi extends BaseApi { + Future crateApiClientClientConnect({String? pipeName}); + + Future crateApiClientClientNotify( + {required Client that, required List monitors}); + + Future crateApiClientClientPersist({required List monitors}); + + Stream> crateApiClientClientReceiveEvents( + {required Client that}); + + Future crateApiClientClientRemove( + {required Client that, required List ids}); + + Future crateApiClientClientRemoveAll({required Client that}); + + Future> crateApiClientClientRequestState( + {required Client that}); + + void crateApiDriverClientDriverClientAdd( + {required DriverClient that, required Monitor monitor}); + + void crateApiDriverClientDriverClientAddMode( + {required DriverClient that, required int id, required Mode mode}); + + Future crateApiDriverClientDriverClientConnect( + {String? pipeName}); + + Monitor? crateApiDriverClientDriverClientFindMonitor( + {required DriverClient that, required int id}); + + int? crateApiDriverClientDriverClientNewId( + {required DriverClient that, int? preferredId}); + + Future crateApiDriverClientDriverClientNotify( + {required DriverClient that}); + + Future crateApiDriverClientDriverClientPersist( + {required DriverClient that}); + + Stream> crateApiDriverClientDriverClientReceiveEvents( + {required DriverClient that}); + + Future> crateApiDriverClientDriverClientRefreshState( + {required DriverClient that}); + + void crateApiDriverClientDriverClientRemove( + {required DriverClient that, required List ids}); + + void crateApiDriverClientDriverClientRemoveAll({required DriverClient that}); + + void crateApiDriverClientDriverClientRemoveMode( + {required DriverClient that, + required int id, + required (int, int) resolution}); + + void crateApiDriverClientDriverClientReplaceMonitor( + {required DriverClient that, required Monitor monitor}); + + void crateApiDriverClientDriverClientSetEnabled( + {required DriverClient that, + required List ids, + required bool enabled}); + + void crateApiDriverClientDriverClientSetMonitors( + {required DriverClient that, required List monitors}); + + List crateApiDriverClientDriverClientState( + {required DriverClient that}); + + Future crateApiMockMockServerCreate({required String pipeName}); + + String crateApiMockMockServerPipeName({required MockServer that}); + + Future crateApiMockMockServerPump({required MockServer that}); + + Future crateApiMockMockServerSetState( + {required MockServer that, required List state}); + + List crateApiMockMockServerState({required MockServer that}); + + RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_Client; + + RustArcDecrementStrongCountFnType get rust_arc_decrement_strong_count_Client; + + CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_ClientPtr; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_DriverClient; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_DriverClient; + + CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_DriverClientPtr; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_MockServer; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_MockServer; + + CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_MockServerPtr; +} + +class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { + RustLibApiImpl({ + required super.handler, + required super.wire, + required super.generalizedFrbRustBinding, + required super.portManager, + }); + + @override + Future crateApiClientClientConnect({String? pipeName}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_opt_String(pipeName, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 1, port: port_); + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient, + decodeErrorData: sse_decode_connection_error, + ), + constMeta: kCrateApiClientClientConnectConstMeta, + argValues: [pipeName], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiClientClientConnectConstMeta => + const TaskConstMeta( + debugName: "Client_connect", + argNames: ["pipeName"], + ); + + @override + Future crateApiClientClientNotify( + {required Client that, required List monitors}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + that, serializer); + sse_encode_list_monitor(monitors, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 2, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_send_error, + ), + constMeta: kCrateApiClientClientNotifyConstMeta, + argValues: [that, monitors], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiClientClientNotifyConstMeta => const TaskConstMeta( + debugName: "Client_notify", + argNames: ["that", "monitors"], + ); + + @override + Future crateApiClientClientPersist({required List monitors}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_list_monitor(monitors, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 3, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_persist_error, + ), + constMeta: kCrateApiClientClientPersistConstMeta, + argValues: [monitors], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiClientClientPersistConstMeta => + const TaskConstMeta( + debugName: "Client_persist", + argNames: ["monitors"], + ); + + @override + Stream> crateApiClientClientReceiveEvents( + {required Client that}) { + final sink = RustStreamSink>(); + unawaited(handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + that, serializer); + sse_encode_StreamSink_list_monitor_Sse(sink, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 4, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_receive_error, + ), + constMeta: kCrateApiClientClientReceiveEventsConstMeta, + argValues: [that, sink], + apiImpl: this, + ))); + return sink.stream; + } + + TaskConstMeta get kCrateApiClientClientReceiveEventsConstMeta => + const TaskConstMeta( + debugName: "Client_receive_events", + argNames: ["that", "sink"], + ); + + @override + Future crateApiClientClientRemove( + {required Client that, required List ids}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + that, serializer); + sse_encode_list_prim_u_32_loose(ids, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 5, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_send_error, + ), + constMeta: kCrateApiClientClientRemoveConstMeta, + argValues: [that, ids], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiClientClientRemoveConstMeta => const TaskConstMeta( + debugName: "Client_remove", + argNames: ["that", "ids"], + ); + + @override + Future crateApiClientClientRemoveAll({required Client that}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 6, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_send_error, + ), + constMeta: kCrateApiClientClientRemoveAllConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiClientClientRemoveAllConstMeta => + const TaskConstMeta( + debugName: "Client_remove_all", + argNames: ["that"], + ); + + @override + Future> crateApiClientClientRequestState( + {required Client that}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 7, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_monitor, + decodeErrorData: sse_decode_request_error, + ), + constMeta: kCrateApiClientClientRequestStateConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiClientClientRequestStateConstMeta => + const TaskConstMeta( + debugName: "Client_request_state", + argNames: ["that"], + ); + + @override + void crateApiDriverClientDriverClientAdd( + {required DriverClient that, required Monitor monitor}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_box_autoadd_monitor(monitor, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 8)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_duplicate_error, + ), + constMeta: kCrateApiDriverClientDriverClientAddConstMeta, + argValues: [that, monitor], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientAddConstMeta => + const TaskConstMeta( + debugName: "DriverClient_add", + argNames: ["that", "monitor"], + ); + + @override + void crateApiDriverClientDriverClientAddMode( + {required DriverClient that, required int id, required Mode mode}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_u_32(id, serializer); + sse_encode_box_autoadd_mode(mode, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 9)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_add_mode_error, + ), + constMeta: kCrateApiDriverClientDriverClientAddModeConstMeta, + argValues: [that, id, mode], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientAddModeConstMeta => + const TaskConstMeta( + debugName: "DriverClient_add_mode", + argNames: ["that", "id", "mode"], + ); + + @override + Future crateApiDriverClientDriverClientConnect( + {String? pipeName}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_opt_String(pipeName, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 10, port: port_); + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient, + decodeErrorData: sse_decode_init_error, + ), + constMeta: kCrateApiDriverClientDriverClientConnectConstMeta, + argValues: [pipeName], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientConnectConstMeta => + const TaskConstMeta( + debugName: "DriverClient_connect", + argNames: ["pipeName"], + ); + + @override + Monitor? crateApiDriverClientDriverClientFindMonitor( + {required DriverClient that, required int id}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_u_32(id, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 11)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_opt_box_autoadd_monitor, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientFindMonitorConstMeta, + argValues: [that, id], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientFindMonitorConstMeta => + const TaskConstMeta( + debugName: "DriverClient_find_monitor", + argNames: ["that", "id"], + ); + + @override + int? crateApiDriverClientDriverClientNewId( + {required DriverClient that, int? preferredId}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_opt_box_autoadd_u_32(preferredId, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 12)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_opt_box_autoadd_u_32, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientNewIdConstMeta, + argValues: [that, preferredId], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientNewIdConstMeta => + const TaskConstMeta( + debugName: "DriverClient_new_id", + argNames: ["that", "preferredId"], + ); + + @override + Future crateApiDriverClientDriverClientNotify( + {required DriverClient that}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 13, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_send_error, + ), + constMeta: kCrateApiDriverClientDriverClientNotifyConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientNotifyConstMeta => + const TaskConstMeta( + debugName: "DriverClient_notify", + argNames: ["that"], + ); + + @override + Future crateApiDriverClientDriverClientPersist( + {required DriverClient that}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 14, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_persist_error, + ), + constMeta: kCrateApiDriverClientDriverClientPersistConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientPersistConstMeta => + const TaskConstMeta( + debugName: "DriverClient_persist", + argNames: ["that"], + ); + + @override + Stream> crateApiDriverClientDriverClientReceiveEvents( + {required DriverClient that}) { + final sink = RustStreamSink>(); + unawaited(handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_StreamSink_list_monitor_Sse(sink, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 15, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_receive_error, + ), + constMeta: kCrateApiDriverClientDriverClientReceiveEventsConstMeta, + argValues: [that, sink], + apiImpl: this, + ))); + return sink.stream; + } + + TaskConstMeta get kCrateApiDriverClientDriverClientReceiveEventsConstMeta => + const TaskConstMeta( + debugName: "DriverClient_receive_events", + argNames: ["that", "sink"], + ); + + @override + Future> crateApiDriverClientDriverClientRefreshState( + {required DriverClient that}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 16, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_monitor, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientRefreshStateConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientRefreshStateConstMeta => + const TaskConstMeta( + debugName: "DriverClient_refresh_state", + argNames: ["that"], + ); + + @override + void crateApiDriverClientDriverClientRemove( + {required DriverClient that, required List ids}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_list_prim_u_32_loose(ids, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 17)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientRemoveConstMeta, + argValues: [that, ids], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientRemoveConstMeta => + const TaskConstMeta( + debugName: "DriverClient_remove", + argNames: ["that", "ids"], + ); + + @override + void crateApiDriverClientDriverClientRemoveAll({required DriverClient that}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 18)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientRemoveAllConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientRemoveAllConstMeta => + const TaskConstMeta( + debugName: "DriverClient_remove_all", + argNames: ["that"], + ); + + @override + void crateApiDriverClientDriverClientRemoveMode( + {required DriverClient that, + required int id, + required (int, int) resolution}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_u_32(id, serializer); + sse_encode_box_autoadd_record_u_32_u_32(resolution, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 19)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_monitor_not_found_error, + ), + constMeta: kCrateApiDriverClientDriverClientRemoveModeConstMeta, + argValues: [that, id, resolution], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientRemoveModeConstMeta => + const TaskConstMeta( + debugName: "DriverClient_remove_mode", + argNames: ["that", "id", "resolution"], + ); + + @override + void crateApiDriverClientDriverClientReplaceMonitor( + {required DriverClient that, required Monitor monitor}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_box_autoadd_monitor(monitor, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 20)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_monitor_not_found_error, + ), + constMeta: kCrateApiDriverClientDriverClientReplaceMonitorConstMeta, + argValues: [that, monitor], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientReplaceMonitorConstMeta => + const TaskConstMeta( + debugName: "DriverClient_replace_monitor", + argNames: ["that", "monitor"], + ); + + @override + void crateApiDriverClientDriverClientSetEnabled( + {required DriverClient that, + required List ids, + required bool enabled}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_list_prim_u_32_loose(ids, serializer); + sse_encode_bool(enabled, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 21)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientSetEnabledConstMeta, + argValues: [that, ids, enabled], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientSetEnabledConstMeta => + const TaskConstMeta( + debugName: "DriverClient_set_enabled", + argNames: ["that", "ids", "enabled"], + ); + + @override + void crateApiDriverClientDriverClientSetMonitors( + {required DriverClient that, required List monitors}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_list_monitor(monitors, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 22)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_duplicate_error, + ), + constMeta: kCrateApiDriverClientDriverClientSetMonitorsConstMeta, + argValues: [that, monitors], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientSetMonitorsConstMeta => + const TaskConstMeta( + debugName: "DriverClient_set_monitors", + argNames: ["that", "monitors"], + ); + + @override + List crateApiDriverClientDriverClientState( + {required DriverClient that}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 23)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_monitor, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientStateConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientStateConstMeta => + const TaskConstMeta( + debugName: "DriverClient_state", + argNames: ["that"], + ); + + @override + Future crateApiMockMockServerCreate({required String pipeName}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_String(pipeName, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 24, port: port_); + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer, + decodeErrorData: null, + ), + constMeta: kCrateApiMockMockServerCreateConstMeta, + argValues: [pipeName], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMockMockServerCreateConstMeta => + const TaskConstMeta( + debugName: "MockServer_create", + argNames: ["pipeName"], + ); + + @override + String crateApiMockMockServerPipeName({required MockServer that}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + that, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 25)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_String, + decodeErrorData: null, + ), + constMeta: kCrateApiMockMockServerPipeNameConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMockMockServerPipeNameConstMeta => + const TaskConstMeta( + debugName: "MockServer_pipe_name", + argNames: ["that"], + ); + + @override + Future crateApiMockMockServerPump({required MockServer that}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 26, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiMockMockServerPumpConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMockMockServerPumpConstMeta => const TaskConstMeta( + debugName: "MockServer_pump", + argNames: ["that"], + ); + + @override + Future crateApiMockMockServerSetState( + {required MockServer that, required List state}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + that, serializer); + sse_encode_list_monitor(state, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 27, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiMockMockServerSetStateConstMeta, + argValues: [that, state], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMockMockServerSetStateConstMeta => + const TaskConstMeta( + debugName: "MockServer_set_state", + argNames: ["that", "state"], + ); + + @override + List crateApiMockMockServerState({required MockServer that}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + that, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 28)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_monitor, + decodeErrorData: null, + ), + constMeta: kCrateApiMockMockServerStateConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMockMockServerStateConstMeta => + const TaskConstMeta( + debugName: "MockServer_state", + argNames: ["that"], + ); + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_Client => wire + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_Client => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_DriverClient => wire + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_DriverClient => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_MockServer => wire + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_MockServer => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer; + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return AnyhowException(raw as String); + } + + @protected + Client + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return ClientImpl.frbInternalDcoDecode(raw as List); + } + + @protected + DriverClient + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return DriverClientImpl.frbInternalDcoDecode(raw as List); + } + + @protected + MockServer + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return MockServerImpl.frbInternalDcoDecode(raw as List); + } + + @protected + DriverClient + dco_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return DriverClientImpl.frbInternalDcoDecode(raw as List); + } + + @protected + MockServer + dco_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return MockServerImpl.frbInternalDcoDecode(raw as List); + } + + @protected + Client + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return ClientImpl.frbInternalDcoDecode(raw as List); + } + + @protected + DriverClient + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return DriverClientImpl.frbInternalDcoDecode(raw as List); + } + + @protected + MockServer + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return MockServerImpl.frbInternalDcoDecode(raw as List); + } + + @protected + Duration dco_decode_Chrono_Duration(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dcoDecodeDuration(dco_decode_i_64(raw).toInt()); + } + + @protected + Client + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return ClientImpl.frbInternalDcoDecode(raw as List); + } + + @protected + DriverClient + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return DriverClientImpl.frbInternalDcoDecode(raw as List); + } + + @protected + MockServer + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return MockServerImpl.frbInternalDcoDecode(raw as List); + } + + @protected + RustStreamSink> dco_decode_StreamSink_list_monitor_Sse( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + throw UnimplementedError(); + } + + @protected + String dco_decode_String(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as String; + } + + @protected + AddModeError dco_decode_add_mode_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return AddModeError_MonitorNotFound( + id: dco_decode_u_32(raw[1]), + ); + case 1: + return AddModeError_ModeExists( + monitorId: dco_decode_u_32(raw[1]), + width: dco_decode_u_32(raw[2]), + height: dco_decode_u_32(raw[3]), + ); + case 2: + return AddModeError_RefreshRateExists( + monitorId: dco_decode_u_32(raw[1]), + width: dco_decode_u_32(raw[2]), + height: dco_decode_u_32(raw[3]), + refreshRate: dco_decode_u_32(raw[4]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + bool dco_decode_bool(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as bool; + } + + @protected + ConnectionError dco_decode_box_autoadd_connection_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_connection_error(raw); + } + + @protected + Mode dco_decode_box_autoadd_mode(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_mode(raw); + } + + @protected + Monitor dco_decode_box_autoadd_monitor(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_monitor(raw); + } + + @protected + (int, int) dco_decode_box_autoadd_record_u_32_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as (int, int); + } + + @protected + RequestError dco_decode_box_autoadd_request_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_request_error(raw); + } + + @protected + int dco_decode_box_autoadd_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + ConnectionError dco_decode_connection_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return ConnectionError_Failed( + message: dco_decode_String(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + DuplicateError dco_decode_duplicate_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return DuplicateError_Monitor( + id: dco_decode_u_32(raw[1]), + ); + case 1: + return DuplicateError_Mode( + monitorId: dco_decode_u_32(raw[1]), + width: dco_decode_u_32(raw[2]), + height: dco_decode_u_32(raw[3]), + ); + case 2: + return DuplicateError_RefreshRate( + monitorId: dco_decode_u_32(raw[1]), + width: dco_decode_u_32(raw[2]), + height: dco_decode_u_32(raw[3]), + refreshRate: dco_decode_u_32(raw[4]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + PlatformInt64 dco_decode_i_64(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dcoDecodeI64(raw); + } + + @protected + InitError dco_decode_init_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return InitError_Connect( + inner: dco_decode_box_autoadd_connection_error(raw[1]), + ); + case 1: + return InitError_RequestState( + inner: dco_decode_box_autoadd_request_error(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + List dco_decode_list_mode(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return (raw as List).map(dco_decode_mode).toList(); + } + + @protected + List dco_decode_list_monitor(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return (raw as List).map(dco_decode_monitor).toList(); + } + + @protected + List dco_decode_list_prim_u_32_loose(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as List; + } + + @protected + Uint32List dco_decode_list_prim_u_32_strict(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as Uint32List; + } + + @protected + Uint8List dco_decode_list_prim_u_8_strict(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as Uint8List; + } + + @protected + Mode dco_decode_mode(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 3) + throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); + return Mode( + width: dco_decode_u_32(arr[0]), + height: dco_decode_u_32(arr[1]), + refreshRates: dco_decode_list_prim_u_32_strict(arr[2]), + ); + } + + @protected + Monitor dco_decode_monitor(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 4) + throw Exception('unexpected arr length: expect 4 but see ${arr.length}'); + return Monitor( + id: dco_decode_u_32(arr[0]), + name: dco_decode_opt_String(arr[1]), + enabled: dco_decode_bool(arr[2]), + modes: dco_decode_list_mode(arr[3]), + ); + } + + @protected + MonitorNotFoundError dco_decode_monitor_not_found_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 1) + throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return MonitorNotFoundError( + id: dco_decode_u_32(arr[0]), + ); + } + + @protected + String? dco_decode_opt_String(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_String(raw); + } + + @protected + Monitor? dco_decode_opt_box_autoadd_monitor(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_monitor(raw); + } + + @protected + int? dco_decode_opt_box_autoadd_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_u_32(raw); + } + + @protected + PersistError dco_decode_persist_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return PersistError_Open( + message: dco_decode_String(raw[1]), + ); + case 1: + return PersistError_Set( + message: dco_decode_String(raw[1]), + ); + case 2: + return PersistError_Serialize( + message: dco_decode_String(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + ReceiveError dco_decode_receive_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 1) + throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return ReceiveError( + message: dco_decode_String(arr[0]), + ); + } + + @protected + (int, int) dco_decode_record_u_32_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 2) { + throw Exception('Expected 2 elements, got ${arr.length}'); + } + return ( + dco_decode_u_32(arr[0]), + dco_decode_u_32(arr[1]), + ); + } + + @protected + RequestError dco_decode_request_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return RequestError_Send( + message: dco_decode_String(raw[1]), + ); + case 1: + return RequestError_Receive( + message: dco_decode_String(raw[1]), + ); + case 2: + return RequestError_Timeout( + duration: dco_decode_Chrono_Duration(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + SendError dco_decode_send_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return SendError_PipeBroken( + message: dco_decode_String(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + int dco_decode_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + int dco_decode_u_8(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + void dco_decode_unit(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return; + } + + @protected + BigInt dco_decode_usize(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dcoDecodeU64(raw); + } + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_String(deserializer); + return AnyhowException(inner); + } + + @protected + Client + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return ClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + DriverClient + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return DriverClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + MockServer + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return MockServerImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + DriverClient + sse_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return DriverClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + MockServer + sse_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return MockServerImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + Client + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return ClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + DriverClient + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return DriverClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + MockServer + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return MockServerImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + Duration sse_decode_Chrono_Duration(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_64(deserializer); + return Duration(microseconds: inner.toInt()); + } + + @protected + Client + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return ClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + DriverClient + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return DriverClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + MockServer + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return MockServerImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + RustStreamSink> sse_decode_StreamSink_list_monitor_Sse( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + throw UnimplementedError('Unreachable ()'); + } + + @protected + String sse_decode_String(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_list_prim_u_8_strict(deserializer); + return utf8.decoder.convert(inner); + } + + @protected + AddModeError sse_decode_add_mode_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_id = sse_decode_u_32(deserializer); + return AddModeError_MonitorNotFound(id: var_id); + case 1: + var var_monitorId = sse_decode_u_32(deserializer); + var var_width = sse_decode_u_32(deserializer); + var var_height = sse_decode_u_32(deserializer); + return AddModeError_ModeExists( + monitorId: var_monitorId, width: var_width, height: var_height); + case 2: + var var_monitorId = sse_decode_u_32(deserializer); + var var_width = sse_decode_u_32(deserializer); + var var_height = sse_decode_u_32(deserializer); + var var_refreshRate = sse_decode_u_32(deserializer); + return AddModeError_RefreshRateExists( + monitorId: var_monitorId, + width: var_width, + height: var_height, + refreshRate: var_refreshRate); + default: + throw UnimplementedError(''); + } + } + + @protected + bool sse_decode_bool(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint8() != 0; + } + + @protected + ConnectionError sse_decode_box_autoadd_connection_error( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_connection_error(deserializer)); + } + + @protected + Mode sse_decode_box_autoadd_mode(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_mode(deserializer)); + } + + @protected + Monitor sse_decode_box_autoadd_monitor(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_monitor(deserializer)); + } + + @protected + (int, int) sse_decode_box_autoadd_record_u_32_u_32( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_record_u_32_u_32(deserializer)); + } + + @protected + RequestError sse_decode_box_autoadd_request_error( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_request_error(deserializer)); + } + + @protected + int sse_decode_box_autoadd_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_u_32(deserializer)); + } + + @protected + ConnectionError sse_decode_connection_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_message = sse_decode_String(deserializer); + return ConnectionError_Failed(message: var_message); + default: + throw UnimplementedError(''); + } + } + + @protected + DuplicateError sse_decode_duplicate_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_id = sse_decode_u_32(deserializer); + return DuplicateError_Monitor(id: var_id); + case 1: + var var_monitorId = sse_decode_u_32(deserializer); + var var_width = sse_decode_u_32(deserializer); + var var_height = sse_decode_u_32(deserializer); + return DuplicateError_Mode( + monitorId: var_monitorId, width: var_width, height: var_height); + case 2: + var var_monitorId = sse_decode_u_32(deserializer); + var var_width = sse_decode_u_32(deserializer); + var var_height = sse_decode_u_32(deserializer); + var var_refreshRate = sse_decode_u_32(deserializer); + return DuplicateError_RefreshRate( + monitorId: var_monitorId, + width: var_width, + height: var_height, + refreshRate: var_refreshRate); + default: + throw UnimplementedError(''); + } + } + + @protected + PlatformInt64 sse_decode_i_64(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getPlatformInt64(); + } + + @protected + InitError sse_decode_init_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_inner = sse_decode_box_autoadd_connection_error(deserializer); + return InitError_Connect(inner: var_inner); + case 1: + var var_inner = sse_decode_box_autoadd_request_error(deserializer); + return InitError_RequestState(inner: var_inner); + default: + throw UnimplementedError(''); + } + } + + @protected + List sse_decode_list_mode(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var len_ = sse_decode_i_32(deserializer); + var ans_ = []; + for (var idx_ = 0; idx_ < len_; ++idx_) { + ans_.add(sse_decode_mode(deserializer)); + } + return ans_; + } + + @protected + List sse_decode_list_monitor(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var len_ = sse_decode_i_32(deserializer); + var ans_ = []; + for (var idx_ = 0; idx_ < len_; ++idx_) { + ans_.add(sse_decode_monitor(deserializer)); + } + return ans_; + } + + @protected + List sse_decode_list_prim_u_32_loose(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var len_ = sse_decode_i_32(deserializer); + return deserializer.buffer.getUint32List(len_); + } + + @protected + Uint32List sse_decode_list_prim_u_32_strict(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var len_ = sse_decode_i_32(deserializer); + return deserializer.buffer.getUint32List(len_); + } + + @protected + Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var len_ = sse_decode_i_32(deserializer); + return deserializer.buffer.getUint8List(len_); + } + + @protected + Mode sse_decode_mode(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_width = sse_decode_u_32(deserializer); + var var_height = sse_decode_u_32(deserializer); + var var_refreshRates = sse_decode_list_prim_u_32_strict(deserializer); + return Mode( + width: var_width, height: var_height, refreshRates: var_refreshRates); + } + + @protected + Monitor sse_decode_monitor(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_id = sse_decode_u_32(deserializer); + var var_name = sse_decode_opt_String(deserializer); + var var_enabled = sse_decode_bool(deserializer); + var var_modes = sse_decode_list_mode(deserializer); + return Monitor( + id: var_id, name: var_name, enabled: var_enabled, modes: var_modes); + } + + @protected + MonitorNotFoundError sse_decode_monitor_not_found_error( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_id = sse_decode_u_32(deserializer); + return MonitorNotFoundError(id: var_id); + } + + @protected + String? sse_decode_opt_String(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_String(deserializer)); + } else { + return null; + } + } + + @protected + Monitor? sse_decode_opt_box_autoadd_monitor(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_monitor(deserializer)); + } else { + return null; + } + } + + @protected + int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_u_32(deserializer)); + } else { + return null; + } + } + + @protected + PersistError sse_decode_persist_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_message = sse_decode_String(deserializer); + return PersistError_Open(message: var_message); + case 1: + var var_message = sse_decode_String(deserializer); + return PersistError_Set(message: var_message); + case 2: + var var_message = sse_decode_String(deserializer); + return PersistError_Serialize(message: var_message); + default: + throw UnimplementedError(''); + } + } + + @protected + ReceiveError sse_decode_receive_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_message = sse_decode_String(deserializer); + return ReceiveError(message: var_message); + } + + @protected + (int, int) sse_decode_record_u_32_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_field0 = sse_decode_u_32(deserializer); + var var_field1 = sse_decode_u_32(deserializer); + return (var_field0, var_field1); + } + + @protected + RequestError sse_decode_request_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_message = sse_decode_String(deserializer); + return RequestError_Send(message: var_message); + case 1: + var var_message = sse_decode_String(deserializer); + return RequestError_Receive(message: var_message); + case 2: + var var_duration = sse_decode_Chrono_Duration(deserializer); + return RequestError_Timeout(duration: var_duration); + default: + throw UnimplementedError(''); + } + } + + @protected + SendError sse_decode_send_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_message = sse_decode_String(deserializer); + return SendError_PipeBroken(message: var_message); + default: + throw UnimplementedError(''); + } + } + + @protected + int sse_decode_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint32(); + } + + @protected + int sse_decode_u_8(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint8(); + } + + @protected + void sse_decode_unit(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + } + + @protected + BigInt sse_decode_usize(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getBigUint64(); + } + + @protected + int sse_decode_i_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getInt32(); + } + + @protected + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String(self.message, serializer); + } + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + Client self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as ClientImpl).frbInternalSseEncode(move: true), serializer); + } + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as DriverClientImpl).frbInternalSseEncode(move: true), + serializer); + } + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + MockServer self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as MockServerImpl).frbInternalSseEncode(move: true), serializer); + } + + @protected + void + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as DriverClientImpl).frbInternalSseEncode(move: false), + serializer); + } + + @protected + void + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + MockServer self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as MockServerImpl).frbInternalSseEncode(move: false), serializer); + } + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + Client self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as ClientImpl).frbInternalSseEncode(move: false), serializer); + } + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as DriverClientImpl).frbInternalSseEncode(move: false), + serializer); + } + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + MockServer self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as MockServerImpl).frbInternalSseEncode(move: false), serializer); + } + + @protected + void sse_encode_Chrono_Duration(Duration self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_64(PlatformInt64Util.from(self.inMicroseconds), serializer); + } + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + Client self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as ClientImpl).frbInternalSseEncode(move: null), serializer); + } + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as DriverClientImpl).frbInternalSseEncode(move: null), + serializer); + } + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + MockServer self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as MockServerImpl).frbInternalSseEncode(move: null), serializer); + } + + @protected + void sse_encode_StreamSink_list_monitor_Sse( + RustStreamSink> self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String( + self.setupAndSerialize( + codec: SseCodec( + decodeSuccessData: sse_decode_list_monitor, + decodeErrorData: sse_decode_AnyhowException, + )), + serializer); + } + + @protected + void sse_encode_String(String self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer); + } + + @protected + void sse_encode_add_mode_error(AddModeError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case AddModeError_MonitorNotFound(id: final id): + sse_encode_i_32(0, serializer); + sse_encode_u_32(id, serializer); + case AddModeError_ModeExists( + monitorId: final monitorId, + width: final width, + height: final height + ): + sse_encode_i_32(1, serializer); + sse_encode_u_32(monitorId, serializer); + sse_encode_u_32(width, serializer); + sse_encode_u_32(height, serializer); + case AddModeError_RefreshRateExists( + monitorId: final monitorId, + width: final width, + height: final height, + refreshRate: final refreshRate + ): + sse_encode_i_32(2, serializer); + sse_encode_u_32(monitorId, serializer); + sse_encode_u_32(width, serializer); + sse_encode_u_32(height, serializer); + sse_encode_u_32(refreshRate, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_bool(bool self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint8(self ? 1 : 0); + } + + @protected + void sse_encode_box_autoadd_connection_error( + ConnectionError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_connection_error(self, serializer); + } + + @protected + void sse_encode_box_autoadd_mode(Mode self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_mode(self, serializer); + } + + @protected + void sse_encode_box_autoadd_monitor(Monitor self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_monitor(self, serializer); + } + + @protected + void sse_encode_box_autoadd_record_u_32_u_32( + (int, int) self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_record_u_32_u_32(self, serializer); + } + + @protected + void sse_encode_box_autoadd_request_error( + RequestError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_request_error(self, serializer); + } + + @protected + void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self, serializer); + } + + @protected + void sse_encode_connection_error( + ConnectionError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case ConnectionError_Failed(message: final message): + sse_encode_i_32(0, serializer); + sse_encode_String(message, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_duplicate_error( + DuplicateError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case DuplicateError_Monitor(id: final id): + sse_encode_i_32(0, serializer); + sse_encode_u_32(id, serializer); + case DuplicateError_Mode( + monitorId: final monitorId, + width: final width, + height: final height + ): + sse_encode_i_32(1, serializer); + sse_encode_u_32(monitorId, serializer); + sse_encode_u_32(width, serializer); + sse_encode_u_32(height, serializer); + case DuplicateError_RefreshRate( + monitorId: final monitorId, + width: final width, + height: final height, + refreshRate: final refreshRate + ): + sse_encode_i_32(2, serializer); + sse_encode_u_32(monitorId, serializer); + sse_encode_u_32(width, serializer); + sse_encode_u_32(height, serializer); + sse_encode_u_32(refreshRate, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_i_64(PlatformInt64 self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putPlatformInt64(self); + } + + @protected + void sse_encode_init_error(InitError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case InitError_Connect(inner: final inner): + sse_encode_i_32(0, serializer); + sse_encode_box_autoadd_connection_error(inner, serializer); + case InitError_RequestState(inner: final inner): + sse_encode_i_32(1, serializer); + sse_encode_box_autoadd_request_error(inner, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_list_mode(List self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + for (final item in self) { + sse_encode_mode(item, serializer); + } + } + + @protected + void sse_encode_list_monitor(List self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + for (final item in self) { + sse_encode_monitor(item, serializer); + } + } + + @protected + void sse_encode_list_prim_u_32_loose( + List self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + serializer.buffer + .putUint32List(self is Uint32List ? self : Uint32List.fromList(self)); + } + + @protected + void sse_encode_list_prim_u_32_strict( + Uint32List self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + serializer.buffer.putUint32List(self); + } + + @protected + void sse_encode_list_prim_u_8_strict( + Uint8List self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + serializer.buffer.putUint8List(self); + } + + @protected + void sse_encode_mode(Mode self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self.width, serializer); + sse_encode_u_32(self.height, serializer); + sse_encode_list_prim_u_32_strict(self.refreshRates, serializer); + } + + @protected + void sse_encode_monitor(Monitor self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self.id, serializer); + sse_encode_opt_String(self.name, serializer); + sse_encode_bool(self.enabled, serializer); + sse_encode_list_mode(self.modes, serializer); + } + + @protected + void sse_encode_monitor_not_found_error( + MonitorNotFoundError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self.id, serializer); + } + + @protected + void sse_encode_opt_String(String? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_String(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_monitor( + Monitor? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_box_autoadd_monitor(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_u_32(int? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_box_autoadd_u_32(self, serializer); + } + } + + @protected + void sse_encode_persist_error(PersistError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case PersistError_Open(message: final message): + sse_encode_i_32(0, serializer); + sse_encode_String(message, serializer); + case PersistError_Set(message: final message): + sse_encode_i_32(1, serializer); + sse_encode_String(message, serializer); + case PersistError_Serialize(message: final message): + sse_encode_i_32(2, serializer); + sse_encode_String(message, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_receive_error(ReceiveError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String(self.message, serializer); + } + + @protected + void sse_encode_record_u_32_u_32((int, int) self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self.$1, serializer); + sse_encode_u_32(self.$2, serializer); + } + + @protected + void sse_encode_request_error(RequestError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case RequestError_Send(message: final message): + sse_encode_i_32(0, serializer); + sse_encode_String(message, serializer); + case RequestError_Receive(message: final message): + sse_encode_i_32(1, serializer); + sse_encode_String(message, serializer); + case RequestError_Timeout(duration: final duration): + sse_encode_i_32(2, serializer); + sse_encode_Chrono_Duration(duration, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_send_error(SendError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case SendError_PipeBroken(message: final message): + sse_encode_i_32(0, serializer); + sse_encode_String(message, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_u_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint32(self); + } + + @protected + void sse_encode_u_8(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint8(self); + } + + @protected + void sse_encode_unit(void self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + } + + @protected + void sse_encode_usize(BigInt self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putBigUint64(self); + } + + @protected + void sse_encode_i_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putInt32(self); + } +} + +@sealed +class ClientImpl extends RustOpaque implements Client { + // Not to be used by end users + ClientImpl.frbInternalDcoDecode(List wire) + : super.frbInternalDcoDecode(wire, _kStaticData); + + // Not to be used by end users + ClientImpl.frbInternalSseDecode(BigInt ptr, int externalSizeOnNative) + : super.frbInternalSseDecode(ptr, externalSizeOnNative, _kStaticData); + + static final _kStaticData = RustArcStaticData( + rustArcIncrementStrongCount: + RustLib.instance.api.rust_arc_increment_strong_count_Client, + rustArcDecrementStrongCount: + RustLib.instance.api.rust_arc_decrement_strong_count_Client, + rustArcDecrementStrongCountPtr: + RustLib.instance.api.rust_arc_decrement_strong_count_ClientPtr, + ); + + /// Send new state to the driver. + Future notify({required List monitors}) => RustLib.instance.api + .crateApiClientClientNotify(that: this, monitors: monitors); + + /// Receive continuous events from the driver. + /// + /// Only new events after calling this method are received. + /// + /// May be called multiple times. + Stream> receiveEvents() => + RustLib.instance.api.crateApiClientClientReceiveEvents( + that: this, + ); + + /// Remove all monitors with the specified IDs. + Future remove({required List ids}) => + RustLib.instance.api.crateApiClientClientRemove(that: this, ids: ids); + + /// Remove all monitors. + Future removeAll() => + RustLib.instance.api.crateApiClientClientRemoveAll( + that: this, + ); + + /// Request the current state of the driver. + /// + /// Throws [RequestError.timeout] if the driver does not respond within 5 + /// seconds. + Future> requestState() => + RustLib.instance.api.crateApiClientClientRequestState( + that: this, + ); +} + +@sealed +class DriverClientImpl extends RustOpaque implements DriverClient { + // Not to be used by end users + DriverClientImpl.frbInternalDcoDecode(List wire) + : super.frbInternalDcoDecode(wire, _kStaticData); + + // Not to be used by end users + DriverClientImpl.frbInternalSseDecode(BigInt ptr, int externalSizeOnNative) + : super.frbInternalSseDecode(ptr, externalSizeOnNative, _kStaticData); + + static final _kStaticData = RustArcStaticData( + rustArcIncrementStrongCount: + RustLib.instance.api.rust_arc_increment_strong_count_DriverClient, + rustArcDecrementStrongCount: + RustLib.instance.api.rust_arc_decrement_strong_count_DriverClient, + rustArcDecrementStrongCountPtr: + RustLib.instance.api.rust_arc_decrement_strong_count_DriverClientPtr, + ); + + /// Add a new monitor. + /// + /// Returns an error if a monitor with this ID already exists, or if the + /// monitor is invalid. A monitor is invalid if it has duplicate modes, or + /// if any of its modes has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void add({required Monitor monitor}) => RustLib.instance.api + .crateApiDriverClientDriverClientAdd(that: this, monitor: monitor); + + /// Add a mode to the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist, or if the mode already + /// exists on that monitor, or if the mode is invalid. A mode is invalid if + /// it has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void addMode({required int id, required Mode mode}) => RustLib.instance.api + .crateApiDriverClientDriverClientAddMode(that: this, id: id, mode: mode); + + /// Find the monitor with the given ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + Monitor? findMonitor({required int id}) => RustLib.instance.api + .crateApiDriverClientDriverClientFindMonitor(that: this, id: id); + + /// Get the closest available free ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + /// + /// Note: Duplicate monitors are ignored when send to the Driver using + /// [DriverClient.notify]. + int? newId({int? preferredId}) => + RustLib.instance.api.crateApiDriverClientDriverClientNewId( + that: this, preferredId: preferredId); + + /// Send the current client state to the driver. + /// + /// State changes of the client are not automatically sent to the driver. + /// You must manually call this method to send changes to the driver. + Future notify() => + RustLib.instance.api.crateApiDriverClientDriverClientNotify( + that: this, + ); + + /// Write client state to the registry for current user. + /// + /// Next time the driver is started, it will load this state from the + /// registry. This might be after a reboot or a driver restart. + Future persist() => + RustLib.instance.api.crateApiDriverClientDriverClientPersist( + that: this, + ); + + /// Returns a stream of continuous events from the driver. + /// + /// This stream will always reflect the real state of the driver, regardless + /// of who changed its state. This means, if it is changed by another + /// process, this stream will still be updated. + Stream> receiveEvents() => + RustLib.instance.api.crateApiDriverClientDriverClientReceiveEvents( + that: this, + ); + + /// Manually synchronize with the driver. + Future> refreshState() => + RustLib.instance.api.crateApiDriverClientDriverClientRefreshState( + that: this, + ); + + /// Remove monitors by id. + /// + /// Silently skips IDs that do not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void remove({required List ids}) => RustLib.instance.api + .crateApiDriverClientDriverClientRemove(that: this, ids: ids); + + /// Remove all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + void removeAll() => + RustLib.instance.api.crateApiDriverClientDriverClientRemoveAll( + that: this, + ); + + /// Remove a mode from the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist. If the mode does not + /// exist, it is silently skipped. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void removeMode({required int id, required (int, int) resolution}) => + RustLib.instance.api.crateApiDriverClientDriverClientRemoveMode( + that: this, id: id, resolution: resolution); + + /// Replace an existing monitor. The monitor is identified by its ID. + /// + /// Throws [MonitorNotFoundError] if the monitor does not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void replaceMonitor({required Monitor monitor}) => + RustLib.instance.api.crateApiDriverClientDriverClientReplaceMonitor( + that: this, monitor: monitor); + + /// Set enabled state of all monitors with the given IDs. + /// + /// Silently skips incorrect IDs. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void setEnabled({required List ids, required bool enabled}) => + RustLib.instance.api.crateApiDriverClientDriverClientSetEnabled( + that: this, ids: ids, enabled: enabled); + + /// Replace all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + void setMonitors({required List monitors}) => + RustLib.instance.api.crateApiDriverClientDriverClientSetMonitors( + that: this, monitors: monitors); + + /// Get the current monitor state stored inside this client. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + List get state => + RustLib.instance.api.crateApiDriverClientDriverClientState( + that: this, + ); +} + +@sealed +class MockServerImpl extends RustOpaque implements MockServer { + // Not to be used by end users + MockServerImpl.frbInternalDcoDecode(List wire) + : super.frbInternalDcoDecode(wire, _kStaticData); + + // Not to be used by end users + MockServerImpl.frbInternalSseDecode(BigInt ptr, int externalSizeOnNative) + : super.frbInternalSseDecode(ptr, externalSizeOnNative, _kStaticData); + + static final _kStaticData = RustArcStaticData( + rustArcIncrementStrongCount: + RustLib.instance.api.rust_arc_increment_strong_count_MockServer, + rustArcDecrementStrongCount: + RustLib.instance.api.rust_arc_decrement_strong_count_MockServer, + rustArcDecrementStrongCountPtr: + RustLib.instance.api.rust_arc_decrement_strong_count_MockServerPtr, + ); + + String get pipeName => RustLib.instance.api.crateApiMockMockServerPipeName( + that: this, + ); + + Future pump() => RustLib.instance.api.crateApiMockMockServerPump( + that: this, + ); + + Future setState({required List state}) => RustLib.instance.api + .crateApiMockMockServerSetState(that: this, state: state); + + List get state => RustLib.instance.api.crateApiMockMockServerState( + that: this, + ); +} diff --git a/rust/bindings/dart/lib/src/generated/frb_generated.io.dart b/rust/bindings/dart/lib/src/generated/frb_generated.io.dart new file mode 100644 index 00000000..caf29566 --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/frb_generated.io.dart @@ -0,0 +1,657 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.2.0. + +// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field + +import 'api.dart'; +import 'api/client.dart'; +import 'api/driver_client.dart'; +import 'api/mock.dart'; +import 'dart:async'; +import 'dart:convert'; +import 'dart:ffi' as ffi; +import 'frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_io.dart'; + +abstract class RustLibApiImplPlatform extends BaseApiImpl { + RustLibApiImplPlatform({ + required super.handler, + required super.wire, + required super.generalizedFrbRustBinding, + required super.portManager, + }); + + CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_ClientPtr => wire + ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClientPtr; + + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_DriverClientPtr => wire + ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClientPtr; + + CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_MockServerPtr => + wire._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServerPtr; + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw); + + @protected + Client + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + dynamic raw); + + @protected + DriverClient + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw); + + @protected + MockServer + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + dynamic raw); + + @protected + DriverClient + dco_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw); + + @protected + MockServer + dco_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + dynamic raw); + + @protected + Client + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + dynamic raw); + + @protected + DriverClient + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw); + + @protected + MockServer + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + dynamic raw); + + @protected + Duration dco_decode_Chrono_Duration(dynamic raw); + + @protected + Client + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + dynamic raw); + + @protected + DriverClient + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw); + + @protected + MockServer + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + dynamic raw); + + @protected + RustStreamSink> dco_decode_StreamSink_list_monitor_Sse( + dynamic raw); + + @protected + String dco_decode_String(dynamic raw); + + @protected + AddModeError dco_decode_add_mode_error(dynamic raw); + + @protected + bool dco_decode_bool(dynamic raw); + + @protected + ConnectionError dco_decode_box_autoadd_connection_error(dynamic raw); + + @protected + Mode dco_decode_box_autoadd_mode(dynamic raw); + + @protected + Monitor dco_decode_box_autoadd_monitor(dynamic raw); + + @protected + (int, int) dco_decode_box_autoadd_record_u_32_u_32(dynamic raw); + + @protected + RequestError dco_decode_box_autoadd_request_error(dynamic raw); + + @protected + int dco_decode_box_autoadd_u_32(dynamic raw); + + @protected + ConnectionError dco_decode_connection_error(dynamic raw); + + @protected + DuplicateError dco_decode_duplicate_error(dynamic raw); + + @protected + PlatformInt64 dco_decode_i_64(dynamic raw); + + @protected + InitError dco_decode_init_error(dynamic raw); + + @protected + List dco_decode_list_mode(dynamic raw); + + @protected + List dco_decode_list_monitor(dynamic raw); + + @protected + List dco_decode_list_prim_u_32_loose(dynamic raw); + + @protected + Uint32List dco_decode_list_prim_u_32_strict(dynamic raw); + + @protected + Uint8List dco_decode_list_prim_u_8_strict(dynamic raw); + + @protected + Mode dco_decode_mode(dynamic raw); + + @protected + Monitor dco_decode_monitor(dynamic raw); + + @protected + MonitorNotFoundError dco_decode_monitor_not_found_error(dynamic raw); + + @protected + String? dco_decode_opt_String(dynamic raw); + + @protected + Monitor? dco_decode_opt_box_autoadd_monitor(dynamic raw); + + @protected + int? dco_decode_opt_box_autoadd_u_32(dynamic raw); + + @protected + PersistError dco_decode_persist_error(dynamic raw); + + @protected + ReceiveError dco_decode_receive_error(dynamic raw); + + @protected + (int, int) dco_decode_record_u_32_u_32(dynamic raw); + + @protected + RequestError dco_decode_request_error(dynamic raw); + + @protected + SendError dco_decode_send_error(dynamic raw); + + @protected + int dco_decode_u_32(dynamic raw); + + @protected + int dco_decode_u_8(dynamic raw); + + @protected + void dco_decode_unit(dynamic raw); + + @protected + BigInt dco_decode_usize(dynamic raw); + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer); + + @protected + Client + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + SseDeserializer deserializer); + + @protected + DriverClient + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer); + + @protected + MockServer + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + SseDeserializer deserializer); + + @protected + DriverClient + sse_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer); + + @protected + MockServer + sse_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + SseDeserializer deserializer); + + @protected + Client + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + SseDeserializer deserializer); + + @protected + DriverClient + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer); + + @protected + MockServer + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + SseDeserializer deserializer); + + @protected + Duration sse_decode_Chrono_Duration(SseDeserializer deserializer); + + @protected + Client + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + SseDeserializer deserializer); + + @protected + DriverClient + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer); + + @protected + MockServer + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + SseDeserializer deserializer); + + @protected + RustStreamSink> sse_decode_StreamSink_list_monitor_Sse( + SseDeserializer deserializer); + + @protected + String sse_decode_String(SseDeserializer deserializer); + + @protected + AddModeError sse_decode_add_mode_error(SseDeserializer deserializer); + + @protected + bool sse_decode_bool(SseDeserializer deserializer); + + @protected + ConnectionError sse_decode_box_autoadd_connection_error( + SseDeserializer deserializer); + + @protected + Mode sse_decode_box_autoadd_mode(SseDeserializer deserializer); + + @protected + Monitor sse_decode_box_autoadd_monitor(SseDeserializer deserializer); + + @protected + (int, int) sse_decode_box_autoadd_record_u_32_u_32( + SseDeserializer deserializer); + + @protected + RequestError sse_decode_box_autoadd_request_error( + SseDeserializer deserializer); + + @protected + int sse_decode_box_autoadd_u_32(SseDeserializer deserializer); + + @protected + ConnectionError sse_decode_connection_error(SseDeserializer deserializer); + + @protected + DuplicateError sse_decode_duplicate_error(SseDeserializer deserializer); + + @protected + PlatformInt64 sse_decode_i_64(SseDeserializer deserializer); + + @protected + InitError sse_decode_init_error(SseDeserializer deserializer); + + @protected + List sse_decode_list_mode(SseDeserializer deserializer); + + @protected + List sse_decode_list_monitor(SseDeserializer deserializer); + + @protected + List sse_decode_list_prim_u_32_loose(SseDeserializer deserializer); + + @protected + Uint32List sse_decode_list_prim_u_32_strict(SseDeserializer deserializer); + + @protected + Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer); + + @protected + Mode sse_decode_mode(SseDeserializer deserializer); + + @protected + Monitor sse_decode_monitor(SseDeserializer deserializer); + + @protected + MonitorNotFoundError sse_decode_monitor_not_found_error( + SseDeserializer deserializer); + + @protected + String? sse_decode_opt_String(SseDeserializer deserializer); + + @protected + Monitor? sse_decode_opt_box_autoadd_monitor(SseDeserializer deserializer); + + @protected + int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer); + + @protected + PersistError sse_decode_persist_error(SseDeserializer deserializer); + + @protected + ReceiveError sse_decode_receive_error(SseDeserializer deserializer); + + @protected + (int, int) sse_decode_record_u_32_u_32(SseDeserializer deserializer); + + @protected + RequestError sse_decode_request_error(SseDeserializer deserializer); + + @protected + SendError sse_decode_send_error(SseDeserializer deserializer); + + @protected + int sse_decode_u_32(SseDeserializer deserializer); + + @protected + int sse_decode_u_8(SseDeserializer deserializer); + + @protected + void sse_decode_unit(SseDeserializer deserializer); + + @protected + BigInt sse_decode_usize(SseDeserializer deserializer); + + @protected + int sse_decode_i_32(SseDeserializer deserializer); + + @protected + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + Client self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + MockServer self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + MockServer self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + Client self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + MockServer self, SseSerializer serializer); + + @protected + void sse_encode_Chrono_Duration(Duration self, SseSerializer serializer); + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + Client self, SseSerializer serializer); + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer); + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + MockServer self, SseSerializer serializer); + + @protected + void sse_encode_StreamSink_list_monitor_Sse( + RustStreamSink> self, SseSerializer serializer); + + @protected + void sse_encode_String(String self, SseSerializer serializer); + + @protected + void sse_encode_add_mode_error(AddModeError self, SseSerializer serializer); + + @protected + void sse_encode_bool(bool self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_connection_error( + ConnectionError self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_mode(Mode self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_monitor(Monitor self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_record_u_32_u_32( + (int, int) self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_request_error( + RequestError self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer); + + @protected + void sse_encode_connection_error( + ConnectionError self, SseSerializer serializer); + + @protected + void sse_encode_duplicate_error( + DuplicateError self, SseSerializer serializer); + + @protected + void sse_encode_i_64(PlatformInt64 self, SseSerializer serializer); + + @protected + void sse_encode_init_error(InitError self, SseSerializer serializer); + + @protected + void sse_encode_list_mode(List self, SseSerializer serializer); + + @protected + void sse_encode_list_monitor(List self, SseSerializer serializer); + + @protected + void sse_encode_list_prim_u_32_loose( + List self, SseSerializer serializer); + + @protected + void sse_encode_list_prim_u_32_strict( + Uint32List self, SseSerializer serializer); + + @protected + void sse_encode_list_prim_u_8_strict( + Uint8List self, SseSerializer serializer); + + @protected + void sse_encode_mode(Mode self, SseSerializer serializer); + + @protected + void sse_encode_monitor(Monitor self, SseSerializer serializer); + + @protected + void sse_encode_monitor_not_found_error( + MonitorNotFoundError self, SseSerializer serializer); + + @protected + void sse_encode_opt_String(String? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_monitor( + Monitor? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_u_32(int? self, SseSerializer serializer); + + @protected + void sse_encode_persist_error(PersistError self, SseSerializer serializer); + + @protected + void sse_encode_receive_error(ReceiveError self, SseSerializer serializer); + + @protected + void sse_encode_record_u_32_u_32((int, int) self, SseSerializer serializer); + + @protected + void sse_encode_request_error(RequestError self, SseSerializer serializer); + + @protected + void sse_encode_send_error(SendError self, SseSerializer serializer); + + @protected + void sse_encode_u_32(int self, SseSerializer serializer); + + @protected + void sse_encode_u_8(int self, SseSerializer serializer); + + @protected + void sse_encode_unit(void self, SseSerializer serializer); + + @protected + void sse_encode_usize(BigInt self, SseSerializer serializer); + + @protected + void sse_encode_i_32(int self, SseSerializer serializer); +} + +// Section: wire_class + +class RustLibWire implements BaseWire { + factory RustLibWire.fromExternalLibrary(ExternalLibrary lib) => + RustLibWire(lib.ffiDynamicLibrary); + + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + RustLibWire(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + ffi.Pointer ptr, + ) { + return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + ptr, + ); + } + + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClientPtr = + _lookup)>>( + 'frbgen_vdd_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient'); + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient = + _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClientPtr + .asFunction)>(); + + void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + ffi.Pointer ptr, + ) { + return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + ptr, + ); + } + + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClientPtr = + _lookup)>>( + 'frbgen_vdd_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient'); + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient = + _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClientPtr + .asFunction)>(); + + void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ffi.Pointer ptr, + ) { + return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ptr, + ); + } + + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClientPtr = + _lookup)>>( + 'frbgen_vdd_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient'); + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient = + _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClientPtr + .asFunction)>(); + + void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ffi.Pointer ptr, + ) { + return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ptr, + ); + } + + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClientPtr = + _lookup)>>( + 'frbgen_vdd_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient'); + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient = + _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClientPtr + .asFunction)>(); + + void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + ffi.Pointer ptr, + ) { + return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + ptr, + ); + } + + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServerPtr = + _lookup)>>( + 'frbgen_vdd_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer'); + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer = + _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServerPtr + .asFunction)>(); + + void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + ffi.Pointer ptr, + ) { + return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + ptr, + ); + } + + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServerPtr = + _lookup)>>( + 'frbgen_vdd_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer'); + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer = + _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServerPtr + .asFunction)>(); +} diff --git a/rust/bindings/dart/lib/src/init.dart b/rust/bindings/dart/lib/src/init.dart new file mode 100644 index 00000000..c93aad9e --- /dev/null +++ b/rust/bindings/dart/lib/src/init.dart @@ -0,0 +1,19 @@ +import 'dart:ffi'; + +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:vdd/src/generated/frb_generated.dart'; + +Future init() async { + // There is currently no way to locate a native asset in dart. + + // HACK: Force dart to load the dll into the process + frb_get_rust_content_hash(); + + await RustLib.init( + externalLibrary: ExternalLibrary.process(iKnowHowToUseIt: true)); +} + +// HACK: Only used to force dart to load the dll into the process +@Native(assetId: "package:vdd/vdd_lib") +// ignore: non_constant_identifier_names +external int frb_get_rust_content_hash(); diff --git a/rust/bindings/dart/lib/test.dart b/rust/bindings/dart/lib/test.dart new file mode 100644 index 00000000..43f4322f --- /dev/null +++ b/rust/bindings/dart/lib/test.dart @@ -0,0 +1 @@ +export 'src/generated/api/mock.dart' show MockServer; diff --git a/rust/bindings/dart/lib/vdd.dart b/rust/bindings/dart/lib/vdd.dart new file mode 100644 index 00000000..a4b1d17d --- /dev/null +++ b/rust/bindings/dart/lib/vdd.dart @@ -0,0 +1,7 @@ +library; + +export 'src/init.dart' show init; + +export 'src/generated/api.dart' show Mode, Monitor; +export 'src/generated/api/client.dart' show Client; +export 'src/generated/api/driver_client.dart' show DriverClient; diff --git a/rust/bindings/dart/pubspec.yaml b/rust/bindings/dart/pubspec.yaml new file mode 100644 index 00000000..9beb0e54 --- /dev/null +++ b/rust/bindings/dart/pubspec.yaml @@ -0,0 +1,18 @@ +name: vdd +description: Control virtual-display-rs using Dart +version: 0.1.0 +repository: https://github.com/MolotovCherry/virtual-display-rs/tree/master/rust/bindings/dart + +environment: + sdk: ^3.4.3 + +dependencies: + flutter_rust_bridge: ^2.2.0 + freezed_annotation: ^2.4.4 + native_assets_cli: ^0.7.2 + +dev_dependencies: + build_runner: ^2.4.11 + freezed: ^2.5.7 + lints: ^3.0.0 + test: ^1.24.0 diff --git a/rust/bindings/dart/rust/Cargo.toml b/rust/bindings/dart/rust/Cargo.toml new file mode 100644 index 00000000..6d1339ed --- /dev/null +++ b/rust/bindings/dart/rust/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "dart_vdd" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[lints] +workspace = true + +[dependencies] +flutter_rust_bridge = { version = "=2.2.0", features = ["chrono"] } +driver-ipc = { path = "../../../driver-ipc" } +tokio-stream = "0.1.15" +chrono = "0.4.38" +tokio = "1.39.2" + +[build-dependencies] +flutter_rust_bridge_codegen = "2.2.0" diff --git a/rust/bindings/dart/rust/src/api/client.rs b/rust/bindings/dart/rust/src/api/client.rs new file mode 100644 index 00000000..838f8877 --- /dev/null +++ b/rust/bindings/dart/rust/src/api/client.rs @@ -0,0 +1,210 @@ +use flutter_rust_bridge::frb; +use tokio_stream::StreamExt; + +use crate::frb_generated::StreamSink; + +mod ipc { + pub use driver_ipc::client::*; + pub use driver_ipc::*; +} + +/// Client for interacting with the Virtual Display Driver. +/// +/// Connects via a named pipe to the driver. +/// +/// You can send changes to the driver and receive continuous events from it. +#[frb(opaque)] +pub struct Client(ipc::Client); + +impl Client { + /// Connect to the driver. + /// + /// You can optionally specify the name of the named pipe to connect to. The + /// default value is "virtualdisplaydriver". + pub async fn connect(pipe_name: Option) -> Result { + match pipe_name { + Some(pipe_name) => Ok(Self(ipc::Client::connect_to(&pipe_name).await?)), + None => Ok(Self(ipc::Client::connect().await?)), + } + } + + /// Send new state to the driver. + pub async fn notify(&self, monitors: &[ipc::Monitor]) -> Result<(), SendError> { + self.0.notify(monitors).await?; + Ok(()) + } + + /// Remove all monitors with the specified IDs. + pub async fn remove(&self, ids: &[u32]) -> Result<(), SendError> { + self.0.remove(ids).await?; + Ok(()) + } + + /// Remove all monitors. + pub async fn remove_all(&self) -> Result<(), SendError> { + self.0.remove_all().await?; + Ok(()) + } + + /// Request the current state of the driver. + /// + /// Throws [RequestError.timeout] if the driver does not respond within 5 + /// seconds. + pub async fn request_state(&self) -> Result, RequestError> { + Ok(self.0.request_state().await?) + } + + /// Receive continuous events from the driver. + /// + /// Only new events after calling this method are received. + /// + /// May be called multiple times. + #[allow(clippy::unused_async)] // Must be async, because we need a tokio reactor. + pub async fn receive_events( + &self, + sink: StreamSink>, + ) -> Result<(), ReceiveError> { + let mut stream = self.0.receive_events(); + tokio::task::spawn(async move { + while let Some(v) = stream.next().await { + let result = match v { + Ok(ipc::EventCommand::Changed(monitors)) => sink.add(monitors), + Err(err) => sink.add_error(ReceiveError::from(err)), + Ok(_) => continue, + }; + + if result.is_err() { + break; + } + } + }); + Ok(()) + } + + /// Write `monitors` to the registry for current user. + /// + /// Next time the driver is started, it will load this state from the + /// registry. This might be after a reboot or a driver restart. + pub fn persist(monitors: &[ipc::Monitor]) -> Result<(), PersistError> { + ipc::Client::persist(monitors)?; + Ok(()) + } +} + +#[frb(dart_code = " + @override + String toString() => switch (this) { + ConnectionError_Failed(:final message) => 'Failed to open pipe: $message', + }; +")] +pub enum ConnectionError { + Failed { message: String }, +} + +impl From for ConnectionError { + fn from(err: ipc::error::ConnectionError) -> Self { + match err { + ipc::error::ConnectionError::Failed(err) => ConnectionError::Failed { + message: err.to_string(), + }, + } + } +} + +#[frb(dart_code = " + @override + String toString() => switch (this) { + SendError_PipeBroken(:final message) => 'Failed to send message (pipe broken): $message', + }; +")] +pub enum SendError { + PipeBroken { message: String }, +} + +impl From for SendError { + fn from(err: ipc::error::SendError) -> Self { + match err { + ipc::error::SendError::PipeBroken(err) => SendError::PipeBroken { + message: err.to_string(), + }, + } + } +} + +#[frb(dart_code = " + @override + String toString() => switch (this) { + RequestError_Send(:final message) => 'Failed to send message (pipe broken): $message', + RequestError_Receive(:final message) => 'Failed to receive message (pipe broken): $message', + RequestError_Timeout(:final duration) => 'Did not get a response in time ($duration)', + }; +")] +pub enum RequestError { + Send { message: String }, + Receive { message: String }, + Timeout { duration: chrono::Duration }, +} + +impl From for RequestError { + fn from(err: ipc::error::RequestError) -> Self { + match err { + ipc::error::RequestError::Send(err) => RequestError::Send { + message: err.to_string(), + }, + ipc::error::RequestError::Receive(err) => RequestError::Receive { + message: err.to_string(), + }, + ipc::error::RequestError::Timeout(duration) => RequestError::Timeout { + duration: chrono::Duration::from_std(duration).unwrap(), + }, + } + } +} + +#[frb(dart_code = " + @override + String toString() => switch (this) { + ReceiveError(:final message) => 'Failed to receive event: $message', + }; +")] +pub struct ReceiveError { + pub message: String, +} + +impl From for ReceiveError { + fn from(err: ipc::error::ReceiveError) -> Self { + ReceiveError { + message: err.to_string(), + } + } +} + +#[frb(dart_code = " + @override + String toString() => switch (this) { + PersistError_Open(:final message) => 'Failed to open registry key: $message', + PersistError_Set(:final message) => 'Failed to set registry key: $message', + PersistError_Serialize(:final message) => 'Failed to serialize data: $message', + }; +")] +pub enum PersistError { + Open { message: String }, + Set { message: String }, + Serialize { message: String }, +} + +impl From for PersistError { + fn from(err: ipc::error::PersistError) -> Self { + match err { + ipc::error::PersistError::Open(err) => PersistError::Open { + message: err.to_string(), + }, + ipc::error::PersistError::Set(err) => PersistError::Set { + message: err.to_string(), + }, + ipc::error::PersistError::Serialize(err) => PersistError::Serialize { + message: err.to_string(), + }, + } + } +} diff --git a/rust/bindings/dart/rust/src/api/driver_client.rs b/rust/bindings/dart/rust/src/api/driver_client.rs new file mode 100644 index 00000000..90d2c99b --- /dev/null +++ b/rust/bindings/dart/rust/src/api/driver_client.rs @@ -0,0 +1,366 @@ +#![allow(clippy::doc_markdown)] + +use driver_ipc::Monitor; +use flutter_rust_bridge::frb; +use tokio_stream::StreamExt; + +use crate::frb_generated::StreamSink; + +use super::client; + +mod ipc { + pub use driver_ipc::driver_client::*; + pub use driver_ipc::*; +} + +/// Abstraction layer over [Client]. +/// +/// It manages its own state. Changing this state does not affect the driver +/// directly. You must call [DriverClient.notify] to send changes to the +/// driver. To make your changes persistent across reboots, call +/// [DriverClient.persist]. To synchronize this object with the driver, you +/// must call [DriverClient.refreshState]. The state will not be updated +/// automatically. +#[frb(opaque)] +pub struct DriverClient(ipc::DriverClient); + +impl DriverClient { + /// Connect to driver on pipe with default name. + /// + /// You can optionally specify the name of the named pipe to connect to. The + /// default name is "virtualdisplaydriver" + pub async fn connect(pipe_name: Option) -> Result { + match pipe_name { + Some(pipe_name) => Ok(Self(ipc::DriverClient::new_with(&pipe_name).await?)), + None => Ok(Self(ipc::DriverClient::new().await?)), + } + } + + /// Manually synchronize with the driver. + pub fn refresh_state(&mut self) -> Vec { + self.0.refresh_state().to_owned() + } + + /// Returns a stream of continuous events from the driver. + /// + /// This stream will always reflect the real state of the driver, regardless + /// of who changed its state. This means, if it is changed by another + /// process, this stream will still be updated. + #[allow(clippy::unused_async)] // Must be async, because we need a tokio reactor. + pub async fn receive_events( + &self, + sink: StreamSink>, + ) -> Result<(), client::ReceiveError> { + let mut stream = self.0.receive_events(); + tokio::task::spawn(async move { + while let Some(v) = stream.next().await { + let result = match v { + Ok(ipc::EventCommand::Changed(monitors)) => sink.add(monitors), + Err(err) => sink.add_error(client::ReceiveError::from(err)), + Ok(_) => continue, + }; + + if result.is_err() { + break; + } + } + }); + Ok(()) + } + + /// Get the current monitor state stored inside this client. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(getter, sync)] + pub fn state(&self) -> Vec { + self.0.monitors().to_owned() + } + + /// Send the current client state to the driver. + /// + /// State changes of the client are not automatically sent to the driver. + /// You must manually call this method to send changes to the driver. + pub async fn notify(&mut self) -> Result<(), client::SendError> { + self.0.notify().await?; + Ok(()) + } + + /// Find the monitor with the given ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[must_use] + #[frb(sync)] + pub fn find_monitor(&self, id: u32) -> Option { + self.0.find_monitor(id).cloned() + } + + /// Replace all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + #[frb(sync)] + pub fn set_monitors(&mut self, monitors: &[Monitor]) -> Result<(), DuplicateError> { + self.0.set_monitors(monitors)?; + Ok(()) + } + + /// Replace an existing monitor. The monitor is identified by its ID. + /// + /// Throws [MonitorNotFoundError] if the monitor does not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn replace_monitor(&mut self, monitor: Monitor) -> Result<(), MonitorNotFoundError> { + self.0.replace_monitor(monitor)?; + Ok(()) + } + + /// Remove monitors by id. + /// + /// Silently skips IDs that do not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn remove(&mut self, ids: &[u32]) { + self.0.remove(ids); + } + + /// Remove all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + #[frb(sync)] + pub fn remove_all(&mut self) { + self.0.remove_all(); + } + + /// Add a new monitor. + /// + /// Returns an error if a monitor with this ID already exists, or if the + /// monitor is invalid. A monitor is invalid if it has duplicate modes, or + /// if any of its modes has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn add(&mut self, monitor: Monitor) -> Result<(), DuplicateError> { + self.0.add(monitor)?; + Ok(()) + } + + /// Set enabled state of all monitors with the given IDs. + /// + /// Silently skips incorrect IDs. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn set_enabled(&mut self, ids: &[u32], enabled: bool) { + self.0.set_enabled(ids, enabled); + } + + /// Add a mode to the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist, or if the mode already + /// exists on that monitor, or if the mode is invalid. A mode is invalid if + /// it has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn add_mode(&mut self, id: u32, mode: ipc::Mode) -> Result<(), AddModeError> { + self.0.add_mode(id, mode)?; + Ok(()) + } + + /// Remove a mode from the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist. If the mode does not + /// exist, it is silently skipped. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn remove_mode( + &mut self, + id: u32, + resolution: (u32, u32), + ) -> Result<(), MonitorNotFoundError> { + self.0.remove_mode(id, resolution)?; + Ok(()) + } + + /// Get the closest available free ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + /// + /// Note: Duplicate monitors are ignored when send to the Driver using + /// [DriverClient.notify]. + #[must_use] + #[frb(sync)] + pub fn new_id(&self, preferred_id: Option) -> Option { + self.0.new_id(preferred_id) + } + + /// Write client state to the registry for current user. + /// + /// Next time the driver is started, it will load this state from the + /// registry. This might be after a reboot or a driver restart. + pub fn persist(&self) -> Result<(), client::PersistError> { + self.0.persist()?; + Ok(()) + } +} + +#[frb(dart_code = " + @override + String toString() => 'Failed to initialize DriverClient: $inner'; +")] +pub enum InitError { + Connect { inner: client::ConnectionError }, + RequestState { inner: client::RequestError }, +} + +impl From for InitError { + fn from(value: ipc::error::InitError) -> Self { + match value { + ipc::error::InitError::Connect(inner) => InitError::Connect { + inner: inner.into(), + }, + ipc::error::InitError::RequestState(inner) => InitError::RequestState { + inner: inner.into(), + }, + } + } +} + +#[frb(dart_code = " + @override + String toString() => switch (this) { + DuplicateError_Monitor(:final id) => 'Monitor with id $id already exists', + DuplicateError_Mode(:final monitorId, :final width, :final height) => 'Mode ${width}x$height already exists on monitor $monitorId', + DuplicateError_RefreshRate(:final monitorId, :final width, :final height, :final refreshRate) => 'Refresh rate $refreshRate already exists on mode ${width}x$height on monitor $monitorId', + }; +")] +pub enum DuplicateError { + Monitor { + id: u32, + }, + Mode { + monitor_id: u32, + width: u32, + height: u32, + }, + RefreshRate { + monitor_id: u32, + width: u32, + height: u32, + refresh_rate: u32, + }, +} + +impl From for DuplicateError { + fn from(value: ipc::error::DuplicateError) -> Self { + match value { + ipc::error::DuplicateError::Monitor(id) => DuplicateError::Monitor { id }, + ipc::error::DuplicateError::Mode(width, height, monitor_id) => DuplicateError::Mode { + monitor_id, + width, + height, + }, + ipc::error::DuplicateError::RefreshRate(refresh_rate, width, height, monitor_id) => { + DuplicateError::RefreshRate { + monitor_id, + width, + height, + refresh_rate, + } + } + } + } +} + +#[frb(dart_code = " + @override + String toString() => 'Monitor with id $id not found'; +")] +pub struct MonitorNotFoundError { + pub id: u32, +} + +impl From for MonitorNotFoundError { + fn from(value: ipc::error::MonNotFound) -> Self { + MonitorNotFoundError { id: value.0 } + } +} + +#[frb(dart_code = " + @override + String toString() => switch (this) { + AddModeError_MonitorNotFound(:final id) => 'Monitor with id $id not found', + AddModeError_ModeExists(:final monitorId, :final width, :final height) => 'Mode ${width}x$height already exists on monitor $monitorId', + AddModeError_RefreshRateExists(:final monitorId, :final width, :final height, :final refreshRate) => 'Refresh rate $refreshRate already exists on mode ${width}x$height on monitor $monitorId', + }; +")] +pub enum AddModeError { + MonitorNotFound { + id: u32, + }, + ModeExists { + monitor_id: u32, + width: u32, + height: u32, + }, + RefreshRateExists { + monitor_id: u32, + width: u32, + height: u32, + refresh_rate: u32, + }, +} + +impl From for AddModeError { + fn from(value: ipc::error::AddModeError) -> Self { + match value { + ipc::error::AddModeError::MonNotFound(id) => AddModeError::MonitorNotFound { id }, + ipc::error::AddModeError::DupMode(monitor_id, width, height) => { + AddModeError::ModeExists { + monitor_id, + width, + height, + } + } + ipc::error::AddModeError::DupRefreshRate(refresh_rate, width, height, monitor_id) => { + AddModeError::RefreshRateExists { + monitor_id, + width, + height, + refresh_rate, + } + } + } + } +} diff --git a/rust/bindings/dart/rust/src/api/mock.rs b/rust/bindings/dart/rust/src/api/mock.rs new file mode 100644 index 00000000..05707295 --- /dev/null +++ b/rust/bindings/dart/rust/src/api/mock.rs @@ -0,0 +1,39 @@ +use flutter_rust_bridge::frb; + +mod ipc { + pub use driver_ipc::mock::*; + pub use driver_ipc::*; +} + +#[frb(opaque)] +pub struct MockServer { + server: ipc::MockServer, + pipe_name: String, +} + +impl MockServer { + pub async fn create(pipe_name: String) -> Self { + Self { + server: ipc::MockServer::new(&pipe_name).await, + pipe_name, + } + } + + #[frb(getter, sync)] + pub fn pipe_name(&self) -> String { + self.pipe_name.clone() + } + + #[frb(getter, sync)] + pub fn state(&self) -> Vec { + self.server.state().to_owned() + } + + pub async fn set_state(&mut self, state: Vec) { + self.server.set_state(state).await; + } + + pub async fn pump(&mut self) { + self.server.pump().await; + } +} diff --git a/rust/bindings/dart/rust/src/api/mod.rs b/rust/bindings/dart/rust/src/api/mod.rs new file mode 100644 index 00000000..121d2f9b --- /dev/null +++ b/rust/bindings/dart/rust/src/api/mod.rs @@ -0,0 +1,27 @@ +pub mod client; +pub mod driver_client; +pub mod mock; + +pub use client::*; +pub use driver_client::*; +pub use mock::*; + +pub use driver_ipc::Mode; +pub use driver_ipc::Monitor; + +use flutter_rust_bridge::frb; + +#[frb(mirror(Monitor), dart_metadata=("freezed"))] +struct _Monitor { + pub id: u32, + pub name: Option, + pub enabled: bool, + pub modes: Vec, +} + +#[frb(mirror(Mode), dart_metadata=("freezed"))] +struct _Mode { + pub width: u32, + pub height: u32, + pub refresh_rates: Vec, +} diff --git a/rust/bindings/dart/rust/src/frb_generated.rs b/rust/bindings/dart/rust/src/frb_generated.rs new file mode 100644 index 00000000..abb477c7 --- /dev/null +++ b/rust/bindings/dart/rust/src/frb_generated.rs @@ -0,0 +1,2917 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.2.0. + +#![allow( + non_camel_case_types, + unused, + non_snake_case, + clippy::needless_return, + clippy::redundant_closure_call, + clippy::redundant_closure, + clippy::useless_conversion, + clippy::unit_arg, + clippy::unused_unit, + clippy::double_parens, + clippy::let_and_return, + clippy::too_many_arguments, + clippy::match_single_binding, + clippy::clone_on_copy, + clippy::let_unit_value, + clippy::deref_addrof, + clippy::explicit_auto_deref, + clippy::borrow_deref_ref, + clippy::needless_borrow +)] + +// Section: imports + +use crate::api::client::*; +use crate::api::driver_client::*; +use crate::api::mock::*; +use flutter_rust_bridge::for_generated::byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt}; +use flutter_rust_bridge::for_generated::{transform_result_dco, Lifetimeable, Lockable}; +use flutter_rust_bridge::{Handler, IntoIntoDart}; + +// Section: boilerplate + +flutter_rust_bridge::frb_generated_boilerplate!( + default_stream_sink_codec = SseCodec, + default_rust_opaque = RustOpaqueMoi, + default_rust_auto_opaque = RustAutoOpaqueMoi, +); +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.2.0"; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -527967754; + +// Section: executor + +flutter_rust_bridge::frb_generated_default_handler!(); + +// Section: wire_funcs + +fn wire__crate__api__client__Client_connect_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_connect", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_pipe_name = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::ConnectionError>( + (move || async move { + let output_ok = crate::api::client::Client::connect(api_pipe_name).await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__client__Client_notify_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_notify", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_monitors = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::SendError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::client::Client::notify(&*api_that_guard, &api_monitors) + .await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__client__Client_persist_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_persist", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_monitors = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::client::PersistError>((move || { + let output_ok = crate::api::client::Client::persist(&api_monitors)?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__client__Client_receive_events_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_receive_events", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_sink = , + flutter_rust_bridge::for_generated::SseCodec, + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::ReceiveError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::client::Client::receive_events(&*api_that_guard, api_sink) + .await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__client__Client_remove_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_remove", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_ids = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::SendError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::client::Client::remove(&*api_that_guard, &api_ids).await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__client__Client_remove_all_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_remove_all", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::SendError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::client::Client::remove_all(&*api_that_guard).await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__client__Client_request_state_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_request_state", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::RequestError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::client::Client::request_state(&*api_that_guard).await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_add_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_add", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_monitor = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, crate::api::driver_client::DuplicateError>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::add( + &mut *api_that_guard, + api_monitor, + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_add_mode_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_add_mode", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_id = ::sse_decode(&mut deserializer); + let api_mode = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, crate::api::driver_client::AddModeError>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::add_mode( + &mut *api_that_guard, + api_id, + api_mode, + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_connect_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_connect", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_pipe_name = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::driver_client::InitError>( + (move || async move { + let output_ok = + crate::api::driver_client::DriverClient::connect(api_pipe_name).await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_find_monitor_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_find_monitor", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_id = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok( + crate::api::driver_client::DriverClient::find_monitor(&*api_that_guard, api_id), + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_new_id_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_new_id", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_preferred_id = >::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + Result::<_, ()>::Ok(crate::api::driver_client::DriverClient::new_id( + &*api_that_guard, + api_preferred_id, + ))?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_notify_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_notify", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::SendError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref_mut().await) + } + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::driver_client::DriverClient::notify(&mut *api_that_guard) + .await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_persist_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_persist", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::client::PersistError>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::driver_client::DriverClient::persist(&*api_that_guard)?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_receive_events_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_receive_events", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_sink = , + flutter_rust_bridge::for_generated::SseCodec, + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::ReceiveError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::receive_events( + &*api_that_guard, + api_sink, + ) + .await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_refresh_state_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_refresh_state", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok( + crate::api::driver_client::DriverClient::refresh_state( + &mut *api_that_guard, + ), + )?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_remove_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_remove", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_ids = >::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::driver_client::DriverClient::remove(&mut *api_that_guard, &api_ids); + })?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_remove_all_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_remove_all", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::driver_client::DriverClient::remove_all(&mut *api_that_guard); + })?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_remove_mode_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_remove_mode", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_id = ::sse_decode(&mut deserializer); + let api_resolution = <(u32, u32)>::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, crate::api::driver_client::MonitorNotFoundError>( + (move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::remove_mode( + &mut *api_that_guard, + api_id, + api_resolution, + )?; + Ok(output_ok) + })(), + ) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_replace_monitor_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_replace_monitor", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_monitor = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, crate::api::driver_client::MonitorNotFoundError>( + (move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::replace_monitor( + &mut *api_that_guard, + api_monitor, + )?; + Ok(output_ok) + })(), + ) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_set_enabled_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_set_enabled", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_ids = >::sse_decode(&mut deserializer); + let api_enabled = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::driver_client::DriverClient::set_enabled( + &mut *api_that_guard, + &api_ids, + api_enabled, + ); + })?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_set_monitors_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_set_monitors", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_monitors = >::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, crate::api::driver_client::DuplicateError>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::set_monitors( + &mut *api_that_guard, + &api_monitors, + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_state_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_state", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok( + crate::api::driver_client::DriverClient::state(&*api_that_guard), + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__mock__MockServer_create_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "MockServer_create", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_pipe_name = ::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, ()>( + (move || async move { + let output_ok = Result::<_, ()>::Ok( + crate::api::mock::MockServer::create(api_pipe_name).await, + )?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__mock__MockServer_pipe_name_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "MockServer_pipe_name", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + Result::<_, ()>::Ok(crate::api::mock::MockServer::pipe_name(&*api_that_guard))?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__mock__MockServer_pump_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "MockServer_pump", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, ()>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref_mut().await) + } + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::mock::MockServer::pump(&mut *api_that_guard).await; + })?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__mock__MockServer_set_state_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "MockServer_set_state", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_state = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, ()>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref_mut().await) + } + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::mock::MockServer::set_state( + &mut *api_that_guard, + api_state, + ) + .await; + })?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__mock__MockServer_state_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "MockServer_state", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + Result::<_, ()>::Ok(crate::api::mock::MockServer::state(&*api_that_guard))?; + Ok(output_ok) + })()) + }, + ) +} + +// Section: static_checks + +#[allow(clippy::unnecessary_literal_unwrap)] +const _: fn() = || { + { + let Mode = None::.unwrap(); + let _: u32 = Mode.width; + let _: u32 = Mode.height; + let _: Vec = Mode.refresh_rates; + } + { + let Monitor = None::.unwrap(); + let _: u32 = Monitor.id; + let _: Option = Monitor.name; + let _: bool = Monitor.enabled; + let _: Vec = Monitor.modes; + } +}; + +// Section: related_funcs + +flutter_rust_bridge::frb_generated_moi_arc_impl_value!( + flutter_rust_bridge::for_generated::RustAutoOpaqueInner +); +flutter_rust_bridge::frb_generated_moi_arc_impl_value!( + flutter_rust_bridge::for_generated::RustAutoOpaqueInner +); +flutter_rust_bridge::frb_generated_moi_arc_impl_value!( + flutter_rust_bridge::for_generated::RustAutoOpaqueInner +); + +// Section: dart2rust + +impl SseDecode for flutter_rust_bridge::for_generated::anyhow::Error { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return flutter_rust_bridge::for_generated::anyhow::anyhow!("{}", inner); + } +} + +impl SseDecode for Client { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = , + >>::sse_decode(deserializer); + return flutter_rust_bridge::for_generated::rust_auto_opaque_decode_owned(inner); + } +} + +impl SseDecode for DriverClient { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = , + >>::sse_decode(deserializer); + return flutter_rust_bridge::for_generated::rust_auto_opaque_decode_owned(inner); + } +} + +impl SseDecode for MockServer { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = , + >>::sse_decode(deserializer); + return flutter_rust_bridge::for_generated::rust_auto_opaque_decode_owned(inner); + } +} + +impl SseDecode for chrono::Duration { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return chrono::Duration::microseconds(inner); + } +} + +impl SseDecode for RustOpaqueMoi> { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return decode_rust_opaque_moi(inner); + } +} + +impl SseDecode + for RustOpaqueMoi> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return decode_rust_opaque_moi(inner); + } +} + +impl SseDecode + for RustOpaqueMoi> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return decode_rust_opaque_moi(inner); + } +} + +impl SseDecode + for StreamSink, flutter_rust_bridge::for_generated::SseCodec> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return StreamSink::deserialize(inner); + } +} + +impl SseDecode for String { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = >::sse_decode(deserializer); + return String::from_utf8(inner).unwrap(); + } +} + +impl SseDecode for crate::api::driver_client::AddModeError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_id = ::sse_decode(deserializer); + return crate::api::driver_client::AddModeError::MonitorNotFound { id: var_id }; + } + 1 => { + let mut var_monitorId = ::sse_decode(deserializer); + let mut var_width = ::sse_decode(deserializer); + let mut var_height = ::sse_decode(deserializer); + return crate::api::driver_client::AddModeError::ModeExists { + monitor_id: var_monitorId, + width: var_width, + height: var_height, + }; + } + 2 => { + let mut var_monitorId = ::sse_decode(deserializer); + let mut var_width = ::sse_decode(deserializer); + let mut var_height = ::sse_decode(deserializer); + let mut var_refreshRate = ::sse_decode(deserializer); + return crate::api::driver_client::AddModeError::RefreshRateExists { + monitor_id: var_monitorId, + width: var_width, + height: var_height, + refresh_rate: var_refreshRate, + }; + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for bool { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u8().unwrap() != 0 + } +} + +impl SseDecode for crate::api::client::ConnectionError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::ConnectionError::Failed { + message: var_message, + }; + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for crate::api::driver_client::DuplicateError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_id = ::sse_decode(deserializer); + return crate::api::driver_client::DuplicateError::Monitor { id: var_id }; + } + 1 => { + let mut var_monitorId = ::sse_decode(deserializer); + let mut var_width = ::sse_decode(deserializer); + let mut var_height = ::sse_decode(deserializer); + return crate::api::driver_client::DuplicateError::Mode { + monitor_id: var_monitorId, + width: var_width, + height: var_height, + }; + } + 2 => { + let mut var_monitorId = ::sse_decode(deserializer); + let mut var_width = ::sse_decode(deserializer); + let mut var_height = ::sse_decode(deserializer); + let mut var_refreshRate = ::sse_decode(deserializer); + return crate::api::driver_client::DuplicateError::RefreshRate { + monitor_id: var_monitorId, + width: var_width, + height: var_height, + refresh_rate: var_refreshRate, + }; + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for i64 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_i64::().unwrap() + } +} + +impl SseDecode for crate::api::driver_client::InitError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_inner = ::sse_decode(deserializer); + return crate::api::driver_client::InitError::Connect { inner: var_inner }; + } + 1 => { + let mut var_inner = ::sse_decode(deserializer); + return crate::api::driver_client::InitError::RequestState { inner: var_inner }; + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(::sse_decode(deserializer)); + } + return ans_; + } +} + +impl SseDecode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(::sse_decode(deserializer)); + } + return ans_; + } +} + +impl SseDecode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(::sse_decode(deserializer)); + } + return ans_; + } +} + +impl SseDecode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(::sse_decode(deserializer)); + } + return ans_; + } +} + +impl SseDecode for crate::api::Mode { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_width = ::sse_decode(deserializer); + let mut var_height = ::sse_decode(deserializer); + let mut var_refreshRates = >::sse_decode(deserializer); + return crate::api::Mode { + width: var_width, + height: var_height, + refresh_rates: var_refreshRates, + }; + } +} + +impl SseDecode for crate::api::Monitor { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_id = ::sse_decode(deserializer); + let mut var_name = >::sse_decode(deserializer); + let mut var_enabled = ::sse_decode(deserializer); + let mut var_modes = >::sse_decode(deserializer); + return crate::api::Monitor { + id: var_id, + name: var_name, + enabled: var_enabled, + modes: var_modes, + }; + } +} + +impl SseDecode for crate::api::driver_client::MonitorNotFoundError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_id = ::sse_decode(deserializer); + return crate::api::driver_client::MonitorNotFoundError { id: var_id }; + } +} + +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for crate::api::client::PersistError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::PersistError::Open { + message: var_message, + }; + } + 1 => { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::PersistError::Set { + message: var_message, + }; + } + 2 => { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::PersistError::Serialize { + message: var_message, + }; + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for crate::api::client::ReceiveError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::ReceiveError { + message: var_message, + }; + } +} + +impl SseDecode for (u32, u32) { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_field0 = ::sse_decode(deserializer); + let mut var_field1 = ::sse_decode(deserializer); + return (var_field0, var_field1); + } +} + +impl SseDecode for crate::api::client::RequestError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::RequestError::Send { + message: var_message, + }; + } + 1 => { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::RequestError::Receive { + message: var_message, + }; + } + 2 => { + let mut var_duration = ::sse_decode(deserializer); + return crate::api::client::RequestError::Timeout { + duration: var_duration, + }; + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for crate::api::client::SendError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::SendError::PipeBroken { + message: var_message, + }; + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for u32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u32::().unwrap() + } +} + +impl SseDecode for u8 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u8().unwrap() + } +} + +impl SseDecode for () { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {} +} + +impl SseDecode for usize { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u64::().unwrap() as _ + } +} + +impl SseDecode for i32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_i32::().unwrap() + } +} + +fn pde_ffi_dispatcher_primary_impl( + func_id: i32, + port: flutter_rust_bridge::for_generated::MessagePort, + ptr: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len: i32, + data_len: i32, +) { + // Codec=Pde (Serialization + dispatch), see doc to use other codecs + match func_id { + 1 => wire__crate__api__client__Client_connect_impl(port, ptr, rust_vec_len, data_len), + 2 => wire__crate__api__client__Client_notify_impl(port, ptr, rust_vec_len, data_len), + 3 => wire__crate__api__client__Client_persist_impl(port, ptr, rust_vec_len, data_len), + 4 => { + wire__crate__api__client__Client_receive_events_impl(port, ptr, rust_vec_len, data_len) + } + 5 => wire__crate__api__client__Client_remove_impl(port, ptr, rust_vec_len, data_len), + 6 => wire__crate__api__client__Client_remove_all_impl(port, ptr, rust_vec_len, data_len), + 7 => wire__crate__api__client__Client_request_state_impl(port, ptr, rust_vec_len, data_len), + 10 => wire__crate__api__driver_client__DriverClient_connect_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 13 => wire__crate__api__driver_client__DriverClient_notify_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 14 => wire__crate__api__driver_client__DriverClient_persist_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 15 => wire__crate__api__driver_client__DriverClient_receive_events_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 16 => wire__crate__api__driver_client__DriverClient_refresh_state_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 24 => wire__crate__api__mock__MockServer_create_impl(port, ptr, rust_vec_len, data_len), + 26 => wire__crate__api__mock__MockServer_pump_impl(port, ptr, rust_vec_len, data_len), + 27 => wire__crate__api__mock__MockServer_set_state_impl(port, ptr, rust_vec_len, data_len), + _ => unreachable!(), + } +} + +fn pde_ffi_dispatcher_sync_impl( + func_id: i32, + ptr: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len: i32, + data_len: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + // Codec=Pde (Serialization + dispatch), see doc to use other codecs + match func_id { + 8 => wire__crate__api__driver_client__DriverClient_add_impl(ptr, rust_vec_len, data_len), + 9 => { + wire__crate__api__driver_client__DriverClient_add_mode_impl(ptr, rust_vec_len, data_len) + } + 11 => wire__crate__api__driver_client__DriverClient_find_monitor_impl( + ptr, + rust_vec_len, + data_len, + ), + 12 => { + wire__crate__api__driver_client__DriverClient_new_id_impl(ptr, rust_vec_len, data_len) + } + 17 => { + wire__crate__api__driver_client__DriverClient_remove_impl(ptr, rust_vec_len, data_len) + } + 18 => wire__crate__api__driver_client__DriverClient_remove_all_impl( + ptr, + rust_vec_len, + data_len, + ), + 19 => wire__crate__api__driver_client__DriverClient_remove_mode_impl( + ptr, + rust_vec_len, + data_len, + ), + 20 => wire__crate__api__driver_client__DriverClient_replace_monitor_impl( + ptr, + rust_vec_len, + data_len, + ), + 21 => wire__crate__api__driver_client__DriverClient_set_enabled_impl( + ptr, + rust_vec_len, + data_len, + ), + 22 => wire__crate__api__driver_client__DriverClient_set_monitors_impl( + ptr, + rust_vec_len, + data_len, + ), + 23 => wire__crate__api__driver_client__DriverClient_state_impl(ptr, rust_vec_len, data_len), + 25 => wire__crate__api__mock__MockServer_pipe_name_impl(ptr, rust_vec_len, data_len), + 28 => wire__crate__api__mock__MockServer_state_impl(ptr, rust_vec_len, data_len), + _ => unreachable!(), + } +} + +// Section: rust2dart + +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for FrbWrapper { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, MoiArc<_>>(self.0) + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for FrbWrapper {} + +impl flutter_rust_bridge::IntoIntoDart> for Client { + fn into_into_dart(self) -> FrbWrapper { + self.into() + } +} + +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for FrbWrapper { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, MoiArc<_>>(self.0) + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for FrbWrapper {} + +impl flutter_rust_bridge::IntoIntoDart> for DriverClient { + fn into_into_dart(self) -> FrbWrapper { + self.into() + } +} + +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for FrbWrapper { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, MoiArc<_>>(self.0) + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for FrbWrapper {} + +impl flutter_rust_bridge::IntoIntoDart> for MockServer { + fn into_into_dart(self) -> FrbWrapper { + self.into() + } +} + +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::driver_client::AddModeError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::driver_client::AddModeError::MonitorNotFound { id } => { + [0.into_dart(), id.into_into_dart().into_dart()].into_dart() + } + crate::api::driver_client::AddModeError::ModeExists { + monitor_id, + width, + height, + } => [ + 1.into_dart(), + monitor_id.into_into_dart().into_dart(), + width.into_into_dart().into_dart(), + height.into_into_dart().into_dart(), + ] + .into_dart(), + crate::api::driver_client::AddModeError::RefreshRateExists { + monitor_id, + width, + height, + refresh_rate, + } => [ + 2.into_dart(), + monitor_id.into_into_dart().into_dart(), + width.into_into_dart().into_dart(), + height.into_into_dart().into_dart(), + refresh_rate.into_into_dart().into_dart(), + ] + .into_dart(), + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::driver_client::AddModeError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::driver_client::AddModeError +{ + fn into_into_dart(self) -> crate::api::driver_client::AddModeError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::client::ConnectionError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::client::ConnectionError::Failed { message } => { + [0.into_dart(), message.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::client::ConnectionError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::client::ConnectionError +{ + fn into_into_dart(self) -> crate::api::client::ConnectionError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::driver_client::DuplicateError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::driver_client::DuplicateError::Monitor { id } => { + [0.into_dart(), id.into_into_dart().into_dart()].into_dart() + } + crate::api::driver_client::DuplicateError::Mode { + monitor_id, + width, + height, + } => [ + 1.into_dart(), + monitor_id.into_into_dart().into_dart(), + width.into_into_dart().into_dart(), + height.into_into_dart().into_dart(), + ] + .into_dart(), + crate::api::driver_client::DuplicateError::RefreshRate { + monitor_id, + width, + height, + refresh_rate, + } => [ + 2.into_dart(), + monitor_id.into_into_dart().into_dart(), + width.into_into_dart().into_dart(), + height.into_into_dart().into_dart(), + refresh_rate.into_into_dart().into_dart(), + ] + .into_dart(), + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::driver_client::DuplicateError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::driver_client::DuplicateError +{ + fn into_into_dart(self) -> crate::api::driver_client::DuplicateError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::driver_client::InitError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::driver_client::InitError::Connect { inner } => { + [0.into_dart(), inner.into_into_dart().into_dart()].into_dart() + } + crate::api::driver_client::InitError::RequestState { inner } => { + [1.into_dart(), inner.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::driver_client::InitError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::driver_client::InitError +{ + fn into_into_dart(self) -> crate::api::driver_client::InitError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for FrbWrapper { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.0.width.into_into_dart().into_dart(), + self.0.height.into_into_dart().into_dart(), + self.0.refresh_rates.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for FrbWrapper {} +impl flutter_rust_bridge::IntoIntoDart> for crate::api::Mode { + fn into_into_dart(self) -> FrbWrapper { + self.into() + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for FrbWrapper { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.0.id.into_into_dart().into_dart(), + self.0.name.into_into_dart().into_dart(), + self.0.enabled.into_into_dart().into_dart(), + self.0.modes.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for FrbWrapper +{ +} +impl flutter_rust_bridge::IntoIntoDart> for crate::api::Monitor { + fn into_into_dart(self) -> FrbWrapper { + self.into() + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::driver_client::MonitorNotFoundError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [self.id.into_into_dart().into_dart()].into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::driver_client::MonitorNotFoundError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::driver_client::MonitorNotFoundError +{ + fn into_into_dart(self) -> crate::api::driver_client::MonitorNotFoundError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::client::PersistError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::client::PersistError::Open { message } => { + [0.into_dart(), message.into_into_dart().into_dart()].into_dart() + } + crate::api::client::PersistError::Set { message } => { + [1.into_dart(), message.into_into_dart().into_dart()].into_dart() + } + crate::api::client::PersistError::Serialize { message } => { + [2.into_dart(), message.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::client::PersistError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::client::PersistError +{ + fn into_into_dart(self) -> crate::api::client::PersistError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::client::ReceiveError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [self.message.into_into_dart().into_dart()].into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::client::ReceiveError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::client::ReceiveError +{ + fn into_into_dart(self) -> crate::api::client::ReceiveError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::client::RequestError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::client::RequestError::Send { message } => { + [0.into_dart(), message.into_into_dart().into_dart()].into_dart() + } + crate::api::client::RequestError::Receive { message } => { + [1.into_dart(), message.into_into_dart().into_dart()].into_dart() + } + crate::api::client::RequestError::Timeout { duration } => { + [2.into_dart(), duration.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::client::RequestError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::client::RequestError +{ + fn into_into_dart(self) -> crate::api::client::RequestError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::client::SendError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::client::SendError::PipeBroken { message } => { + [0.into_dart(), message.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for crate::api::client::SendError {} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::client::SendError +{ + fn into_into_dart(self) -> crate::api::client::SendError { + self + } +} + +impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(format!("{:?}", self), serializer); + } +} + +impl SseEncode for Client { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >>::sse_encode(flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, MoiArc<_>>(self), serializer); + } +} + +impl SseEncode for DriverClient { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >>::sse_encode(flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, MoiArc<_>>(self), serializer); + } +} + +impl SseEncode for MockServer { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >>::sse_encode(flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, MoiArc<_>>(self), serializer); + } +} + +impl SseEncode for chrono::Duration { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + self.num_microseconds() + .expect("cannot get microseconds from time"), + serializer, + ); + } +} + +impl SseEncode for RustOpaqueMoi> { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + let (ptr, size) = self.sse_encode_raw(); + ::sse_encode(ptr, serializer); + ::sse_encode(size, serializer); + } +} + +impl SseEncode + for RustOpaqueMoi> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + let (ptr, size) = self.sse_encode_raw(); + ::sse_encode(ptr, serializer); + ::sse_encode(size, serializer); + } +} + +impl SseEncode + for RustOpaqueMoi> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + let (ptr, size) = self.sse_encode_raw(); + ::sse_encode(ptr, serializer); + ::sse_encode(size, serializer); + } +} + +impl SseEncode + for StreamSink, flutter_rust_bridge::for_generated::SseCodec> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + unimplemented!("") + } +} + +impl SseEncode for String { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >::sse_encode(self.into_bytes(), serializer); + } +} + +impl SseEncode for crate::api::driver_client::AddModeError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::driver_client::AddModeError::MonitorNotFound { id } => { + ::sse_encode(0, serializer); + ::sse_encode(id, serializer); + } + crate::api::driver_client::AddModeError::ModeExists { + monitor_id, + width, + height, + } => { + ::sse_encode(1, serializer); + ::sse_encode(monitor_id, serializer); + ::sse_encode(width, serializer); + ::sse_encode(height, serializer); + } + crate::api::driver_client::AddModeError::RefreshRateExists { + monitor_id, + width, + height, + refresh_rate, + } => { + ::sse_encode(2, serializer); + ::sse_encode(monitor_id, serializer); + ::sse_encode(width, serializer); + ::sse_encode(height, serializer); + ::sse_encode(refresh_rate, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for bool { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u8(self as _).unwrap(); + } +} + +impl SseEncode for crate::api::client::ConnectionError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::client::ConnectionError::Failed { message } => { + ::sse_encode(0, serializer); + ::sse_encode(message, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for crate::api::driver_client::DuplicateError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::driver_client::DuplicateError::Monitor { id } => { + ::sse_encode(0, serializer); + ::sse_encode(id, serializer); + } + crate::api::driver_client::DuplicateError::Mode { + monitor_id, + width, + height, + } => { + ::sse_encode(1, serializer); + ::sse_encode(monitor_id, serializer); + ::sse_encode(width, serializer); + ::sse_encode(height, serializer); + } + crate::api::driver_client::DuplicateError::RefreshRate { + monitor_id, + width, + height, + refresh_rate, + } => { + ::sse_encode(2, serializer); + ::sse_encode(monitor_id, serializer); + ::sse_encode(width, serializer); + ::sse_encode(height, serializer); + ::sse_encode(refresh_rate, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for i64 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_i64::(self).unwrap(); + } +} + +impl SseEncode for crate::api::driver_client::InitError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::driver_client::InitError::Connect { inner } => { + ::sse_encode(0, serializer); + ::sse_encode(inner, serializer); + } + crate::api::driver_client::InitError::RequestState { inner } => { + ::sse_encode(1, serializer); + ::sse_encode(inner, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.len() as _, serializer); + for item in self { + ::sse_encode(item, serializer); + } + } +} + +impl SseEncode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.len() as _, serializer); + for item in self { + ::sse_encode(item, serializer); + } + } +} + +impl SseEncode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.len() as _, serializer); + for item in self { + ::sse_encode(item, serializer); + } + } +} + +impl SseEncode for Vec { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.len() as _, serializer); + for item in self { + ::sse_encode(item, serializer); + } + } +} + +impl SseEncode for crate::api::Mode { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.width, serializer); + ::sse_encode(self.height, serializer); + >::sse_encode(self.refresh_rates, serializer); + } +} + +impl SseEncode for crate::api::Monitor { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.id, serializer); + >::sse_encode(self.name, serializer); + ::sse_encode(self.enabled, serializer); + >::sse_encode(self.modes, serializer); + } +} + +impl SseEncode for crate::api::driver_client::MonitorNotFoundError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.id, serializer); + } +} + +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for crate::api::client::PersistError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::client::PersistError::Open { message } => { + ::sse_encode(0, serializer); + ::sse_encode(message, serializer); + } + crate::api::client::PersistError::Set { message } => { + ::sse_encode(1, serializer); + ::sse_encode(message, serializer); + } + crate::api::client::PersistError::Serialize { message } => { + ::sse_encode(2, serializer); + ::sse_encode(message, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for crate::api::client::ReceiveError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.message, serializer); + } +} + +impl SseEncode for (u32, u32) { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.0, serializer); + ::sse_encode(self.1, serializer); + } +} + +impl SseEncode for crate::api::client::RequestError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::client::RequestError::Send { message } => { + ::sse_encode(0, serializer); + ::sse_encode(message, serializer); + } + crate::api::client::RequestError::Receive { message } => { + ::sse_encode(1, serializer); + ::sse_encode(message, serializer); + } + crate::api::client::RequestError::Timeout { duration } => { + ::sse_encode(2, serializer); + ::sse_encode(duration, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for crate::api::client::SendError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::client::SendError::PipeBroken { message } => { + ::sse_encode(0, serializer); + ::sse_encode(message, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for u32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u32::(self).unwrap(); + } +} + +impl SseEncode for u8 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u8(self).unwrap(); + } +} + +impl SseEncode for () { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {} +} + +impl SseEncode for usize { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer + .cursor + .write_u64::(self as _) + .unwrap(); + } +} + +impl SseEncode for i32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_i32::(self).unwrap(); + } +} + +#[cfg(not(target_family = "wasm"))] +mod io { + // This file is automatically generated, so please do not edit it. + // Generated by `flutter_rust_bridge`@ 2.2.0. + + // Section: imports + + use super::*; + use crate::api::client::*; + use crate::api::driver_client::*; + use crate::api::mock::*; + use flutter_rust_bridge::for_generated::byteorder::{ + NativeEndian, ReadBytesExt, WriteBytesExt, + }; + use flutter_rust_bridge::for_generated::{transform_result_dco, Lifetimeable, Lockable}; + use flutter_rust_bridge::{Handler, IntoIntoDart}; + + // Section: boilerplate + + flutter_rust_bridge::frb_generated_boilerplate_io!(); + + #[no_mangle] + pub extern "C" fn frbgen_vdd_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::increment_strong_count(ptr as _); + } + + #[no_mangle] + pub extern "C" fn frbgen_vdd_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::decrement_strong_count(ptr as _); + } + + #[no_mangle] + pub extern "C" fn frbgen_vdd_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::increment_strong_count(ptr as _); + } + + #[no_mangle] + pub extern "C" fn frbgen_vdd_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::decrement_strong_count(ptr as _); + } + + #[no_mangle] + pub extern "C" fn frbgen_vdd_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::increment_strong_count(ptr as _); + } + + #[no_mangle] + pub extern "C" fn frbgen_vdd_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::decrement_strong_count(ptr as _); + } +} +#[cfg(not(target_family = "wasm"))] +pub use io::*; diff --git a/rust/bindings/dart/rust/src/lib.rs b/rust/bindings/dart/rust/src/lib.rs new file mode 100644 index 00000000..f11554f5 --- /dev/null +++ b/rust/bindings/dart/rust/src/lib.rs @@ -0,0 +1,4 @@ +pub mod api; + +#[allow(warnings)] +mod frb_generated; diff --git a/rust/bindings/dart/test/vdd_test.dart b/rust/bindings/dart/test/vdd_test.dart new file mode 100644 index 00000000..ee302b5f --- /dev/null +++ b/rust/bindings/dart/test/vdd_test.dart @@ -0,0 +1,426 @@ +import 'dart:typed_data'; + +import 'package:vdd/errors.dart'; +import 'package:vdd/test.dart'; +import 'package:vdd/vdd.dart'; +import 'package:test/test.dart'; + +void main() { + final monitor = Monitor( + id: 0, + enabled: true, + modes: [ + Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60]), + ), + ], + ); + + setUpAll(() async { + await init(); + }); + + group('Client', () { + test('Client.connect throws correct error', () async { + try { + await Client.connect(pipeName: "nonexisting"); + fail("Expected ConnectionError"); + } catch (e) { + expect(e, isA()); + } + }); + + test('Client can connect', () async { + final server = await MockServer.create(pipeName: "client_can_connect"); + + await Client.connect(pipeName: server.pipeName); + }); + + test('Client can notify', () async { + final server = await MockServer.create(pipeName: "client_can_notify"); + + final client = await Client.connect(pipeName: server.pipeName); + + await client.notify(monitors: [monitor]); + + await server.pump(); + + expect(server.state, [monitor]); + + await client.notify(monitors: []); + + await server.pump(); + + expect(server.state, []); + }); + + test('Client can remove', () async { + final server = await MockServer.create(pipeName: "client_can_remove"); + + final client = await Client.connect(pipeName: server.pipeName); + + await client.notify( + monitors: List.generate(5, (i) => monitor.copyWith(id: i))); + + await server.pump(); + + expect(server.state, List.generate(5, (i) => monitor.copyWith(id: i))); + + await client.remove(ids: [2, 3]); + + await server.pump(); + + expect(server.state, [ + monitor.copyWith(id: 0), + monitor.copyWith(id: 1), + monitor.copyWith(id: 4), + ]); + + await client.removeAll(); + + await server.pump(); + + expect(server.state, []); + }); + + test('Client can receive events', () async { + final server = await MockServer.create(pipeName: "client_can_receive"); + + final client = await Client.connect(pipeName: server.pipeName); + + final stream = client.receiveEvents(); + + await client.notify(monitors: [monitor]); + + await server.pump(); + + await client.notify(monitors: [monitor.copyWith(enabled: false)]); + + await server.pump(); + + await client.notify(monitors: [monitor.copyWith(id: 1)]); + + await server.pump(); + + expect(await stream.take(3).toList(), [ + [monitor], + [monitor.copyWith(enabled: false)], + [monitor.copyWith(id: 1)], + ]); + }); + + test('Client can request state', () async { + final server = await MockServer.create(pipeName: "client_can_request"); + + final client = await Client.connect(pipeName: server.pipeName); + + await Future.wait([ + Future(() async { + expect(await client.requestState(), []); + }), + server.pump(), + ]); + + await client.notify(monitors: [monitor]); + + await server.pump(); + + await Future.wait([ + Future(() async { + expect(await client.requestState(), [monitor]); + }), + server.pump(), + ]); + }); + }); + + group('DriverClient', () { + Future<(MockServer, DriverClient)> createDeps(String pipeName) async { + final server = await MockServer.create(pipeName: pipeName); + + final client = DriverClient.connect(pipeName: pipeName); + + await server.pump(); + + return (server, await client); + } + + test('DriverClient.connect throws correct error', () async { + try { + await DriverClient.connect(pipeName: "nonexisting"); + fail("Expected ConnectionError"); + } on InitError_Connect catch (e) { + expect(e.inner, isA()); + } catch (e) { + fail("Expected InitError_Connect, got $e"); + } + }); + + test('DiverClient can connect', () async { + final (_, client) = await createDeps("driver_client_can_connect"); + + expect(client.state, []); + }); + + test('DriverClient can notify', () async { + final (server, client) = await createDeps("driver_client_can_notify"); + + client.add(monitor: monitor); + + expect(client.state, [monitor]); + expect(server.state, []); + + await client.notify(); + + await server.pump(); + + expect(client.state, [monitor]); + expect(server.state, [monitor]); + }); + + test('DriverClient can refresh its state', () async { + final (server, client) = await createDeps("driver_client_can_refresh"); + + expect(client.state, []); + + await server.setState(state: [monitor]); + expect(server.state, [monitor]); + + expect(client.state, []); + + expect(await client.refreshState(), [monitor]); + + expect(client.state, [monitor]); + }); + + test('Adding existing monitor throws correct error', () async { + final (_, client) = await createDeps("driver_client_add_existing"); + + client.add(monitor: monitor); + + try { + client.add(monitor: monitor); + fail("Expected DuplicateError_Monitor"); + } on DuplicateError_Monitor catch (e) { + expect(e.id, monitor.id); + } catch (e) { + fail("Expected DuplicateError_Monitor, got $e"); + } + }); + + test('Setting duplicate monitors throws correct error', () async { + final (_, client) = + await createDeps("driver_client_set_duplicate_monitors"); + + try { + client.setMonitors(monitors: [monitor, monitor]); + fail("Expected DuplicateError_Monitor"); + } on DuplicateError_Monitor catch (e) { + expect(e.id, monitor.id); + } catch (e) { + fail("Expected DuplicateError_Monitor, got $e"); + } + + try { + client.setMonitors(monitors: [ + monitor.copyWith(modes: [ + Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60]), + ), + Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([120]), + ), + ]) + ]); + fail("Expected DuplicateError_Mode"); + } on DuplicateError_Mode catch (e) { + expect(e.monitorId, monitor.id); + expect(e.width, 1920); + expect(e.height, 1080); + } catch (e) { + fail("Expected DuplicateError_Mode, got $e"); + } + + try { + client.setMonitors(monitors: [ + monitor.copyWith(modes: [ + Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60, 60]), + ), + ]) + ]); + fail("Expected DuplicateError_RefreshRate"); + } on DuplicateError_RefreshRate catch (e) { + expect(e.monitorId, monitor.id); + expect(e.width, 1920); + expect(e.height, 1080); + expect(e.refreshRate, 60); + } catch (e) { + fail("Expected DuplicateError_RefreshRate, got $e"); + } + }); + + test('Adding duplicate mode throws correct error', () async { + final (_, client) = await createDeps("driver_client_add_duplicate_mode"); + + try { + client.addMode( + id: monitor.id, + mode: monitor.modes.first, + ); + fail("Expected AddModeError_MonitorNotFound"); + } on AddModeError_MonitorNotFound catch (e) { + expect(e.id, monitor.id); + } catch (e) { + fail("Expected AddModeError_MonitorNotFound, got $e"); + } + + client.add(monitor: monitor); + + try { + client.addMode( + id: monitor.id, + mode: monitor.modes.first, + ); + fail("Expected AddModeError_ModeExists"); + } on AddModeError_ModeExists catch (e) { + expect(e.monitorId, monitor.id); + expect(e.width, 1920); + expect(e.height, 1080); + } catch (e) { + fail("Expected AddModeError_ModeExists, got $e"); + } + + try { + client.addMode( + id: monitor.id, + mode: monitor.modes.first + .copyWith(refreshRates: Uint32List.fromList([60, 60])), + ); + fail("Expected AddModeError_RefreshRateExists"); + } on AddModeError_RefreshRateExists catch (e) { + expect(e.monitorId, monitor.id); + expect(e.width, 1920); + expect(e.height, 1080); + expect(e.refreshRate, 60); + } catch (e) { + fail("Expected AddModeError_RefreshRateExists, got $e"); + } + }); + + test('DriverClient can modify its state', () async { + final (server, client) = await createDeps("driver_client_can_modify"); + + expect(client.state, []); + + client.add(monitor: monitor); + + expect(client.state, [monitor]); + + final newId = client.newId(); + expect(newId, 1); + + client.add(monitor: monitor.copyWith(id: newId!)); + + expect(client.state, [monitor, monitor.copyWith(id: newId)]); + + client.replaceMonitor( + monitor: monitor.copyWith(id: newId, enabled: false)); + + expect( + client.state, [monitor, monitor.copyWith(id: newId, enabled: false)]); + + client.setEnabled(ids: [newId], enabled: true); + + expect( + client.state, [monitor, monitor.copyWith(id: newId, enabled: true)]); + + client.setMonitors(monitors: [ + monitor, + monitor.copyWith(id: 2), + monitor.copyWith(id: 3), + monitor.copyWith(id: 4), + monitor.copyWith(id: 5), + ]); + + expect(client.state, [ + monitor, + monitor.copyWith(id: 2), + monitor.copyWith(id: 3), + monitor.copyWith(id: 4), + monitor.copyWith(id: 5), + ]); + + client.addMode( + id: 3, + mode: Mode( + width: 2560, + height: 1440, + refreshRates: Uint32List.fromList([60, 120]), + ), + ); + + expect( + client.findMonitor(id: 3), + monitor.copyWith(id: 3, modes: [ + Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60]), + ), + Mode( + width: 2560, + height: 1440, + refreshRates: Uint32List.fromList([60, 120]), + ), + ]), + ); + + client.removeMode(id: 3, resolution: (1920, 1080)); + + expect( + client.findMonitor(id: 3), + monitor.copyWith(id: 3, modes: [ + Mode( + width: 2560, + height: 1440, + refreshRates: Uint32List.fromList([60, 120]), + ), + ]), + ); + + expect(client.newId(preferredId: 3), null); + expect(client.newId(preferredId: 0), null); + expect(client.newId(preferredId: 1), 1); + expect(client.newId(), 1); + + expect(server.state, []); + + await client.notify(); + + await server.pump(); + + expect(server.state, client.state); + + client.remove(ids: [2, 3]); + + expect(client.state, [ + monitor, + monitor.copyWith(id: 4), + monitor.copyWith(id: 5), + ]); + + client.removeAll(); + + expect(client.state, []); + }); + }); +} diff --git a/rust/driver-ipc/Cargo.toml b/rust/driver-ipc/Cargo.toml index cc8d1ddd..8e2a9e62 100644 --- a/rust/driver-ipc/Cargo.toml +++ b/rust/driver-ipc/Cargo.toml @@ -14,16 +14,6 @@ windows = { version = "0.58.0", features = ["Win32_Foundation"] } lazy_format = "2.0.3" joinery = "3.1.0" winreg = "0.52.0" -tokio = { version = "1.39.2", features = [ - "rt-multi-thread", - "sync", - "time", - "net", - "macros", -] } -tokio-stream = { version = "0.1.15", features = ["sync"] } - -[dev-dependencies] tokio = { version = "1.39.2", features = [ "rt-multi-thread", "sync", @@ -32,3 +22,4 @@ tokio = { version = "1.39.2", features = [ "macros", "io-util", ] } +tokio-stream = { version = "0.1.15", features = ["sync"] } diff --git a/rust/driver-ipc/src/client.rs b/rust/driver-ipc/src/client.rs index 1cb9b120..d214fa61 100644 --- a/rust/driver-ipc/src/client.rs +++ b/rust/driver-ipc/src/client.rs @@ -403,7 +403,7 @@ mod test { async fn receiver_stops_when_client_closed() { const PIPE_NAME: &str = "virtualdisplaydriver-test-receiver_stops_when_client_closed"; - let mut server = MockServer::new(PIPE_NAME); + let mut server = MockServer::new(PIPE_NAME).await; let client1 = Client::connect_to(PIPE_NAME) .await @@ -438,7 +438,7 @@ mod test { async fn receiver_stops_when_server_closed() { const PIPE_NAME: &str = "virtualdisplaydriver-test-receiver_stops_when_server_closed"; - let server = MockServer::new(PIPE_NAME); + let server = MockServer::new(PIPE_NAME).await; let client = Client::connect_to(PIPE_NAME) .await @@ -463,7 +463,7 @@ mod test { async fn general_test_1() { const PIPE_NAME: &str = "virtualdisplaydriver-test-general_test_1"; - let mut server = MockServer::new(PIPE_NAME); + let mut server = MockServer::new(PIPE_NAME).await; let client = Client::connect_to(PIPE_NAME) .await diff --git a/rust/driver-ipc/src/driver_client.rs b/rust/driver-ipc/src/driver_client.rs index 04bb5560..09087fde 100644 --- a/rust/driver-ipc/src/driver_client.rs +++ b/rust/driver-ipc/src/driver_client.rs @@ -274,7 +274,7 @@ impl DriverClient { .collect::>(); if let Some(id) = preferred_id { - if !existing_ids.contains(&id) { + if existing_ids.contains(&id) { return None; } @@ -433,20 +433,7 @@ impl DriverClient { .iter() .any(|_mode| _mode.height == mode.height && _mode.width == mode.width) { - return Err(error::AddModeError::DupMode(mode.width, mode.height, id)); - } - - let iter = mode.refresh_rates.iter().copied(); - - for (i, &rr) in mode.refresh_rates.iter().enumerate() { - if iter.clone().skip(i).any(|_rr| _rr == rr) { - return Err(error::AddModeError::DupRefreshRate( - rr, - mode.width, - mode.height, - id, - )); - } + return Err(error::AddModeError::DupMode(id, mode.width, mode.height)); } mon.modes.push(mode); @@ -616,7 +603,7 @@ pub mod error { pub enum DuplicateError { #[error("Duplicate monitor with ID {0}")] Monitor(Id), - #[error("Duplicate mode {1}x{2} on monitor {0}")] + #[error("Duplicate mode {0}x{1} on monitor {2}")] Mode(u32, u32, Id), #[error("Duplicate refresh rate {0} on mode {1}x{2} on monitor {3}")] RefreshRate(u32, u32, u32, Id), diff --git a/rust/driver-ipc/src/lib.rs b/rust/driver-ipc/src/lib.rs index 2a5e2df5..16d6b96e 100644 --- a/rust/driver-ipc/src/lib.rs +++ b/rust/driver-ipc/src/lib.rs @@ -1,13 +1,12 @@ -mod client; +pub mod client; mod core; -mod driver_client; +pub mod driver_client; pub mod sync; pub use client::Client; pub use core::*; pub use driver_client::DriverClient; -#[cfg(test)] -mod mock; +pub mod mock; pub static DEFAULT_PIPE_NAME: &str = "virtualdisplaydriver"; diff --git a/rust/driver-ipc/src/mock.rs b/rust/driver-ipc/src/mock.rs index ce903066..b7bdc660 100644 --- a/rust/driver-ipc/src/mock.rs +++ b/rust/driver-ipc/src/mock.rs @@ -1,4 +1,4 @@ -use std::{io, sync::Arc}; +use std::{io, mem, sync::Arc}; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, @@ -20,7 +20,8 @@ pub struct MockServer { } impl MockServer { - pub fn new(name: &str) -> Self { + /// async because needs a tokio reactor to run. Will return immediately. + pub async fn new(name: &str) -> Self { let server = named_pipe::ServerOptions::new() .access_inbound(true) .access_outbound(true) @@ -86,6 +87,13 @@ impl MockServer { &self.state } + pub async fn set_state(&mut self, state: Vec) { + let state = mem::replace(&mut self.state, state); + if state != self.state { + self.send_changed_event().await; + } + } + pub fn check_next(&mut self, cb: impl FnOnce(ServerCommand) + Send + 'static) { let mut rx = self.command_tx.subscribe(); @@ -138,16 +146,26 @@ impl MockServer { }; if changed { - let event = EventCommand::Changed(self.state.clone()); - let mut event = serde_json::to_vec(&event).unwrap(); - event.push(EOF); - - server - .write_all(&event) - .await - .expect("Failed to write event"); + self.send_changed_event().await; } } + + async fn send_changed_event(&self) { + let server = unsafe { + (self.server.as_ref() as *const _ as *mut named_pipe::NamedPipeServer) + .as_mut() + .unwrap() + }; + + let event = EventCommand::Changed(self.state.clone()); + let mut event = serde_json::to_vec(&event).unwrap(); + event.push(EOF); + + server + .write_all(&event) + .await + .expect("Failed to write event"); + } } impl Drop for MockServer { diff --git a/rust/driver-ipc/src/sync.rs b/rust/driver-ipc/src/sync.rs index 44ae3501..b24eb254 100644 --- a/rust/driver-ipc/src/sync.rs +++ b/rust/driver-ipc/src/sync.rs @@ -1,5 +1,5 @@ -mod client; -mod driver_client; +pub mod client; +pub mod driver_client; use std::sync::LazyLock; diff --git a/rust/driver-ipc/src/sync/client.rs b/rust/driver-ipc/src/sync/client.rs index cc4ef95a..6f74c966 100644 --- a/rust/driver-ipc/src/sync/client.rs +++ b/rust/driver-ipc/src/sync/client.rs @@ -248,7 +248,7 @@ mod test { fn event_receiver_not_canceled_after_drop() { const PIPE_NAME: &str = "virtualdisplaydriver-sync-event_receiver_not_canceled_after_drop"; - let mut server = RUNTIME.block_on(async { MockServer::new(PIPE_NAME) }); + let mut server = RUNTIME.block_on(MockServer::new(PIPE_NAME)); let client = Client::connect_to(PIPE_NAME).unwrap(); @@ -276,7 +276,7 @@ mod test { fn catch_unwind_when_receiver_panics() { const PIPE_NAME: &str = "virtualdisplaydriver-sync-catch_unwind_when_receiver_panics"; - let mut server = RUNTIME.block_on(async { MockServer::new(PIPE_NAME) }); + let mut server = RUNTIME.block_on(MockServer::new(PIPE_NAME)); let client = Client::connect_to(PIPE_NAME).unwrap(); @@ -306,7 +306,7 @@ mod test { fn event_receiver() { const PIPE_NAME: &str = "virtualdisplaydriver-sync-event_receiver"; - let mut server = RUNTIME.block_on(async { MockServer::new(PIPE_NAME) }); + let mut server = RUNTIME.block_on(MockServer::new(PIPE_NAME)); let client = Client::connect_to(PIPE_NAME).unwrap(); @@ -341,7 +341,7 @@ mod test { fn event_receiver_cancel_from_cb() { const PIPE_NAME: &str = "virtualdisplaydriver-sync-event_receiver_cancel_from_cb"; - let mut server = RUNTIME.block_on(async { MockServer::new(PIPE_NAME) }); + let mut server = RUNTIME.block_on(MockServer::new(PIPE_NAME)); let client = Client::connect_to(PIPE_NAME).unwrap();