~nicohman/signal-rs

d6e86916abec6daf69a9afaddb3c3559d4535a2c — nicohman 1 year, 1 month ago 51dbfc5
Imgui
4 files changed, 1209 insertions(+), 76 deletions(-)

M Cargo.lock
M Cargo.toml
M src/main.rs
M src/signal.rs
M Cargo.lock => Cargo.lock +895 -21
@@ 1,6 1,56 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "addr2line"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"
dependencies = [
 "gimli",
]

[[package]]
name = "adler"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"

[[package]]
name = "andrew"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e"
dependencies = [
 "bitflags",
 "line_drawing",
 "rusttype 0.7.9",
 "walkdir",
 "xdg",
 "xml-rs",
]

[[package]]
name = "android_glue"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407"

[[package]]
name = "android_log-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8052e2d8aabbb8d556d6abbcce2a22b9590996c5f849b9c7ce4544a2e3b984e"

[[package]]
name = "approx"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3"
dependencies = [
 "num-traits",
]

[[package]]
name = "arc-swap"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 13,6 63,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"

[[package]]
name = "backtrace"
version = "0.3.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293"
dependencies = [
 "addr2line",
 "cfg-if",
 "libc",
 "miniz_oxide",
 "object",
 "rustc-demangle",
]

[[package]]
name = "base64"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 25,6 89,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"

[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"

[[package]]
name = "block-buffer"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 46,6 116,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"

[[package]]
name = "calloop"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7aa2097be53a00de9e8fc349fea6d76221f398f5c4fa550d420669906962d160"
dependencies = [
 "mio 0.6.22",
 "mio-extras",
 "nix",
]

[[package]]
name = "cc"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 58,6 139,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"

[[package]]
name = "cgl"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff"
dependencies = [
 "libc",
]

[[package]]
name = "cloudabi"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
dependencies = [
 "bitflags",
]

[[package]]
name = "cocoa"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c49e86fc36d5704151f5996b7b3795385f50ce09e3be0f47a0cfde869681cf8"
dependencies = [
 "bitflags",
 "block",
 "core-foundation",
 "core-graphics",
 "foreign-types",
 "libc",
 "objc",
]

[[package]]
name = "core-foundation"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 74,12 188,69 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"

[[package]]
name = "core-graphics"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923"
dependencies = [
 "bitflags",
 "core-foundation",
 "foreign-types",
 "libc",
]

[[package]]
name = "core-video-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828"
dependencies = [
 "cfg-if",
 "core-foundation-sys",
 "core-graphics",
 "libc",
 "objc",
]

[[package]]
name = "cpuid-bool"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"

[[package]]
name = "crossbeam-channel"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87"
dependencies = [
 "crossbeam-utils",
 "maybe-uninit",
]

[[package]]
name = "crossbeam-utils"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
 "autocfg",
 "cfg-if",
 "lazy_static",
]

[[package]]
name = "derivative"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f"
dependencies = [
 "proc-macro2 1.0.20",
 "quote 1.0.7",
 "syn",
]

[[package]]
name = "digest"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 89,14 260,35 @@ dependencies = [
]

[[package]]
name = "dispatch"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"

[[package]]
name = "dlib"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76"
dependencies = [
 "libloading 0.6.3",
]

[[package]]
name = "downcast-rs"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"

[[package]]
name = "enum_variant_type"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1bd85a79872123319ccaa668d1d46912d61053e1a6deb7c2c1e392e034f5824"
dependencies = [
 "proc-macro2",
 "proc-macro2 1.0.20",
 "proc_macro_roids",
 "quote",
 "quote 1.0.7",
 "syn",
]



@@ 150,8 342,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39"
dependencies = [
 "proc-macro-hack",
 "proc-macro2",
 "quote",
 "proc-macro2 1.0.20",
 "quote 1.0.7",
 "syn",
]



@@ 209,6 401,111 @@ dependencies = [
]

[[package]]
name = "gimli"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"

[[package]]
name = "gl_generator"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
dependencies = [
 "khronos_api",
 "log",
 "xml-rs",
]

[[package]]
name = "glium"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "030bb23a12fac7e589b002c5e131e89348df88f91b56e3f3dbc4249527eeebf9"
dependencies = [
 "backtrace",
 "fnv",
 "gl_generator",
 "glutin",
 "lazy_static",
 "memoffset",
 "smallvec",
 "takeable-option",
]

