add plugin system

This commit is contained in:
sleptworld 2024-01-29 00:45:50 +08:00
parent faf1995470
commit e27d9427fd
2567 changed files with 7713 additions and 225 deletions

100
Cargo.lock generated
View File

@ -151,9 +151,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.72"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854"
checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "approx"
@ -341,9 +341,9 @@ checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
[[package]]
name = "byteorder"
version = "1.4.3"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
@ -463,14 +463,15 @@ dependencies = [
[[package]]
name = "chrono"
version = "0.4.32"
version = "0.4.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a"
checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"serde",
"wasm-bindgen",
"windows-targets 0.52.0",
]
@ -484,10 +485,13 @@ dependencies = [
"async-trait",
"cairo-rs",
"chrono",
"core_extensions",
"crossbeam",
"epoxy",
"etws_loader",
"euclid",
"femtovg",
"flate2",
"geo",
"geo-macros",
"geo-types",
@ -513,10 +517,13 @@ dependencies = [
"proj-sys",
"proj5",
"quadtree_rs",
"radarg_plugin_interface",
"relm4",
"relm4-components",
"relm4-icons",
"rstar",
"serde",
"serde_json",
"shapefile",
"surfman",
"svg",
@ -970,6 +977,24 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1"
[[package]]
name = "etws_loader"
version = "0.1.0"
dependencies = [
"abi_stable",
"anyhow",
"byteorder",
"chrono",
"flate2",
"nom",
"nom-derive",
"num-traits",
"radarg_plugin_interface",
"serde",
"serde_json",
"thiserror",
]
[[package]]
name = "euclid"
version = "0.22.9"
@ -1049,9 +1074,9 @@ dependencies = [
[[package]]
name = "flate2"
version = "1.0.26"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"
dependencies = [
"crc32fast",
"miniz_oxide",
@ -2281,6 +2306,28 @@ dependencies = [
"minimal-lexical",
]
[[package]]
name = "nom-derive"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ff943d68b88d0b87a6e0d58615e8fa07f9fd5a1319fa0a72efc1f62275c79a7"
dependencies = [
"nom",
"nom-derive-impl",
"rustversion",
]
[[package]]
name = "nom-derive-impl"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd0b9a93a84b0d3ec3e70e02d332dc33ac6dfac9cde63e17fcb77172dededa62"
dependencies = [
"proc-macro2 1.0.76",
"quote 1.0.35",
"syn 1.0.109",
]
[[package]]
name = "npyz"
version = "0.8.1"
@ -2394,9 +2441,9 @@ dependencies = [
[[package]]
name = "num-traits"
version = "0.2.15"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
dependencies = [
"autocfg",
"libm",
@ -2974,6 +3021,13 @@ dependencies = [
"proc-macro2 1.0.76",
]
[[package]]
name = "radarg_plugin_interface"
version = "0.1.0"
dependencies = [
"abi_stable",
]
[[package]]
name = "rand_core"
version = "0.6.4"
@ -3175,6 +3229,12 @@ dependencies = [
"semver",
]
[[package]]
name = "rustversion"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
[[package]]
name = "rustybuzz"
version = "0.7.0"
@ -3251,18 +3311,18 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed"
[[package]]
name = "serde"
version = "1.0.164"
version = "1.0.196"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d"
checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.164"
version = "1.0.196"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68"
checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"
dependencies = [
"proc-macro2 1.0.76",
"quote 1.0.35",
@ -3271,9 +3331,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.99"
version = "1.0.112"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3"
checksum = "4d1bd37ce2324cf3bf85e5a25f96eb4baf0d5aa6eba43e7ae8958870c4ec48ed"
dependencies = [
"itoa",
"ryu",
@ -3563,18 +3623,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.40"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.40"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
dependencies = [
"proc-macro2 1.0.76",
"quote 1.0.35",

View File

@ -39,6 +39,7 @@ geo = "0.26.0"
topojson = "0.5.1"
geojson = "0.24.1"
plotters = "0.3.5"
core_extensions={ version = "1.5.2", default_features = false, features = ["std"] }
plotters-backend = "0.3.5"
tokio = { version = "1.35.1", features = [
"time",
@ -68,6 +69,9 @@ crossbeam = "0.8.4"
chrono = "0.4.32"
tracker = "0.2.1"
abi_stable = "0.11.3"
serde = "1.0.196"
serde_json = "1.0.112"
flate2 = "1.0.28"
# plotters-cairo = "0.5.0"
@ -76,6 +80,12 @@ glib-build-tools = "0.17.0"
[dependencies.geo-macros]
path = "geo-macros"
[dependencies.radarg_plugin_interface]
path = "radarg_plugin_interface"
[dependencies.etws_loader]
path = "etws_loader"
[dependencies.adw]
package = "libadwaita"
version = "*"

780
etws_loader/Cargo.lock generated Normal file
View File

@ -0,0 +1,780 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "abi_stable"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69d6512d3eb05ffe5004c59c206de7f99c34951504056ce23fc953842f12c445"
dependencies = [
"abi_stable_derive",
"abi_stable_shared",
"const_panic",
"core_extensions",
"crossbeam-channel",
"generational-arena",
"libloading",
"lock_api",
"parking_lot",
"paste",
"repr_offset",
"rustc_version",
"serde",
"serde_derive",
"serde_json",
]
[[package]]
name = "abi_stable_derive"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7178468b407a4ee10e881bc7a328a65e739f0863615cca4429d43916b05e898"
dependencies = [
"abi_stable_shared",
"as_derive_utils",
"core_extensions",
"proc-macro2",
"quote",
"rustc_version",
"syn 1.0.109",
"typed-arena",
]
[[package]]
name = "abi_stable_shared"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2b5df7688c123e63f4d4d649cba63f2967ba7f7861b1664fca3f77d3dad2b63"
dependencies = [
"core_extensions",
]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[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 = "anyhow"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "as_derive_utils"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff3c96645900a44cf11941c111bd08a6573b0e2f9f69bc9264b179d8fae753c4"
dependencies = [
"core_extensions",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bumpalo"
version = "3.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cc"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"serde",
"wasm-bindgen",
"windows-targets 0.52.0",
]
[[package]]
name = "const_panic"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6051f239ecec86fde3410901ab7860d458d160371533842974fc61f96d15879b"
[[package]]
name = "core-foundation-sys"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]]
name = "core_extensions"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92c71dc07c9721607e7a16108336048ee978c3a8b129294534272e8bac96c0ee"
dependencies = [
"core_extensions_proc_macros",
]
[[package]]
name = "core_extensions_proc_macros"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69f3b219d28b6e3b4ac87bc1fc522e0803ab22e055da177bff0068c4150c61a6"
[[package]]
name = "crc32fast"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
"cfg-if",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
[[package]]
name = "etws_loader"
version = "0.1.0"
dependencies = [
"abi_stable",
"anyhow",
"byteorder",
"chrono",
"flate2",
"nom",
"nom-derive",
"num-traits",
"radarg_plugin_interface",
"serde",
"serde_json",
"thiserror",
]
[[package]]
name = "flate2"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]]
name = "generational-arena"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877e94aff08e743b651baaea359664321055749b398adff8740a7399af7796e7"
dependencies = [
"cfg-if",
]
[[package]]
name = "iana-time-zone"
version = "0.1.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[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 = "itoa"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "js-sys"
version = "0.3.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "libc"
version = "0.2.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
[[package]]
name = "libloading"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"winapi",
]
[[package]]
name = "lock_api"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "memchr"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
dependencies = [
"adler",
]
[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]]
name = "nom-derive"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ff943d68b88d0b87a6e0d58615e8fa07f9fd5a1319fa0a72efc1f62275c79a7"
dependencies = [
"nom",
"nom-derive-impl",
"rustversion",
]
[[package]]
name = "nom-derive-impl"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd0b9a93a84b0d3ec3e70e02d332dc33ac6dfac9cde63e17fcb77172dededa62"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "num-traits"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
dependencies = [
"autocfg",
]
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "parking_lot"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets 0.48.5",
]
[[package]]
name = "paste"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]]
name = "proc-macro2"
version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
[[package]]
name = "radarg_plugin_interface"
version = "0.1.0"
dependencies = [
"abi_stable",
]
[[package]]
name = "redox_syscall"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
"bitflags",
]
[[package]]
name = "repr_offset"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb1070755bd29dffc19d0971cab794e607839ba2ef4b69a9e6fbc8733c1b72ea"
dependencies = [
"tstr",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
]
[[package]]
name = "rustversion"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
[[package]]
name = "ryu"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
[[package]]
name = "serde"
version = "1.0.196"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.196"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
name = "serde_json"
version = "1.0.112"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d1bd37ce2324cf3bf85e5a25f96eb4baf0d5aa6eba43e7ae8958870c4ec48ed"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "smallvec"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thiserror"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
name = "tstr"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cca3264971090dec0feef3b455a3c178f02762f7550cf4592991ac64b3be2d7e"
dependencies = [
"tstr_proc_macros",
]
[[package]]
name = "tstr_proc_macros"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78122066b0cb818b8afd08f7ed22f7fdbc3e90815035726f0840d0d26c0747a"
[[package]]
name = "typed-arena"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "wasm-bindgen"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.48",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b"
[[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-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[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.0",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
]
[[package]]
name = "windows-targets"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm 0.52.0",
"windows_aarch64_msvc 0.52.0",
"windows_i686_gnu 0.52.0",
"windows_i686_msvc 0.52.0",
"windows_x86_64_gnu 0.52.0",
"windows_x86_64_gnullvm 0.52.0",
"windows_x86_64_msvc 0.52.0",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"

26
etws_loader/Cargo.toml Normal file
View File

@ -0,0 +1,26 @@
[package]
name = "etws_loader"
version = "0.1.0"
authors = ["tsuki <tsuki@keitsuki.top>"]
edition = "2021"
[dependencies]
abi_stable = "*"
anyhow = "1.0.79"
byteorder = "1.5.0"
chrono = {version="0.4.33", features=["serde"]}
flate2 = "1.0.28"
nom = "7.1.3"
nom-derive = "0.10.1"
num-traits = "0.2.17"
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.112"
thiserror = "1.0.56"
[dependencies.radarg_plugin_interface]
version="0.1"
path="../radarg_plugin_interface"
[lib]
name = "etws_loader"
crate-type = ["cdylib",'rlib']

14
etws_loader/src/error.rs Normal file
View File

@ -0,0 +1,14 @@
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ETWSError {
#[error("IO Error")]
IOError {
#[from]
source: std::io::Error,
},
#[error("Format Error")]
FormatError {
#[from]
source: anyhow::Error,
},
}

148
etws_loader/src/lib.rs Normal file
View File

@ -0,0 +1,148 @@
mod error;
mod parser;
use abi_stable::{
export_root_module,
prefix_type::PrefixTypeTrait,
sabi_extern_fn,
sabi_trait::prelude::TD_Opaque,
std_types::{
RNone, ROk,
ROption::RSome,
RResult::{self, RErr},
RStr, RString, RVec,
},
};
use parser::{Record, ValueResult};
use radarg_plugin_interface::{
CoordType, Error, Plugin, PluginId, PluginMod, PluginMod_Ref, PluginResult, PluginResultType,
PluginType, Plugin_TO,
};
#[export_root_module]
fn instantiate_root_module() -> PluginMod_Ref {
PluginMod { new }.leak_into_prefix()
}
struct ETWSLoader {
id: PluginId,
}
impl Plugin for ETWSLoader {
fn plugin_id(&self) -> &PluginId {
&self.id
}
fn load(&self, path: RStr<'_>) -> RResult<PluginResult, Error> where {
if let Ok(record) = Record::parse_from_path(path.to_string()) {
let result_blocks = record
.blocks
.into_iter()
.map(|b| {
let (dimension_len, data) = match b.data {
ValueResult::F32(data) => (
data.len(),
radarg_plugin_interface::VecResult::F32(RVec::from(data)),
),
ValueResult::F64(data) => (
data.len(),
radarg_plugin_interface::VecResult::F64(RVec::from(data)),
),
ValueResult::I32(data) => (
data.len(),
radarg_plugin_interface::VecResult::I32(RVec::from(data)),
),
ValueResult::U32(data) => (
data.len(),
radarg_plugin_interface::VecResult::U32(RVec::from(data)),
),
ValueResult::I64(data) => (
data.len(),
radarg_plugin_interface::VecResult::I64(RVec::from(data)),
),
ValueResult::U64(data) => (
data.len(),
radarg_plugin_interface::VecResult::U64(RVec::from(data)),
),
ValueResult::I8(data) => (
data.len(),
radarg_plugin_interface::VecResult::I8(RVec::from(data)),
),
ValueResult::U8(data) => (
data.len(),
radarg_plugin_interface::VecResult::U8(RVec::from(data)),
),
};
let dimension_des = b.info.dimension_des;
let c = if dimension_des.contains(&format!("lat")) {
CoordType::Cartesian
} else if dimension_des.contains(&format!("ele"))
|| dimension_des.contains(&format!("elevation"))
{
CoordType::Polar
} else {
CoordType::Other
};
radarg_plugin_interface::Block {
data: data,
shape: radarg_plugin_interface::DataShape::Vector,
size: RVec::from(b.info.dimension_size)
.into_iter()
.map(|p| p as usize)
.collect::<RVec<_>>(),
datetime: RNone,
dimensions: RVec::from(vec![RString::from("time")]),
coord_type: c,
dimension_values: RVec::from(
b.info
.dimension_values
.into_iter()
.map(|p| RVec::from(p))
.collect::<Vec<_>>(),
),
fill_value: b.info.fill_value,
data_type: PluginResultType::DBZ,
}
})
.collect::<RVec<_>>();
ROk(PluginResult {
datetime: RString::from(record.filetime.format("%Y%m%d%H%M").to_string()),
blocks: result_blocks,
})
} else {
RErr(Error::UnsupportedFormat)
}
}
fn plugin_info(&self) -> radarg_plugin_interface::PluginInfo where {
radarg_plugin_interface::PluginInfo {
name: "ETWS_Loader".into(),
version: "0.1.0".into(),
author: "Tsuki".into(),
description: RSome("ETWS Loader".into()),
url: RSome("https://keitsuki.club".into()),
}
}
}
#[sabi_extern_fn]
pub fn new(plugin_id: PluginId) -> RResult<PluginType, Error> {
let this = ETWSLoader { id: plugin_id };
ROk(Plugin_TO::from_value(this, TD_Opaque))
}
// 测试模块
#[cfg(test)]
mod tests {
// 导入外部作用域中的所有项
use super::*;
// 一个简单的测试
#[test]
fn test() {
let result =
Record::parse_from_path("/Users/ruomu/Documents/ZJSXAA_20230627163200_FR.dat.gz")
.unwrap();
}
}

504
etws_loader/src/parser.rs Normal file
View File

@ -0,0 +1,504 @@
use crate::error::ETWSError;
use byteorder::{BigEndian, ByteOrder, LittleEndian};
use chrono::{DateTime, Utc};
use flate2::read::GzDecoder;
use nom::{
bytes::complete::{tag, take},
multi::count,
IResult,
};
use nom_derive::*;
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::{self, Read, Write};
use std::path::Path;
pub enum ValueResult {
I64(Vec<i64>),
F64(Vec<f64>),
I32(Vec<i32>),
F32(Vec<f32>),
U64(Vec<u64>),
U32(Vec<u32>),
I8(Vec<i8>),
U8(Vec<u8>),
}
enum ValueTypes {
I64,
F64,
I32,
F32,
U64,
U32,
I8,
U8,
}
#[derive(Clone, Copy)]
enum Order {
BigEndian,
LittleEndian,
}
pub struct Record {
pub filetime: DateTime<Utc>,
pub blocks: Vec<ParsedBlock>, // Fill in generic types appropriately
}
impl Record {
pub fn parse_from_path(path: impl AsRef<Path>) -> Result<Self, ETWSError> {
let path = path.as_ref();
if !(path.ends_with(".dat") || !path.ends_with(".dat.gz")) {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"Invalid file extension",
)
.into());
}
if !path.exists() {
return Err(std::io::Error::new(std::io::ErrorKind::NotFound, "File not found").into());
}
let mut file = File::open(path)?;
let binary_data = if path.extension().unwrap() == "gz" {
let mut result: Vec<u8> = Vec::new();
let mut decoder = GzDecoder::new(file);
decoder.read_to_end(&mut result)?;
result
} else {
let mut result = Vec::new();
file.read_to_end(&mut result)?;
result
};
let (_, parsed) =
Self::_parse(binary_data.as_slice()).map_err(|_| anyhow::Error::msg("Parse error"))?;
Ok(Record {
filetime: Utc::now(),
blocks: parsed,
})
}
fn _parse(binary_data: &[u8]) -> IResult<&[u8], Vec<ParsedBlock>> {
let start_tag = b"UNI_DATA";
let (input, _) = tag(start_tag)(binary_data)?;
let (input, order) = Self::_parse_split_fn(input, 8, 8, Self::_parse_order)?;
let (input, hlen) = take(4usize)(input)?;
let hlen = match order {
Order::BigEndian => BigEndian::read_u32(hlen),
_ => LittleEndian::read_u32(hlen),
};
let (input, record_info) = Self::_parse_split_fn(input, 0, 8, |input| {
let (input, p) = take(hlen)(input)?;
let p: RecordInfo = serde_json::from_slice(p).unwrap();
Ok((input, p))
})?;
let (input, blocks) =
count(Self::_parse_block_fn(order), record_info.block_num as usize)(input)?;
Ok((input, blocks))
}
fn _parse_order(input: &[u8]) -> IResult<&[u8], Order> {
let (input, order) = take(4usize)(input)?;
let result = if order == b"LEND" {
Order::LittleEndian
} else {
Order::BigEndian
};
let (input, _) = take(4usize)(input)?;
Ok((input, result))
}
fn _parse_split(input: &[u8], s: usize, fore: usize, after: usize) -> IResult<&[u8], &[u8]> {
let (input, _) = take(fore)(input)?;
let (input, result) = take(s)(input)?;
let (input, _) = take(after)(input)?;
Ok((input, result))
}
fn _parse_split_fn<E, F: Fn(&[u8]) -> IResult<&[u8], E>>(
input: &[u8],
fore: usize,
after: usize,
f: F,
) -> IResult<&[u8], E> {
let (input, _) = take(fore)(input)?;
let (input, result) = (f)(input)?;
let (input, _) = take(after)(input)?;
Ok((input, result))
}
fn _parse_block_fn(order: Order) -> impl FnMut(&[u8]) -> IResult<&[u8], ParsedBlock> {
move |input| Self::_parse_split_fn(input, 0, 0, |input| Self::_parse_block(input, order))
}
fn _parse_block(input: &[u8], order: Order) -> IResult<&[u8], ParsedBlock> {
let (input, _) = take(8usize)(input)?;
let (input, hlen1) = Self::_parse_u32(input, order)?;
let (input, block_info) = Self::_parse_split_fn(input, 0, 8, |input| {
let (input, p) = take(hlen1)(input)?;
let p: BlockJsonInfo = serde_json::from_slice(p).unwrap();
Ok((input, p))
})?;
let (input, _) = take(8usize)(input)?; // skip 8 bytes
let (input, hlen2) = Self::_parse_u32(input, order)?;
let dimension_size = block_info.dimension_size.clone();
let size = dimension_size.iter().fold(1, |acc, x| acc * x) as usize;
let value_type = block_info.value_type.clone();
let value_type = Self::_parse_type(&value_type);
let (input, data) = Self::_parse_matrix(
input,
value_type,
order,
size,
block_info.value_offset,
block_info.value_scale,
block_info.fill_value,
)?;
Ok((
input,
ParsedBlock {
info: block_info,
data,
},
))
}
fn _parse_i32(input: &[u8], order: Order) -> IResult<&[u8], i32> {
let (input, hlen) = take(4usize)(input)?;
let hlen = match order {
Order::BigEndian => BigEndian::read_i32(hlen),
_ => LittleEndian::read_i32(hlen),
};
Ok((input, hlen))
}
fn _parse_u32(input: &[u8], order: Order) -> IResult<&[u8], u32> {
let (input, hlen) = take(4usize)(input)?;
let hlen = match order {
Order::BigEndian => BigEndian::read_u32(hlen),
_ => LittleEndian::read_u32(hlen),
};
Ok((input, hlen))
}
fn _parse_i64(input: &[u8], order: Order) -> IResult<&[u8], i64> {
let (input, hlen) = take(8usize)(input)?;
let hlen = match order {
Order::BigEndian => BigEndian::read_i64(hlen),
_ => LittleEndian::read_i64(hlen),
};
Ok((input, hlen))
}
fn _parse_u64(input: &[u8], order: Order) -> IResult<&[u8], u64> {
let (input, hlen) = take(8usize)(input)?;
let hlen = match order {
Order::BigEndian => BigEndian::read_u64(hlen),
_ => LittleEndian::read_u64(hlen),
};
Ok((input, hlen))
}
fn _parse_matrix(
input: &[u8],
type_: ValueTypes,
order: Order,
len: usize,
offset: f32,
scale: f32,
fill_value: f64,
) -> IResult<&[u8], ValueResult> {
use std::mem;
let need_trans = offset != 0.0 || scale != 1.0;
let trans_to_bigger = offset.trunc() != offset || scale != 1.0;
match type_ {
ValueTypes::I64 => {
let ratio = mem::size_of::<i64>() / mem::size_of::<u8>();
let (input, result) = take(len * ratio)(input)?;
let result = unsafe {
let ptr = result.as_ptr() as *const i64;
let slice = std::slice::from_raw_parts(ptr, len);
let slice = slice.to_vec();
if trans_to_bigger {
let offset = offset as f32;
ValueResult::F32(
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p as f32 - offset / scale)
.collect::<Vec<f32>>(),
)
} else {
ValueResult::I64(if need_trans {
let offset = offset as i64;
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p - offset)
.collect::<Vec<i64>>()
} else {
slice
})
}
};
Ok((input, result))
}
ValueTypes::F64 => {
let ratio = mem::size_of::<f64>() / mem::size_of::<u8>();
let (input, result) = take(len * ratio)(input)?;
let result = unsafe {
let ptr = result.as_ptr() as *const f64;
let slice = std::slice::from_raw_parts(ptr, len);
let slice = slice.to_vec();
ValueResult::F64(if need_trans {
let offset = offset as f64;
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p - offset / scale as f64)
.collect::<Vec<f64>>()
} else {
slice
})
};
Ok((input, result))
}
ValueTypes::I32 => {
let ratio = mem::size_of::<i32>() / mem::size_of::<u8>();
let (input, result) = take(len * ratio)(input)?;
let result = unsafe {
let ptr = result.as_ptr() as *const i32;
let slice = std::slice::from_raw_parts(ptr, len);
let slice = slice.to_vec();
if trans_to_bigger {
let offset = offset as f32;
ValueResult::F32(
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p as f32 - offset / scale)
.collect::<Vec<f32>>(),
)
} else {
ValueResult::I32(if need_trans {
let offset = offset as i32;
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p - offset)
.collect::<Vec<i32>>()
} else {
slice
})
}
};
Ok((input, result))
}
ValueTypes::U32 => {
let ratio = mem::size_of::<u32>() / mem::size_of::<u8>();
let (input, result) = take(len * ratio)(input)?;
let result = unsafe {
let ptr = result.as_ptr() as *const u32;
let slice = std::slice::from_raw_parts(ptr, len);
let slice = slice.to_vec();
if trans_to_bigger {
let offset = offset as f32;
ValueResult::F32(
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p as f32 - offset / scale)
.collect::<Vec<f32>>(),
)
} else {
ValueResult::U32(if need_trans {
let offset = offset as u32;
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p - offset)
.collect::<Vec<u32>>()
} else {
slice
})
}
};
Ok((input, result))
}
ValueTypes::F32 => {
let ratio = mem::size_of::<f32>() / mem::size_of::<u8>();
let (input, result) = take(len * ratio)(input)?;
let result = unsafe {
let ptr = result.as_ptr() as *const f32;
let slice = std::slice::from_raw_parts(ptr, len);
let slice = slice.to_vec();
ValueResult::F32(if need_trans {
let offset = offset as f32;
slice
.into_iter()
.map(|p| p - offset / scale)
.collect::<Vec<f32>>()
} else {
slice
})
};
Ok((input, result))
}
ValueTypes::U64 => {
let ratio = mem::size_of::<u64>() / mem::size_of::<u8>();
let (input, result) = take(len * ratio)(input)?;
let result = unsafe {
let ptr = result.as_ptr() as *const u64;
let slice = std::slice::from_raw_parts(ptr, len);
let slice = slice.to_vec();
if trans_to_bigger {
let offset = offset as f64;
let scale = scale as f64;
ValueResult::F64(
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p as f64 - offset / scale)
.collect::<Vec<f64>>(),
)
} else {
ValueResult::U64(if need_trans {
let offset = offset as u64;
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p - offset)
.collect::<Vec<u64>>()
} else {
slice
})
}
};
Ok((input, result))
}
ValueTypes::I8 => {
let (input, result) = take(len)(input)?;
let result = unsafe {
let ptr = result.as_ptr() as *const i8;
let slice = std::slice::from_raw_parts(ptr, len);
let slice = slice.to_vec();
if trans_to_bigger {
let offset = offset as f32;
ValueResult::F32(
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p as f32 - offset / scale)
.collect::<Vec<f32>>(),
)
} else {
ValueResult::I8(if need_trans {
let offset = offset as i8;
slice
.into_iter()
.filter(|p| *p as f64 != fill_value)
.map(|p| p - offset)
.collect::<Vec<i8>>()
} else {
slice
})
}
};
Ok((input, result))
}
ValueTypes::U8 => {
let (input, slice) = take(len)(input)?;
let slice = slice.to_vec();
let result = if trans_to_bigger {
let offset = offset as f32;
ValueResult::F32(
slice
.into_iter()
.map(|p| p as f32 - offset / scale)
.collect::<Vec<f32>>(),
)
} else {
ValueResult::U8(if need_trans {
let offset = offset as u8;
slice.into_iter().map(|p| p - offset).collect::<Vec<u8>>()
} else {
slice
})
};
Ok((input, result))
}
}
}
fn _parse_type<'a>(type_str: &'a str) -> ValueTypes {
match type_str {
"b" => ValueTypes::I8,
"B" => ValueTypes::U8,
"i" => ValueTypes::I32,
"I" => ValueTypes::U32,
"f" => ValueTypes::F32,
"d" => ValueTypes::F64,
_ => panic!("Invalid type"),
}
}
}
#[derive(Serialize, Deserialize, Debug)]
struct RecordInfo {
file_time: String,
block_num: i32,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct BlockJsonInfo {
pub value_name: String,
pub value_des: String,
pub value_type: String,
pub dimension_size: Vec<u64>,
pub dimension: usize,
pub dimension_des: Vec<String>,
pub dimension_start: Vec<f64>,
pub dimension_end: Vec<f64>,
pub dimension_values: Vec<Vec<f64>>,
pub fill_value: f64,
pub value_scale: f32,
pub value_offset: f32,
}
pub struct ParsedBlock {
pub info: BlockJsonInfo,
pub data: ValueResult,
}

View File

@ -0,0 +1 @@
{"rustc_fingerprint":8475780184195034948,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/ruomu/.rustup/toolchains/nightly-x86_64-apple-darwin\noff\npacked\nunpacked\n___\ndebug_assertions\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"ssse3\"\ntarget_has_atomic\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.74.0-nightly (8142a319e 2023-09-13)\nbinary: rustc\ncommit-hash: 8142a319ed5c1d1f96e5a1881a6546e463b77c8f\ncommit-date: 2023-09-13\nhost: x86_64-apple-darwin\nrelease: 1.74.0-nightly\nLLVM version: 17.0.0\n","stderr":""}},"successes":{}}

