From b76f027455aaaa5bf2f958f34fbbc165a54fcece Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sat, 10 Dec 2022 06:52:04 -0600 Subject: [PATCH] rearranging rust files and updating crates --- Cargo.lock | 371 ++++++++++++++++++++++++++ Cargo.nix | 541 ++++++++++++++++++++++++++++++++++++++ Cargo.toml | 25 ++ build.rs | 6 + src/rust/cxxqt_object.rs | 57 ++++ src/rust/lib.rs | 17 ++ src/rust/service_thing.rs | 80 ++++++ 7 files changed, 1097 insertions(+) create mode 100644 Cargo.lock create mode 100644 Cargo.nix create mode 100644 Cargo.toml create mode 100644 build.rs create mode 100644 src/rust/cxxqt_object.rs create mode 100644 src/rust/lib.rs create mode 100644 src/rust/service_thing.rs diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..1d147fc --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,371 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cc" +version = "1.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +dependencies = [ + "jobserver", +] + +[[package]] +name = "clang-format" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "486ab3d84d57c53ad2cfbc8964731bc26e92711aad57396d06550d01fd3a123e" +dependencies = [ + "once_cell", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "cxx" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxx-gen" +version = "0.7.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79ee482f08a625160786c0282ba4266e0ea649a34ea617081994ec7984aba137" +dependencies = [ + "codespan-reporting", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cxx-qt" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73020d52e6c40820c46b81bbbe873f5d2dd1607271844c466255058831189d98" +dependencies = [ + "cxx-qt-gen", + "proc-macro2", + "syn", +] + +[[package]] +name = "cxx-qt-build" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ebd436cecf49c16288288e58f97092e161543360515e6ecce99f2a70e6531a" +dependencies = [ + "cc", + "convert_case", + "cxx-gen", + "cxx-qt-gen", + "cxx-qt-lib-headers", + "proc-macro2", + "qt-build-utils", + "quote", +] + +[[package]] +name = "cxx-qt-gen" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354788c8c719c708c8793d84954e938394d1af7ae26ae2b74950f9823545346" +dependencies = [ + "clang-format", + "convert_case", + "indoc", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cxx-qt-lib" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2467d707cbe665bc5ac2617688a4c06bd2529c495352d212ddf5229a7a58bbca" +dependencies = [ + "cxx", + "cxx-build", + "cxx-qt-lib-headers", + "qt-build-utils", +] + +[[package]] +name = "cxx-qt-lib-headers" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e74805ac9bd18d2907d158aa2696033c22a209146941bc3142df190d65a31414" + +[[package]] +name = "cxxbridge-flags" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "indoc" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adab1eaa3408fb7f0c777a73e7465fd5656136fc93b670eb6df3c88c2c1344e3" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "jobserver" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" + +[[package]] +name = "libre-presenter" +version = "0.1.0" +dependencies = [ + "cxx", + "cxx-qt", + "cxx-qt-build", + "cxx-qt-lib", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "proc-macro2" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "qt-build-utils" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44058bc241aeb84485cfb90e0f6ba28e12db0ed0f5b6eadb1853cf0ea68e21eb" +dependencies = [ + "thiserror", + "versions", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + +[[package]] +name = "syn" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "unicode-segmentation" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "versions" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee97e1d97bd593fb513912a07691b742361b3dd64ad56f2c694ea2dbfe0665d3" +dependencies = [ + "itertools", + "nom", +] + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.nix b/Cargo.nix new file mode 100644 index 0000000..fe8f6e8 --- /dev/null +++ b/Cargo.nix @@ -0,0 +1,541 @@ +# This file was @generated by cargo2nix 0.11.0. +# It is not intended to be manually edited. + +args@{ + release ? true, + rootFeatures ? [ + "libre-presenter/default" + ], + rustPackages, + buildRustPackages, + hostPlatform, + hostPlatformCpu ? null, + hostPlatformFeatures ? [], + target ? null, + codegenOpts ? null, + profileOpts ? null, + rustcLinkFlags ? null, + rustcBuildFlags ? null, + mkRustCrate, + rustLib, + lib, + workspaceSrc, +}: +let + workspaceSrc = if args.workspaceSrc == null then ./. else args.workspaceSrc; +in let + inherit (rustLib) fetchCratesIo fetchCrateLocal fetchCrateGit fetchCrateAlternativeRegistry expandFeatures decideProfile genDrvsByProfile; + profilesByName = { + }; + rootFeatures' = expandFeatures rootFeatures; + overridableMkRustCrate = f: + let + drvs = genDrvsByProfile profilesByName ({ profile, profileName }: mkRustCrate ({ inherit release profile hostPlatformCpu hostPlatformFeatures target profileOpts codegenOpts rustcLinkFlags rustcBuildFlags; } // (f profileName))); + in { compileMode ? null, profileName ? decideProfile compileMode release }: + let drv = drvs.${profileName}; in if compileMode == null then drv else drv.override { inherit compileMode; }; +in +{ + cargo2nixVersion = "0.11.0"; + workspace = { + libre-presenter = rustPackages.unknown.libre-presenter."0.1.0"; + }; + "registry+https://github.com/rust-lang/crates.io-index".cc."1.0.77" = overridableMkRustCrate (profileName: rec { + name = "cc"; + version = "1.0.77"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"; }; + features = builtins.concatLists [ + [ "jobserver" ] + [ "parallel" ] + ]; + dependencies = { + jobserver = rustPackages."registry+https://github.com/rust-lang/crates.io-index".jobserver."0.1.25" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".clang-format."0.1.2" = overridableMkRustCrate (profileName: rec { + name = "clang-format"; + version = "0.1.2"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "486ab3d84d57c53ad2cfbc8964731bc26e92711aad57396d06550d01fd3a123e"; }; + dependencies = { + once_cell = rustPackages."registry+https://github.com/rust-lang/crates.io-index".once_cell."1.16.0" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".codespan-reporting."0.11.1" = overridableMkRustCrate (profileName: rec { + name = "codespan-reporting"; + version = "0.11.1"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"; }; + dependencies = { + termcolor = rustPackages."registry+https://github.com/rust-lang/crates.io-index".termcolor."1.1.3" { inherit profileName; }; + unicode_width = rustPackages."registry+https://github.com/rust-lang/crates.io-index".unicode-width."0.1.10" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".convert_case."0.6.0" = overridableMkRustCrate (profileName: rec { + name = "convert_case"; + version = "0.6.0"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"; }; + dependencies = { + unicode_segmentation = rustPackages."registry+https://github.com/rust-lang/crates.io-index".unicode-segmentation."1.10.0" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".cxx."1.0.83" = overridableMkRustCrate (profileName: rec { + name = "cxx"; + version = "1.0.83"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf"; }; + features = builtins.concatLists [ + [ "alloc" ] + [ "default" ] + [ "std" ] + ]; + dependencies = { + cxxbridge_macro = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".cxxbridge-macro."1.0.83" { profileName = "__noProfile"; }; + link_cplusplus = rustPackages."registry+https://github.com/rust-lang/crates.io-index".link-cplusplus."1.0.7" { inherit profileName; }; + }; + buildDependencies = { + cc = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".cc."1.0.77" { profileName = "__noProfile"; }; + cxxbridge_flags = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".cxxbridge-flags."1.0.83" { profileName = "__noProfile"; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".cxx-build."1.0.83" = overridableMkRustCrate (profileName: rec { + name = "cxx-build"; + version = "1.0.83"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39"; }; + features = builtins.concatLists [ + [ "parallel" ] + ]; + dependencies = { + cc = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cc."1.0.77" { inherit profileName; }; + codespan_reporting = rustPackages."registry+https://github.com/rust-lang/crates.io-index".codespan-reporting."0.11.1" { inherit profileName; }; + once_cell = rustPackages."registry+https://github.com/rust-lang/crates.io-index".once_cell."1.16.0" { inherit profileName; }; + proc_macro2 = rustPackages."registry+https://github.com/rust-lang/crates.io-index".proc-macro2."1.0.47" { inherit profileName; }; + quote = rustPackages."registry+https://github.com/rust-lang/crates.io-index".quote."1.0.21" { inherit profileName; }; + scratch = rustPackages."registry+https://github.com/rust-lang/crates.io-index".scratch."1.0.2" { inherit profileName; }; + syn = rustPackages."registry+https://github.com/rust-lang/crates.io-index".syn."1.0.105" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".cxx-gen."0.7.83" = overridableMkRustCrate (profileName: rec { + name = "cxx-gen"; + version = "0.7.83"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "79ee482f08a625160786c0282ba4266e0ea649a34ea617081994ec7984aba137"; }; + dependencies = { + codespan_reporting = rustPackages."registry+https://github.com/rust-lang/crates.io-index".codespan-reporting."0.11.1" { inherit profileName; }; + proc_macro2 = rustPackages."registry+https://github.com/rust-lang/crates.io-index".proc-macro2."1.0.47" { inherit profileName; }; + quote = rustPackages."registry+https://github.com/rust-lang/crates.io-index".quote."1.0.21" { inherit profileName; }; + syn = rustPackages."registry+https://github.com/rust-lang/crates.io-index".syn."1.0.105" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".cxx-qt."0.4.1" = overridableMkRustCrate (profileName: rec { + name = "cxx-qt"; + version = "0.4.1"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "73020d52e6c40820c46b81bbbe873f5d2dd1607271844c466255058831189d98"; }; + dependencies = { + cxx_qt_gen = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx-qt-gen."0.4.1" { inherit profileName; }; + proc_macro2 = rustPackages."registry+https://github.com/rust-lang/crates.io-index".proc-macro2."1.0.47" { inherit profileName; }; + syn = rustPackages."registry+https://github.com/rust-lang/crates.io-index".syn."1.0.105" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".cxx-qt-build."0.4.1" = overridableMkRustCrate (profileName: rec { + name = "cxx-qt-build"; + version = "0.4.1"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "57ebd436cecf49c16288288e58f97092e161543360515e6ecce99f2a70e6531a"; }; + dependencies = { + cc = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cc."1.0.77" { inherit profileName; }; + convert_case = rustPackages."registry+https://github.com/rust-lang/crates.io-index".convert_case."0.6.0" { inherit profileName; }; + cxx_gen = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx-gen."0.7.83" { inherit profileName; }; + cxx_qt_gen = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx-qt-gen."0.4.1" { inherit profileName; }; + cxx_qt_lib_headers = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx-qt-lib-headers."0.4.1" { inherit profileName; }; + proc_macro2 = rustPackages."registry+https://github.com/rust-lang/crates.io-index".proc-macro2."1.0.47" { inherit profileName; }; + qt_build_utils = rustPackages."registry+https://github.com/rust-lang/crates.io-index".qt-build-utils."0.4.1" { inherit profileName; }; + quote = rustPackages."registry+https://github.com/rust-lang/crates.io-index".quote."1.0.21" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".cxx-qt-gen."0.4.1" = overridableMkRustCrate (profileName: rec { + name = "cxx-qt-gen"; + version = "0.4.1"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "3354788c8c719c708c8793d84954e938394d1af7ae26ae2b74950f9823545346"; }; + dependencies = { + clang_format = rustPackages."registry+https://github.com/rust-lang/crates.io-index".clang-format."0.1.2" { inherit profileName; }; + convert_case = rustPackages."registry+https://github.com/rust-lang/crates.io-index".convert_case."0.6.0" { inherit profileName; }; + indoc = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".indoc."1.0.7" { profileName = "__noProfile"; }; + proc_macro2 = rustPackages."registry+https://github.com/rust-lang/crates.io-index".proc-macro2."1.0.47" { inherit profileName; }; + quote = rustPackages."registry+https://github.com/rust-lang/crates.io-index".quote."1.0.21" { inherit profileName; }; + syn = rustPackages."registry+https://github.com/rust-lang/crates.io-index".syn."1.0.105" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".cxx-qt-lib."0.4.1" = overridableMkRustCrate (profileName: rec { + name = "cxx-qt-lib"; + version = "0.4.1"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "2467d707cbe665bc5ac2617688a4c06bd2529c495352d212ddf5229a7a58bbca"; }; + dependencies = { + cxx = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx."1.0.83" { inherit profileName; }; + }; + buildDependencies = { + cxx_build = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx-build."1.0.83" { profileName = "__noProfile"; }; + cxx_qt_lib_headers = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx-qt-lib-headers."0.4.1" { profileName = "__noProfile"; }; + qt_build_utils = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".qt-build-utils."0.4.1" { profileName = "__noProfile"; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".cxx-qt-lib-headers."0.4.1" = overridableMkRustCrate (profileName: rec { + name = "cxx-qt-lib-headers"; + version = "0.4.1"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "e74805ac9bd18d2907d158aa2696033c22a209146941bc3142df190d65a31414"; }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".cxxbridge-flags."1.0.83" = overridableMkRustCrate (profileName: rec { + name = "cxxbridge-flags"; + version = "1.0.83"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12"; }; + features = builtins.concatLists [ + [ "default" ] + ]; + }); + + "registry+https://github.com/rust-lang/crates.io-index".cxxbridge-macro."1.0.83" = overridableMkRustCrate (profileName: rec { + name = "cxxbridge-macro"; + version = "1.0.83"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6"; }; + dependencies = { + proc_macro2 = rustPackages."registry+https://github.com/rust-lang/crates.io-index".proc-macro2."1.0.47" { inherit profileName; }; + quote = rustPackages."registry+https://github.com/rust-lang/crates.io-index".quote."1.0.21" { inherit profileName; }; + syn = rustPackages."registry+https://github.com/rust-lang/crates.io-index".syn."1.0.105" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".either."1.8.0" = overridableMkRustCrate (profileName: rec { + name = "either"; + version = "1.8.0"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"; }; + features = builtins.concatLists [ + [ "use_std" ] + ]; + }); + + "registry+https://github.com/rust-lang/crates.io-index".indoc."1.0.7" = overridableMkRustCrate (profileName: rec { + name = "indoc"; + version = "1.0.7"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "adab1eaa3408fb7f0c777a73e7465fd5656136fc93b670eb6df3c88c2c1344e3"; }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".itertools."0.10.5" = overridableMkRustCrate (profileName: rec { + name = "itertools"; + version = "0.10.5"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"; }; + features = builtins.concatLists [ + [ "default" ] + [ "use_alloc" ] + [ "use_std" ] + ]; + dependencies = { + either = rustPackages."registry+https://github.com/rust-lang/crates.io-index".either."1.8.0" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".jobserver."0.1.25" = overridableMkRustCrate (profileName: rec { + name = "jobserver"; + version = "0.1.25"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b"; }; + dependencies = { + ${ if hostPlatform.isUnix then "libc" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".libc."0.2.138" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".libc."0.2.138" = overridableMkRustCrate (profileName: rec { + name = "libc"; + version = "0.2.138"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"; }; + features = builtins.concatLists [ + [ "default" ] + [ "std" ] + ]; + }); + + "unknown".libre-presenter."0.1.0" = overridableMkRustCrate (profileName: rec { + name = "libre-presenter"; + version = "0.1.0"; + registry = "unknown"; + src = fetchCrateLocal workspaceSrc; + dependencies = { + cxx = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx."1.0.83" { inherit profileName; }; + cxx_qt = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx-qt."0.4.1" { profileName = "__noProfile"; }; + cxx_qt_lib = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx-qt-lib."0.4.1" { inherit profileName; }; + }; + buildDependencies = { + cxx_qt_build = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".cxx-qt-build."0.4.1" { profileName = "__noProfile"; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".link-cplusplus."1.0.7" = overridableMkRustCrate (profileName: rec { + name = "link-cplusplus"; + version = "1.0.7"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369"; }; + features = builtins.concatLists [ + [ "default" ] + ]; + buildDependencies = { + cc = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".cc."1.0.77" { profileName = "__noProfile"; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".memchr."2.5.0" = overridableMkRustCrate (profileName: rec { + name = "memchr"; + version = "2.5.0"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"; }; + features = builtins.concatLists [ + [ "std" ] + ]; + }); + + "registry+https://github.com/rust-lang/crates.io-index".minimal-lexical."0.2.1" = overridableMkRustCrate (profileName: rec { + name = "minimal-lexical"; + version = "0.2.1"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"; }; + features = builtins.concatLists [ + [ "std" ] + ]; + }); + + "registry+https://github.com/rust-lang/crates.io-index".nom."7.1.1" = overridableMkRustCrate (profileName: rec { + name = "nom"; + version = "7.1.1"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"; }; + features = builtins.concatLists [ + [ "alloc" ] + [ "default" ] + [ "std" ] + ]; + dependencies = { + memchr = rustPackages."registry+https://github.com/rust-lang/crates.io-index".memchr."2.5.0" { inherit profileName; }; + minimal_lexical = rustPackages."registry+https://github.com/rust-lang/crates.io-index".minimal-lexical."0.2.1" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".once_cell."1.16.0" = overridableMkRustCrate (profileName: rec { + name = "once_cell"; + version = "1.16.0"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"; }; + features = builtins.concatLists [ + [ "alloc" ] + [ "default" ] + [ "race" ] + [ "std" ] + ]; + }); + + "registry+https://github.com/rust-lang/crates.io-index".proc-macro2."1.0.47" = overridableMkRustCrate (profileName: rec { + name = "proc-macro2"; + version = "1.0.47"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"; }; + features = builtins.concatLists [ + [ "default" ] + [ "proc-macro" ] + [ "span-locations" ] + ]; + dependencies = { + unicode_ident = rustPackages."registry+https://github.com/rust-lang/crates.io-index".unicode-ident."1.0.5" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".qt-build-utils."0.4.1" = overridableMkRustCrate (profileName: rec { + name = "qt-build-utils"; + version = "0.4.1"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "44058bc241aeb84485cfb90e0f6ba28e12db0ed0f5b6eadb1853cf0ea68e21eb"; }; + dependencies = { + thiserror = rustPackages."registry+https://github.com/rust-lang/crates.io-index".thiserror."1.0.37" { inherit profileName; }; + versions = rustPackages."registry+https://github.com/rust-lang/crates.io-index".versions."4.1.0" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".quote."1.0.21" = overridableMkRustCrate (profileName: rec { + name = "quote"; + version = "1.0.21"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"; }; + features = builtins.concatLists [ + [ "default" ] + [ "proc-macro" ] + ]; + dependencies = { + proc_macro2 = rustPackages."registry+https://github.com/rust-lang/crates.io-index".proc-macro2."1.0.47" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".scratch."1.0.2" = overridableMkRustCrate (profileName: rec { + name = "scratch"; + version = "1.0.2"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"; }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".syn."1.0.105" = overridableMkRustCrate (profileName: rec { + name = "syn"; + version = "1.0.105"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908"; }; + features = builtins.concatLists [ + [ "clone-impls" ] + [ "default" ] + [ "derive" ] + [ "extra-traits" ] + [ "full" ] + [ "parsing" ] + [ "printing" ] + [ "proc-macro" ] + [ "quote" ] + ]; + dependencies = { + proc_macro2 = rustPackages."registry+https://github.com/rust-lang/crates.io-index".proc-macro2."1.0.47" { inherit profileName; }; + quote = rustPackages."registry+https://github.com/rust-lang/crates.io-index".quote."1.0.21" { inherit profileName; }; + unicode_ident = rustPackages."registry+https://github.com/rust-lang/crates.io-index".unicode-ident."1.0.5" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".termcolor."1.1.3" = overridableMkRustCrate (profileName: rec { + name = "termcolor"; + version = "1.1.3"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"; }; + dependencies = { + ${ if hostPlatform.isWindows then "winapi_util" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".winapi-util."0.1.5" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".thiserror."1.0.37" = overridableMkRustCrate (profileName: rec { + name = "thiserror"; + version = "1.0.37"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"; }; + dependencies = { + thiserror_impl = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".thiserror-impl."1.0.37" { profileName = "__noProfile"; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".thiserror-impl."1.0.37" = overridableMkRustCrate (profileName: rec { + name = "thiserror-impl"; + version = "1.0.37"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"; }; + dependencies = { + proc_macro2 = rustPackages."registry+https://github.com/rust-lang/crates.io-index".proc-macro2."1.0.47" { inherit profileName; }; + quote = rustPackages."registry+https://github.com/rust-lang/crates.io-index".quote."1.0.21" { inherit profileName; }; + syn = rustPackages."registry+https://github.com/rust-lang/crates.io-index".syn."1.0.105" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".unicode-ident."1.0.5" = overridableMkRustCrate (profileName: rec { + name = "unicode-ident"; + version = "1.0.5"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"; }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".unicode-segmentation."1.10.0" = overridableMkRustCrate (profileName: rec { + name = "unicode-segmentation"; + version = "1.10.0"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a"; }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".unicode-width."0.1.10" = overridableMkRustCrate (profileName: rec { + name = "unicode-width"; + version = "0.1.10"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"; }; + features = builtins.concatLists [ + [ "default" ] + ]; + }); + + "registry+https://github.com/rust-lang/crates.io-index".versions."4.1.0" = overridableMkRustCrate (profileName: rec { + name = "versions"; + version = "4.1.0"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "ee97e1d97bd593fb513912a07691b742361b3dd64ad56f2c694ea2dbfe0665d3"; }; + dependencies = { + itertools = rustPackages."registry+https://github.com/rust-lang/crates.io-index".itertools."0.10.5" { inherit profileName; }; + nom = rustPackages."registry+https://github.com/rust-lang/crates.io-index".nom."7.1.1" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".winapi."0.3.9" = overridableMkRustCrate (profileName: rec { + name = "winapi"; + version = "0.3.9"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"; }; + features = builtins.concatLists [ + [ "consoleapi" ] + [ "errhandlingapi" ] + [ "fileapi" ] + [ "minwindef" ] + [ "processenv" ] + [ "std" ] + [ "winbase" ] + [ "wincon" ] + [ "winerror" ] + [ "winnt" ] + ]; + dependencies = { + ${ if hostPlatform.config == "i686-pc-windows-gnu" then "winapi_i686_pc_windows_gnu" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".winapi-i686-pc-windows-gnu."0.4.0" { inherit profileName; }; + ${ if hostPlatform.config == "x86_64-pc-windows-gnu" then "winapi_x86_64_pc_windows_gnu" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".winapi-x86_64-pc-windows-gnu."0.4.0" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".winapi-i686-pc-windows-gnu."0.4.0" = overridableMkRustCrate (profileName: rec { + name = "winapi-i686-pc-windows-gnu"; + version = "0.4.0"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"; }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".winapi-util."0.1.5" = overridableMkRustCrate (profileName: rec { + name = "winapi-util"; + version = "0.1.5"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"; }; + dependencies = { + ${ if hostPlatform.isWindows then "winapi" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".winapi."0.3.9" { inherit profileName; }; + }; + }); + + "registry+https://github.com/rust-lang/crates.io-index".winapi-x86_64-pc-windows-gnu."0.4.0" = overridableMkRustCrate (profileName: rec { + name = "winapi-x86_64-pc-windows-gnu"; + version = "0.4.0"; + registry = "registry+https://github.com/rust-lang/crates.io-index"; + src = fetchCratesIo { inherit name version; sha256 = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"; }; + }); + +} diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..d1534c2 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "libre-presenter" +version = "0.1.0" +edition = "2021" +authors = [ + "Chris Cochrun " +] +license = "GPL-3.0" + +# This will instruct Cargo to create a static +# library which CMake can link against +[lib] +crate-type = ["staticlib"] +path = "src/rust/lib.rs" + +[dependencies] +cxx = "1.0.83" +cxx-qt = "0.4.1" +cxx-qt-lib = "0.4.1" + +# cxx-qt-build generates C++ code from the `#[cxx_qt::bridge]` module +# and compiles it together with the Rust static library +[build-dependencies] +cxx-qt-build = "0.4.1" + diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..49a6caf --- /dev/null +++ b/build.rs @@ -0,0 +1,6 @@ +use cxx_qt_build::CxxQtBuilder; + +fn main() { + CxxQtBuilder::new().file("src/rust/cxxqt_object.rs").build(); + CxxQtBuilder::new().file("src/rust/service_thing.rs").build(); +} diff --git a/src/rust/cxxqt_object.rs b/src/rust/cxxqt_object.rs new file mode 100644 index 0000000..0062145 --- /dev/null +++ b/src/rust/cxxqt_object.rs @@ -0,0 +1,57 @@ +#[cxx_qt::bridge] +mod my_object { + use cxx_qt_lib::QVariantValue; + + unsafe extern "C++" { + include!("cxx-qt-lib/qstring.h"); + type QString = cxx_qt_lib::QString; + include!("cxx-qt-lib/qvariant.h"); + type QVariant = cxx_qt_lib::QVariant; + } + + #[cxx_qt::qobject] + pub struct MyObject { + #[qproperty] + number: i32, + #[qproperty] + string: QString, + } + + impl Default for MyObject { + fn default() -> Self { + Self { + number: 0, + string: QString::from(""), + } + } + } + + impl qobject::MyObject { + #[qinvokable] + pub fn increment_number(self: Pin<&mut Self>) { + let previous = *self.as_ref().number(); + self.set_number(previous + 1); + } + + #[qinvokable] + pub fn say_hi(self: Pin<&mut Self>, string: &QString, number: i32) { + println!( + "Hi from Rust! String is '{}' and number is {}", + string, number + ); + println!("length is: {}", string.to_string().len()); + let mut nstr: String = string.to_string(); + nstr.push_str(" hi"); + self.set_string(QString::from(nstr.as_str())); + } + + #[qinvokable] + pub fn slap_variant_around(self: Pin<&mut Self>, variant: &QVariant) { + println!("wow!"); + match variant.value() { + QVariantValue::QString(string) => self.set_string(string), + _ => println!("Unknown QVariant type"), + } + } + } +} diff --git a/src/rust/lib.rs b/src/rust/lib.rs new file mode 100644 index 0000000..380ac19 --- /dev/null +++ b/src/rust/lib.rs @@ -0,0 +1,17 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} + +mod cxxqt_object; +mod service_thing; diff --git a/src/rust/service_thing.rs b/src/rust/service_thing.rs new file mode 100644 index 0000000..a7b2d6f --- /dev/null +++ b/src/rust/service_thing.rs @@ -0,0 +1,80 @@ +#[cxx_qt::bridge] +mod service_thing { + use cxx_qt_lib::QVariantValue; + + unsafe extern "C++" { + include!("cxx-qt-lib/qstring.h"); + type QString = cxx_qt_lib::QString; + include!("cxx-qt-lib/qvariant.h"); + type QVariant = cxx_qt_lib::QVariant; + } + + #[cxx_qt::qobject] + pub struct ServiceThing { + #[qproperty] + name: QString, + #[qproperty] + kind: QString, + #[qproperty] + background: QString, + #[qproperty] + background_type: QString, + #[qproperty] + text: QString, + #[qproperty] + audio: QString, + #[qproperty] + font: QString, + #[qproperty] + font_size: QString, + #[qproperty] + active: bool, + #[qproperty] + selected: bool, + } + + impl Default for ServiceThing { + fn default() -> Self { + Self { + name: QString::from(""), + kind: QString::from(""), + background: QString::from(""), + background_type: QString::from(""), + text: QString::from(""), + audio: QString::from(""), + font: QString::from(""), + font_size: QString::from(""), + active: false, + selected: false, + } + } + } + + impl qobject::ServiceThing { + #[qinvokable] + pub fn activate(self: Pin<&mut Self>) { + self.set_active(true); + } + + #[qinvokable] + pub fn say_hi(self: Pin<&mut Self>, string: &QString, number: i32) { + println!( + "Hi from Rust! String is '{}' and number is {}", + string, number + ); + println!("length is: {}", string.to_string().len()); + let mut nstr: String = string.to_string(); + nstr.push_str(" hi"); + self.set_name(QString::from(nstr.as_str())); + } + + #[qinvokable] + pub fn slap_variant_around(self: Pin<&mut Self>, variant: &QVariant) { + println!("wow!"); + match variant.value() { + QVariantValue::QString(string) => self.set_name(string), + _ => println!("Unknown QVariant type"), + } + } + } +}