[[package]]
name = "glutin"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a9666c8fd9afd008f6559e2468c35e11aad1d110d525bb3b354e4138ec0e20f"
dependencies = [
 "android_glue",
 "cgl",
 "cocoa",
 "core-foundation",
 "core-graphics",
 "glutin_egl_sys",
 "glutin_emscripten_sys",
 "glutin_gles2_sys",
 "glutin_glx_sys",
 "glutin_wgl_sys",
 "lazy_static",
 "libloading 0.5.2",
 "log",
 "objc",
 "osmesa-sys",
 "parking_lot",
 "wayland-client",
 "winapi 0.3.9",
 "winit",
]

[[package]]
name = "glutin_egl_sys"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2abb6aa55523480c4adc5a56bbaa249992e2dddb2fc63dc96e04a3355364c211"
dependencies = [
 "gl_generator",
 "winapi 0.3.9",
]

[[package]]
name = "glutin_emscripten_sys"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1"

[[package]]
name = "glutin_gles2_sys"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8094e708b730a7c8a1954f4f8a31880af00eb8a1c5b5bf85d28a0a3c6d69103"
dependencies = [
 "gl_generator",
 "objc",
]

[[package]]
name = "glutin_glx_sys"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e393c8fc02b807459410429150e9c4faffdb312d59b8c038566173c81991351"
dependencies = [
 "gl_generator",
 "x11-dl",
]

[[package]]
name = "glutin_wgl_sys"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3da5951a1569dbab865c6f2a863efafff193a93caf05538d193e9e3816d21696"
dependencies = [
 "gl_generator",
]

[[package]]
name = "hermit-abi"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 246,6 543,48 @@ dependencies = [
]

[[package]]
name = "imgui"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fdb2bcc7e498e78137ce28705ae836d69e36ee2eac89d0d926cfabfcf550570"
dependencies = [
 "bitflags",
 "glium",
 "imgui-sys",
 "lazy_static",
 "parking_lot",
]

[[package]]
name = "imgui-glium-renderer"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c73e47cb3db3e354e3977265b14d7e6ff8b55a83f06ab6c7d04b4d441d64f586"
dependencies = [
 "glium",
 "imgui",
]

[[package]]
name = "imgui-sys"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72be9671d64dd0ed26bb708cd10060a431262ac90ae70cf7c5912feefe6849da"
dependencies = [
 "cc",
]

[[package]]
name = "imgui-winit-support"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98171c35263e3eb0dfb66cb876e3efdb788d777c1b613c7d2592303d1276bb5"
dependencies = [
 "imgui",
 "winit",
]

[[package]]
name = "input_buffer"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 255,6 594,12 @@ dependencies = [
]

[[package]]
name = "instant"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"

[[package]]
name = "iovec"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 270,6 615,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"

[[package]]
name = "jni-sys"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"

