summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-04-03 21:31:55 -0400
committerLLLL Colonq <llll@colonq>2025-04-03 21:31:55 -0400
commit4ba01304ede403816de069357ca5aeff535ccac7 (patch)
tree9dd69c0ac84ab788e6cb95543cc5962907b9861d
parent1e0f17abbc9ae45aee8d9dde875fad3aabcac18b (diff)
Binary saves
-rw-r--r--Cargo.lock295
-rw-r--r--Cargo.toml8
-rw-r--r--src/lib.rs7
-rw-r--r--src/save.rs11
4 files changed, 52 insertions, 269 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 95437be..58884c5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
-version = 3
+version = 4
[[package]]
name = "ab_glyph"
@@ -232,6 +232,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7"
[[package]]
+name = "bincode"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740"
+dependencies = [
+ "bincode_derive",
+ "serde",
+ "unty",
+]
+
+[[package]]
+name = "bincode_derive"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09"
+dependencies = [
+ "virtue",
+]
+
+[[package]]
name = "bindgen"
version = "0.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -256,12 +276,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2c54ff287cfc0a34f38a6b832ea1bd8e448a330b3e40a50859e6488bee07f22"
[[package]]
-name = "bit_field"
-version = "0.10.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
-
-[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -411,12 +425,6 @@ dependencies = [
]
[[package]]
-name = "color_quant"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
-
-[[package]]
name = "colorchoice"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -610,12 +618,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
[[package]]
-name = "crunchy"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
-
-[[package]]
name = "cursor-icon"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -754,22 +756,6 @@ dependencies = [
]
[[package]]
-name = "exr"
-version = "1.72.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4"
-dependencies = [
- "bit_field",
- "flume",
- "half",
- "lebe",
- "miniz_oxide",
- "rayon-core",
- "smallvec",
- "zune-inflate",
-]
-
-[[package]]
name = "extended"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -811,15 +797,6 @@ dependencies = [
]
[[package]]
-name = "flume"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181"
-dependencies = [
- "spin",
-]
-
-[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -955,16 +932,6 @@ dependencies = [
]
[[package]]
-name = "gif"
-version = "0.13.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2"
-dependencies = [
- "color_quant",
- "weezl",
-]
-
-[[package]]
name = "gimli"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -992,9 +959,9 @@ dependencies = [
[[package]]
name = "glob"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
+checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
[[package]]
name = "glow"
@@ -1015,7 +982,7 @@ dependencies = [
"base64 0.13.1",
"byteorder",
"gltf-json",
- "image 0.25.5",
+ "image",
"lazy_static",
"serde_json",
"urlencoding",
@@ -1061,16 +1028,6 @@ dependencies = [
]
[[package]]
-name = "half"
-version = "2.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e"
-dependencies = [
- "cfg-if",
- "crunchy",
-]
-
-[[package]]
name = "hash32"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1257,24 +1214,6 @@ dependencies = [
[[package]]
name = "image"
-version = "0.24.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d"
-dependencies = [
- "bytemuck",
- "byteorder",
- "color_quant",
- "exr",
- "gif",
- "jpeg-decoder",
- "num-traits",
- "png",
- "qoi",
- "tiff",
-]
-
-[[package]]
-name = "image"
version = "0.25.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b"
@@ -1368,15 +1307,6 @@ dependencies = [
]
[[package]]
-name = "jpeg-decoder"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0"
-dependencies = [
- "rayon",
-]
-
-[[package]]
name = "js-sys"
version = "0.3.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1408,12 +1338,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
-name = "lebe"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
-
-[[package]]
name = "libc"
version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1463,16 +1387,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[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.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1878,29 +1792,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
[[package]]
-name = "parking_lot"
-version = "0.12.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
-dependencies = [
- "lock_api",
- "parking_lot_core",
-]
-
-[[package]]
-name = "parking_lot_core"
-version = "0.9.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
-dependencies = [
- "cfg-if",
- "libc",
- "redox_syscall 0.5.8",
- "smallvec",
- "windows-targets 0.52.6",
-]
-
-[[package]]
name = "parry3d"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2027,15 +1918,6 @@ dependencies = [
]
[[package]]
-name = "qoi"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001"
-dependencies = [
- "bytemuck",
-]
-
-[[package]]
name = "quick-xml"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2120,26 +2002,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
[[package]]
-name = "rayon"
-version = "1.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd"
-dependencies = [
- "either",
- "rayon-core",
-]
-
-[[package]]
-name = "rayon-core"
-version = "1.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
-dependencies = [
- "crossbeam-deque",
- "crossbeam-utils",
-]
-
-[[package]]
name = "redox_syscall"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2158,15 +2020,6 @@ dependencies = [
]
[[package]]
-name = "redox_syscall"
-version = "0.5.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
-dependencies = [
- "bitflags 2.6.0",
-]
-
-[[package]]
name = "redox_users"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2406,12 +2259,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
[[package]]
-name = "scopeguard"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
-
-[[package]]
name = "sctk-adwaita"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2513,15 +2360,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
-name = "signal-hook-registry"
-version = "1.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
-dependencies = [
- "libc",
-]
-
-[[package]]
name = "simba"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2625,9 +2463,6 @@ name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
-dependencies = [
- "lock_api",
-]
[[package]]
name = "stable_deref_trait"
@@ -2654,8 +2489,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "815c942ae7ee74737bb00f965fa5b5a2ac2ce7b6c01c0cc169bbeaf7abd5f5a9"
dependencies = [
"lazy_static",
- "symphonia-bundle-flac",
- "symphonia-bundle-mp3",
"symphonia-codec-pcm",
"symphonia-codec-vorbis",
"symphonia-core",
@@ -2665,30 +2498,6 @@ dependencies = [
]
[[package]]
-name = "symphonia-bundle-flac"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "72e34f34298a7308d4397a6c7fbf5b84c5d491231ce3dd379707ba673ab3bd97"
-dependencies = [
- "log",
- "symphonia-core",
- "symphonia-metadata",
- "symphonia-utils-xiph",
-]
-
-[[package]]
-name = "symphonia-bundle-mp3"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c01c2aae70f0f1fb096b6f0ff112a930b1fb3626178fba3ae68b09dce71706d4"
-dependencies = [
- "lazy_static",
- "log",
- "symphonia-core",
- "symphonia-metadata",
-]
-
-[[package]]
name = "symphonia-codec-pcm"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2814,6 +2623,7 @@ name = "teleia"
version = "0.1.0"
dependencies = [
"bimap",
+ "bincode",
"bitflags 2.6.0",
"bytes",
"color-eyre",
@@ -2828,7 +2638,7 @@ dependencies = [
"glfw",
"glow",
"gltf",
- "image 0.24.9",
+ "image",
"js-sys",
"kira",
"log",
@@ -2840,7 +2650,6 @@ dependencies = [
"serde",
"serde_json",
"tobj",
- "tokio",
"tracing-wasm",
"wasm-bindgen",
"wasm-bindgen-futures",
@@ -2912,17 +2721,6 @@ dependencies = [
]
[[package]]
-name = "tiff"
-version = "0.9.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e"
-dependencies = [
- "flate2",
- "jpeg-decoder",
- "weezl",
-]
-
-[[package]]
name = "tiny-skia"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2981,26 +2779,12 @@ dependencies = [
"bytes",
"libc",
"mio",
- "parking_lot",
"pin-project-lite",
- "signal-hook-registry",
"socket2",
- "tokio-macros",
"windows-sys 0.52.0",
]
[[package]]
-name = "tokio-macros"
-version = "2.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
name = "tokio-native-tls"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3177,6 +2961,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
+name = "unty"
+version = "0.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae"
+
+[[package]]
name = "url"
version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3212,6 +3002,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
+name = "virtue"
+version = "0.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1"
+
+[[package]]
name = "walkdir"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3436,12 +3232,6 @@ dependencies = [
]
[[package]]
-name = "weezl"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
-
-[[package]]
name = "wide"
version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3903,15 +3693,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a"
[[package]]
-name = "zune-inflate"
-version = "0.2.54"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02"
-dependencies = [
- "simd-adler32",
-]
-
-[[package]]
name = "zune-jpeg"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 19f7eea..ea4902b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,15 +17,16 @@ opt-level = 2
[dependencies]
glow = {version = "=0.13.1", features = []} # rendering
tobj = "*" # loader for .obj meshes loader
-gltf = {path = "deps/gltf", features = ["extras", "names", "utils"]} # loader for .gltf scenes
+gltf = {path = "deps/gltf", features = ["extras", "import", "names", "utils"]} # loader for .gltf scenes
# gltf = {version = "*", features = ["extras", "names"]} # model loader
-image = "*" # texture loader
+image = { version = "0.25", default-features = false, features = ["jpeg", "png"] } # texture loader
fontdue = "*" # truetype fonts
glam = "0.29" # linear algebra
log = "*" # logging
rand = {version = "=0.8.5", features = ["small_rng"]} # rng
serde = {version = "*", features = ["derive"]} # serialization
serde_json = "*" # serialize JSON
+bincode = {version = "*", features = ["serde"]} # binary serialization
enum-map = "*" # fast maps with enums as keys
bimap = "*" # bijective maps
reqwest = "*" # http requests
@@ -49,7 +50,6 @@ web-sys = { version = "*", features = ["Document", "Window", "Element", "HtmlCan
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
env_logger = "*" # configurable logging to stdout
-tokio = { version = "*", features = ["full"] } # async runtime
glfw = { path = "deps/glfw-rs", features = ["serde"] } # window management
-kira = "=0.9.6" # audio
+kira = { version = "=0.9.6", default-features = false, features = ["cpal", "ogg", "wav"] } # audio
directories = { path = "deps/directories-rs" } # standard system directories \ No newline at end of file
diff --git a/src/lib.rs b/src/lib.rs
index a77ff19..71c1cf6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -56,11 +56,10 @@ where
}
#[cfg(not(target_arch = "wasm32"))]
-pub async fn run<'a, F, G, Fut>(title: &str, w: u32, h: u32, options: Options, gnew: F) -> Erm<()>
+pub fn run<'a, F, G>(title: &str, w: u32, h: u32, options: Options, gnew: F) -> Erm<()>
where
- Fut: std::future::Future<Output = G>,
G: state::Game + 'static,
- F: (Fn(&'a context::Context) -> Fut),
+ F: (Fn(&'a context::Context) -> G),
{
env_logger::Builder::new()
.filter(None, log::LevelFilter::Info)
@@ -121,7 +120,7 @@ where
glfw, window, gl,
w as f32, h as f32, resize,
)));
- let game = Box::leak(Box::new(gnew(ctx).await));
+ let game = Box::leak(Box::new(gnew(ctx)));
let st = Box::leak(Box::new(state::State::new(&ctx)));
unsafe {
diff --git a/src/save.rs b/src/save.rs
index 0f0d20b..3f244cc 100644
--- a/src/save.rs
+++ b/src/save.rs
@@ -26,8 +26,10 @@ pub fn save<W>(id: &str, data: &W) where W: serde::Serialize {
let pd = directories::ProjectDirs::from("", "milkfat", id).expect("failed to get save directory");
let _ = std::fs::create_dir_all(pd.data_dir());
let path = pd.data_dir().join("teleia.save");
- let file = std::fs::File::create(&path).expect("failed to open save file");
- serde_json::to_writer(file, data).expect("failed to write save file");
+ let mut file = std::fs::File::create(&path).expect("failed to open save file");
+ // serde_json::to_writer(file, data).expect("failed to write save file");
+ bincode::serde::encode_into_std_write(data, &mut file, bincode::config::standard())
+ .expect("failed to write save file");
}
#[cfg(not(target_arch = "wasm32"))]
@@ -35,6 +37,7 @@ pub fn load<W>(id: &str) -> Option<W> where W: serde::de::DeserializeOwned {
let pd = directories::ProjectDirs::from("", "milkfat", id).expect("failed to get save directory");
let _ = std::fs::create_dir_all(pd.data_dir());
let path = pd.data_dir().join("teleia.save");
- let file = std::fs::File::open(&path).ok()?;
- serde_json::from_reader(file).ok()
+ let mut file = std::fs::File::open(&path).ok()?;
+ // serde_json::from_reader(file).ok()
+ bincode::serde::decode_from_std_read(&mut file, bincode::config::standard()).ok()
}