View File

@ -0,0 +1,3 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by cargo.
# For information about cache directory tags see https://bford.info/cachedir/

View File

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
b64d46ab3ab7091c

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"channels\", \"crossbeam-channel\", \"default\", \"serde_json\"]","target":701087079898301699,"profile":16209747773763956088,"path":3483666061643384809,"deps":[[75838619123750943,"const_panic",false,12691611242057761700],[376510933113901675,"generational_arena",false,13937842665477031649],[511886667611543159,"repr_offset",false,16828736502814221855],[2334936782960947306,"lock_api",false,1814916025853382219],[3470807962260834726,"serde",false,2576951082755195512],[4860695056264358199,"libloading",false,5824429438708793824],[6147374319788932929,"serde_json",false,11236813085233191832],[6343765419002388362,"serde_derive",false,9627720618521990881],[7131157336065139194,"parking_lot",false,5851677261104018123],[12155930792469046819,"abi_stable_shared",false,1817612520392020941],[13893895338837028091,"abi_stable_derive",false,8573669010448238979],[15340987198089805406,"paste",false,12489583535308820193],[15600852585069698717,"crossbeam_channel",false,15516608726300844274],[15864077453136584493,"core_extensions",false,3951692198506941310]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/abi_stable-9eb39852acc98e54/dep-lib-abi_stable"}}],"rustflags":[],"metadata":9435643437466700796,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
f51585f9eca8801c

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"channels\", \"crossbeam-channel\", \"default\", \"serde_json\"]","target":701087079898301699,"profile":16209747773763956088,"path":3483666061643384809,"deps":[[75838619123750943,"const_panic",false,12691611242057761700],[376510933113901675,"generational_arena",false,13937842665477031649],[511886667611543159,"repr_offset",false,16828736502814221855],[2334936782960947306,"lock_api",false,1814916025853382219],[3470807962260834726,"serde",false,9399666183325579216],[4860695056264358199,"libloading",false,5824429438708793824],[6147374319788932929,"serde_json",false,13097563080143870957],[6343765419002388362,"serde_derive",false,2362000623912333219],[7131157336065139194,"parking_lot",false,5851677261104018123],[12155930792469046819,"abi_stable_shared",false,1817612520392020941],[13893895338837028091,"abi_stable_derive",false,8573669010448238979],[15340987198089805406,"paste",false,12489583535308820193],[15600852585069698717,"crossbeam_channel",false,15516608726300844274],[15864077453136584493,"core_extensions",false,3951692198506941310]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/abi_stable-b1a6858d85dd1136/dep-lib-abi_stable"}}],"rustflags":[],"metadata":9435643437466700796,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[]","target":9605427451028622447,"profile":13904479058746662784,"path":1099273460411680649,"deps":[[9618700007800273094,"quote",false,6379146116811555066],[12155930792469046819,"abi_stable_shared",false,11203920157373099594],[13139357714157917144,"as_derive_utils",false,5632803739914540072],[13655734084378430773,"typed_arena",false,7437203902841699976],[15864077453136584493,"core_extensions",false,3709068585806090695],[16285336375947054926,"proc_macro2",false,16188898386888559878],[17143850428905299221,"syn",false,1384463259395083165]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/abi_stable_derive-fde60242f08ff382/dep-lib-abi_stable_derive"}}],"rustflags":[],"metadata":12997815436956875762,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[]","target":12698902921255915372,"profile":16209747773763956088,"path":6889060375905054719,"deps":[[15864077453136584493,"core_extensions",false,3709068585806090695]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/abi_stable_shared-7467ad0bb26bb0d7/dep-lib-abi_stable_shared"}}],"rustflags":[],"metadata":12997815436956875762,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[]","target":12698902921255915372,"profile":16209747773763956088,"path":6889060375905054719,"deps":[[15864077453136584493,"core_extensions",false,3951692198506941310]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/abi_stable_shared-8268aabae3931dea/dep-lib-abi_stable_shared"}}],"rustflags":[],"metadata":12997815436956875762,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
5ab9b882d56ac979

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[]","target":4568273168033506088,"profile":16209747773763956088,"path":6636319934073535045,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/adler-eda12c9f4b25ced4/dep-lib-adler"}}],"rustflags":[],"metadata":10673633425720882208,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
8a60dd2393e4805c

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"default\", \"std\"]","target":18338613112069040866,"profile":16209747773763956088,"path":12467799346501152726,"deps":[[12732307821348191974,"build_script_build",false,13267540570474358888]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/anyhow-4471721bd4161c6d/dep-lib-anyhow"}}],"rustflags":[],"metadata":17154292783084528516,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"","target":0,"profile":0,"path":0,"deps":[[12732307821348191974,"build_script_build",false,12627723519205405700]],"local":[{"RerunIfChanged":{"output":"debug/build/anyhow-954605a42df9fdf6/output","paths":["build/probe.rs"]}}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0}

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"default\", \"std\"]","target":2297296889237502566,"profile":13904479058746662784,"path":3351817288307809929,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/anyhow-a70c9949da6a082d/dep-build-script-build-script-build"}}],"rustflags":[],"metadata":17154292783084528516,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[]","target":1400909187434544587,"profile":13904479058746662784,"path":6682596017441764228,"deps":[[9618700007800273094,"quote",false,6379146116811555066],[15864077453136584493,"core_extensions",false,3709068585806090695],[16285336375947054926,"proc_macro2",false,16188898386888559878],[17143850428905299221,"syn",false,1384463259395083165]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/as_derive_utils-d41208c8ed09bbf4/dep-lib-as_derive_utils"}}],"rustflags":[],"metadata":7370422634555397116,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
69f94948ff09b377

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[]","target":14886237245231788030,"profile":13904479058746662784,"path":14015843474043098663,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/autocfg-12a56df7b7c0b956/dep-lib-autocfg"}}],"rustflags":[],"metadata":13102859075309379048,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
a29097e770176155

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"default\", \"std\"]","target":18335588937564793828,"profile":16209747773763956088,"path":8958115263489412291,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/byteorder-444b7f7a82990a29/dep-lib-byteorder"}}],"rustflags":[],"metadata":5398730104718078656,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
1c4cb16f379816cc

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[]","target":10623512480563079566,"profile":16209747773763956088,"path":17367574703338398341,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/cfg-if-f6104691743a3683/dep-lib-cfg-if"}}],"rustflags":[],"metadata":8462187951337715540,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
1984459a51c0dfbb

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"alloc\", \"android-tzdata\", \"clock\", \"default\", \"iana-time-zone\", \"js-sys\", \"now\", \"oldtime\", \"std\", \"wasm-bindgen\", \"wasmbind\", \"winapi\", \"windows-targets\"]","target":11745563112108967737,"profile":16209747773763956088,"path":11247779219060438002,"deps":[[11138931377059941435,"num_traits",false,12000539450629646242],[14035281238073165402,"iana_time_zone",false,5697753900861887262]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/chrono-71ba641e27f18940/dep-lib-chrono"}}],"rustflags":[],"metadata":9803565982372010724,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
29415f43220f4d26

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"alloc\", \"android-tzdata\", \"clock\", \"default\", \"iana-time-zone\", \"js-sys\", \"now\", \"oldtime\", \"serde\", \"std\", \"wasm-bindgen\", \"wasmbind\", \"winapi\", \"windows-targets\"]","target":11745563112108967737,"profile":16209747773763956088,"path":11247779219060438002,"deps":[[3470807962260834726,"serde",false,2576951082755195512],[11138931377059941435,"num_traits",false,12000539450629646242],[14035281238073165402,"iana_time_zone",false,5697753900861887262]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/chrono-c4e48e62783c44d3/dep-lib-chrono"}}],"rustflags":[],"metadata":9803565982372010724,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
f3f6bc4be737c711

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"alloc\", \"android-tzdata\", \"clock\", \"default\", \"iana-time-zone\", \"js-sys\", \"now\", \"oldtime\", \"serde\", \"std\", \"wasm-bindgen\", \"wasmbind\", \"winapi\", \"windows-targets\"]","target":11745563112108967737,"profile":16209747773763956088,"path":11247779219060438002,"deps":[[3470807962260834726,"serde",false,9399666183325579216],[11138931377059941435,"num_traits",false,12000539450629646242],[14035281238073165402,"iana_time_zone",false,5697753900861887262]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/chrono-f6a1c6bb5be42a2d/dep-lib-chrono"}}],"rustflags":[],"metadata":9803565982372010724,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
a403357e2ea921b0

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[]","target":5894236464472984878,"profile":16209747773763956088,"path":5898848853681656166,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/const_panic-5e4aff3d8b836cc1/dep-lib-const_panic"}}],"rustflags":[],"metadata":16622668056747015544,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"default\", \"link\"]","target":8020353244595097195,"profile":16209747773763956088,"path":6973137832163423786,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/core-foundation-sys-e40f6c3da6ccd76a/dep-lib-core-foundation-sys"}}],"rustflags":[],"metadata":7246173313922784557,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"alloc\", \"iterators\", \"self_ops\", \"slices\", \"std\", \"type_level_bool\"]","target":18436429881084749908,"profile":13904479058746662784,"path":5901368123383174012,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/core_extensions-434aa31566851167/dep-lib-core_extensions"}}],"rustflags":[],"metadata":3830408521381924977,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"alloc\", \"core_extensions_proc_macros\", \"enable_proc_macro_crate\", \"iterators\", \"macro_utils\", \"self_ops\", \"slices\", \"std\", \"type_asserts\", \"type_identity\", \"type_level_bool\", \"void\"]","target":18436429881084749908,"profile":16209747773763956088,"path":5901368123383174012,"deps":[[2740732257086883650,"core_extensions_proc_macros",false,13895181402411839407]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/core_extensions-841f75e9f60fa115/dep-lib-core_extensions"}}],"rustflags":[],"metadata":3830408521381924977,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"macro_utils\"]","target":4366471891106971943,"profile":13904479058746662784,"path":4206779001807000561,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/core_extensions_proc_macros-48cf22fe30e64472/dep-lib-core_extensions_proc_macros"}}],"rustflags":[],"metadata":7494240123924969357,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"","target":0,"profile":0,"path":0,"deps":[[16212523666406317869,"build_script_build",false,15818357371452694659]],"local":[{"RerunIfChanged":{"output":"debug/build/crc32fast-912e6aaa021e696d/output","paths":["build.rs"]}}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0}

View File

@ -0,0 +1 @@
{"rustc":2034204546556879275,"features":"[\"default\", \"std\"]","target":8188216131759486267,"profile":13904479058746662784,"path":14227286011977300793,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/crc32fast-de9bc9254e076c8e/dep-build-script-build-script-build"}}],"rustflags":[],"metadata":1784606463606881981,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

Some files were not shown because too many files have changed in this diff Show More