[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 280,18 631,68 @@ dependencies = [
]

[[package]]
name = "khronos_api"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"

[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"

[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"

[[package]]
name = "libc"
version = "0.2.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "755456fae044e6fa1ebbbd1b3e902ae19e73097ed4ed87bb79934a867c007bc3"

[[package]]
name = "libloading"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753"
dependencies = [
 "cc",
 "winapi 0.3.9",
]

[[package]]
name = "libloading"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2443d8f0478b16759158b2f66d525991a05491138bc05814ef52a250148ef4f9"
dependencies = [
 "cfg-if",
 "winapi 0.3.9",
]

[[package]]
name = "line_drawing"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9"
dependencies = [
 "num-traits",
]

[[package]]
name = "lock_api"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75"
dependencies = [
 "scopeguard",
]

[[package]]
name = "log"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 301,16 702,60 @@ dependencies = [
]

[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
dependencies = [
 "libc",
]

[[package]]
name = "matches"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"

[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"

[[package]]
name = "memchr"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"

[[package]]
name = "memmap"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
dependencies = [
 "libc",
 "winapi 0.3.9",
]

[[package]]
name = "memoffset"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f"
dependencies = [
 "autocfg",
]

[[package]]
name = "memchr"
version = "2.3.3"
name = "miniz_oxide"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
checksum = "c60c0dfe32c10b43a144bad8fc83538c52f58302c92300ea7ec7bf7b38d5a7b9"
dependencies = [
 "adler",
 "autocfg",
]

[[package]]
name = "mio"


@@ 346,6 791,18 @@ dependencies = [
]

[[package]]
name = "mio-extras"
version = "2.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19"
dependencies = [
 "lazycell",
 "log",
 "mio 0.6.22",
 "slab",
]

[[package]]
name = "mio-named-pipes"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 409,6 866,37 @@ dependencies = [
]

[[package]]
name = "ndk"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95a356cafe20aee088789830bfea3a61336e84ded9e545e00d3869ce95dcb80c"
dependencies = [
 "jni-sys",
 "ndk-sys",
 "num_enum",
]

[[package]]
name = "ndk-glue"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1730ee2e3de41c3321160a6da815f008c4006d71b095880ea50e17cf52332b8"
dependencies = [
 "android_log-sys",
 "lazy_static",
 "libc",
 "log",
 "ndk",
 "ndk-sys",
]

[[package]]
name = "ndk-sys"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2820aca934aba5ed91c79acc72b6a44048ceacc5d36c035ed4e051f12d887d"

[[package]]
name = "net2"
version = "0.2.35"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 420,6 908,19 @@ dependencies = [
]

[[package]]
name = "nix"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce"
dependencies = [
 "bitflags",
 "cc",
 "cfg-if",
 "libc",
 "void",
]

[[package]]
name = "ntapi"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 429,6 930,15 @@ dependencies = [
]

[[package]]
name = "num-traits"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
dependencies = [
 "autocfg",
]

[[package]]
name = "num_cpus"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 439,6 949,43 @@ dependencies = [
]

[[package]]
name = "num_enum"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca565a7df06f3d4b485494f25ba05da1435950f4dc263440eda7a6fa9b8e36e4"
dependencies = [
 "derivative",
 "num_enum_derive",
]

[[package]]
name = "num_enum_derive"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d"
dependencies = [
 "proc-macro-crate",
 "proc-macro2 1.0.20",
 "quote 1.0.7",
 "syn",
]

[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
 "malloc_buf",
]

[[package]]
name = "object"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"

[[package]]
name = "once_cell"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 484,6 1031,48 @@ dependencies = [
]

[[package]]
name = "ordered-float"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3741934be594d77de1c8461ebcbbe866f585ea616a9753aa78f2bdc69f0e4579"
dependencies = [
 "num-traits",
]

[[package]]
name = "osmesa-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b"
dependencies = [
 "shared_library",
]

[[package]]
name = "parking_lot"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
dependencies = [
 "lock_api",
 "parking_lot_core",
]

[[package]]
name = "parking_lot_core"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
dependencies = [
 "cfg-if",
 "cloudabi",
 "libc",
 "redox_syscall",
 "smallvec",
 "winapi 0.3.9",
]

[[package]]
name = "percent-encoding"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 504,8 1093,8 @@ version = "0.4.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c0e815c3ee9a031fdf5af21c10aa17c573c9c6a566328d99e3936c34e36461f"
dependencies = [
 "proc-macro2",
 "quote",
 "proc-macro2 1.0.20",
 "quote 1.0.7",
 "syn",
]



@@ 534,6 1123,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20"

[[package]]
name = "proc-macro-crate"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
dependencies = [
 "toml",
]

[[package]]
name = "proc-macro-hack"
version = "0.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 547,11 1145,20 @@ checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a"

[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
 "unicode-xid 0.1.0",
]

[[package]]
name = "proc-macro2"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "175c513d55719db99da20232b06cda8bab6b83ec2d04e3283edf0213c37c1a29"
dependencies = [
 "unicode-xid",
 "unicode-xid 0.2.1",
]

[[package]]


@@ 560,18 1167,27 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06675fa2c577f52bcf77fbb511123927547d154faa08097cc012c66ec3c9611a"
dependencies = [
 "proc-macro2",
 "quote",
 "proc-macro2 1.0.20",
 "quote 1.0.7",
 "syn",
]

[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
 "proc-macro2 0.4.30",
]

[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
 "proc-macro2",
 "proc-macro2 1.0.20",
]

[[package]]


@@ 616,6 1232,15 @@ dependencies = [
]

[[package]]
name = "raw-window-handle"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211"
dependencies = [
 "libc",
]

[[package]]
name = "redox_syscall"
version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 631,12 1256,47 @@ dependencies = [
]

[[package]]
name = "rustc-demangle"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"

[[package]]
name = "rusttype"
version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5"
dependencies = [
 "rusttype 0.8.3",
]

[[package]]
name = "rusttype"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0"
dependencies = [
 "approx",
 "ordered-float",
 "stb_truetype",
]

[[package]]
name = "ryu"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"

[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
 "winapi-util",
]

[[package]]
name = "schannel"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 647,6 1307,12 @@ dependencies = [
]

[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"

[[package]]
name = "security-framework"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 684,8 1350,8 @@ version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48"
dependencies = [
 "proc-macro2",
 "quote",
 "proc-macro2 1.0.20",
 "quote 1.0.7",
 "syn",
]



@@ 714,6 1380,16 @@ dependencies = [
]

[[package]]
name = "shared_library"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
dependencies = [
 "lazy_static",
 "libc",
]

[[package]]
name = "signal-hook-registry"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 727,8 1403,13 @@ dependencies = [
name = "signal-rs"
version = "0.1.0"
dependencies = [
 "crossbeam-channel",
 "enum_variant_type",
 "futures-util",
 "glium",
 "imgui",
 "imgui-glium-renderer",
 "imgui-winit-support",
 "mio 0.7.0",
 "serde",
 "serde_json",


@@ 745,6 1426,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"

[[package]]
name = "smallvec"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"

[[package]]
name = "smithay-client-toolkit"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "421c8dc7acf5cb205b88160f8b4cc2c5cfabe210e43b2f80f009f4c1ef910f1d"
dependencies = [
 "andrew",
 "bitflags",
 "dlib",
 "lazy_static",
 "memmap",
 "nix",
 "wayland-client",
 "wayland-protocols",
]

[[package]]
name = "socket2"
version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 757,17 1460,32 @@ dependencies = [
]

[[package]]
name = "stb_truetype"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f77b6b07e862c66a9f3e62a07588fee67cd90a9135a2b942409f195507b4fb51"
dependencies = [
 "byteorder",
]

[[package]]
name = "syn"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350"
dependencies = [
 "proc-macro2",
 "quote",
 "unicode-xid",
 "proc-macro2 1.0.20",
 "quote 1.0.7",
 "unicode-xid 0.2.1",
]

[[package]]
name = "takeable-option"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36ae8932fcfea38b7d3883ae2ab357b0d57a02caaa18ebb4f5ece08beaec4aa0"

[[package]]
name = "tempfile"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 817,8 1535,8 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389"
dependencies = [
 "proc-macro2",
 "quote",
 "proc-macro2 1.0.20",
 "quote 1.0.7",
 "syn",
]



@@ 836,6 1554,15 @@ dependencies = [
]

[[package]]
name = "toml"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
dependencies = [
 "serde",
]

[[package]]
name = "tungstenite"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 881,6 1608,12 @@ dependencies = [

[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"

[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"


@@ 915,12 1648,89 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"

[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"

[[package]]
name = "walkdir"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
dependencies = [
 "same-file",
 "winapi 0.3.9",
 "winapi-util",
]

[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"

[[package]]
name = "wayland-client"
version = "0.23.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1080ebe0efabcf12aef2132152f616038f2d7dcbbccf7b2d8c5270fe14bcda"
dependencies = [
 "bitflags",
 "calloop",
 "downcast-rs",
 "libc",
 "mio 0.6.22",
 "nix",
 "wayland-commons",
 "wayland-scanner",
 "wayland-sys",
]

[[package]]
name = "wayland-commons"
version = "0.23.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb66b0d1a27c39bbce712b6372131c6e25149f03ffb0cd017cf8f7de8d66dbdb"
dependencies = [
 "nix",
 "wayland-sys",
]

[[package]]
name = "wayland-protocols"
version = "0.23.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6cc286643656742777d55dc8e70d144fa4699e426ca8e9d4ef454f4bf15ffcf9"
dependencies = [
 "bitflags",
 "wayland-client",
 "wayland-commons",
 "wayland-scanner",
]

[[package]]
name = "wayland-scanner"
version = "0.23.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93b02247366f395b9258054f964fe293ddd019c3237afba9be2ccbe9e1651c3d"
dependencies = [
 "proc-macro2 0.4.30",
 "quote 0.6.13",
 "xml-rs",
]

[[package]]
name = "wayland-sys"
version = "0.23.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d94e89a86e6d6d7c7c9b19ebf48a03afaac4af6bc22ae570e9a24124b75358f4"
dependencies = [
 "dlib",
 "lazy_static",
]

[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 949,12 1759,52 @@ 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 0.3.9",
]

[[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 = "winit"
version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e4ccbf7ddb6627828eace16cacde80fc6bf4dbb3469f88487262a02cf8e7862"
dependencies = [
 "bitflags",
 "cocoa",
 "core-foundation",
 "core-graphics",
 "core-video-sys",
 "dispatch",
 "instant",
 "lazy_static",
 "libc",
 "log",
 "mio 0.6.22",
 "mio-extras",
 "ndk",
 "ndk-glue",
 "ndk-sys",
 "objc",
 "parking_lot",
 "percent-encoding",
 "raw-window-handle",
 "smithay-client-toolkit",
 "wayland-client",
 "winapi 0.3.9",
 "x11-dl",
]

[[package]]
name = "ws2_32-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 963,3 1813,27 @@ dependencies = [
 "winapi 0.2.8",
 "winapi-build",
]

[[package]]
name = "x11-dl"
version = "2.18.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8"
dependencies = [
 "lazy_static",
 "libc",
 "maybe-uninit",
 "pkg-config",
]

[[package]]
name = "xdg"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"

[[package]]
name = "xml-rs"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a"

M Cargo.toml => Cargo.toml +6 -1
@@ 15,4 15,9 @@ mio = { version = "0.7", features = ["tcp", "os-poll"]}
futures-util = { version = "0.3", default-features = true, features = ["async-await", "sink", "std"] }
tokio = { version = "0.2.22",features = ["io-util", "full", "stream"] }
tokio-tungstenite = "*"
enum_variant_type = "0.2.0"
\ No newline at end of file
enum_variant_type = "0.2.0"
glium = { version = "0.27", default-features = true }
imgui-glium-renderer = "0.4.0"
imgui-winit-support = "0.4.0"
imgui = "0.4.0"
crossbeam-channel = "0.4.4"
\ No newline at end of file

M src/main.rs => src/main.rs +191 -20
@@ 1,40 1,211 @@
#[macro_use]
extern crate serde;

extern crate glium;
extern crate imgui_glium_renderer;
extern crate imgui_winit_support;
extern crate mio;
extern crate tungstenite;
extern crate url;
extern crate mio;
#[macro_use]
extern crate imgui;
#[macro_use]
extern crate enum_variant_type;
#[macro_use]
extern crate serde_json;
extern crate crossbeam_channel;
#[macro_use]
extern crate tokio;
extern crate tokio_tungstenite;
extern crate futures_util;
use tokio::prelude::*;
use serde::*;
extern crate tokio_tungstenite;
use crossbeam_channel::*;
use futures_util::sink::SinkExt;
use futures_util::{future, pin_mut, StreamExt};
use serde::*;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::prelude::*;
use tokio::sync::mpsc::*;
use tokio_tungstenite::{connect_async, tungstenite::protocol::Message};
use futures_util::sink::SinkExt;
const CONNECTION : &'static str = "ws://localhost:9080/ws";

const CONNECTION: &'static str = "ws://localhost:9080/ws";
mod signal;

use glium::glutin;
use glium::glutin::event::{Event, WindowEvent};
use glium::glutin::event_loop::{ControlFlow, EventLoop};
use glium::glutin::window::WindowBuilder;
use glium::{Display, Surface};
use imgui::*;
use imgui::{Context, FontConfig, FontGlyphRanges, FontSource, Ui};
use imgui_glium_renderer::Renderer;
use imgui_winit_support::{HiDpiMode, WinitPlatform};
use signal::*;
use std::time::Duration;
use std::time::Instant;
use tungstenite::*;
use url::Url;
use signal::*;
pub struct GuiController {
    pub event_loop: EventLoop<()>,
    pub display: glium::Display,
    pub imgui: Context,
    pub platform: WinitPlatform,
    pub renderer: Renderer,
    pub font_size: f32,
}
#[tokio::main]
async fn main() -> Result<()>{
    let (mut socket, response) = connect_async(Url::parse(CONNECTION).unwrap()).await.unwrap();
    let mut session = SignalSession::from_socket(socket);
    let req = SignalRequest::GetContactList;
    let req2 = SignalRequest::GetChatList;
    let res : ContactList = session.send_request(req).await.unwrap();
    let res2 : ChatList = session.send_request(req2).await.unwrap();
    println!("{}", serde_json::to_string(&res).unwrap());

    println!("{}", serde_json::to_string(&res2).unwrap());
async fn main() -> Result<()> {
    let controller = init();
    let (resSender, resReceiver) = unbounded::<SignalResponse>();
    let (reqSender, mut reqReceiver) = unbounded_channel::<SignalRequest>();
    let handle = tokio::spawn(async move {
        let (mut socket, response) = connect_async(Url::parse(CONNECTION).unwrap())
            .await
            .unwrap();
        let mut session = SignalSession::from_socket(socket);
        loop {
            tokio::select! {
                next = session.stream.next() => {
                    println!("Got response");
                    resSender.send(next.unwrap());
                },
                inc = reqReceiver.recv() => {
                    println!("Sending reqest");
                    session.send(inc.unwrap()).await;
                },
            };
        }
        let req = SignalRequest::GetContactList;
        let req2 = SignalRequest::GetChatList;
        let req3 = SignalRequest::AddContact {
            name: "Nico".to_string(),
            phone: "+14254920949".to_string(),
        };
        let res: ContactList = session.send_res(req).await.unwrap();
        //let res2 : ChatList = session.send_res(req2).await.unwrap();
        session.send(req3).await.unwrap();
        println!("{}", serde_json::to_string(&res).unwrap());
        //println!("{}", serde_json::to_string(&res2).unwrap());
    });
    let mut total : Vec<SignalResponse> = vec![];
    let mut manager = SignalManager::new();
    controller
        .main_loop(move |_, ui, display| {
            let inc_count = resReceiver.len();
            let mut incoming : Vec<SignalResponse> = resReceiver.iter().take(inc_count).collect();
            manager.process_responses(incoming);
            Window::new(im_str!("Signal"))
                .size(
                    display.gl_window().window().outer_size().into(),
                    Condition::Always,
                )
                .resizable(false)
                .menu_bar(false)
                .position([0.0, 0.0], Condition::Always)
                .title_bar(true)
                .collapsible(false)
                .build(ui, || {
                    ui.separator();
                    let clicked = ui.button(im_str!("Fetch contacts"), [120.0,20.0]);
                    if clicked {
                        println!("Fetching contacts");
                        reqSender.send(SignalRequest::GetContactList);
                    }
                    ui.separator();
                    for (tel, contact) in &manager.contacts {
                        ui.text_wrapped(&ImString::new(format!("{} - {}", contact.name, contact.tel)));
                        if ui.is_item_clicked(MouseButton::Left) {
                            println!("{}", tel);
                        }
                    }
                });
        })
        .await;
    Ok(())
}
fn init() -> GuiController {
    let title = "Signal".to_string();
    let event_loop = EventLoop::new();
    let context = glutin::ContextBuilder::new().with_vsync(true);
    let builder = WindowBuilder::new()
        .with_title(title)
        .with_inner_size(glutin::dpi::LogicalSize::new(1024f64, 768f64));
    let display =
        Display::new(builder, context, &event_loop).expect("Failed to initialize display");
    let mut imgui = Context::create();
    imgui.style_mut().window_rounding = 0.0;
    imgui.set_ini_filename(None);
    let mut platform = WinitPlatform::init(&mut imgui);
    {
        let gl_window = display.gl_window();
        let window = gl_window.window();
        platform.attach_window(imgui.io_mut(), &window, HiDpiMode::Rounded);
    }
    let hidpi_factor = platform.hidpi_factor();
    let font_size = (13.0 * hidpi_factor) as f32;
    imgui.fonts().add_font(&[FontSource::DefaultFontData {
        config: Some(FontConfig {
            size_pixels: font_size,
            ..FontConfig::default()
        }),
    }]);
    imgui.io_mut().font_global_scale = (1.0 / hidpi_factor) as f32;
    let renderer = Renderer::init(&mut imgui, &display).expect("Failed to initialize renderer");
    GuiController {
        event_loop,
        display,
        imgui,
        platform,
        renderer,
        font_size,
    }
}
impl GuiController {
    pub async fn main_loop<F: FnMut(&mut bool, &mut Ui, &Display) + 'static>(self, mut run_ui: F) {
        let GuiController {
            event_loop,
            display,
            mut imgui,
            mut platform,
            mut renderer,
            ..
        } = self;
        let mut last_frame = Instant::now();

        event_loop.run(move |event, _, control_flow| match event {
            Event::NewEvents(_) => {
                let now = Instant::now();
                imgui.io_mut().update_delta_time(now);
                last_frame = now;
            }
            Event::MainEventsCleared => {
                let gl_window = display.gl_window();
                platform
                    .prepare_frame(imgui.io_mut(), &gl_window.window())
                    .expect("Failed to prepare frame");
                gl_window.window().request_redraw();
            }
            Event::RedrawRequested(_) => {
                let mut ui = imgui.frame();
                let mut run = true;
                run_ui(&mut run, &mut ui, &display);
                if !run {
                    *control_flow = ControlFlow::Exit;
                }
                let gl_window = display.gl_window();
                let mut target = display.draw();
                target.clear_color_srgb(1.0, 1.0, 1.0, 1.0);
                platform.prepare_render(&ui, gl_window.window());
                let draw_data = ui.render();
                renderer
                    .render(&mut target, draw_data)
                    .expect("Rendering failed");
                target.finish().expect("Failed to swap buffers");
            }
            Event::WindowEvent {
                event: WindowEvent::CloseRequested,
                ..
            } => *control_flow = ControlFlow::Poll,
            event => {
                let gl_window = display.gl_window();
                platform.handle_event(imgui.io_mut(), gl_window.window(), &event);
            }
        })
    }
}

M src/signal.rs => src/signal.rs +117 -34
@@ 1,38 1,48 @@
use tokio::prelude::*;
use serde::*;
use mio::net::TcpStream;
use futures_util::{future, pin_mut, StreamExt};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio_tungstenite::*;
use enum_variant_type::EnumVariantType;
use futures_util::future::*;
use futures_util::sink::SinkExt;
use tokio_tungstenite::tungstenite::protocol::*;
use serde::{Serialize, Deserialize};
use futures_util::*;
use futures_util::sink::*;
use futures_util::stream::*;
use futures_util::stream::{select_all, SelectAll};
use futures_util::sink::*;
use tokio::stream::*;
use futures_util::future::*;
use enum_variant_type::EnumVariantType;
use futures_util::*;
use futures_util::{future, pin_mut, StreamExt};
use mio::net::TcpStream;
use serde::*;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::prelude::*;
use tokio::stream::*;
use tokio_tungstenite::tungstenite::protocol::*;
use tokio_tungstenite::*;
use std::collections::*;
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "request")]
pub enum SignalRequest {
    SendMessage { to: String, message: String},
    SendMessage { to: String, message: String },
    GetMessageList { id: String },
    CreateChat { tel: String },
    OpenChat { id: String },
    DelChat { id: String },
    GetChatList,
    GetContactList,
    GetDevices,
    GetMoreMessages { lastId: String },
    LeaveChat,
    ToggleNotifications { chat: String },
    CreateNewGroup { name: String, members: Vec<String> },
    GetConfig,
    AddContact { name: String, phone: String },
}
#[derive(Serialize, Deserialize, Clone, EnumVariantType)]
#[derive(Serialize, Deserialize, Clone, EnumVariantType, Debug)]
pub enum SignalResponse {
    #[evt(derive(Clone, Serialize, Deserialize))]
    #[evt(derive(Clone, Serialize, Deserialize, Debug))]
    ContactList(Vec<Contact>),
    #[evt(derive(Clone, Serialize, Deserialize))]
    ChatList(Vec<Chat>)
    #[evt(derive(Clone, Serialize, Deserialize, Debug))]
    ChatList(Vec<Chat>),
}
#[derive(Serialize, Deserialize, Clone)]
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "PascalCase")]
pub struct Chat {
    #[serde(rename = "ID")]


@@ 41,12 51,45 @@ pub struct Chat {
    pub tel: String,
    pub is_group: bool,
    pub last: String,
    pub timestamp: i64,
    pub when: String,
    pub c_type: i32,
    pub messages: Vec<SignalMessage>,
    pub unread: i32,
    pub active: bool,
    pub len: i32,
    pub notification: bool,
    pub expire_timer: i32,
}
trait SignalResponseTrait {}
impl SignalResponseTrait for SignalResponse {
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "PascalCase")]
pub struct SignalMessage {
    #[serde(rename = "ID")]
    pub ID: i32,
    #[serde(rename = "SID")]
    pub SID: i32,
    #[serde(rename = "ChatID")]
    pub chat_id: String,
    pub source: String,
    pub message: String,
    pub outgoing: bool,
    pub sent_at: i64,
    pub received_at: i64,
    pub h_time: String,
    pub c_type: i32,
    pub attachment: Option<String>,
    pub is_sent: bool,
    pub is_read: bool,
    pub flags: i32,
    pub expire_timer: i32,
    pub sending_error: bool,
    pub receipt: bool,
    pub status_message: bool,
}
trait SignalResponseTrait {}
impl SignalResponseTrait for SignalResponse {}
#[serde(rename_all = "PascalCase")]
#[derive(Serialize, Deserialize, Clone)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Contact {
    pub tel: String,
    pub uuid: String,


@@ 57,14 100,16 @@ pub struct Contact {
    pub expire_timer: i32,
}
pub struct SignalSession<'a> {
    sink: SplitSink<WebSocketStream<tokio::net::TcpStream>, Message>,
    stream: BoxStream<'a, SignalResponse>,
    pub sink: SplitSink<WebSocketStream<tokio::net::TcpStream>, Message>,
    pub stream: BoxStream<'a, SignalResponse>,
}
impl<'a> SignalSession<'a> {
    pub fn from_socket(mut socket: WebSocketStream<tokio::net::TcpStream>) -> SignalSession<'a> {
        let (mut write, mut read) = socket.split();
        let st = read.filter_map(|x| {
            if let Some(attempt) = serde_json::from_str::<SignalResponse>(&x.unwrap().into_text().unwrap()).ok() {
            if let Some(attempt) =
                serde_json::from_str::<SignalResponse>(&x.unwrap().into_text().unwrap()).ok()
            {
                return future::ready(Some(attempt));
            }
            future::ready(None)


@@ 74,15 119,53 @@ impl<'a> SignalSession<'a> {
            stream: st.boxed(),
        }
    }
    pub async fn send_request<T>(&mut self, req: SignalRequest) -> Result<T, Box<dyn std::error::Error>> where T:TryFrom<SignalResponse> {
        self.sink.send(Message::Text(serde_json::to_string(&req)?)).await?;
        Ok(self.stream.by_ref().filter_map(|x| {

            if let Some(v) = T::try_from(x).ok() {
                future::ready(Some(v))
            } else {
                future::ready(None)
    pub async fn send(&mut self, req: SignalRequest) -> Result<(), Box<dyn std::error::Error>> {
        Ok(self
            .sink
            .send(Message::Text(serde_json::to_string(&req)?))
            .await?)
    }
    pub async fn send_res<T>(&mut self, req: SignalRequest) -> Result<T, Box<dyn std::error::Error>>
    where
        T: TryFrom<SignalResponse>,
    {
        self.send(req).await?;
        Ok(self
            .stream
            .by_ref()
            .filter_map(|x| {
                if let Some(v) = T::try_from(x).ok() {
                    future::ready(Some(v))
                } else {
                    future::ready(None)
                }
            })
            .next()
            .await
            .unwrap())
    }
}
pub struct SignalManager {
    pub contacts : HashMap<String, Contact>,
}
impl SignalManager {
    pub fn new() -> SignalManager {
        SignalManager {
            contacts: HashMap::new(),
        }
    }
    pub fn process_responses(&mut self, responses: Vec<SignalResponse>) {
        for res in responses.into_iter() {
            match res {
                SignalResponse::ContactList(v) => {
                    for contact in v.into_iter() {
                        self.contacts.insert(contact.tel.clone(), contact);
                    }
                },
                _ => {
                    
                }
            }
        }).next().await.unwrap())
        }
    }
}