Compare commits
13 Commits
37c7e04820
...
c3a5c5fbb7
Author | SHA1 | Date |
---|---|---|
Savanni D'Gerinel | c3a5c5fbb7 | |
Savanni D'Gerinel | b3be5a1ea9 | |
Savanni D'Gerinel | fad1648063 | |
Savanni D'Gerinel | d40e9bb3d0 | |
Savanni D'Gerinel | 72b62ecb5d | |
Savanni D'Gerinel | 2a2f1048d3 | |
Savanni D'Gerinel | afd10cff66 | |
Savanni D'Gerinel | 132293be00 | |
Savanni D'Gerinel | 9346f4a9b8 | |
Savanni D'Gerinel | 7d6413c91d | |
Savanni D'Gerinel | 782c442a21 | |
Savanni D'Gerinel | a07cfd49a8 | |
Savanni D'Gerinel | 0448eb03de |
|
@ -5,7 +5,7 @@ dist
|
|||
result
|
||||
*.tgz
|
||||
*.tar.gz
|
||||
*.sqlite
|
||||
*.sqlite-shm
|
||||
*.sqlite-wal
|
||||
file-service/*.sqlite
|
||||
file-service/*.sqlite-shm
|
||||
file-service/*.sqlite-wal
|
||||
file-service/var
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"rust-analyzer.showUnlinkedFileNotification": false
|
||||
}
|
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
10
Cargo.toml
|
@ -13,22 +13,18 @@ members = [
|
|||
"dashboard",
|
||||
"emseries",
|
||||
"file-service",
|
||||
"fitnesstrax/core",
|
||||
"fitnesstrax/app",
|
||||
"fluent-ergonomics",
|
||||
"geo-types",
|
||||
"gm-control-panel",
|
||||
"hex-grid",
|
||||
"icon-test",
|
||||
"ifc",
|
||||
"kifu/core",
|
||||
"kifu/gtk",
|
||||
"memorycache",
|
||||
"nom-training",
|
||||
"otg/core",
|
||||
"otg/gtk",
|
||||
"pico-blink",
|
||||
"result-extended",
|
||||
"screenplay",
|
||||
"sgf",
|
||||
"timezone-testing",
|
||||
"tree",
|
||||
"visions/server",
|
||||
]
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
all: test bin
|
||||
|
||||
test: kifu-core/test-oneshot sgf/test-oneshot
|
||||
|
||||
bin: kifu-gtk
|
||||
|
||||
kifu-core/dev:
|
||||
cd kifu/core && make test
|
||||
|
||||
kifu-core/test:
|
||||
cd kifu/core && make test
|
||||
|
||||
kifu-core/test-oneshot:
|
||||
cd kifu/core && make test-oneshot
|
||||
|
||||
kifu-gtk:
|
||||
cd kifu/gtk && make release
|
||||
|
||||
kifu-gtk/dev:
|
||||
cd kifu/gtk && make dev
|
||||
|
||||
kifu-pwa:
|
||||
cd kifu/pwa && make release
|
||||
|
||||
kifu-pwa/dev:
|
||||
pushd kifu/pwa && make dev
|
||||
|
||||
kifu-pwa/server:
|
||||
pushd kifu/pwa && make server
|
|
@ -8,7 +8,7 @@ use az::*;
|
|||
use core::cell::RefCell;
|
||||
use cortex_m::delay::Delay;
|
||||
use embedded_alloc::Heap;
|
||||
use embedded_hal::{blocking::spi::Write, digital::v2::InputPin, digital::v2::OutputPin};
|
||||
use embedded_hal::{blocking::spi::Write, digital::v2::InputPin};
|
||||
use fixed::types::I16F16;
|
||||
use fugit::RateExtU32;
|
||||
use lights_core::{App, BodyPattern, DashboardPattern, Event, Instant, FPS, UI};
|
||||
|
@ -209,7 +209,6 @@ fn main() -> ! {
|
|||
let mut app = App::new(Box::new(ui));
|
||||
|
||||
let mut led_pin = pins.led.into_push_pull_output();
|
||||
led_pin.set_high();
|
||||
|
||||
let mut time = Instant::default();
|
||||
let delay_ms = 1000 / (FPS as u32);
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
RUST_ALL_TARGETS=(
|
||||
"changeset"
|
||||
"config"
|
||||
"config-derive"
|
||||
"coordinates"
|
||||
"cyberpunk-splash"
|
||||
"dashboard"
|
||||
"emseries"
|
||||
"file-service"
|
||||
"fluent-ergonomics"
|
||||
"geo-types"
|
||||
"gm-control-panel"
|
||||
"hex-grid"
|
||||
"ifc"
|
||||
"kifu-core"
|
||||
"kifu-gtk"
|
||||
"memorycache"
|
||||
"nom-training"
|
||||
"result-extended"
|
||||
"screenplay"
|
||||
"sgf"
|
||||
"tree"
|
||||
)
|
||||
|
||||
build_rust_targets() {
|
||||
local CMD=$1
|
||||
local TARGETS=${@/$CMD}
|
||||
|
||||
for target in $TARGETS; do
|
||||
MODULE=$target CMD=$CMD ./builders/rust.sh
|
||||
done
|
||||
}
|
||||
|
||||
build_dist() {
|
||||
local TARGETS=${@/$CMD}
|
||||
|
||||
for target in $TARGETS; do
|
||||
if [ -f $target/dist.sh ]; then
|
||||
build_rust_targets release ${TARGETS[*]}
|
||||
cd $target && ./dist.sh
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
export CARGO=`which cargo`
|
||||
|
||||
if [ -z "${TARGET-}" ]; then
|
||||
TARGET="all"
|
||||
fi
|
||||
|
||||
if [ -z "${CMD-}" ]; then
|
||||
CMD="test release"
|
||||
fi
|
||||
|
||||
if [ "${CMD}" == "clean" ]; then
|
||||
cargo clean
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for cmd in $CMD; do
|
||||
if [ "${CMD}" == "dist" ]; then
|
||||
build_dist $TARGET
|
||||
elif [ "${TARGET}" == "all" ]; then
|
||||
build_rust_targets $cmd ${RUST_ALL_TARGETS[*]}
|
||||
else
|
||||
build_rust_targets $cmd $TARGET
|
||||
fi
|
||||
done
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ ! -z "$MODULE" ]; then
|
||||
MODULE="-p $MODULE"
|
||||
fi
|
||||
|
||||
if [ -z "${PARAMS-}" ]; then
|
||||
PARAMS=""
|
||||
fi
|
||||
|
||||
case $CMD in
|
||||
build)
|
||||
$CARGO build $MODULE $PARAMS
|
||||
;;
|
||||
lint)
|
||||
$CARGO clippy $MODULE $PARAMS -- -Dwarnings
|
||||
;;
|
||||
test)
|
||||
$CARGO test $MODULE $PARAMS
|
||||
;;
|
||||
run)
|
||||
$CARGO run $MODULE $PARAMS
|
||||
;;
|
||||
release)
|
||||
$CARGO clippy $MODULE $PARAMS -- -Dwarnings
|
||||
$CARGO build --release $MODULE $PARAMS
|
||||
$CARGO test --release $MODULE $PARAMS
|
||||
;;
|
||||
clean)
|
||||
$CARGO clean $MODULE
|
||||
;;
|
||||
"")
|
||||
echo "No command specified. Use build | lint | test | run | release | clean"
|
||||
;;
|
||||
*)
|
||||
echo "$CMD is unknown. Use build | lint | test | run | release | clean"
|
||||
;;
|
||||
esac
|
||||
|
|
@ -35,7 +35,7 @@ macro_rules! define_config {
|
|||
$($name($struct)),+
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Config {
|
||||
values: std::collections::HashMap<ConfigName, ConfigOption>,
|
||||
}
|
||||
|
|
|
@ -1,474 +0,0 @@
|
|||
{
|
||||
"registry+https://github.com/rust-lang/crates.io-index#addr2line@0.21.0": "1jx0k3iwyqr8klqbzk6kjvr496yd94aspis10vwsj5wy7gib4c4a",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#adler32@1.2.0": "0d7jq7jsjyhsgbhnfq5fvrlh9j0i9g1fqrl2735ibv5f75yjgqda",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#adler@1.0.2": "1zim79cvzd5yrkzl3nyfx0avijwgk9fqv3yrscdy1cc79ih02qpj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#ahash@0.8.6": "0yn9i8nc6mmv28ig9w3dga571q09vg9f1f650mi5z8phx42r6hli",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#aho-corasick@1.1.2": "1w510wnixvlgimkx1zjbvlxh6xps2vjgfqgwf5a6adlbjp5rv5mj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#allocator-api2@0.2.16": "1iayppgq4wqbfbfcqmsbwgamj0s65012sskfvyx07pxavk3gyhh9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#android-tzdata@0.1.1": "1w7ynjxrfs97xg3qlcdns4kgfpwcdv824g611fq32cag4cdr96g9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#android_system_properties@0.1.5": "04b3wrz12837j7mdczqd95b732gw5q7q66cv4yn4646lvccp57l1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#anstream@0.6.5": "1dm1mdbs1x6y3m3pz0qlamgiskb50i4q859676kx0pz8r8pajr6n",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#anstyle-parse@0.2.3": "134jhzrz89labrdwxxnjxqjdg06qvaflj1wkfnmyapwyldfwcnn7",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#anstyle-query@1.0.2": "0j3na4b1nma39g4x7cwvj009awxckjf3z2vkwhldgka44hqj72g2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#anstyle-wincon@3.0.2": "19v0fv400bmp4niqpzxnhg83vz12mmqv7l2l8vi80qcdxj0lpm8w",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#anstyle@1.0.4": "11yxw02b6parn29s757z96rgiqbn8qy0fk9a3p3bhczm85dhfybh",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#anyhow@1.0.75": "1rmcjkim91c5mw7h9wn8nv0k6x118yz0xg0z1q18svgn42mqqrm4",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-channel@1.9.0": "0dbdlkzlncbibd3ij6y6jmvjd0cmdn48ydcfdpfhw09njd93r5c1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-channel@2.1.1": "1337ywc1paw03rdlwh100kh8pa0zyp0nrlya8bpsn6zdqi5kz8qw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-executor@1.8.0": "0z7rpayidhdqs4sdzjhh26z5155c1n94fycqni9793n4zjz5xbhp",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-global-executor@2.4.1": "1762s45cc134d38rrv0hyp41hv4iv6nmx59vswid2p0il8rvdc85",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-io@1.13.0": "1byj7lpw0ahk6k63sbc9859v68f28hpaab41dxsjj1ggjdfv9i8g",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-io@2.3.1": "0rggn074kbqxxajci1aq14b17gp75rw9l6rpbazcv9q0bc6ap5wg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-lock@2.8.0": "0asq5xdzgp3d5m82y5rg7a0k9q0g95jy6mgc7ivl334x7qlp4wi8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-lock@3.3.0": "0yxflkfw46rad4lv86f59b5z555dlfmg1riz1n8830rgi0qb8d6h",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-std@1.12.0": "0pbgxhyb97h4n0451r26njvr20ywqsbm6y1wjllnp4if82s5nmk2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-task@4.7.0": "16975vx6aqy5yf16fs9xz5vx1zq8mwkzfmykvcilc1j7b6c6xczv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#async-trait@0.1.77": "1adf1jh2yg39rkpmqjqyr9xyd6849p0d95425i6imgbhx0syx069",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#atoi@2.0.0": "0a05h42fggmy7h0ajjv6m7z72l924i7igbx13hk9d8pyign9k3gj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#atomic-waker@1.1.2": "1h5av1lw56m0jf0fd3bchxq8a30xv0b4wv8s4zkp4s0i7mfvs18m",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#atomic-write-file@0.1.2": "0dl4x0srdwjxm3zz3fj1c7m44i3b7mjiad550fqklj1n4bfbxkgd",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#autocfg@0.1.8": "0y4vw4l4izdxq1v0rrhvmlbqvalrqrmk60v1z0dqlgnlbzkl7phd",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#autocfg@1.1.0": "1ylp3cb47ylzabimazvbz9ms6ap784zhb6syaz6c1jqpmcmq0s6l",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#backtrace@0.3.69": "0dsq23dhw4pfndkx2nsa1ml2g31idm7ss7ljxp8d57avygivg290",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#base64@0.21.5": "1y8x2xs9nszj5ix7gg4ycn5a6wy7ca74zxwqri3bdqzdjha6lqrm",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#base64@0.9.3": "0hs62r35bgxslawyrn1vp9rmvrkkm76fqv0vqcwd048vs876r7a8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#base64ct@1.6.0": "0nvdba4jb8aikv60az40x2w1y96sjdq8z3yp09rwzmkhiwv1lg4c",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#bit-set@0.5.3": "1wcm9vxi00ma4rcxkl3pzzjli6ihrpn9cfdi0c5b4cvga2mxs007",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#bit-vec@0.6.3": "1ywqjnv60cdh1slhz67psnp422md6jdliji6alq0gmly2xm9p7rl",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#bit_field@0.10.2": "0qav5rpm4hqc33vmf4vc4r0mh51yjx5vmd9zhih26n9yjs3730nw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#bitflags@1.3.2": "12ki6w8gn1ldq7yz9y680llwk5gmrhrzszaa17g1sbrw2r2qvwxy",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#bitflags@2.4.1": "01ryy3kd671b0ll4bhdvhsz67vwz1lz53fz504injrd7wpv64xrj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#block-buffer@0.10.4": "0w9sa2ypmrsqqvc20nhwr75wbb5cjr4kkyhpjm1z1lv2kdicfy1h",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#blocking@1.5.1": "064i3d6b8ln34fgdw49nmx9m36bwi3r3nv8c9xhcrpf4ilz92dva",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#build_html@2.4.0": "188nibbsv33vgjjiq9cn2irsgdb75gxfipavcavnyydcwxpzw21i",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#bumpalo@3.14.0": "1v4arnv9kwk54v5d0qqpv4vyw2sgr660nk0w3apzixi1cm3yfc3z",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#bytemuck@1.14.0": "1ik1ma5n3bg700skkzhx50zjk7kj7mbsphi773if17l04pn2hk9p",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#byteorder@1.5.0": "0jzncxyf404mwqdbspihyzpkndfgda450l0893pz5xj685cg5l0z",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#bytes@1.5.0": "08w2i8ac912l8vlvkv3q51cd4gr09pwlg3sjsjffcizlrb0i5gd2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#cairo-rs@0.18.3": "18d80lk853bjhx36rjaj78clzfjrmlgi01863drnmshdgxi16dpk",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#cairo-sys-rs@0.18.2": "0lfsxl7ylw3phbnwmz3k58j1gnqi6kc2hdc7g3bb7f4hwnl9yp38",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#cc@1.0.83": "1l643zidlb5iy1dskc5ggqs4wqa29a02f44piczqc8zcnsq4y5zi",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#cfg-expr@0.15.5": "1cqicd9qi8mzzgh63dw03zhbdihqfl3lbiklrkynyzkq67s5m483",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#cfg-if@1.0.0": "1za0vb97n4brpzpv8lsbnzmq5r8f2b0cpqqr0sy8h5bn751xxwds",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#chrono-tz-build@0.2.1": "03rmzd69cn7fp0fgkjr5042b3g54s2l941afjm3001ls7kqkjgj3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#chrono-tz@0.8.4": "0xhd3dsfs72im0sbc7w889lfy7bxgjlbvqhj5a1yvxhxwb08acg2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#chrono@0.4.31": "0f6vg67pipm8cziad2yms6a639pssnvysk1m05dd9crymmdnhb3z",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#clap@4.4.11": "1wj5gb2fnqls00zfahg3490bdfc36d9cwpl80qjacb5jyrqzdbxz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#clap_builder@4.4.11": "1fxdsmw1ilgswz3lg2hjlvsdyyz04k78scjirlbd7c9bc83ba5m2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#clap_derive@4.4.7": "0hk4hcxl56qwqsf4hmf7c0gr19r9fbxk0ah2bgkr36pmmaph966g",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#clap_lex@0.6.0": "1l8bragdvim7mva9flvd159dskn2bdkpl0jqrr41wnjfn8pcfbvh",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#cloudabi@0.0.3": "0kxcg83jlihy0phnd2g8c2c303px3l2p3pkjz357ll6llnd5pz6x",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#color_quant@1.1.0": "12q1n427h2bbmmm1mnglr57jaz2dj9apk0plcxw7nwqiai7qjyrx",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#colorchoice@1.0.0": "1ix7w85kwvyybwi2jdkl3yva2r2bvdcc3ka2grjfzfgrapqimgxc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#concurrent-queue@2.4.0": "0qvk23ynj311adb4z7v89wk3bs65blps4n24q8rgl23vjk6lhq6i",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#const-oid@0.9.6": "1y0jnqaq7p2wvspnx7qj76m7hjcqpz73qzvr9l2p9n2s51vr6if2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#cookie@0.17.0": "096c52jg9iq4lfcps2psncswv33fc30mmnaa2sbzzcfcw71kgyvy",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#cool_asserts@2.0.3": "1v18dg7ifx41k2f82j3gsnpm1fg9wk5s4zv7sf42c7pnad72b7zf",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#core-foundation-sys@0.8.6": "13w6sdf06r0hn7bx2b45zxsg1mm2phz34jikm6xc5qrbr6djpsh6",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#core-foundation@0.9.4": "13zvbbj07yk3b61b8fhwfzhy35535a583irf23vlcg59j7h9bqci",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#cpufeatures@0.2.11": "1l0gzsyy576n017g9bf0vkv5hhg9cpz1h1libxyfdlzcgbh0yhnf",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#crc-catalog@2.4.0": "1xg7sz82w3nxp1jfn425fvn1clvbzb3zgblmxsyqpys0dckp9lqr",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#crc32fast@1.3.2": "03c8f29yx293yf43xar946xbls1g60c207m9drf8ilqhr25vsh5m",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#crc@3.0.1": "1zkx87a5x06xfd6xm5956w4vmdfs0wcxpsn7iwj5jbp2rcapmv46",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#crossbeam-deque@0.8.4": "0la7fx9n1vbx3h23va0xmcy36hziql1pkik08s3j3asv4479ma7w",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#crossbeam-epoch@0.9.16": "1anr32r8px0vb65cgwbwp3zhqz69scz5dgq9bmx54w5qa59yjbrd",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#crossbeam-queue@0.3.9": "0lz17pgydh29w8brld8dysi1m4n5bxfpnj8w9bxk0q6xpyyzbg5r",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#crossbeam-utils@0.8.17": "13y7wh993i7q71kg6wcfj65w3rlmizzrz7cqgz1l9whlgw9rcvf0",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#crunchy@0.2.2": "1dx9mypwd5mpfbbajm78xcrg5lirqk7934ik980mmaffg3hdm0bs",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#crypto-common@0.1.6": "1cvby95a6xg7kxdz5ln3rl9xh66nz66w46mm3g56ri1z5x815yqv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#data-encoding@2.5.0": "1rcbnwfmfxhlshzbn3r7srm3azqha3mn33yxyqxkzz2wpqcjm5ky",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#deflate@0.8.6": "0x6iqlayg129w63999kz97m279m0jj4x4sm6gkqlvmp73y70yxvk",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#der@0.7.8": "070bwiyr80800h31c5zd96ckkgagfjgnrrdmz3dzg2lccsd3dypz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#deranged@0.3.10": "1p4i64nkadamksa943d6gk39sl1kximz0xr69n408fvsl1q0vcwf",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#digest@0.10.7": "14p2n6ih29x81akj097lvz7wi9b6b9hvls0lwrv7b6xwyy0s5ncy",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#dimensioned@0.7.0": "09ky8s3higkf677lmyqg30hmj66gpg7hx907s6hfvbk2a9av05r5",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#dimensioned@0.8.0": "15s3j4ry943xqlac63bp81sgdk9s3yilysabzww35j9ibmnaic50",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#displaydoc@0.2.4": "0p8pyg10csc782qlwx3znr6qx46ni96m1qh597kmyrf6s3s8axa8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#dotenvy@0.15.7": "16s3n973n5aqym02692i1npb079n5mb0fwql42ikmwn8wnrrbbqs",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#either@1.9.0": "01qy3anr7jal5lpc20791vxrw0nl6vksb5j7x56q2fycgcyy8sm2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#encoding_rs@0.8.33": "1qa5k4a0ipdrxq4xg9amms9r9pnnfn7nfh2i9m3mw0ka563b6s3j",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#env_logger@0.10.1": "1kmy9xmfjaqfvd4wkxr1f7d16ld3h9b487vqs2q9r0s8f3kg7cwm",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#equivalent@1.0.1": "1malmx5f4lkfvqasz319lq6gb3ddg19yzf9s8cykfsgzdmyq0hsl",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#errno@0.3.8": "0ia28ylfsp36i27g1qih875cyyy4by2grf80ki8vhgh6vinf8n52",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#etcetera@0.8.0": "0hxrsn75dirbjhwgkdkh0pnpqrnq17ypyhjpjaypgax1hd91nv8k",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#event-listener-strategy@0.4.0": "1lwprdjqp2ibbxhgm9khw7s7y7k4xiqj5i5yprqiks6mnrq4v3lm",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#event-listener@2.5.3": "1q4w3pndc518crld6zsqvvpy9lkzwahp2zgza9kbzmmqh9gif1h2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#event-listener@4.0.1": "04k7qbi5kgs36s905gxijj41kcr78xs2s6cp6vbg50254z7wvwl4",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#exr@1.71.0": "1a58k179b0h8zpf1cfgc2vl60j2syg7cdgdzp9j6cgmb6lgpcal3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#fastrand@1.9.0": "1gh12m56265ihdbzh46bhh0jf74i197wm51jg1cw75q7ggi96475",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#fastrand@2.0.1": "19flpv5zbzpf0rk4x77z4zf25in0brg8l7m304d3yrf47qvwxjr5",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#fdeflate@0.3.1": "0s5885wdsih2hqx3hsl7l8cl3666fgsgiwvglifzy229hpydmmk4",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#field-offset@0.3.6": "0zq5sssaa2ckmcmxxbly8qgz3sxpb8g1lwv90sdh1z74qif2gqiq",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#finl_unicode@1.2.0": "1ipdx778849czik798sjbgk5yhwxqybydac18d2g9jb20dxdrkwg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#flate2@1.0.28": "03llhsh4gqdirnfxxb9g2w9n0721dyn4yjir3pz7z4vjaxb3yc26",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#fluent-bundle@0.15.2": "1zbzm13rfz7fay7bps7jd4j1pdnlxmdzzfymyq2iawf9vq0wchp2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#fluent-langneg@0.13.0": "152yxplc11vmxkslvmaqak9x86xnavnhdqyhrh38ym37jscd0jic",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#fluent-syntax@0.11.0": "0y6ac7z7sbv51nsa6km5z8rkjj4nvqk91vlghq1ck5c3cjbyvay0",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#fluent@0.16.0": "19s7z0gw95qdsp9hhc00xcy11nwhnx93kknjmdvdnna435w97xk1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#flume@0.11.0": "10girdbqn77wi802pdh55lwbmymy437k7kklnvj12aaiwaflbb2m",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#fnv@1.0.7": "1hc2mcqha06aibcaza94vbi81j6pr9a1bbxrxjfhc91zin8yr7iz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#foreign-types-shared@0.1.1": "0jxgzd04ra4imjv8jgkmdq59kj8fsz6w4zxsbmlai34h26225c00",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#foreign-types@0.3.2": "1cgk0vyd7r45cj769jym4a6s7vwshvd0z4bqrb92q1fwibmkkwzn",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#form_urlencoded@1.2.1": "0milh8x7nl4f450s3ddhg57a3flcv6yq8hlkyk6fyr3mcb128dp1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#fuchsia-cprng@0.1.1": "1fnkqrbz7ixxzsb04bsz9p0zzazanma8znfdqjvh39n14vapfvx0",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-channel@0.3.29": "1jxsifvrbqzdadk0svbax71cba5d3qg3wgjq8i160mxmd1kdckgz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-core@0.3.29": "1308bpj0g36nhx2y6bl4mm6f1gnh9xyvvw2q2wpdgnb6dv3247gb",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-executor@0.3.29": "1g4pjni0sw28djx6mlcfz584abm2lpifz86cmng0kkxh7mlvhkqg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-intrusive@0.5.0": "0vwm08d1pli6bdaj0i7xhk3476qlx4pll6i0w03gzdnh7lh0r4qx",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-io@0.3.29": "1ajsljgny3zfxwahba9byjzclrgvm1ypakca8z854k2w7cb4mwwb",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-lite@1.13.0": "1kkbqhaib68nzmys2dc8j9fl2bwzf2s91jfk13lb2q3nwhfdbaa9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-lite@2.2.0": "1flj85i6xm0rjicxixmajrp6rhq8i4bnbzffmrd6h23ln8jshns4",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-macro@0.3.29": "1nwd18i8kvpkdfwm045hddjli0n96zi7pn6f99zi9c74j7ym7cak",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-sink@0.3.29": "05q8jykqddxzp8nwf00wjk5m5mqi546d7i8hsxma7hiqxrw36vg3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-task@0.3.29": "1qmsss8rb5ppql4qvd4r70h9gpfcpd0bg2b3qilxrnhdkc397lgg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures-util@0.3.29": "0141rkqh0psj4h8x8lgsl1p29dhqr7z2wcixkcbs60z74kb2d5d1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#futures@0.3.29": "0dak2ilpcmyjrb1j54fzy9hlw6vd10vqljq9gd59pbrq9dqr00ns",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gdk-pixbuf-sys@0.18.0": "1xya543c4ffd2n7aiwwrdxsyc9casdbasafi6ixcknafckm3k61z",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gdk-pixbuf@0.18.3": "0b68ssdyapvq3bgsna9frabbzhjkvvzz8jld4mxkphr29nvk4vs4",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gdk4-sys@0.7.2": "1w7yvir565sjrrw828lss07749hfpfsr19jdjzwivkx36brl7ayv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gdk4@0.7.3": "1xiacc63p73apr033gjrb9dsk0y4yxnsljwfxbwfry41snd03nvy",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#generic-array@0.11.2": "0a7w8w0rg47nmcinnfzv443lcyb8mplwc251p1jyr5xj2yh6wzv6",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#generic-array@0.14.7": "16lyyrzrljfq424c3n8kfwkqihlimmsg5nhshbbp48np3yjrqr45",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#getrandom@0.2.11": "03q7120cc2kn7ry013i67zmjl2g9q73h1ks5z08hq5v9syz0d47y",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gif@0.11.4": "01hbw3isapzpzff8l6aw55jnaqx2bcscrbwyf3rglkbbfp397p9y",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gif@0.12.0": "0ibhjyrslfv9qm400gp4hd50v9ibva01j4ab9bwiq1aycy9jayc0",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gimli@0.28.1": "0lv23wc8rxvmjia3mcxc6hj9vkqnv1bqq0h8nzjcgf71mrxx6wa2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gio-sys@0.18.1": "1lip8z35iy9d184x2qwjxlbxi64q9cpayy7v1p5y9xdsa3w6smip",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gio@0.18.4": "0wsc6mnx057s4ailacg99dwgna38dbqli5x7a6y9rdw75x9qzz6l",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#glib-build-tools@0.16.3": "1z73bl10zmxwrv16v4f5wcky1f3z5a2v0hknca54al4k2p5ka695",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#glib-build-tools@0.17.10": "05p7ab2vn8962cbchi7a6hndhvw64nqk4w5kpg5z53iizsgdfrbs",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#glib-build-tools@0.18.0": "0p5c2ayiam5bkp9wvq9f9ihwp06nqs5j801npjlwnhrl8rpwac9l",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#glib-macros@0.18.3": "19crnw5a57w02njpbsmdqwbkncl6hw6g3mv554y8dqzcrri3jybj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#glib-sys@0.18.1": "164qhsfmlzd5mhyxs8123jzbdfldwxbikfpq5cysj3lddbmy4g06",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#glib@0.18.4": "0kjws6ns6dym48nzxz9skhipk55flc2hy5q5kzg4w12wvizvs6wm",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gloo-timers@0.2.6": "0p2yqcxw0q9kclhwpgshq1r4ijns07nmmagll3lvrgl7pdk5m6cv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gobject-sys@0.18.0": "0i6fhp3m6vs3wkzyc22rk2cqj68qvgddxmpaai34l72da5xi4l08",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#graphene-rs@0.18.1": "00f4q1ra4haap5i7lazwhkdgnb49fs8adk2nm6ki6mjhl76jh8iv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#graphene-sys@0.18.1": "0n8zlg7z26lwpnvlqp1hjlgrs671skqwagdpm7r8i1zwx3748hfc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#grid@0.9.0": "0iswdcxggyxp9m1rz0m7bfg4xacinvn78zp2fgfp0l0079x10d06",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gsk4-sys@0.7.3": "0mbdlm9qi1hql48rr29vsj9vlqwc7gxg67wg1q19z67azwz9xg8j",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gsk4@0.7.3": "0zhzs2dkgiinhgc11akpn2harq3x5n1iq21dnc4h689g3lsqx58d",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gtk4-macros@0.7.2": "0bw3cchiycf7dw1bw4p8946gv38azxy05a5w0ndgcmxnz6fc8znm",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gtk4-sys@0.7.3": "1f2ylskyqkjdik9fij2m46pra4jagnif5xyalbxfk3334fmc9n2l",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#gtk4@0.7.3": "0hh8nzglmz94v1m1h6vy8z12m6fr7ia467ry0md5fa4p7sm53sss",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#h2@0.3.22": "0y41jlflvw8niifdirgng67zdmic62cjf5m2z69hzrpn5qr50qjd",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#half@2.2.1": "1l1gdlzxgm7wc8xl5fxas20kfi1j35iyb7vfjkghbdzijcvazd02",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#hashbrown@0.14.3": "012nywlg0lj9kwanh69my5x67vjlfmzfi9a0rq4qvis2j8fil3r9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#hashlink@0.8.4": "1xy8agkyp0llbqk9fcffc1xblayrrywlyrm2a7v93x8zygm4y2g8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#headers-core@0.2.0": "0ab469xfpd411mc3dhmjhmzrhqikzyj8a17jn5bkj9zfpy0n9xp7",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#headers@0.3.9": "0w62gnwh2p1lml0zqdkrx9dp438881nhz32zrzdy61qa0a9kns06",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#heck@0.4.1": "1a7mqsnycv5z4z5vnv1k34548jzmc0ajic7c1j8jsaspnhw5ql4m",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#hermit-abi@0.3.3": "1dyc8qsjh876n74a3rcz8h43s27nj1sypdhsn2ms61bd3b47wzyp",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#hex-string@0.1.0": "02sgrgrbp693jv0v5iga7z47y6aj93cq0ia39finby9x17fw53l4",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#hex@0.4.3": "0w1a4davm1lgzpamwnba907aysmlrnygbqmfis2mqjx5m552a93z",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#hkdf@0.12.4": "1xxxzcarz151p1b858yn5skmhyrvn8fs4ivx5km3i1kjmnr8wpvv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#hmac@0.12.1": "0pmbr069sfg76z7wsssfk5ddcqd9ncp79fyz6zcm6yn115yc6jbc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#home@0.5.9": "19grxyg35rqfd802pcc9ys1q3lafzlcjcv2pl2s5q8xpyr5kblg3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#http-body@0.4.6": "1lmyjfk6bqk6k9gkn1dxq770sb78pqbqshga241hr5p995bb5skw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#http@0.2.11": "1fwz3mhh86h5kfnr5767jlx9agpdggclq7xsqx930fflzakb2iw9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#http@1.0.0": "1sllw565jn8r5w7h928nsfqq33x586pyasdfr7vid01scwwgsamk",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#httparse@1.8.0": "010rrfahm1jss3p022fqf3j3jmm72vhn4iqhykahb9ynpaag75yq",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#httpdate@1.0.3": "1aa9rd2sac0zhjqh24c9xvir96g188zldkx0hr6dnnlx5904cfyz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#humantime@2.1.0": "1r55pfkkf5v0ji1x6izrjwdq9v6sc7bv99xj6srywcar37xmnfls",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#hyper-tls@0.5.0": "01crgy13102iagakf6q4mb75dprzr7ps1gj0l5hxm1cvm7gks66n",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#hyper@0.10.16": "0wwjh9p3mzvg3fss2lqz5r7ddcgl1fh9w6my2j69d6k0lbcm41ha",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#hyper@0.14.28": "107gkvqx4h9bl17d602zkm2dgpfq86l2dr36yzfsi8l3xcsy35mz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#iana-time-zone-haiku@0.1.2": "17r6jmj31chn7xs9698r122mapq85mfnv98bb4pg6spm0si2f67k",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#iana-time-zone@0.1.58": "081vcr8z8ddhl5r1ywif6grnswk01b2ac4nks2bhn8zzdimvh9l3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#idna@0.1.5": "0kl4gs5kaydn4v07c6ka33spm9qdh2np0x7iw7g5zd8z1c7rxw1q",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#idna@0.5.0": "1xhjrcjqq0l5bpzvdgylvpkgk94panxgsirzhjnnqfdgc4a9nkb3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#image@0.23.14": "18gn2f7xp30pf9aqka877knlq308khxqiwjvsccvzaa4f9zcpzr4",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#image@0.24.7": "04d7f25b8nlszfv9a474n4a0al4m2sv9gqj3yiphhqr0syyzsgbg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#indent_write@2.2.0": "1hqjp80argdskrhd66g9sh542yxy8qi77j6rc69qd0l7l52rdzhc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#indexmap@2.1.0": "07rxrqmryr1xfnmhrjlz8ic6jw28v6h5cig3ws2c9d0wifhy2c6m",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#instant@0.1.12": "0b2bx5qdlwayriidhrag8vhy10kdfimfhmb3jnjmsz2h9j1bwnvs",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#intl-memoizer@0.5.1": "0vx6cji8ifw77zrgipwmvy1i3v43dcm58hwjxpb1h29i98z46463",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#intl_pluralrules@7.0.2": "0wprd3h6h8nfj62d8xk71h178q7zfn3srxm787w4sawsqavsg3h7",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#io-lifetimes@1.0.11": "1hph5lz4wd3drnn6saakwxr497liznpfnv70via6s0v8x6pbkrza",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#ipnet@2.9.0": "1hzrcysgwf0knf83ahb3535hrkw63mil88iqc6kjaryfblrqylcg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#iron@0.6.1": "1s4mf8395f693nhwsr0znw3j5frzn56gzllypyl50il85p50ily6",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#is-terminal@0.4.9": "12xgvc7nsrp3pn8hcxajfhbli2l5wnh3679y2fmky88nhj4qj26b",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#itertools@0.12.0": "1c07gzdlc6a1c8p8jrvvw3gs52bss3y58cs2s21d9i978l36pnr5",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#itoa@1.0.10": "0k7xjfki7mnv6yzjrbnbnjllg86acmbnk4izz2jmm1hx2wd6v95i",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#jpeg-decoder@0.1.22": "1wnh0bmmswpgwhgmlizz545x8334nlbmkq8imy9k224ri3am7792",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#jpeg-decoder@0.3.0": "0gkv0zx95i4fr40fj1a10d70lqi6lfyia8r5q8qjxj8j4pj0005w",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#js-sys@0.3.66": "1ji9la5ydg0vy17q54i7dnwc0wwb9zkx662w1583pblylm6wdsff",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#kv-log-macro@1.0.7": "0zwp4bxkkp87rl7xy2dain77z977rvcry1gmr5bssdbn541v7s0d",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#language-tags@0.2.2": "16hrjdpa827carq5x4b8zhas24d8kg4s16m6nmmn1kb7cr5qh7d9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#lazy_static@1.4.0": "0in6ikhw8mgl33wjv6q6xfrb5b9jr16q8ygjy803fay4zcisvaz2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#lebe@0.5.2": "1j2l6chx19qpa5gqcw434j83gyskq3g2cnffrbl3842ymlmpq203",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#libadwaita-sys@0.5.3": "16n6xsy6jhbj0jbpz8yvql6c9b89a99v9vhdz5s37mg1inisl42y",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#libadwaita@0.5.3": "174pzn9dwsk8ikvrhx13vkh0zrpvb3rhg9yd2q5d2zjh0q6fgrrg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#libc@0.2.151": "1x28f0zgp4zcwr891p8n9ag9w371sbib30vp4y6hi2052frplb9h",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#libm@0.2.8": "0n4hk1rs8pzw8hdfmwn96c4568s93kfxqgcqswr7sajd2diaihjf",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#libsqlite3-sys@0.27.0": "05pp60ncrmyjlxxjj187808jkvpxm06w5lvvdwwvxd2qrmnj4kng",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#linux-raw-sys@0.3.8": "068mbigb3frrxvbi5g61lx25kksy98f2qgkvc4xg8zxznwp98lzg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#linux-raw-sys@0.4.12": "0mhlla3gk1jgn6mrq9s255rvvq8a1w3yk2vpjiwsd6hmmy1imkf4",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#lock_api@0.4.11": "0iggx0h4jx63xm35861106af3jkxq06fpqhpkhgw0axi2n38y5iw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#log@0.3.9": "0jq23hhn5h35k7pa8r7wqnsywji6x3wn1q5q7lif5q536if8v7p1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#log@0.4.20": "13rf7wphnwd61vazpxr7fiycin6cb1g8fmvgqg18i464p0y1drmm",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#logger@0.4.0": "14xlxvkspcfnspjil0xi63qj5cybxn1hjmr5gq8m4v1g9k5p54bc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#matches@0.1.10": "1994402fq4viys7pjhzisj4wcw894l53g798kkm2y74laxk0jci5",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#md-5@0.10.6": "1kvq5rnpm4fzwmyv5nmnxygdhhb2369888a06gdc9pxyrzh7x7nq",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#memchr@2.6.4": "0rq1ka8790ns41j147npvxcqcl2anxyngsdimy85ag2api0fwrgn",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#memoffset@0.9.0": "0v20ihhdzkfw1jx00a7zjpk2dcp5qjq6lz302nyqamd9c4f4nqss",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#mime@0.2.6": "1q1s1ax1gaz8ld3513nvhidfwnik5asbs1ma3hp6inp5dn56nqms",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#mime@0.3.17": "16hkibgvb9klh0w0jk5crr5xv90l3wlf77ggymzjmvl1818vnxv8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#mime_guess@1.8.8": "18qcd5aa3363mb742y7lf39j7ha88pkzbv9ff2qidlsdxsjjjs91",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#mime_guess@2.0.4": "1vs28rxnbfwil6f48hh58lfcx90klcvg68gxdc60spwa4cy2d4j1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#minimal-lexical@0.2.1": "16ppc5g84aijpri4jzv14rvcnslvlpphbszc7zzp6vfkddf4qdb8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#miniz_oxide@0.3.7": "0dblrhgbm0wa8jjl8cjp81akaj36yna92df4z1h9b26n3spal7br",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#miniz_oxide@0.4.4": "0jsfv00hl5rmx1nijn59sr9jmjd4rjnjhh4kdjy8d187iklih9d9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#miniz_oxide@0.7.1": "1ivl3rbbdm53bzscrd01g60l46lz5krl270487d8lhjvwl5hx0g7",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#mio@0.8.10": "02gyaxvaia9zzi4drrw59k9s0j6pa5d1y2kv7iplwjipdqlhngcg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#modifier@0.1.0": "0n3fmgli1nsskl0whrfzm1gk0rmwwl6pw1q4nb9sqqmn5h8wkxa1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#multer@2.1.0": "1hjiphaypj3phqaj5igrzcia9xfmf4rr4ddigbh8zzb96k1bvb01",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#nary_tree@0.4.3": "1iqray1a716995l9mmvz5sfqrwg9a235bvrkpcn8bcqwjnwfv1pv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#native-tls@0.2.11": "0bmrlg0fmzxaycjpkgkchi93av07v2yf9k33gc12ca9gqdrn28h7",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#nix@0.27.1": "0ly0kkmij5f0sqz35lx9czlbk6zpihb7yh1bsy4irzwfd2f4xc1f",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#no-std-compat@0.4.1": "132vrf710zsdp40yp1z3kgc2ss8pi0z4gmihsz3y7hl4dpd56f5r",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#nom@7.1.3": "0jha9901wxam390jcf5pfa0qqfrgh8li787jx2ip0yk5b8y9hwyj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#num-bigint-dig@0.8.4": "0lb12df24wgxxbspz4gw1sf1kdqwvpdcpwq4fdlwg4gj41c1k16w",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#num-integer@0.1.45": "1ncwavvwdmsqzxnn65phv6c6nn72pnv9xhpmjd6a429mzf4k6p92",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#num-iter@0.1.43": "0lp22isvzmmnidbq9n5kbdh8gj0zm3yhxv1ddsn5rp65530fc0vx",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#num-rational@0.3.2": "01sgiwny9iflyxh2xz02sak71v2isc3x608hfdpwwzxi3j5l5b0j",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#num-rational@0.4.1": "1c0rb8x4avxy3jvvzv764yk7afipzxncfnqlb10r3h53s34s2f06",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#num-traits@0.2.17": "0z16bi5zwgfysz6765v3rd6whfbjpihx3mhsn4dg8dzj2c221qrr",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#num_cpus@1.16.0": "0hra6ihpnh06dvfvz9ipscys0xfqa9ca9hzp384d5m02ssvgqqa1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#object@0.32.1": "1c02x4kvqpnl3wn7gz9idm4jrbirbycyqjgiw6lm1g9k77fzkxcw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#once_cell@1.19.0": "14kvw7px5z96dk4dwdm1r9cqhhy2cyj1l5n5b29mynbb8yr15nrz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#openssl-macros@0.1.1": "173xxvfc63rr5ybwqwylsir0vq6xsj4kxiv4hmg4c3vscdmncj59",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#openssl-probe@0.1.5": "1kq18qm48rvkwgcggfkqq6pm948190czqc94d6bm2sir5hq1l0gz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#openssl-sys@0.9.97": "02s670ir38fsavphdna07144y41dkvrcfkwnjzg82zfrrlsavsn3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#openssl@0.10.61": "0idv3n9n9f2sxq8cqzxvq44633vg5sx4n9q1p3g6dn66ikf1k13b",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pango-sys@0.18.0": "1iaxalcaaj59cl9n10svh4g50v8jrc1a36kd7n9yahx8j7ikfrs3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pango@0.18.3": "1r5ygq7036sv7w32kp8yxr6vgggd54iaavh3yckanmq4xg0px8kw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#parking@2.2.0": "1blwbkq6im1hfxp5wlbr475mw98rsyc0bbr2d5n16m38z253p0dv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#parking_lot@0.12.1": "13r2xk7mnxfc5g0g6dkdxqdqad99j7s7z8zhzz4npw5r0g0v4hip",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#parking_lot_core@0.9.9": "13h0imw1aq86wj28gxkblhkzx6z1gk8q18n0v76qmmj6cliajhjc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#parse-zoneinfo@0.3.0": "0h8g6jy4kckn2gk8sd5adaws180n1ip65xhzw5jxlq4w8ibg41f7",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#paste@1.0.14": "0k7d54zz8zrz0623l3xhvws61z5q2wd3hkwim6gylk8212placfy",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pem-rfc7468@0.7.0": "04l4852scl4zdva31c1z6jafbak0ni5pi0j38ml108zwzjdrrcw8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#percent-encoding@1.0.1": "0cgq08v1fvr6bs5fvy390cz830lq4fak8havdasdacxcw790s09i",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#percent-encoding@2.3.1": "0gi8wgx0dcy8rnv1kywdv98lwcx67hz0a0zwpib5v2i08r88y573",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#phf@0.11.2": "1p03rsw66l7naqhpgr1a34r9yzi1gv9jh16g3fsk6wrwyfwdiqmd",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#phf@0.7.24": "066xwv4dr6056a9adlkarwp4n94kbpwngbmd47ngm3cfbyw49nmk",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#phf_codegen@0.11.2": "0nia6h4qfwaypvfch3pnq1nd2qj64dif4a6kai3b7rjrsf49dlz8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#phf_codegen@0.7.24": "0zjiblicfm0nrmr2xxrs6pnf6zz2394wgch6dcbd8jijkq98agmh",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#phf_generator@0.11.2": "1c14pjyxbcpwkdgw109f7581cc5fa3fnkzdq1ikvx7mdq9jcrr28",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#phf_generator@0.7.24": "0qi62gxk3x3whrmw5c4i71406icqk11qmpgln438p6qm7k4lqdh9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#phf_shared@0.11.2": "0azphb0a330ypqx3qvyffal5saqnks0xvl8rj73jlk3qxxgbkz4h",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#phf_shared@0.7.24": "18371fla0vsj7d6d5rlfb747xbr2in11ar9vgv5qna72bnhp2kr3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pin-project-internal@1.1.3": "01a4l3vb84brv9v7wl71chzxra2kynm6yvcjca66xv3ij6fgsna3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pin-project-lite@0.2.13": "0n0bwr5qxlf0mhn2xkl36sy55118s9qmvx2yl5f3ixkb007lbywa",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pin-project@1.1.3": "08k4cpy8q3j93qqgnrbzkcgpn7g0a88l4a9nm33kyghpdhffv97x",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pin-utils@0.1.0": "117ir7vslsl2z1a7qzhws4pd01cg2d3338c47swjyvqv2n60v1wb",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#piper@0.2.1": "1m45fkdq7q5l9mv3b0ra10qwm0kb67rjp2q8y91958gbqjqk33b6",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pkcs1@0.7.5": "0zz4mil3nchnxljdfs2k5ab1cjqn7kq5lqp62n9qfix01zqvkzy8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pkcs8@0.10.2": "1dx7w21gvn07azszgqd3ryjhyphsrjrmq5mmz1fbxkj5g0vv4l7r",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pkg-config@0.3.27": "0r39ryh1magcq4cz5g9x88jllsnxnhcqr753islvyk4jp9h2h1r6",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#plugin@0.2.6": "1q7nghkpvxxr168y2jnzh3w7qc9vfrby9n7ygy3xpj0bj71hsshs",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#png@0.16.8": "1ipl44q3vy4kvx6j296vk7d4v8gvcg203lrkvvixwixq1j98fciw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#png@0.17.10": "0r5a8a25ad0jq2pkp2zbab3wwhpgp6jmdg6d0ybjnw6kilnvyxfx",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#polling@2.8.0": "1kixxfq1af1k7gkmmk9yv4j2krpp4fji2r8j4cz6p6d7ihz34bab",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#polling@3.4.0": "052am20b5r03nwhpnjw86rv3dwsdabvb07anv3fqxfbs65r4w19h",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#powerfmt@0.2.0": "14ckj2xdpkhv3h6l5sdmb9f1d57z8hbfpdldjc2vl5givq2y77j3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#ppv-lite86@0.2.17": "1pp6g52aw970adv3x2310n7glqnji96z0a9wiamzw89ibf0ayh2v",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#pretty_env_logger@0.5.0": "076w9dnvcpx6d3mdbkqad8nwnsynb7c8haxmscyrz7g3vga28mw6",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#proc-macro-crate@1.3.1": "069r1k56bvgk0f58dm5swlssfcp79im230affwk6d9ck20g04k3z",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#proc-macro-crate@2.0.1": "06jbv5w6s04dbjbwq0iv7zil12ildf3w8dvvb4pqvhig4gm5zp4p",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#proc-macro-error-attr@1.0.4": "0sgq6m5jfmasmwwy8x4mjygx5l7kp8s4j60bv25ckv2j1qc41gm1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#proc-macro-error@1.0.4": "1373bhxaf0pagd8zkyd03kkx6bchzf6g0dkwrwzsnal9z47lj9fs",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#proc-macro2@1.0.78": "1bjak27pqdn4f4ih1c9nr3manzyavsgqmf76ygw9k76q8pb2lhp2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#proptest@1.4.0": "1gzmw40pgmwzb7x6jsyr88z5w151snv5rp1g0dlcp1iw3h9pdd1i",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#qoi@0.4.1": "00c0wkb112annn2wl72ixyd78mf56p4lxkhlmsggx65l3v3n8vbz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#quick-error@1.2.3": "1q6za3v78hsspisc197bg3g7rpc989qycy8ypr8ap8igv10ikl51",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#quote@1.0.35": "1vv8r2ncaz4pqdr78x7f138ka595sp2ncr1sa2plm4zxbsmwj7i9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand@0.3.23": "0v679h38pjjqj5h4md7v2slsvj6686qgcn7p9fbw3h43iwnk1b34",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand@0.4.6": "14qjfv3gggzhnma20k0sc1jf8y6pplsaq7n1j9ls5c8kf2wl0a2m",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand@0.6.5": "1jl4449jcl4wgmzld6ffwqj5gwxrp8zvx8w573g1z368qg6xlwbd",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand@0.8.5": "013l6931nn7gkc23jz5mm3qdhf93jjf0fg64nz2lp4i51qd8vbrl",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_chacha@0.1.1": "1vxwyzs4fy1ffjc8l00fsyygpiss135irjf7nyxgq2v0lqf3lvam",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_chacha@0.3.1": "123x2adin558xbhvqb8w4f6syjsdkmqff8cxwhmjacpsl1ihmhg6",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_core@0.3.1": "0jzdgszfa4bliigiy4hi66k7fs3gfwi2qxn8vik84ph77fwdwvvs",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_core@0.4.2": "1p09ynysrq1vcdlmcqnapq4qakl2yd1ng3kxh3qscpx09k2a6cww",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_core@0.6.4": "0b4j2v4cb5krak1pv6kakv4sz6xcwbrmy2zckc32hsigbrwy82zc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_hc@0.1.0": "1i0vl8q5ddvvy0x8hf1zxny393miyzxkwqnw31ifg6p0gdy6fh3v",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_isaac@0.1.1": "027flpjr4znx2csxk7gxb7vrf9c7y5mydmvg5az2afgisp4rgnfy",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_jitter@0.1.4": "16z387y46bfz3csc42zxbjq89vcr1axqacncvv8qhyy93p4xarhi",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_os@0.1.3": "0wahppm0s64gkr2vmhcgwc0lij37in1lgfxg5rbgqlz0l5vgcxbv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_pcg@0.1.2": "0i0bdla18a8x4jn1w0fxsbs3jg7ajllz6azmch1zw33r06dv1ydb",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_xorshift@0.1.1": "0p2x8nr00hricpi2m6ca5vysiha7ybnghz79yqhhx6sl4gkfkxyb",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rand_xorshift@0.3.0": "13vcag7gmqspzyabfl1gr9ykvxd2142q2agrj8dkyjmfqmgg4nyj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rayon-core@1.12.0": "1vaq0q71yfvcwlmia0iqf6ixj2fibjcf2xjy92n1m1izv1mgpqsw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rayon@1.8.0": "1cfdnvchf7j4cpha5jkcrrsr61li9i9lp5ak7xdq6d3pvc1xn9ww",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rdrand@0.4.0": "1cjq0kwx1bk7jx3kzyciiish5gqsj7620dm43dc52sr8fzmm9037",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#redox_syscall@0.4.1": "1aiifyz5dnybfvkk4cdab9p2kmphag1yad6iknc7aszlxxldf8j7",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#regex-automata@0.4.3": "0gs8q9yhd3kcg4pr00ag4viqxnh5l7jpyb9fsfr8hzh451w4r02z",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#regex-syntax@0.8.2": "17rd2s8xbiyf6lb4aj2nfi44zqlj98g2ays8zzj2vfs743k79360",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#regex@1.10.2": "0hxkd814n4irind8im5c9am221ri6bprx49nc7yxv02ykhd9a2rq",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#remove_dir_all@0.5.3": "1rzqbsgkmr053bxxl04vmvsd1njyz0nxvly97aip6aa2cmb15k9s",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#reqwest@0.11.23": "0hgvzb7r46656r9vqhl5qk1kbr2xzjb91yr2cb321160ka6sxc9p",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rsa@0.9.6": "1z0d1aavfm0v4pv8jqmqhhvvhvblla1ydzlvwykpc3mkzhj523jx",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rustc-demangle@0.1.23": "0xnbk2bmyzshacjm2g1kd4zzv2y2az14bw3sjccq5qkpmsfvn9nn",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rustc-hash@1.1.0": "1qkc5khrmv5pqi5l5ca9p5nl5hs742cagrndhbrlk3dhlrx3zm08",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rustc_version@0.4.0": "0rpk9rcdk405xhbmgclsh4pai0svn49x35aggl4nhbkd4a2zb85z",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rustix@0.37.27": "1lidfswa8wbg358yrrkhfvsw0hzlvl540g4lwqszw09sg8vcma7y",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rustix@0.38.28": "05m3vacvbqbg6r6ksmx9k5afpi0lppjdv712crrpsrfax2jp5rbj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rustls-pemfile@1.0.4": "1324n5bcns0rnw6vywr5agff3rwfvzphi7rmbyzwnv6glkhclx0w",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#rusty-fork@0.3.0": "0kxwq5c480gg6q0j3bg4zzyfh2kwmc3v2ba94jw8ncjc8mpcqgfb",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#ryu@1.0.16": "0k7b90xr48ag5bzmfjp82rljasw2fx28xr3bg1lrpx7b5sljm3gr",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#safemem@0.3.3": "0wp0d2b2284lw11xhybhaszsczpbq1jbdklkxgifldcknmy3nw7g",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#schannel@0.1.22": "126zy5jb95fc5hvzyjwiq6lc81r08rdcn6affn00ispp9jzk6dqc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#scoped-tls@1.0.1": "15524h04mafihcvfpgxd8f4bgc3k95aclz8grjkg9a0rxcvn9kz1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#scoped_threadpool@0.1.9": "1a26d3lk40s9mrf4imhbik7caahmw2jryhhb6vqv6fplbbgzal8x",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#scopeguard@1.2.0": "0jcz9sd47zlsgcnm1hdw0664krxwb5gczlif4qngj2aif8vky54l",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#security-framework-sys@2.9.1": "0yhciwlsy9dh0ps1gw3197kvyqx1bvc4knrhiznhid6kax196cp9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#security-framework@2.9.2": "1pplxk15s5yxvi2m1sz5xfmjibp96cscdcl432w9jzbk0frlzdh5",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#self_cell@0.10.3": "0pci3zh23b7dg6jmlxbn8k4plb7hcg5jprd1qiz0rp04p1ilskp1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#self_cell@1.0.2": "1rmdglwnd77wcw2gv76finpgzjhkynx422d0jpahrf2fsqn37273",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#semver@1.0.20": "140hmbfa743hbmah1zjf07s8apavhvn04204qjigjiz5w6iscvw3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#serde@0.9.15": "1bsla8l5xr9pp5sirkal6mngxcq6q961km88jvf339j5ff8j7dil",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#serde@1.0.193": "129b0j67594f8qg5cbyi3nyk31y97wrqihi026mba34dwrsrkp95",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#serde_derive@1.0.193": "1lwlx2k7wxr1v160kpyqjfabs37gm1yxqg65383rnyrm06jnqms3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#serde_json@1.0.108": "0ssj59s7lpzqh1m50kfzlnrip0p0jg9lmhn4098i33a0mhz7w71x",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#serde_spanned@0.6.5": "1hgh6s3jjwyzhfk3xwb6pnnr1misq9nflwq0f026jafi37s24dpb",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#serde_urlencoded@0.7.1": "1zgklbdaysj3230xivihs30qi5vkhigg323a9m62k8jwf4a1qjfk",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#sha1@0.10.6": "1fnnxlfg08xhkmwf2ahv634as30l1i3xhlhkvxflmasi5nd85gz3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#sha2@0.10.8": "1j1x78zk9il95w9iv46dh9wm73r6xrgj32y6lzzw7bxws9dbfgbr",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#signal-hook-registry@1.4.1": "18crkkw5k82bvcx088xlf5g4n3772m24qhzgfan80nda7d3rn8nq",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#signature@2.2.0": "1pi9hd5vqfr3q3k49k37z06p7gs5si0in32qia4mmr1dancr6m3p",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#simd-adler32@0.3.7": "1zkq40c3iajcnr5936gjp9jjh1lpzhy44p3dq3fiw75iwr1w2vfn",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#siphasher@0.2.3": "1b53m53l24lyhr505lwqzrpjyq5qfnic71mynrcfvm43rybf938b",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#siphasher@0.3.11": "03axamhmwsrmh0psdw3gf7c0zc4fyl5yjxfifz9qfka6yhkqid9q",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#slab@0.4.9": "0rxvsgir0qw5lkycrqgb1cxsvxzjv9bmx73bk5y42svnzfba94lg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#smallvec@1.11.2": "0w79x38f7c0np7hqfmzrif9zmn0avjvvm31b166zdk9d1aad1k2d",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#snowflake@1.3.0": "1wadr7bxdxbmkbqkqsvzan6q1h3mxqpxningi3ss3v9jaav7n817",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#socket2@0.4.10": "03ack54dxhgfifzsj14k7qa3r5c9wqy3v6mqhlim99cc03y1cycz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#socket2@0.5.5": "1sgq315f1njky114ip7wcy83qlphv9qclprfjwvxcpfblmcsqpvv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#spin@0.5.2": "0b84m6dbzrwf2kxylnw82d3dr8w06av7rfkr8s85fb5f43rwyqvf",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#spin@0.9.8": "0rvam5r0p3a6qhc18scqpvpgb3ckzyqxpgdfyjnghh8ja7byi039",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#spki@0.7.3": "17fj8k5fmx4w9mp27l970clrh5qa7r5sjdvbsln987xhb34dc7nr",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#sqlformat@0.2.3": "0v0p70wjdshj18zgjjac9xlx8hmpx33xhq7g8x9rg4s4gjyvg0ff",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#sqlx-core@0.7.3": "1gdz44yb9qwxv4xl4hv6w4vbqx0zzdlzsf9j9gcj1qir6wy0ljyq",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#sqlx-macros-core@0.7.3": "0h88wahkxa6nam536lhwr1y0yxlr6la8b1x0hs0n88v790clbgfh",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#sqlx-macros@0.7.3": "19gjwisiym07q7ibkp9nkvvbywjh0r5rc572msvzyzadvh01r5l9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#sqlx-mysql@0.7.3": "190ygz5a3pqcd9vvqjv2i4r1xh8vi53j4272yrld07zpblwrawg3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#sqlx-postgres@0.7.3": "090wm9s6mm53ggn1xwr183cnn8yxly8rgcksdk4hrlfcnz1hmb6n",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#sqlx-sqlite@0.7.3": "143laha7wf8dmi0xwycwqmvxdcnb25dq7jnqrsgvmis8v6vpc291",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#sqlx@0.7.3": "1kv3hyx7izmmsjqh3l47zrfhjlcblpg20cvnk7pr8dm7klkkr86v",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#stringprep@0.1.4": "1rkfsf7riynsmqj3hbldfrvmna0i9chx2sz39qdpl40s4d7dfhdv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#strsim@0.10.0": "08s69r4rcrahwnickvi0kq49z524ci50capybln83mg6b473qivk",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#subtle@2.5.0": "1g2yjs7gffgmdvkkq0wrrh0pxds3q0dv6dhkw9cdpbib656xdkc1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#syn@1.0.109": "0ds2if4600bd59wsv7jjgfkayfzy3hnazs394kz6zdkmna8l3dkj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#syn@2.0.48": "0gqgfygmrxmp8q32lia9p294kdd501ybn6kn2h4gqza0irik2d8g",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#system-configuration-sys@0.5.0": "1jckxvdr37bay3i9v52izgy52dg690x5xfg3hd394sv2xf4b2px7",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#system-configuration@0.5.1": "1rz0r30xn7fiyqay2dvzfy56cvaa3km74hnbz2d72p97bkf3lfms",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#system-deps@6.2.0": "0c836abhh3k8yn5ymg8wx383ay7n731gkrbbp3gma352yq7mhb9a",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#target-lexicon@0.12.12": "02lk65ik5ffb8vl9qzq02v0df8kxrp16zih78a33mji49789zhql",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tempdir@0.3.7": "1n5n86zxpgd85y0mswrp5cfdisizq2rv3la906g6ipyc03xvbwhm",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tempfile@3.8.1": "1r88v07zdafzf46y63vs39rmzwl4vqd4g2c5qarz9mqa8nnavwby",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#termcolor@1.4.0": "0jfllflbxxffghlq6gx4csv0bv0qv77943dcx01h9zssy39w66zz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#thiserror-impl@1.0.51": "1ps9ylhlk2vn19fv3cxp40j3wcg1xmb117g2z2fbf4vmg2bj4x01",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#thiserror@1.0.51": "1drvyim21w5sga3izvnvivrdp06l2c24xwbhp0vg1mhn2iz2277i",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tiff@0.6.1": "0ds48vs919ccxa3fv1www7788pzkvpg434ilqkq7sjb5dmqg8lws",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tiff@0.9.0": "04b2fd3clxm0pmdlfip8xj594zyrsfwmh641i6x1gfiz9l7jn5vd",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#time-core@0.1.2": "1wx3qizcihw6z151hywfzzyd1y5dl804ydyxci6qm07vbakpr4pg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#time-macros@0.2.16": "0gx4ngf5g7ydqa8lf7kh9sy72rd4dhvpi31y1jvswi0288rpw696",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#time@0.1.45": "0nl0pzv9yf56djy8y5dx25nka5pr2q1ivlandb3d24pksgx7ly8v",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#time@0.3.31": "0gjqcdsdbh0r5vi4c2vrj5a6prdviapx731wwn07cvpqqd1blmzn",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tinystr@0.7.5": "1khf3j95bwwksj2hw76nlvwlwpwi4d1j421lj6x35arqqprjph43",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tinyvec@1.6.0": "0l6bl2h62a5m44jdnpn7lmj14rd44via8180i7121fvm73mmrk47",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tinyvec_macros@0.1.1": "081gag86208sc3y6sdkshgw3vysm5d34p431dzw0bshz66ncng0z",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tokio-macros@2.2.0": "0fwjy4vdx1h9pi4g2nml72wi0fr27b5m954p13ji9anyy8l1x2jv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tokio-native-tls@0.3.1": "1wkfg6zn85zckmv4im7mv20ca6b1vmlib5xwz9p7g19wjfmpdbmv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tokio-stream@0.1.14": "0hi8hcwavh5sdi1ivc9qc4yvyr32f153c212dpd7sb366y6rhz1r",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tokio-tungstenite@0.20.1": "0v1v24l27hxi5hlchs7hfd5rgzi167x0ygbw220nvq0w5b5msb91",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tokio-util@0.7.10": "058y6x4mf0fsqji9rfyb77qbfyc50y4pk2spqgj6xsyr693z66al",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tokio@1.35.1": "01613rkziqp812a288ga65aqygs254wgajdi57v8brivjkx4x6y8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#toml@0.8.2": "0g9ysjaqvm2mv8q85xpqfn7hi710hj24sd56k49wyddvvyq8lp8q",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#toml_datetime@0.6.3": "0jsy7v8bdvmzsci6imj8fzgd255fmy5fzp6zsri14yrry7i77nkw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#toml_edit@0.19.15": "08bl7rp5g6jwmfpad9s8jpw8wjrciadpnbaswgywpr9hv9qbfnqv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#toml_edit@0.20.2": "0f7k5svmxw98fhi28jpcyv7ldr2s3c867pjbji65bdxjpd44svir",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tower-service@0.3.2": "0lmfzmmvid2yp2l36mbavhmqgsvzqf7r2wiwz73ml4xmwaf1rg5n",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tracing-attributes@0.1.27": "1rvb5dn9z6d0xdj14r403z0af0bbaqhg02hq4jc97g5wds6lqw1l",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tracing-core@0.1.32": "0m5aglin3cdwxpvbg6kz0r9r0k31j48n0kcfwsp6l49z26k3svf0",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tracing@0.1.40": "1vv48dac9zgj9650pg2b4d0j3w6f3x9gbggf43scq5hrlysklln3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#traitobject@0.1.0": "0yb0n8822mr59j200fyr2fxgzzgqljyxflx9y8bdy3rlaqngilgg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#try-lock@0.2.5": "0jqijrrvm1pyq34zn1jmy2vihd4jcrjlvsh4alkjahhssjnsn8g4",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#tungstenite@0.20.1": "1fbgcv3h4h1bhhf5sqbwqsp7jnc44bi4m41sgmhzdsk2zl8aqgcy",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#type-map@0.4.0": "0ilsqq7pcl3k9ggxv2x5fbxxfd6x7ljsndrhc38jmjwnbr63dlxn",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#typeable@0.1.2": "11w8dywgnm32hb291izjvh4zjd037ccnkk77ahk63l913zwzc40l",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#typemap@0.3.3": "1xm1gbvz9qisj1l6d36hrl9pw8imr8ngs6qyanjnsad3h0yfcfv5",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#typenum@1.17.0": "09dqxv69m9lj9zvv6xw5vxaqx15ps0vxyy5myg33i0kbqvq0pzs2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#typeshare-annotation@1.0.2": "1adpfhyz3lqjjbq2ym69mv62ymqyd5651gxlqdy8aa446l70srzw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#typeshare@1.0.1": "1mi7snkx2b4g84x8vx38v1myg5r6g48c865j0nz5zcsc8lpilkgl",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unarray@0.1.4": "154smf048k84prsdgh09nkm2n0w0336v84jd4zikyn6v6jrqbspa",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unic-langid-impl@0.9.4": "1ijvqmsrg6qw3b1h9bh537pvwk2jn2kl6ck3z3qlxspxcch5mmab",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unic-langid@0.9.4": "05pm5p3j29c9jw9a4dr3v64g3x6g3zh37splj47i7vclszk251r3",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unicase@1.4.2": "0cwazh4qsmm9msckjk86zc1z35xg7hjxjykrgjalzdv367w6aivz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unicase@2.7.0": "12gd74j79f94k4clxpf06l99wiv4p30wjr0qm04ihqk9zgdd9lpp",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unicode-bidi@0.3.14": "05i4ps31vskq1wdp8yf315fxivyh1frijly9d4gb5clygbr2h9bg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unicode-ident@1.0.12": "0jzf1znfpb2gx8nr8mvmyqs1crnv79l57nxnbiszc7xf7ynbjm1k",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unicode-normalization@0.1.22": "08d95g7b1irc578b2iyhzv4xhsa4pfvwsqxcl9lbcpabzkq16msw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unicode-segmentation@1.10.1": "0dky2hm5k51xy11hc3nk85p533rvghd462b6i0c532b7hl4j9mhx",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unicode_categories@0.1.1": "0kp1d7fryxxm7hqywbk88yb9d1avsam9sg76xh36k5qx2arj9v1r",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#unsafe-any@0.4.2": "0zwwphsqkw5qaiqmjwngnfpv9ym85qcsyj7adip9qplzjzbn00zk",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#url@1.7.2": "0nim1c90mxpi9wgdw2xh8dqd72vlklwlzam436akcrhjac6pqknx",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#url@2.5.0": "0cs65961miawncdg2z20171w0vqrmraswv2ihdpd8lxp7cp31rii",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#urlencoding@2.1.3": "1nj99jp37k47n0hvaz5fvz7z6jd0sb4ppvfy3nphr1zbnyixpy6s",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#utf-8@0.7.6": "1a9ns3fvgird0snjkd3wbdhwd3zdpc2h5gpyybrfr6ra5pkqxk09",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#utf8parse@0.2.1": "02ip1a0az0qmc2786vxk2nqwsgcwf17d3a38fkf0q7hrmwh9c6vi",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#uuid@0.4.0": "0cdj2v6v2yy3zyisij69waksd17cyir1n58kwyk1n622105wbzkw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#uuid@0.8.2": "1dy4ldcp7rnzjy56dxh7d2sgrcvn4q77y0a8r0a48946h66zjp5w",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#uuid@1.6.1": "0q45jxahvysldn3iy04m8xmr8hgig80855y9gq9di8x72v7myfay",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#value-bag@1.7.0": "02r8wccrzi3bzlkrslkcfw9pwp8kwif9szif2i9arn9dzqx44vhj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#vcpkg@0.2.15": "09i4nf5y8lig6xgj3f7fyrvzd3nlaw4znrihw8psidvv5yk4xkdc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#version-compare@0.1.1": "0acg4pmjdbmclg0m7yhijn979mdy66z3k8qrcnvn634f1gy456jp",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#version_check@0.1.5": "1pf91pvj8n6akh7w6j5ypka6aqz08b3qpzgs0ak2kjf4frkiljwi",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#version_check@0.9.4": "0gs8grwdlgh0xq660d7wr80x14vxbizmd8dbp29p2pdncx8lp1s9",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#wait-timeout@0.2.0": "1xpkk0j5l9pfmjfh1pi0i89invlavfrd9av5xp0zhxgb29dhy84z",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#waker-fn@1.1.1": "142n74wlmpwcazfb5v7vhnzj3lb3r97qy8mzpjdpg345aizm3i7k",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#want@0.3.1": "03hbfrnvqqdchb5kgxyavb9jabwza0dmh2vw5kg0dq8rxl57d9xz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#warp@0.3.6": "0sfimrpxkyka1mavfhg5wa4x977qs8vyxa510c627w9zw0i2xsf1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#wasi@0.10.0+wasi-snapshot-preview1": "07y3l8mzfzzz4cj09c8y90yak4hpsi9g7pllyzpr6xvwrabka50s",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#wasi@0.11.0+wasi-snapshot-preview1": "08z4hxwkpdpalxjps1ai9y7ihin26y9f476i53dv98v45gkqg3cw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#wasm-bindgen-backend@0.2.89": "09l8lyylsdssz993h4fzja69zpvpykaw84fivs210fjgwqjzcmhv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#wasm-bindgen-futures@0.4.39": "04lsxpw4jqfwh7c0crzx0smj52nvwp1w3bh4098sq90149da2dmc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#wasm-bindgen-macro-support@0.2.89": "10sj1gr2naxv5q116yjb929hhpvz45dxbkvyk8hyc2lknzy85szh",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#wasm-bindgen-macro@0.2.89": "1cl2w7k5jn2jbd5kx613c8k8vjvda22hfgcgx7y2mk93fbrxnqh1",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#wasm-bindgen-shared@0.2.89": "17s5rppad113c6ggkaq8c3cg7a3zz15i78wxcg6mcl1n15iv7fbs",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#wasm-bindgen@0.2.89": "0kh6akdldy13z9xqj0skz6b4npq1d98bjkgzb8ccq59hibvd9l0f",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#web-sys@0.3.66": "03q1z22djv5ncqkyydcvnchmdsl5gvnyzcyixkxnifw6xi24mhjh",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#weezl@0.1.7": "1frdbq6y5jn2j93i20hc80swpkj30p1wffwxj1nr4fp09m6id4wi",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#whoami@1.4.1": "0l6ca9pl92wmngsn1dh9ih716v216nmn2zvcn94k04x9p1b3gz12",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#winapi-i686-pc-windows-gnu@0.4.0": "1dmpa6mvcvzz16zg6d5vrfy4bxgg541wxrcip7cnshi06v38ffxc",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#winapi-util@0.1.6": "15i5lm39wd44004i9d5qspry2cynkrpvwzghr6s2c3dsk28nz7pj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#winapi-x86_64-pc-windows-gnu@0.4.0": "0gqq64czqb64kskjryj8isp62m2sgvx25yyj3kpc2myh85w24bki",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#winapi@0.3.9": "06gl025x418lchw1wxj64ycr7gha83m44cjr5sarhynd9xkrm0sw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows-core@0.51.1": "0r1f57hsshsghjyc7ypp2s0i78f7b1vr93w68sdb8baxyf2czy7i",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.48.0": "1aan23v5gs7gya1lc46hqn9mdh8yph3fhxmhxlw36pn6pqc28zb7",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows-sys@0.52.0": "0gd3v4ji88490zgb6b5mq5zgbvwv7zx1ibn8v3x83rwcdbryaar8",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows-targets@0.48.5": "034ljxqshifs1lan89xwpcy1hp0lhdh4b5n0d2z4fwjx2piacbws",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows-targets@0.52.0": "1kg7a27ynzw8zz3krdgy6w5gbqcji27j1sz4p7xk2j5j8082064a",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_aarch64_gnullvm@0.48.5": "1n05v7qblg1ci3i567inc7xrkmywczxrs1z3lj3rkkxw18py6f1b",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_aarch64_gnullvm@0.52.0": "1shmn1kbdc0bpphcxz0vlph96bxz0h1jlmh93s9agf2dbpin8xyb",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_aarch64_msvc@0.48.5": "1g5l4ry968p73g6bg6jgyvy9lb8fyhcs54067yzxpcpkf44k2dfw",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_aarch64_msvc@0.52.0": "1vvmy1ypvzdvxn9yf0b8ygfl85gl2gpcyvsvqppsmlpisil07amv",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_i686_gnu@0.48.5": "0gklnglwd9ilqx7ac3cn8hbhkraqisd0n83jxzf9837nvvkiand7",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_i686_gnu@0.52.0": "04zkglz4p3pjsns5gbz85v4s5aw102raz4spj4b0lmm33z5kg1m2",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_i686_msvc@0.48.5": "01m4rik437dl9rdf0ndnm2syh10hizvq0dajdkv2fjqcywrw4mcg",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_i686_msvc@0.52.0": "16kvmbvx0vr0zbgnaz6nsks9ycvfh5xp05bjrhq65kj623iyirgz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_x86_64_gnu@0.48.5": "13kiqqcvz2vnyxzydjh73hwgigsdr2z1xpzx313kxll34nyhmm2k",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_x86_64_gnu@0.52.0": "1zdy4qn178sil5sdm63lm7f0kkcjg6gvdwmcprd2yjmwn8ns6vrx",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_x86_64_gnullvm@0.48.5": "1k24810wfbgz8k48c2yknqjmiigmql6kk3knmddkv8k8g1v54yqb",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_x86_64_gnullvm@0.52.0": "17lllq4l2k1lqgcnw1cccphxp9vs7inq99kjlm2lfl9zklg7wr8s",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_x86_64_msvc@0.48.5": "0f4mdp895kkjh9zv8dxvn4pc10xr7839lf5pa9l0193i2pkgr57d",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#windows_x86_64_msvc@0.52.0": "012wfq37f18c09ij5m6rniw7xxn5fcvrxbqd0wd8vgnl3hfn9yfz",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#winnow@0.5.30": "1ifj9vnqna5qp0d7nb9mrinzf8j7zi1m0gv75870vm91jyw3sp4v",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#winreg@0.50.0": "1cddmp929k882mdh6i9f2as848f13qqna6czwsqzkh1pqnr5fkjj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#zerocopy-derive@0.7.31": "06k0zk4x4n9s1blgxmxqb1g81y8q334aayx61gyy6v9y1dajkhdk",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#zerocopy@0.7.31": "0gcfyrmlrhmsz16qxjp2qzr6vixyaw1p04zl28f08lxkvfz62h0w",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#zeroize@1.7.0": "0bfvby7k9pdp6623p98yz2irqnamcyzpn7zh20nqmdn68b0lwnsj",
|
||||
"registry+https://github.com/rust-lang/crates.io-index#zune-inflate@0.2.54": "00kg24jh3zqa3i6rg6yksnb71bch9yi1casqydl00s7nw8pk7avk"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "dashboard"
|
||||
version = "0.1.2"
|
||||
version = "0.1.1"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
@ -28,5 +28,5 @@ tokio = { version = "1", features = ["full"] }
|
|||
unic-langid = { version = "0.9" }
|
||||
|
||||
[build-dependencies]
|
||||
glib-build-tools = "0.18"
|
||||
glib-build-tools = "0.16"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
fn main() {
|
||||
glib_build_tools::compile_resources(
|
||||
&["resources"],
|
||||
"gresources.xml",
|
||||
"resources",
|
||||
"resources/gresources.xml",
|
||||
"com.luminescent-dreams.dashboard.gresource",
|
||||
);
|
||||
}
|
||||
|
|
|
@ -11,11 +11,10 @@ pub struct DatePrivate {
|
|||
|
||||
impl Default for DatePrivate {
|
||||
fn default() -> Self {
|
||||
let date = chrono::Local::now().date_naive();
|
||||
let year = date.year();
|
||||
let date = date.with_year(year + 10000).unwrap();
|
||||
Self {
|
||||
date: Rc::new(RefCell::new(IFC::from(date))),
|
||||
date: Rc::new(RefCell::new(IFC::from(
|
||||
chrono::Local::now().date_naive().with_year(12023).unwrap(),
|
||||
))),
|
||||
label: Rc::new(RefCell::new(gtk::Label::new(None))),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ pub fn main() {
|
|||
|
||||
let now = Local::now();
|
||||
let state = State {
|
||||
date: IFC::from(now.date_naive().with_year(now.year() + 10000).unwrap()),
|
||||
date: IFC::from(now.date_naive().with_year(12023).unwrap()),
|
||||
next_event: EVENTS.next_event(now.with_timezone(&Utc)).unwrap(),
|
||||
events: EVENTS.yearly_events(now.year()).unwrap(),
|
||||
transit: Some(transit),
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
extern crate chrono;
|
||||
extern crate chrono_tz;
|
||||
|
||||
use chrono::SecondsFormat;
|
||||
use chrono_tz::Etc::UTC;
|
||||
use serde::de::{self, Deserialize, Deserializer, Visitor};
|
||||
use serde::ser::{Serialize, Serializer};
|
||||
use std::{fmt, str::FromStr};
|
||||
|
||||
/// This is a wrapper around date time objects, using timezones from the chroon-tz database and
|
||||
/// providing string representation and parsing of the form "<RFC3339> <Timezone Name>", i.e.,
|
||||
/// "2019-05-15T14:30:00Z US/Central". The to_string method, and serde serialization will
|
||||
/// produce a string of this format. The parser will accept an RFC3339-only string of the forms
|
||||
/// "2019-05-15T14:30:00Z", "2019-05-15T14:30:00+00:00", and also an "RFC3339 Timezone Name"
|
||||
/// string.
|
||||
///
|
||||
/// The function here is to generate as close to unambiguous time/date strings, (for earth's
|
||||
/// gravitational frame of reference), as possible. Clumping together the time, offset from UTC,
|
||||
/// and the named time zone allows future parsers to know the exact interpretation of the time in
|
||||
/// the frame of reference of the original recording.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct DateTimeTz(pub chrono::DateTime<chrono_tz::Tz>);
|
||||
|
||||
impl fmt::Display for DateTimeTz {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
if self.0.timezone() == UTC {
|
||||
write!(f, "{}", self.0.to_rfc3339_opts(SecondsFormat::Secs, true))
|
||||
} else {
|
||||
write!(
|
||||
f,
|
||||
"{} {}",
|
||||
self.0
|
||||
.with_timezone(&chrono_tz::Etc::UTC)
|
||||
.to_rfc3339_opts(SecondsFormat::Secs, true,),
|
||||
self.0.timezone().name()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DateTimeTz {
|
||||
pub fn map<F>(&self, f: F) -> DateTimeTz
|
||||
where
|
||||
F: FnOnce(chrono::DateTime<chrono_tz::Tz>) -> chrono::DateTime<chrono_tz::Tz>,
|
||||
{
|
||||
DateTimeTz(f(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for DateTimeTz {
|
||||
type Err = chrono::ParseError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let v: Vec<&str> = s.split_terminator(' ').collect();
|
||||
if v.len() == 2 {
|
||||
let tz = v[1].parse::<chrono_tz::Tz>().unwrap();
|
||||
chrono::DateTime::parse_from_rfc3339(v[0]).map(|ts| DateTimeTz(ts.with_timezone(&tz)))
|
||||
} else {
|
||||
chrono::DateTime::parse_from_rfc3339(v[0]).map(|ts| DateTimeTz(ts.with_timezone(&UTC)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<chrono::DateTime<chrono_tz::Tz>> for DateTimeTz {
|
||||
fn from(dt: chrono::DateTime<chrono_tz::Tz>) -> DateTimeTz {
|
||||
DateTimeTz(dt)
|
||||
}
|
||||
}
|
||||
|
||||
struct DateTimeTzVisitor;
|
||||
|
||||
impl<'de> Visitor<'de> for DateTimeTzVisitor {
|
||||
type Value = DateTimeTz;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("a string date time representation that can be parsed")
|
||||
}
|
||||
|
||||
fn visit_str<E: de::Error>(self, s: &str) -> Result<Self::Value, E> {
|
||||
DateTimeTz::from_str(s).or(Err(E::custom(
|
||||
"string is not a parsable datetime representation".to_owned(),
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for DateTimeTz {
|
||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
serializer.serialize_str(&self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for DateTimeTz {
|
||||
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
||||
deserializer.deserialize_str(DateTimeTzVisitor)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
extern crate serde_json;
|
||||
|
||||
use super::*;
|
||||
use chrono::TimeZone;
|
||||
use chrono_tz::America::Phoenix;
|
||||
use chrono_tz::Etc::UTC;
|
||||
use chrono_tz::US::{Arizona, Central};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[test]
|
||||
fn it_creates_timestamp_with_z() {
|
||||
let t = DateTimeTz(UTC.with_ymd_and_hms(2019, 5, 15, 12, 0, 0).unwrap());
|
||||
assert_eq!(t.to_string(), "2019-05-15T12:00:00Z");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_parses_utc_rfc3339_z() {
|
||||
let t = DateTimeTz::from_str("2019-05-15T12:00:00Z").unwrap();
|
||||
assert_eq!(
|
||||
t,
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2019, 5, 15, 12, 0, 0).unwrap())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_parses_rfc3339_with_offset() {
|
||||
let t = DateTimeTz::from_str("2019-05-15T12:00:00-06:00").unwrap();
|
||||
assert_eq!(
|
||||
t,
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2019, 5, 15, 18, 0, 0).unwrap())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_parses_rfc3339_with_tz() {
|
||||
let t = DateTimeTz::from_str("2019-06-15T19:00:00Z US/Arizona").unwrap();
|
||||
assert_eq!(
|
||||
t,
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2019, 6, 15, 19, 0, 0).unwrap())
|
||||
);
|
||||
assert_eq!(
|
||||
t,
|
||||
DateTimeTz(Arizona.with_ymd_and_hms(2019, 6, 15, 12, 0, 0).unwrap())
|
||||
);
|
||||
assert_eq!(
|
||||
t,
|
||||
DateTimeTz(Central.with_ymd_and_hms(2019, 6, 15, 14, 0, 0).unwrap())
|
||||
);
|
||||
assert_eq!(t.to_string(), "2019-06-15T19:00:00Z US/Arizona");
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct DemoStruct {
|
||||
id: String,
|
||||
dt: DateTimeTz,
|
||||
}
|
||||
|
||||
// I used Arizona here specifically because large parts of Arizona do not honor DST, and so
|
||||
// that adds in more ambiguity of the -0700 offset with Pacific time.
|
||||
#[test]
|
||||
fn it_json_serializes() {
|
||||
let t = DateTimeTz::from_str("2019-06-15T19:00:00Z America/Phoenix").unwrap();
|
||||
assert_eq!(
|
||||
serde_json::to_string(&t).unwrap(),
|
||||
"\"2019-06-15T19:00:00Z America/Phoenix\""
|
||||
);
|
||||
|
||||
let demo = DemoStruct {
|
||||
id: String::from("abcdefg"),
|
||||
dt: t,
|
||||
};
|
||||
assert_eq!(
|
||||
serde_json::to_string(&demo).unwrap(),
|
||||
"{\"id\":\"abcdefg\",\"dt\":\"2019-06-15T19:00:00Z America/Phoenix\"}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_json_parses() {
|
||||
let t =
|
||||
serde_json::from_str::<DateTimeTz>("\"2019-06-15T19:00:00Z America/Phoenix\"").unwrap();
|
||||
assert_eq!(
|
||||
t,
|
||||
DateTimeTz(Phoenix.with_ymd_and_hms(2019, 6, 15, 12, 0, 0).unwrap())
|
||||
);
|
||||
}
|
||||
}
|
|
@ -71,9 +71,11 @@ extern crate thiserror;
|
|||
extern crate uuid;
|
||||
|
||||
mod criteria;
|
||||
mod date_time_tz;
|
||||
mod series;
|
||||
mod types;
|
||||
|
||||
pub use criteria::*;
|
||||
pub use date_time_tz::DateTimeTz;
|
||||
pub use series::Series;
|
||||
pub use types::{EmseriesReadError, EmseriesWriteError, Record, RecordId, Recordable, Timestamp};
|
||||
pub use types::{EmseriesReadError, EmseriesWriteError, Recordable, Timestamp, UniqueId};
|
||||
|
|
|
@ -18,51 +18,13 @@ use serde::de::DeserializeOwned;
|
|||
use serde::ser::Serialize;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::fs::File;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::{BufRead, BufReader, LineWriter, Write};
|
||||
use std::iter::Iterator;
|
||||
|
||||
use criteria::Criteria;
|
||||
use types::{EmseriesReadError, EmseriesWriteError, Record, RecordId, Recordable};
|
||||
|
||||
// A RecordOnDisk, a private data structure, is useful for handling all of the on-disk
|
||||
// representations of a record. Unlike [Record], this one can accept an empty data value to
|
||||
// represent that the data may have been deleted. This is not made public because, so far as the
|
||||
// user is concerned, any record in the system must have data associated with it.
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
struct RecordOnDisk<T: Clone + Recordable> {
|
||||
id: RecordId,
|
||||
data: Option<T>,
|
||||
}
|
||||
|
||||
/*
|
||||
impl<T> FromStr for RecordOnDisk<T>
|
||||
where
|
||||
T: Clone + Recordable + DeserializeOwned + Serialize,
|
||||
{
|
||||
type Err = EmseriesReadError;
|
||||
|
||||
fn from_str(line: &str) -> Result<Self, Self::Err> {
|
||||
serde_json::from_str(line).map_err(EmseriesReadError::JSONParseError)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
impl<T: Clone + Recordable> TryFrom<RecordOnDisk<T>> for Record<T> {
|
||||
type Error = EmseriesReadError;
|
||||
|
||||
fn try_from(disk_record: RecordOnDisk<T>) -> Result<Self, Self::Error> {
|
||||
match disk_record.data {
|
||||
Some(data) => Ok(Record {
|
||||
id: disk_record.id,
|
||||
data,
|
||||
}),
|
||||
None => Err(Self::Error::RecordDeleted(disk_record.id)),
|
||||
}
|
||||
}
|
||||
}
|
||||
use types::{EmseriesReadError, EmseriesWriteError, Record, Recordable, UniqueId};
|
||||
|
||||
/// An open time series database.
|
||||
///
|
||||
|
@ -71,7 +33,7 @@ impl<T: Clone + Recordable> TryFrom<RecordOnDisk<T>> for Record<T> {
|
|||
pub struct Series<T: Clone + Recordable + DeserializeOwned + Serialize> {
|
||||
//path: String,
|
||||
writer: LineWriter<File>,
|
||||
records: HashMap<RecordId, Record<T>>,
|
||||
records: HashMap<UniqueId, T>,
|
||||
}
|
||||
|
||||
impl<T> Series<T>
|
||||
|
@ -80,7 +42,7 @@ where
|
|||
{
|
||||
/// Open a time series database at the specified path. `path` is the full path and filename for
|
||||
/// the database.
|
||||
pub fn open<P: AsRef<std::path::Path>>(path: P) -> Result<Series<T>, EmseriesReadError> {
|
||||
pub fn open(path: &str) -> Result<Series<T>, EmseriesReadError> {
|
||||
let f = OpenOptions::new()
|
||||
.read(true)
|
||||
.append(true)
|
||||
|
@ -100,18 +62,20 @@ where
|
|||
}
|
||||
|
||||
/// Load a file and return all of the records in it.
|
||||
fn load_file(f: &File) -> Result<HashMap<RecordId, Record<T>>, EmseriesReadError> {
|
||||
let mut records: HashMap<RecordId, Record<T>> = HashMap::new();
|
||||
fn load_file(f: &File) -> Result<HashMap<UniqueId, T>, EmseriesReadError> {
|
||||
let mut records: HashMap<UniqueId, T> = HashMap::new();
|
||||
let reader = BufReader::new(f);
|
||||
for line in reader.lines() {
|
||||
match line {
|
||||
Ok(line_) => {
|
||||
match serde_json::from_str::<RecordOnDisk<T>>(line_.as_ref())
|
||||
.map_err(EmseriesReadError::JSONParseError)
|
||||
.and_then(Record::try_from)
|
||||
{
|
||||
Ok(record) => records.insert(record.id, record.clone()),
|
||||
Err(EmseriesReadError::RecordDeleted(id)) => records.remove(&id),
|
||||
/* Can't create a JSONParseError because I can't actually create the underlying error.
|
||||
fail_point!("parse-line", Err(Error::JSONParseError()))
|
||||
*/
|
||||
match line_.parse::<Record<T>>() {
|
||||
Ok(record) => match record.data {
|
||||
Some(val) => records.insert(record.id.clone(), val),
|
||||
None => records.remove(&record.id.clone()),
|
||||
},
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
}
|
||||
|
@ -123,20 +87,18 @@ where
|
|||
|
||||
/// Put a new record into the database. A unique id will be assigned to the record and
|
||||
/// returned.
|
||||
pub fn put(&mut self, entry: T) -> Result<RecordId, EmseriesWriteError> {
|
||||
let id = RecordId::default();
|
||||
let record = Record { id, data: entry };
|
||||
self.update(record)?;
|
||||
Ok(id)
|
||||
pub fn put(&mut self, entry: T) -> Result<UniqueId, EmseriesWriteError> {
|
||||
let uuid = UniqueId::default();
|
||||
self.update(uuid.clone(), entry).map(|_| uuid)
|
||||
}
|
||||
|
||||
/// Update an existing record. The [RecordId] of the record passed into this function must match
|
||||
/// the [RecordId] of a record already in the database.
|
||||
pub fn update(&mut self, record: Record<T>) -> Result<(), EmseriesWriteError> {
|
||||
self.records.insert(record.id, record.clone());
|
||||
let write_res = match serde_json::to_string(&RecordOnDisk {
|
||||
id: record.id,
|
||||
data: Some(record.data),
|
||||
/// Update an existing record. The `UniqueId` of the record passed into this function must match
|
||||
/// the `UniqueId` of a record already in the database.
|
||||
pub fn update(&mut self, uuid: UniqueId, entry: T) -> Result<(), EmseriesWriteError> {
|
||||
self.records.insert(uuid.clone(), entry.clone());
|
||||
let write_res = match serde_json::to_string(&Record {
|
||||
id: uuid,
|
||||
data: Some(entry),
|
||||
}) {
|
||||
Ok(rec_str) => self
|
||||
.writer
|
||||
|
@ -156,14 +118,14 @@ where
|
|||
/// Future note: while this deletes a record from the view, it only adds an entry to the
|
||||
/// database that indicates `data: null`. If record histories ever become important, the record
|
||||
/// and its entire history (including this delete) will still be available.
|
||||
pub fn delete(&mut self, uuid: &RecordId) -> Result<(), EmseriesWriteError> {
|
||||
pub fn delete(&mut self, uuid: &UniqueId) -> Result<(), EmseriesWriteError> {
|
||||
if !self.records.contains_key(uuid) {
|
||||
return Ok(());
|
||||
};
|
||||
self.records.remove(uuid);
|
||||
|
||||
let rec: RecordOnDisk<T> = RecordOnDisk {
|
||||
id: *uuid,
|
||||
let rec: Record<T> = Record {
|
||||
id: uuid.clone(),
|
||||
data: None,
|
||||
};
|
||||
match serde_json::to_string(&rec) {
|
||||
|
@ -176,8 +138,8 @@ where
|
|||
}
|
||||
|
||||
/// Get all of the records in the database.
|
||||
pub fn records(&self) -> impl Iterator<Item = &Record<T>> {
|
||||
self.records.values()
|
||||
pub fn records(&self) -> impl Iterator<Item = (&UniqueId, &T)> {
|
||||
self.records.iter()
|
||||
}
|
||||
|
||||
/* The point of having Search is so that a lot of internal optimizations can happen once the
|
||||
|
@ -186,29 +148,29 @@ where
|
|||
pub fn search<'s>(
|
||||
&'s self,
|
||||
criteria: impl Criteria + 's,
|
||||
) -> impl Iterator<Item = &'s Record<T>> + 's {
|
||||
self.records().filter(move |&tr| criteria.apply(&tr.data))
|
||||
) -> impl Iterator<Item = (&'s UniqueId, &'s T)> + 's {
|
||||
self.records().filter(move |&tr| criteria.apply(tr.1))
|
||||
}
|
||||
|
||||
/// Perform a search and sort the resulting records based on the comparison.
|
||||
pub fn search_sorted<'s, C, CMP>(&'s self, criteria: C, compare: CMP) -> Vec<&'s Record<T>>
|
||||
pub fn search_sorted<'s, C, CMP>(&'s self, criteria: C, compare: CMP) -> Vec<(&UniqueId, &T)>
|
||||
where
|
||||
C: Criteria + 's,
|
||||
CMP: FnMut(&&Record<T>, &&Record<T>) -> Ordering,
|
||||
CMP: FnMut(&(&UniqueId, &T), &(&UniqueId, &T)) -> Ordering,
|
||||
{
|
||||
let search_iter = self.search(criteria);
|
||||
let mut records: Vec<&Record<T>> = search_iter.collect();
|
||||
let mut records: Vec<(&UniqueId, &T)> = search_iter.collect();
|
||||
records.sort_by(compare);
|
||||
records
|
||||
}
|
||||
|
||||
/// Get an exact record from the database based on unique id.
|
||||
pub fn get(&self, uuid: &RecordId) -> Option<Record<T>> {
|
||||
pub fn get(&self, uuid: &UniqueId) -> Option<T> {
|
||||
self.records.get(uuid).cloned()
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn remove(&self, uuid: RecordId) -> Result<(), EmseriesError> {
|
||||
pub fn remove(&self, uuid: UniqueId) -> Result<(), EmseriesError> {
|
||||
unimplemented!()
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -10,7 +10,10 @@ Luminescent Dreams Tools is distributed in the hope that it will be useful, but
|
|||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use chrono::{DateTime, FixedOffset, NaiveDate};
|
||||
use chrono::NaiveDate;
|
||||
use date_time_tz::DateTimeTz;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::ser::Serialize;
|
||||
use std::{cmp::Ordering, fmt, io, str};
|
||||
use thiserror::Error;
|
||||
use uuid::Uuid;
|
||||
|
@ -25,9 +28,6 @@ pub enum EmseriesReadError {
|
|||
#[error("Error parsing JSON: {0}")]
|
||||
JSONParseError(serde_json::error::Error),
|
||||
|
||||
#[error("Record was deleted")]
|
||||
RecordDeleted(RecordId),
|
||||
|
||||
/// Indicates a general IO error
|
||||
#[error("IO Error: {0}")]
|
||||
IOError(io::Error),
|
||||
|
@ -44,47 +44,17 @@ pub enum EmseriesWriteError {
|
|||
JSONWriteError(serde_json::error::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
/// A Timestamp, stored with reference to human reckoning. This could be either a Naive Date or a
|
||||
/// date and a time with a timezone. The idea of the "human reckoning" is that, no matter what
|
||||
/// timezone the record was created in, we want to group things based on the date that the human
|
||||
/// was perceiving at the time it was recorded.
|
||||
pub enum Timestamp {
|
||||
DateTime(DateTime<FixedOffset>),
|
||||
Date(NaiveDate),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum TimestampJS {
|
||||
DateTime(String),
|
||||
Date(String),
|
||||
}
|
||||
|
||||
impl From<Timestamp> for TimestampJS {
|
||||
fn from(s: Timestamp) -> TimestampJS {
|
||||
match s {
|
||||
Timestamp::DateTime(ts) => TimestampJS::DateTime(ts.to_rfc3339()),
|
||||
Timestamp::Date(ts) => TimestampJS::Date(ts.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TimestampJS> for Timestamp {
|
||||
fn from(s: TimestampJS) -> Timestamp {
|
||||
match s {
|
||||
TimestampJS::DateTime(ts) => {
|
||||
Timestamp::DateTime(DateTime::parse_from_rfc3339(&ts).unwrap())
|
||||
}
|
||||
TimestampJS::Date(ts) => Timestamp::Date(ts.parse::<NaiveDate>().unwrap()),
|
||||
}
|
||||
}
|
||||
pub enum Timestamp {
|
||||
DateTime(DateTimeTz),
|
||||
Date(NaiveDate),
|
||||
}
|
||||
|
||||
impl str::FromStr for Timestamp {
|
||||
type Err = chrono::ParseError;
|
||||
fn from_str(line: &str) -> Result<Self, Self::Err> {
|
||||
DateTime::parse_from_rfc3339(line)
|
||||
DateTimeTz::from_str(line)
|
||||
.map(Timestamp::DateTime)
|
||||
.or(NaiveDate::from_str(line).map(Timestamp::Date))
|
||||
}
|
||||
|
@ -100,13 +70,25 @@ impl Ord for Timestamp {
|
|||
fn cmp(&self, other: &Timestamp) -> Ordering {
|
||||
match (self, other) {
|
||||
(Timestamp::DateTime(dt1), Timestamp::DateTime(dt2)) => dt1.cmp(dt2),
|
||||
(Timestamp::DateTime(dt1), Timestamp::Date(dt2)) => dt1.date_naive().cmp(dt2),
|
||||
(Timestamp::Date(dt1), Timestamp::DateTime(dt2)) => dt1.cmp(&dt2.date_naive()),
|
||||
(Timestamp::DateTime(dt1), Timestamp::Date(dt2)) => dt1.0.date_naive().cmp(dt2),
|
||||
(Timestamp::Date(dt1), Timestamp::DateTime(dt2)) => dt1.cmp(&dt2.0.date_naive()),
|
||||
(Timestamp::Date(dt1), Timestamp::Date(dt2)) => dt1.cmp(dt2),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DateTimeTz> for Timestamp {
|
||||
fn from(d: DateTimeTz) -> Self {
|
||||
Self::DateTime(d)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NaiveDate> for Timestamp {
|
||||
fn from(d: NaiveDate) -> Self {
|
||||
Self::Date(d)
|
||||
}
|
||||
}
|
||||
|
||||
/// Any element to be put into the database needs to be Recordable. This is the common API that
|
||||
/// will aid in searching and later in indexing records.
|
||||
pub trait Recordable {
|
||||
|
@ -120,88 +102,75 @@ pub trait Recordable {
|
|||
/// Uniquely identifies a record.
|
||||
///
|
||||
/// This is a wrapper around a basic uuid with some extra convenience methods.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)]
|
||||
pub struct RecordId(Uuid);
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)]
|
||||
pub struct UniqueId(Uuid);
|
||||
|
||||
impl Default for RecordId {
|
||||
impl Default for UniqueId {
|
||||
fn default() -> Self {
|
||||
Self(Uuid::new_v4())
|
||||
}
|
||||
}
|
||||
|
||||
impl str::FromStr for RecordId {
|
||||
impl str::FromStr for UniqueId {
|
||||
type Err = EmseriesReadError;
|
||||
|
||||
/// Parse a RecordId from a string. Raise UUIDParseError if the parsing fails.
|
||||
/// Parse a UniqueId from a string. Raise UUIDParseError if the parsing fails.
|
||||
fn from_str(val: &str) -> Result<Self, Self::Err> {
|
||||
Uuid::parse_str(val)
|
||||
.map(RecordId)
|
||||
.map(UniqueId)
|
||||
.map_err(EmseriesReadError::UUIDParseError)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for RecordId {
|
||||
impl fmt::Display for UniqueId {
|
||||
/// Convert to a hyphenated string
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||
write!(f, "{}", self.0.to_hyphenated())
|
||||
}
|
||||
}
|
||||
|
||||
/// A record represents data that actually exists in the database. Users cannot make the record
|
||||
/// directly, as the database will create them.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
/// Every record contains a unique ID and then the primary data, which itself must implementd the
|
||||
/// Recordable trait.
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct Record<T: Clone + Recordable> {
|
||||
pub id: RecordId,
|
||||
pub data: T,
|
||||
pub id: UniqueId,
|
||||
pub data: Option<T>,
|
||||
}
|
||||
|
||||
impl<T: Clone + Recordable> Record<T> {
|
||||
pub fn date(&self) -> NaiveDate {
|
||||
match self.data.timestamp() {
|
||||
Timestamp::DateTime(dt) => dt.date_naive(),
|
||||
Timestamp::Date(dt) => dt,
|
||||
}
|
||||
}
|
||||
impl<T> str::FromStr for Record<T>
|
||||
where
|
||||
T: Clone + Recordable + DeserializeOwned + Serialize,
|
||||
{
|
||||
type Err = EmseriesReadError;
|
||||
|
||||
pub fn timestamp(&self) -> Timestamp {
|
||||
self.data.timestamp()
|
||||
}
|
||||
|
||||
pub fn map<Map, U>(self, map: Map) -> Record<U>
|
||||
where
|
||||
Map: Fn(T) -> U,
|
||||
U: Clone + Recordable,
|
||||
{
|
||||
Record {
|
||||
id: self.id,
|
||||
data: map(self.data),
|
||||
}
|
||||
fn from_str(line: &str) -> Result<Self, Self::Err> {
|
||||
serde_json::from_str(line).map_err(EmseriesReadError::JSONParseError)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
extern crate dimensioned;
|
||||
|
||||
extern crate serde_json;
|
||||
|
||||
use self::dimensioned::si::{Kilogram, KG};
|
||||
use super::*;
|
||||
use chrono::TimeZone;
|
||||
use chrono_tz::Etc::UTC;
|
||||
use chrono_tz::{Etc::UTC, US::Central};
|
||||
use date_time_tz::DateTimeTz;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||
pub struct Weight(Kilogram<f64>);
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||
pub struct WeightRecord {
|
||||
pub date: NaiveDate,
|
||||
pub date: Timestamp,
|
||||
pub weight: Weight,
|
||||
}
|
||||
|
||||
impl Recordable for WeightRecord {
|
||||
fn timestamp(&self) -> Timestamp {
|
||||
Timestamp::Date(self.date)
|
||||
self.date.clone()
|
||||
}
|
||||
|
||||
fn tags(&self) -> Vec<String> {
|
||||
|
@ -210,14 +179,12 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn timestamp_parses_utc_time() {
|
||||
fn timestamp_parses_datetimetz_without_timezone() {
|
||||
assert_eq!(
|
||||
"2003-11-10T06:00:00Z".parse::<Timestamp>().unwrap(),
|
||||
Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2003, 11, 10, 6, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap())
|
||||
),
|
||||
Timestamp::DateTime(DateTimeTz(
|
||||
UTC.with_ymd_and_hms(2003, 11, 10, 6, 0, 0).unwrap()
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -229,10 +196,9 @@ mod test {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn v_alpha_serialization() {
|
||||
const WEIGHT_ENTRY: &str = "{\"data\":{\"weight\":77.79109},\"date\":\"2003-11-10\",\"id\":\"3330c5b0-783f-4919-b2c4-8169c38f65ff\"}";
|
||||
const WEIGHT_ENTRY: &str = "{\"data\":{\"weight\":77.79109,\"date\":\"2003-11-10T06:00:00.000000000000Z\"},\"id\":\"3330c5b0-783f-4919-b2c4-8169c38f65ff\"}";
|
||||
|
||||
let rec: Record<WeightRecord> = WEIGHT_ENTRY
|
||||
.parse()
|
||||
|
@ -243,64 +209,66 @@ mod test {
|
|||
);
|
||||
assert_eq!(
|
||||
rec.data,
|
||||
WeightRecord {
|
||||
date: NaiveDate::from_ymd_opt(2003, 11, 10).unwrap(),
|
||||
Some(WeightRecord {
|
||||
date: Timestamp::DateTime(DateTimeTz(
|
||||
UTC.with_ymd_and_hms(2003, 11, 10, 6, 0, 0).unwrap()
|
||||
)),
|
||||
weight: Weight(77.79109 * KG),
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
#[test]
|
||||
fn serialization_output() {
|
||||
let rec = WeightRecord {
|
||||
date: NaiveDate::from_ymd_opt(2003, 11, 10).unwrap(),
|
||||
date: Timestamp::DateTime(DateTimeTz(
|
||||
UTC.with_ymd_and_hms(2003, 11, 10, 6, 0, 0).unwrap(),
|
||||
)),
|
||||
weight: Weight(77.0 * KG),
|
||||
};
|
||||
assert_eq!(
|
||||
serde_json::to_string(&rec).unwrap(),
|
||||
"{\"date\":\"2003-11-10\",\"weight\":77.0}"
|
||||
"{\"date\":\"2003-11-10T06:00:00Z\",\"weight\":77.0}"
|
||||
);
|
||||
|
||||
let rec2 = WeightRecord {
|
||||
date: NaiveDate::from_ymd_opt(2003, 11, 10).unwrap(),
|
||||
date: Timestamp::DateTime(
|
||||
Central
|
||||
.with_ymd_and_hms(2003, 11, 10, 0, 0, 0)
|
||||
.unwrap()
|
||||
.into(),
|
||||
),
|
||||
weight: Weight(77.0 * KG),
|
||||
};
|
||||
assert_eq!(
|
||||
serde_json::to_string(&rec2).unwrap(),
|
||||
"{\"date\":\"2003-11-10\",\"weight\":77.0}"
|
||||
"{\"date\":\"2003-11-10T06:00:00Z US/Central\",\"weight\":77.0}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_datetimes_can_be_compared() {
|
||||
let time1 = Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2003, 11, 10, 6, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
);
|
||||
let time2 = Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2003, 11, 11, 6, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
);
|
||||
let time1 = Timestamp::DateTime(DateTimeTz(
|
||||
UTC.with_ymd_and_hms(2003, 11, 10, 6, 0, 0).unwrap(),
|
||||
));
|
||||
let time2 = Timestamp::DateTime(DateTimeTz(
|
||||
UTC.with_ymd_and_hms(2003, 11, 11, 6, 0, 0).unwrap(),
|
||||
));
|
||||
assert!(time1 < time2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_dates_can_be_compared() {
|
||||
let time1: Timestamp = Timestamp::Date(NaiveDate::from_ymd_opt(2003, 11, 10).unwrap());
|
||||
let time2: Timestamp = Timestamp::Date(NaiveDate::from_ymd_opt(2003, 11, 11).unwrap());
|
||||
let time1 = Timestamp::Date(NaiveDate::from_ymd_opt(2003, 11, 10).unwrap());
|
||||
let time2 = Timestamp::Date(NaiveDate::from_ymd_opt(2003, 11, 11).unwrap());
|
||||
assert!(time1 < time2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn datetime_and_date_can_be_compared() {
|
||||
let time1 = Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2003, 11, 10, 6, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
);
|
||||
let time1 = Timestamp::DateTime(DateTimeTz(
|
||||
UTC.with_ymd_and_hms(2003, 11, 10, 6, 0, 0).unwrap(),
|
||||
));
|
||||
let time2 = Timestamp::Date(NaiveDate::from_ymd_opt(2003, 11, 11).unwrap());
|
||||
assert!(time1 < time2)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ extern crate emseries;
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use chrono::{prelude::*};
|
||||
use chrono::prelude::*;
|
||||
use chrono_tz::Etc::UTC;
|
||||
use dimensioned::si::{Kilogram, Meter, Second, M, S};
|
||||
|
||||
|
@ -34,7 +34,7 @@ mod test {
|
|||
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||
struct BikeTrip {
|
||||
datetime: DateTime<FixedOffset>,
|
||||
datetime: DateTimeTz,
|
||||
distance: Distance,
|
||||
duration: Duration,
|
||||
comments: String,
|
||||
|
@ -42,7 +42,7 @@ mod test {
|
|||
|
||||
impl Recordable for BikeTrip {
|
||||
fn timestamp(&self) -> Timestamp {
|
||||
Timestamp::DateTime(self.datetime)
|
||||
self.datetime.clone().into()
|
||||
}
|
||||
fn tags(&self) -> Vec<String> {
|
||||
Vec::new()
|
||||
|
@ -52,46 +52,31 @@ mod test {
|
|||
fn mk_trips() -> [BikeTrip; 5] {
|
||||
[
|
||||
BikeTrip {
|
||||
datetime: UTC
|
||||
.with_ymd_and_hms(2011, 10, 29, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
datetime: DateTimeTz(UTC.with_ymd_and_hms(2011, 10, 29, 0, 0, 0).unwrap()),
|
||||
distance: Distance(58741.055 * M),
|
||||
duration: Duration(11040.0 * S),
|
||||
comments: String::from("long time ago"),
|
||||
},
|
||||
BikeTrip {
|
||||
datetime: UTC
|
||||
.with_ymd_and_hms(2011, 10, 31, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
datetime: DateTimeTz(UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0).unwrap()),
|
||||
distance: Distance(17702.0 * M),
|
||||
duration: Duration(2880.0 * S),
|
||||
comments: String::from("day 2"),
|
||||
},
|
||||
BikeTrip {
|
||||
datetime: UTC
|
||||
.with_ymd_and_hms(2011, 11, 02, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
datetime: DateTimeTz(UTC.with_ymd_and_hms(2011, 11, 02, 0, 0, 0).unwrap()),
|
||||
distance: Distance(41842.945 * M),
|
||||
duration: Duration(7020.0 * S),
|
||||
comments: String::from("Do Some Distance!"),
|
||||
},
|
||||
BikeTrip {
|
||||
datetime: UTC
|
||||
.with_ymd_and_hms(2011, 11, 04, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
datetime: DateTimeTz(UTC.with_ymd_and_hms(2011, 11, 04, 0, 0, 0).unwrap()),
|
||||
distance: Distance(34600.895 * M),
|
||||
duration: Duration(5580.0 * S),
|
||||
comments: String::from("I did a lot of distance back then"),
|
||||
},
|
||||
BikeTrip {
|
||||
datetime: UTC
|
||||
.with_ymd_and_hms(2011, 11, 05, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
datetime: DateTimeTz(UTC.with_ymd_and_hms(2011, 11, 05, 0, 0, 0).unwrap()),
|
||||
distance: Distance(6437.376 * M),
|
||||
duration: Duration(960.0 * S),
|
||||
comments: String::from("day 5"),
|
||||
|
@ -99,7 +84,7 @@ mod test {
|
|||
]
|
||||
}
|
||||
|
||||
fn run_test<T>(test: T)
|
||||
fn run_test<T>(test: T) -> ()
|
||||
where
|
||||
T: FnOnce(tempfile::TempPath),
|
||||
{
|
||||
|
@ -108,14 +93,14 @@ mod test {
|
|||
test(tmp_path);
|
||||
}
|
||||
|
||||
fn run<T>(test: T)
|
||||
fn run<T>(test: T) -> ()
|
||||
where
|
||||
T: FnOnce(Series<BikeTrip>),
|
||||
{
|
||||
let tmp_file = tempfile::NamedTempFile::new().expect("temporary path created");
|
||||
let tmp_path = tmp_file.into_temp_path();
|
||||
let ts: Series<BikeTrip> =
|
||||
Series::open(&tmp_path).expect("the time series should open correctly");
|
||||
let ts: Series<BikeTrip> = Series::open(&tmp_path.to_string_lossy())
|
||||
.expect("the time series should open correctly");
|
||||
test(ts);
|
||||
}
|
||||
|
||||
|
@ -137,15 +122,11 @@ mod test {
|
|||
Some(tr) => {
|
||||
assert_eq!(
|
||||
tr.timestamp(),
|
||||
Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 10, 29, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap())
|
||||
)
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 10, 29, 0, 0, 0).unwrap()).into()
|
||||
);
|
||||
assert_eq!(tr.data.duration, Duration(11040.0 * S));
|
||||
assert_eq!(tr.data.comments, String::from("long time ago"));
|
||||
assert_eq!(tr.data, trips[0]);
|
||||
assert_eq!(tr.duration, Duration(11040.0 * S));
|
||||
assert_eq!(tr.comments, String::from("long time ago"));
|
||||
assert_eq!(tr, trips[0]);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -155,22 +136,20 @@ mod test {
|
|||
pub fn can_search_for_an_entry_with_exact_time() {
|
||||
run_test(|path| {
|
||||
let trips = mk_trips();
|
||||
let mut ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let mut ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
|
||||
for trip in &trips[0..=4] {
|
||||
ts.put(trip.clone()).expect("expect a successful put");
|
||||
}
|
||||
|
||||
let v: Vec<&Record<BikeTrip>> = ts
|
||||
.search(exact_time(Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
)))
|
||||
let v: Vec<(&UniqueId, &BikeTrip)> = ts
|
||||
.search(exact_time(
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0).unwrap()).into(),
|
||||
))
|
||||
.collect();
|
||||
assert_eq!(v.len(), 1);
|
||||
assert_eq!(v[0].data, trips[1]);
|
||||
assert_eq!(*v[0].1, trips[1]);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -178,34 +157,26 @@ mod test {
|
|||
pub fn can_get_entries_in_time_range() {
|
||||
run_test(|path| {
|
||||
let trips = mk_trips();
|
||||
let mut ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let mut ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
|
||||
for trip in &trips[0..=4] {
|
||||
ts.put(trip.clone()).expect("expect a successful put");
|
||||
}
|
||||
|
||||
let v: Vec<&Record<BikeTrip>> = ts.search_sorted(
|
||||
let v: Vec<(&UniqueId, &BikeTrip)> = ts.search_sorted(
|
||||
time_range(
|
||||
Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
),
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0).unwrap()).into(),
|
||||
true,
|
||||
Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 11, 04, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
),
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 11, 04, 0, 0, 0).unwrap()).into(),
|
||||
true,
|
||||
),
|
||||
|l, r| l.timestamp().cmp(&r.timestamp()),
|
||||
|l, r| l.1.timestamp().cmp(&r.1.timestamp()),
|
||||
);
|
||||
assert_eq!(v.len(), 3);
|
||||
assert_eq!(v[0].data, trips[1]);
|
||||
assert_eq!(v[1].data, trips[2]);
|
||||
assert_eq!(v[2].data, trips[3]);
|
||||
assert_eq!(*v[0].1, trips[1]);
|
||||
assert_eq!(*v[1].1, trips[2]);
|
||||
assert_eq!(*v[2].1, trips[3]);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -215,8 +186,8 @@ mod test {
|
|||
let trips = mk_trips();
|
||||
|
||||
{
|
||||
let mut ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let mut ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
|
||||
for trip in &trips[0..=4] {
|
||||
ts.put(trip.clone()).expect("expect a successful put");
|
||||
|
@ -224,29 +195,21 @@ mod test {
|
|||
}
|
||||
|
||||
{
|
||||
let ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let v: Vec<&Record<BikeTrip>> = ts.search_sorted(
|
||||
let ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
let v: Vec<(&UniqueId, &BikeTrip)> = ts.search_sorted(
|
||||
time_range(
|
||||
Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
),
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0).unwrap()).into(),
|
||||
true,
|
||||
Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 11, 04, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
),
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 11, 04, 0, 0, 0).unwrap()).into(),
|
||||
true,
|
||||
),
|
||||
|l, r| l.timestamp().cmp(&r.timestamp()),
|
||||
|l, r| l.1.timestamp().cmp(&r.1.timestamp()),
|
||||
);
|
||||
assert_eq!(v.len(), 3);
|
||||
assert_eq!(v[0].data, trips[1]);
|
||||
assert_eq!(v[1].data, trips[2]);
|
||||
assert_eq!(v[2].data, trips[3]);
|
||||
assert_eq!(*v[0].1, trips[1]);
|
||||
assert_eq!(*v[1].1, trips[2]);
|
||||
assert_eq!(*v[2].1, trips[3]);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -257,8 +220,8 @@ mod test {
|
|||
let trips = mk_trips();
|
||||
|
||||
{
|
||||
let mut ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let mut ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
|
||||
for trip in &trips[0..=2] {
|
||||
ts.put(trip.clone()).expect("expect a successful put");
|
||||
|
@ -266,57 +229,41 @@ mod test {
|
|||
}
|
||||
|
||||
{
|
||||
let mut ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let v: Vec<&Record<BikeTrip>> = ts.search_sorted(
|
||||
let mut ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
let v: Vec<(&UniqueId, &BikeTrip)> = ts.search_sorted(
|
||||
time_range(
|
||||
Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
),
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0).unwrap()).into(),
|
||||
true,
|
||||
Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 11, 04, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
),
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 11, 04, 0, 0, 0).unwrap()).into(),
|
||||
true,
|
||||
),
|
||||
|l, r| l.timestamp().cmp(&r.timestamp()),
|
||||
|l, r| l.1.timestamp().cmp(&r.1.timestamp()),
|
||||
);
|
||||
assert_eq!(v.len(), 2);
|
||||
assert_eq!(v[0].data, trips[1]);
|
||||
assert_eq!(v[1].data, trips[2]);
|
||||
assert_eq!(*v[0].1, trips[1]);
|
||||
assert_eq!(*v[1].1, trips[2]);
|
||||
ts.put(trips[3].clone()).expect("expect a successful put");
|
||||
ts.put(trips[4].clone()).expect("expect a successful put");
|
||||
}
|
||||
|
||||
{
|
||||
let ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let v: Vec<&Record<BikeTrip>> = ts.search_sorted(
|
||||
let ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
let v: Vec<(&UniqueId, &BikeTrip)> = ts.search_sorted(
|
||||
time_range(
|
||||
Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
),
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 10, 31, 0, 0, 0).unwrap()).into(),
|
||||
true,
|
||||
Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 11, 05, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
),
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 11, 05, 0, 0, 0).unwrap()).into(),
|
||||
true,
|
||||
),
|
||||
|l, r| l.timestamp().cmp(&r.timestamp()),
|
||||
|l, r| l.1.timestamp().cmp(&r.1.timestamp()),
|
||||
);
|
||||
assert_eq!(v.len(), 4);
|
||||
assert_eq!(v[0].data, trips[1]);
|
||||
assert_eq!(v[1].data, trips[2]);
|
||||
assert_eq!(v[2].data, trips[3]);
|
||||
assert_eq!(v[3].data, trips[4]);
|
||||
assert_eq!(*v[0].1, trips[1]);
|
||||
assert_eq!(*v[1].1, trips[2]);
|
||||
assert_eq!(*v[2].1, trips[3]);
|
||||
assert_eq!(*v[3].1, trips[4]);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -326,8 +273,8 @@ mod test {
|
|||
run_test(|path| {
|
||||
let trips = mk_trips();
|
||||
|
||||
let mut ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let mut ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
|
||||
ts.put(trips[0].clone()).expect("expect a successful put");
|
||||
ts.put(trips[1].clone()).expect("expect a successful put");
|
||||
|
@ -336,8 +283,9 @@ mod test {
|
|||
match ts.get(&trip_id) {
|
||||
None => assert!(false, "record not found"),
|
||||
Some(mut trip) => {
|
||||
trip.data.distance = Distance(50000.0 * M);
|
||||
ts.update(trip).expect("expect record to update");
|
||||
trip.distance = Distance(50000.0 * M);
|
||||
ts.update(trip_id.clone(), trip)
|
||||
.expect("expect record to update");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -345,12 +293,12 @@ mod test {
|
|||
None => assert!(false, "record not found"),
|
||||
Some(trip) => {
|
||||
assert_eq!(
|
||||
trip.data.datetime,
|
||||
UTC.with_ymd_and_hms(2011, 11, 02, 0, 0, 0).unwrap()
|
||||
trip.datetime,
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 11, 02, 0, 0, 0).unwrap())
|
||||
);
|
||||
assert_eq!(trip.data.distance, Distance(50000.0 * M));
|
||||
assert_eq!(trip.data.duration, Duration(7020.0 * S));
|
||||
assert_eq!(trip.data.comments, String::from("Do Some Distance!"));
|
||||
assert_eq!(trip.distance, Distance(50000.0 * M));
|
||||
assert_eq!(trip.duration, Duration(7020.0 * S));
|
||||
assert_eq!(trip.comments, String::from("Do Some Distance!"));
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -362,8 +310,8 @@ mod test {
|
|||
let trips = mk_trips();
|
||||
|
||||
{
|
||||
let mut ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let mut ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
|
||||
ts.put(trips[0].clone()).expect("expect a successful put");
|
||||
ts.put(trips[1].clone()).expect("expect a successful put");
|
||||
|
@ -372,36 +320,32 @@ mod test {
|
|||
match ts.get(&trip_id) {
|
||||
None => assert!(false, "record not found"),
|
||||
Some(mut trip) => {
|
||||
trip.data.distance = Distance(50000.0 * M);
|
||||
ts.update(trip).expect("expect record to update");
|
||||
trip.distance = Distance(50000.0 * M);
|
||||
ts.update(trip_id, trip).expect("expect record to update");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
let ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
|
||||
let trips: Vec<&Record<BikeTrip>> = ts.records().collect();
|
||||
let trips: Vec<(&UniqueId, &BikeTrip)> = ts.records().collect();
|
||||
assert_eq!(trips.len(), 3);
|
||||
|
||||
let trips: Vec<&Record<BikeTrip>> = ts
|
||||
.search(exact_time(Timestamp::DateTime(
|
||||
UTC.with_ymd_and_hms(2011, 11, 02, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap()),
|
||||
)))
|
||||
let trips: Vec<(&UniqueId, &BikeTrip)> = ts
|
||||
.search(exact_time(
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 11, 02, 0, 0, 0).unwrap()).into(),
|
||||
))
|
||||
.collect();
|
||||
assert_eq!(trips.len(), 1);
|
||||
assert_eq!(
|
||||
trips[0].data.datetime,
|
||||
UTC.with_ymd_and_hms(2011, 11, 02, 0, 0, 0)
|
||||
.unwrap()
|
||||
.with_timezone(&FixedOffset::east_opt(0).unwrap())
|
||||
trips[0].1.datetime,
|
||||
DateTimeTz(UTC.with_ymd_and_hms(2011, 11, 02, 0, 0, 0).unwrap())
|
||||
);
|
||||
assert_eq!(trips[0].data.distance, Distance(50000.0 * M));
|
||||
assert_eq!(trips[0].data.duration, Duration(7020.0 * S));
|
||||
assert_eq!(trips[0].data.comments, String::from("Do Some Distance!"));
|
||||
assert_eq!(trips[0].1.distance, Distance(50000.0 * M));
|
||||
assert_eq!(trips[0].1.duration, Duration(7020.0 * S));
|
||||
assert_eq!(trips[0].1.comments, String::from("Do Some Distance!"));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -412,21 +356,21 @@ mod test {
|
|||
let trips = mk_trips();
|
||||
|
||||
{
|
||||
let mut ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let mut ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
let trip_id = ts.put(trips[0].clone()).expect("expect a successful put");
|
||||
ts.put(trips[1].clone()).expect("expect a successful put");
|
||||
ts.put(trips[2].clone()).expect("expect a successful put");
|
||||
ts.delete(&trip_id).expect("successful delete");
|
||||
|
||||
let recs: Vec<&Record<BikeTrip>> = ts.records().collect();
|
||||
let recs: Vec<(&UniqueId, &BikeTrip)> = ts.records().collect();
|
||||
assert_eq!(recs.len(), 2);
|
||||
}
|
||||
|
||||
{
|
||||
let ts: Series<BikeTrip> =
|
||||
Series::open(&path).expect("expect the time series to open correctly");
|
||||
let recs: Vec<&Record<BikeTrip>> = ts.records().collect();
|
||||
let ts: Series<BikeTrip> = Series::open(&path.to_string_lossy())
|
||||
.expect("expect the time series to open correctly");
|
||||
let recs: Vec<(&UniqueId, &BikeTrip)> = ts.records().collect();
|
||||
assert_eq!(recs.len(), 2);
|
||||
}
|
||||
})
|
||||
|
@ -443,7 +387,7 @@ mod test {
|
|||
|
||||
impl Recordable for WeightRecord {
|
||||
fn timestamp(&self) -> Timestamp {
|
||||
Timestamp::Date(self.date)
|
||||
self.date.into()
|
||||
}
|
||||
|
||||
fn tags(&self) -> Vec<String> {
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
[package]
|
||||
name = "fitnesstrax"
|
||||
version = "0.6.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
adw = { version = "0.5", package = "libadwaita", features = [ "v1_4" ] }
|
||||
async-channel = { version = "2.1" }
|
||||
async-trait = { version = "0.1" }
|
||||
chrono = { version = "0.4" }
|
||||
chrono-tz = { version = "0.8" }
|
||||
dimensioned = { version = "0.8", features = [ "serde" ] }
|
||||
emseries = { path = "../../emseries" }
|
||||
ft-core = { path = "../core" }
|
||||
gio = { version = "0.18" }
|
||||
glib = { version = "0.18" }
|
||||
gdk = { version = "0.7", package = "gdk4" }
|
||||
gtk = { version = "0.7", package = "gtk4", features = [ "v4_10" ] }
|
||||
thiserror = { version = "1.0" }
|
||||
tokio = { version = "1.34", features = [ "full" ] }
|
||||
|
||||
[build-dependencies]
|
||||
glib-build-tools = "0.18"
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
fn main() {
|
||||
glib_build_tools::compile_resources(
|
||||
&["resources"],
|
||||
"gresources.xml",
|
||||
"com.luminescent-dreams.fitnesstrax.gresource",
|
||||
);
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=`cat Cargo.toml | grep "^version =" | sed -r 's/^version = "(.+)"$/\1/'`
|
||||
|
||||
mkdir -p dist
|
||||
cp ../../target/release/fitnesstrax dist
|
||||
cp resources/com.luminescent-dreams.fitnesstrax.gschema.xml resources/fitnesstrax.desktop dist
|
||||
strip dist/fitnesstrax
|
||||
tar -czf fitnesstrax-${VERSION}.tgz dist/
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/com/luminescent-dreams/fitnesstrax/">
|
||||
<file>style.css</file>
|
||||
</gresource>
|
||||
|
||||
<gresource prefix="/com/luminescent-dreams/fitnesstrax/icons/scalable/actions">
|
||||
<file preprocess="xml-stripblanks">cycling-symbolic.svg</file>
|
||||
</gresource>
|
||||
|
||||
<gresource prefix="/com/luminescent-dreams/fitnesstrax/icons/scalable/actions">
|
||||
<file preprocess="xml-stripblanks">running-symbolic.svg</file>
|
||||
</gresource>
|
||||
|
||||
<gresource prefix="/com/luminescent-dreams/fitnesstrax/icons/scalable/actions/">
|
||||
<file preprocess="xml-stripblanks">walking-symbolic.svg</file>
|
||||
</gresource>
|
||||
</gresources>
|
|
@ -1,14 +0,0 @@
|
|||
{ gtkNativeInputs }:
|
||||
attrs: {
|
||||
nativeBuildInputs = gtkNativeInputs;
|
||||
postInstall = ''
|
||||
install -Dt $out/share/applications resources/fitnesstrax.desktop
|
||||
install -Dt $out/gsettings-schemas/${attrs.crateName}-${attrs.version}/glib-2.0/schemas resources/com.luminescent-dreams.fitnesstrax.gschema.xml
|
||||
glib-compile-schemas $out/gsettings-schemas/${attrs.crateName}-${attrs.version}/glib-2.0/schemas
|
||||
'';
|
||||
preFixup = ''
|
||||
gappsWrapperArgs+=(
|
||||
--prefix XDG_DATA_DIRS : $out/gsettings-schemas/${attrs.crateName}-${attrs.version}
|
||||
)
|
||||
'';
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<schemalist>
|
||||
<schema id="com.luminescent-dreams.fitnesstrax.dev" path="/com/luminescent-dreams/fitnesstrax/dev/">
|
||||
<key name="series-path" type="s">
|
||||
<default>""</default>
|
||||
<summary>Path to the series</summary>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<schemalist>
|
||||
<schema id="com.luminescent-dreams.fitnesstrax" path="/com/luminescent-dreams/fitnesstrax/">
|
||||
<key name="series-path" type="s">
|
||||
<default>""</default>
|
||||
<summary>Path to the series</summary>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
|
@ -1,2 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="16px" viewBox="0 0 16 16" width="16px"><filter id="a" height="100%" width="100%" x="0%" y="0%"><feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/></filter><mask id="b"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.5"/></g></mask><clipPath id="c"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="d"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.7"/></g></mask><clipPath id="e"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="f"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.35"/></g></mask><clipPath id="g"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><path d="m 9.5 2 c -0.828125 0 -1.5 0.671875 -1.5 1.5 s 0.671875 1.5 1.5 1.5 s 1.5 -0.671875 1.5 -1.5 s -0.671875 -1.5 -1.5 -1.5 z m 0 0"/><path d="m 4.285156 13 c 0 0.703125 -0.582031 1.285156 -1.285156 1.285156 s -1.285156 -0.582031 -1.285156 -1.285156 s 0.582031 -1.285156 1.285156 -1.285156 s 1.285156 0.582031 1.285156 1.285156 z m -4.285156 0 c 0 1.675781 1.324219 3 3 3 s 3 -1.324219 3 -3 s -1.324219 -3 -3 -3 s -3 1.324219 -3 3 z m 0 0"/><path d="m 8.992188 13.007812 v -3.003906 c 0 -0.359375 -0.1875 -0.6875 -0.5 -0.867187 l -2.558594 -1.476563 l 0.363281 1.363282 l 1.671875 -2.890626 l -1.367188 0.363282 l 0.910157 0.527344 l -0.40625 -0.4375 c 0.773437 1.621093 1.96875 1.933593 1.96875 1.933593 s 0.578125 0.242188 1.9375 0.429688 c 0.546875 0.074219 1.050781 -0.304688 1.128906 -0.851563 c 0.074219 -0.550781 -0.308594 -1.054687 -0.855469 -1.128906 c -1.179687 -0.164062 -1.601562 -0.355469 -1.601562 -0.355469 s -0.425782 -0.164062 -0.769532 -0.886719 c -0.089843 -0.183593 -0.226562 -0.335937 -0.402343 -0.4375 l -0.910157 -0.523437 c -0.476562 -0.277344 -1.089843 -0.113281 -1.363281 0.367187 l -1.671875 2.890626 c -0.277344 0.480468 -0.113281 1.089843 0.367188 1.367187 l 2.558594 1.480469 l -0.5 -0.867188 v 3.003906 c 0 0.550782 0.449218 1 1 1 c 0.554687 0 1 -0.449218 1 -1 z m 0 0"/><path d="m 14.285156 13 c 0 0.703125 -0.582031 1.285156 -1.285156 1.285156 s -1.285156 -0.582031 -1.285156 -1.285156 s 0.582031 -1.285156 1.285156 -1.285156 s 1.285156 0.582031 1.285156 1.285156 z m -4.285156 0 c 0 1.675781 1.324219 3 3 3 s 3 -1.324219 3 -3 s -1.324219 -3 -3 -3 s -3 1.324219 -3 3 z m 0 0"/><g mask="url(#b)"><g clip-path="url(#c)" transform="matrix(1 0 0 1 -600 -120)"><path d="m 550 182 c -0.351562 0.003906 -0.695312 0.101562 -1 0.28125 v 3.4375 c 0.304688 0.179688 0.648438 0.277344 1 0.28125 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 c -0.339844 0 -0.679688 0.058594 -1 0.175781 v 6.824219 h 4 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#d)"><g clip-path="url(#e)" transform="matrix(1 0 0 1 -600 -120)"><path d="m 569 182 v 4 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 v 7 h 3 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#f)"><g clip-path="url(#g)" transform="matrix(1 0 0 1 -600 -120)"><path d="m 573 182.269531 v 3.449219 c 0.613281 -0.355469 0.996094 -1.007812 1 -1.71875 c 0 -0.714844 -0.382812 -1.375 -1 -1.730469 z m 0 4.90625 v 6.824219 h 2 v -4 c 0 -1.269531 -0.800781 -2.402344 -2 -2.824219 z m 0 0"/></g></g></svg>
|
Before Width: | Height: | Size: 3.3 KiB |
|
@ -1,5 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Version=0.2
|
||||
Type=Application
|
||||
Name=FitnessTrax
|
||||
Exec=fitnesstrax
|
|
@ -1,2 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="16px" viewBox="0 0 16 16" width="16px"><filter id="a" height="100%" width="100%" x="0%" y="0%"><feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/></filter><mask id="b"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.5"/></g></mask><clipPath id="c"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="d"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.7"/></g></mask><clipPath id="e"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="f"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.35"/></g></mask><clipPath id="g"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><path d="m 8.5 0 c -0.828125 0 -1.5 0.671875 -1.5 1.5 s 0.671875 1.5 1.5 1.5 s 1.5 -0.671875 1.5 -1.5 s -0.671875 -1.5 -1.5 -1.5 z m -2.5 4 c -0.117188 0 -0.230469 0.027344 -0.335938 0.082031 l -2 1 c -0.144531 0.070313 -0.261718 0.1875 -0.332031 0.332031 l -1 2 c -0.1875 0.371094 -0.039062 0.820313 0.332031 1.007813 c 0.371094 0.183594 0.820313 0.035156 1.003907 -0.335937 l 0.890625 -1.777344 l 1.5625 -0.773438 c -0.042969 0.074219 -0.726563 2.835938 -0.726563 2.835938 c -0.230469 0.949218 0.398438 1.523437 0.398438 1.523437 l 3.351562 2.703125 l 0.90625 2.71875 c 0.175781 0.523438 0.742188 0.808594 1.265625 0.632813 c 0.523438 -0.175781 0.808594 -0.742188 0.632813 -1.265625 l -1 -3 c -0.0625 -0.183594 -0.171875 -0.34375 -0.324219 -0.464844 l -2 -1.597656 l 0.679688 -2.714844 l 0.25 0.625 c 0.085937 0.222656 0.28125 0.390625 0.515624 0.449219 l 2 0.5 c 0.402344 0.097656 0.808594 -0.144531 0.910157 -0.546875 c 0.097656 -0.40625 -0.144531 -0.8125 -0.546875 -0.910156 l -1.628906 -0.40625 l -0.855469 -2.144532 c -0.117188 -0.285156 -0.390625 -0.472656 -0.699219 -0.472656 z m -1.164062 6.328125 l -0.710938 2.128906 l -1.832031 1.835938 c -0.390625 0.390625 -0.390625 1.023437 0 1.414062 s 1.023437 0.390625 1.414062 0 l 2 -2 c 0.109375 -0.109375 0.191407 -0.242187 0.242188 -0.390625 l 0.542969 -1.628906 z m 0 0"/><g mask="url(#b)"><g clip-path="url(#c)" transform="matrix(1 0 0 1 -620 -120)"><path d="m 550 182 c -0.351562 0.003906 -0.695312 0.101562 -1 0.28125 v 3.4375 c 0.304688 0.179688 0.648438 0.277344 1 0.28125 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 c -0.339844 0 -0.679688 0.058594 -1 0.175781 v 6.824219 h 4 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#d)"><g clip-path="url(#e)" transform="matrix(1 0 0 1 -620 -120)"><path d="m 569 182 v 4 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 v 7 h 3 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#f)"><g clip-path="url(#g)" transform="matrix(1 0 0 1 -620 -120)"><path d="m 573 182.269531 v 3.449219 c 0.613281 -0.355469 0.996094 -1.007812 1 -1.71875 c 0 -0.714844 -0.382812 -1.375 -1 -1.730469 z m 0 4.90625 v 6.824219 h 2 v -4 c 0 -1.269531 -0.800781 -2.402344 -2 -2.824219 z m 0 0"/></g></g></svg>
|
Before Width: | Height: | Size: 3.0 KiB |
|
@ -1,85 +0,0 @@
|
|||
.welcome {
|
||||
margin: 64px;
|
||||
}
|
||||
|
||||
.welcome__title {
|
||||
font-size: x-large;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.welcome__content {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.historical {
|
||||
margin: 32px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.date-range-picker {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
/*
|
||||
.date-range-picker > box:not(:last-child) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
*/
|
||||
|
||||
.date-range-picker__date-field {
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.date-range-picker__search-button {
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.date-range-picker__range-button {
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.date-field__year {
|
||||
margin: 0px 4px 0px 0px;
|
||||
}
|
||||
|
||||
.date-field__month {
|
||||
margin: 0px 4px 0px 4px;
|
||||
}
|
||||
|
||||
.date-field__day {
|
||||
margin: 0px 0px 0px 4px;
|
||||
}
|
||||
|
||||
.day-summary {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.day-summary > *:not(:last-child) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.day-summary__date {
|
||||
font-size: x-large;
|
||||
}
|
||||
|
||||
.day-summary__weight {
|
||||
margin: 4px;
|
||||
}
|
||||
|
||||
.weight-view {
|
||||
padding: 8px;
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.step-view {
|
||||
padding: 8px;
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.about__content {
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.about label {
|
||||
margin-bottom: 16px;
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="16px" viewBox="0 0 16 16" width="16px"><filter id="a" height="100%" width="100%" x="0%" y="0%"><feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/></filter><mask id="b"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.5"/></g></mask><clipPath id="c"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="d"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.7"/></g></mask><clipPath id="e"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="f"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.35"/></g></mask><clipPath id="g"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><path d="m 9.5 1.5 c 0 0.828125 -0.671875 1.5 -1.5 1.5 s -1.5 -0.671875 -1.5 -1.5 s 0.671875 -1.5 1.5 -1.5 s 1.5 0.671875 1.5 1.5 z m 0 0"/><path d="m 7 4 c -0.550781 0 -1 0.449219 -1 1 v 4 c 0 0.265625 0.105469 0.519531 0.292969 0.707031 l 0.445312 0.449219 l -2.59375 4.328125 c -0.285156 0.476563 -0.132812 1.089844 0.34375 1.375 c 0.472657 0.28125 1.085938 0.128906 1.367188 -0.34375 l 2.34375 -3.902344 l 0.925781 0.929688 l 0.925781 2.773437 c 0.082031 0.25 0.265625 0.460938 0.5 0.578125 c 0.238281 0.121094 0.515625 0.140625 0.765625 0.054688 c 0.25 -0.082031 0.460938 -0.265625 0.578125 -0.5 c 0.121094 -0.238281 0.140625 -0.515625 0.054688 -0.765625 l -1 -3 c -0.050781 -0.148438 -0.132813 -0.28125 -0.242188 -0.390625 l -1.707031 -1.707031 v -4.585938 c 0 -0.550781 -0.449219 -1 -1 -1 z m 0 0"/><path d="m 6 4 c -0.101562 0 -0.207031 0.019531 -0.300781 0.0625 c 0 0 -2.113281 0.847656 -2.199219 2.90625 v 0.03125 v 2.25 c 0 0.414062 0.335938 0.75 0.75 0.75 s 0.75 -0.335938 0.75 -0.75 v -2.21875 c 0.039062 -0.894531 1.050781 -1.449219 1.207031 -1.53125 h 2.332031 l 1.042969 2.085938 c 0.097657 0.195312 0.273438 0.339843 0.488281 0.394531 l 2 0.5 c 0.191407 0.046875 0.394532 0.015625 0.566407 -0.085938 c 0.171875 -0.101562 0.292969 -0.269531 0.34375 -0.460937 c 0.046875 -0.195313 0.015625 -0.398438 -0.085938 -0.570313 c -0.101562 -0.171875 -0.269531 -0.292969 -0.464843 -0.34375 l -1.664063 -0.414062 l -1.097656 -2.191407 c -0.125 -0.253906 -0.382813 -0.414062 -0.667969 -0.414062 z m 0 0"/><g mask="url(#b)"><g clip-path="url(#c)" transform="matrix(1 0 0 1 -620 -100)"><path d="m 550 182 c -0.351562 0.003906 -0.695312 0.101562 -1 0.28125 v 3.4375 c 0.304688 0.179688 0.648438 0.277344 1 0.28125 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 c -0.339844 0 -0.679688 0.058594 -1 0.175781 v 6.824219 h 4 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#d)"><g clip-path="url(#e)" transform="matrix(1 0 0 1 -620 -100)"><path d="m 569 182 v 4 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 v 7 h 3 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#f)"><g clip-path="url(#g)" transform="matrix(1 0 0 1 -620 -100)"><path d="m 573 182.269531 v 3.449219 c 0.613281 -0.355469 0.996094 -1.007812 1 -1.71875 c 0 -0.714844 -0.382812 -1.375 -1 -1.730469 z m 0 4.90625 v 6.824219 h 2 v -4 c 0 -1.269531 -0.800781 -2.402344 -2 -2.824219 z m 0 0"/></g></g></svg>
|
Before Width: | Height: | Size: 3.2 KiB |
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
Copyright 2023 - 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct AboutWindowPrivate {}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for AboutWindowPrivate {
|
||||
const NAME: &'static str = "AboutWindow";
|
||||
type Type = AboutWindow;
|
||||
type ParentType = gtk::Window;
|
||||
}
|
||||
|
||||
impl ObjectImpl for AboutWindowPrivate {}
|
||||
impl WidgetImpl for AboutWindowPrivate {}
|
||||
impl WindowImpl for AboutWindowPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct AboutWindow(ObjectSubclass<AboutWindowPrivate>) @extends gtk::Window, gtk::Widget;
|
||||
}
|
||||
|
||||
impl Default for AboutWindow {
|
||||
fn default() -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_width_request(600);
|
||||
s.set_height_request(700);
|
||||
s.add_css_class("about");
|
||||
|
||||
s.set_title(Some("About Fitnesstrax"));
|
||||
let copyright = gtk::Label::builder()
|
||||
.label("Copyright 2023-2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>")
|
||||
.halign(gtk::Align::Start)
|
||||
.build();
|
||||
|
||||
let gtk_rs_thanks = gtk::Label::builder()
|
||||
.label("I owe a huge debt of gratitude to the GTK-RS project (https://gtk-rs.org/), which makes it possible for me to write this application to begin with. Further, I owe a particular debt to Julian Hofer and his book, GUI development with Rust and GTK 4 (https://gtk-rs.org/gtk4-rs/stable/latest/book/). Without this book, I would have continued to stumble around writing bad user interfaces with even worse code.")
|
||||
.halign(gtk::Align::Start).wrap(true)
|
||||
.build();
|
||||
|
||||
let dependencies = gtk::Label::builder()
|
||||
.label("This application depends on many libraries, most of which are licensed under the BSD-3 or GPL-3 licenses.")
|
||||
.halign(gtk::Align::Start).wrap(true)
|
||||
.build();
|
||||
|
||||
let content = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.css_classes(["about__content"])
|
||||
.build();
|
||||
content.append(©right);
|
||||
content.append(>k_rs_thanks);
|
||||
content.append(&dependencies);
|
||||
|
||||
let scroller = gtk::ScrolledWindow::builder()
|
||||
.child(&content)
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.hscrollbar_policy(gtk::PolicyType::Never)
|
||||
.build();
|
||||
|
||||
s.set_child(Some(&scroller));
|
||||
|
||||
s
|
||||
}
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
/*
|
||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use async_trait::async_trait;
|
||||
use chrono::NaiveDate;
|
||||
use emseries::{time_range, Record, RecordId, Series, Timestamp};
|
||||
use ft_core::TraxRecord;
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
use thiserror::Error;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AppError {
|
||||
#[error("no database loaded")]
|
||||
NoDatabase,
|
||||
#[error("failed to open the database")]
|
||||
FailedToOpenDatabase,
|
||||
#[error("unhandled error")]
|
||||
Unhandled,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReadError {
|
||||
#[error("no database loaded")]
|
||||
NoDatabase,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WriteError {
|
||||
#[error("no database loaded")]
|
||||
NoDatabase,
|
||||
#[error("unhandled error")]
|
||||
Unhandled,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait RecordProvider: Send + Sync {
|
||||
async fn records(
|
||||
&self,
|
||||
start: NaiveDate,
|
||||
end: NaiveDate,
|
||||
) -> Result<Vec<Record<TraxRecord>>, ReadError>;
|
||||
async fn put_record(&self, record: TraxRecord) -> Result<RecordId, WriteError>;
|
||||
async fn update_record(&self, record: Record<TraxRecord>) -> Result<(), WriteError>;
|
||||
async fn delete_record(&self, id: RecordId) -> Result<(), WriteError>;
|
||||
}
|
||||
|
||||
/// The real, headless application. This is where all of the logic will reside.
|
||||
#[derive(Clone)]
|
||||
pub struct App {
|
||||
runtime: Arc<Runtime>,
|
||||
database: Arc<RwLock<Option<Series<TraxRecord>>>>,
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn new(db_path: Option<PathBuf>) -> Self {
|
||||
let database = db_path.map(|path| Series::open(path).unwrap());
|
||||
let runtime = Arc::new(
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
Self {
|
||||
runtime,
|
||||
database: Arc::new(RwLock::new(database)),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn open_db(&self, path: PathBuf) -> Result<(), AppError> {
|
||||
let db_ref = self.database.clone();
|
||||
self.runtime
|
||||
.spawn_blocking(move || {
|
||||
let db = Series::open(path).map_err(|_| AppError::FailedToOpenDatabase)?;
|
||||
*db_ref.write().unwrap() = Some(db);
|
||||
Ok(())
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn database_is_open(&self) -> bool {
|
||||
self.database.read().unwrap().is_some()
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl RecordProvider for App {
|
||||
async fn records(
|
||||
&self,
|
||||
start: NaiveDate,
|
||||
end: NaiveDate,
|
||||
) -> Result<Vec<Record<TraxRecord>>, ReadError> {
|
||||
let db = self.database.clone();
|
||||
self.runtime
|
||||
.spawn_blocking(move || {
|
||||
if let Some(ref db) = *db.read().unwrap() {
|
||||
let records = db
|
||||
.search(time_range(
|
||||
Timestamp::Date(start),
|
||||
true,
|
||||
Timestamp::Date(end),
|
||||
true,
|
||||
))
|
||||
.cloned()
|
||||
.collect::<Vec<Record<TraxRecord>>>();
|
||||
Ok(records)
|
||||
} else {
|
||||
Err(ReadError::NoDatabase)
|
||||
}
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
async fn put_record(&self, record: TraxRecord) -> Result<RecordId, WriteError> {
|
||||
let db = self.database.clone();
|
||||
self.runtime
|
||||
.spawn_blocking(move || {
|
||||
if let Some(ref mut db) = *db.write().unwrap() {
|
||||
let id = db.put(record).unwrap();
|
||||
Ok(id)
|
||||
} else {
|
||||
Err(AppError::NoDatabase)
|
||||
}
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
.map_err(|_| WriteError::Unhandled)
|
||||
}
|
||||
|
||||
async fn update_record(&self, record: Record<TraxRecord>) -> Result<(), WriteError> {
|
||||
let db = self.database.clone();
|
||||
self.runtime
|
||||
.spawn_blocking(move || {
|
||||
if let Some(ref mut db) = *db.write().unwrap() {
|
||||
db.update(record).map_err(|_| AppError::Unhandled)
|
||||
} else {
|
||||
Err(AppError::NoDatabase)
|
||||
}
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
.map_err(|_| WriteError::Unhandled)
|
||||
}
|
||||
|
||||
async fn delete_record(&self, _id: RecordId) -> Result<(), WriteError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
/*
|
||||
Copyright 2023-2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
app::App,
|
||||
types::DayInterval,
|
||||
view_models::DayDetailViewModel,
|
||||
views::{DayDetailView, HistoricalView, PlaceholderView, View, WelcomeView},
|
||||
};
|
||||
use adw::prelude::*;
|
||||
use chrono::{Duration, Local};
|
||||
|
||||
use gio::resources_lookup_data;
|
||||
use gtk::STYLE_PROVIDER_PRIORITY_USER;
|
||||
use std::{cell::RefCell, path::PathBuf, rc::Rc};
|
||||
|
||||
/// The application window, or the main window, is the main user interface for the app. Almost
|
||||
/// everything occurs here.
|
||||
#[derive(Clone)]
|
||||
pub struct AppWindow {
|
||||
app: App,
|
||||
layout: gtk::Box,
|
||||
current_view: Rc<RefCell<View>>,
|
||||
settings: gio::Settings,
|
||||
navigation: adw::NavigationView,
|
||||
}
|
||||
|
||||
impl AppWindow {
|
||||
/// Construct a new App Window.
|
||||
///
|
||||
/// adw_app is an Adwaita application. Application windows need to have access to this, but
|
||||
/// otherwise we don't use this.
|
||||
///
|
||||
/// app is a core [crate::app::App] object which encapsulates all of the basic logic.
|
||||
pub fn new(
|
||||
app_id: &str,
|
||||
resource_path: &str,
|
||||
adw_app: &adw::Application,
|
||||
ft_app: App,
|
||||
) -> AppWindow {
|
||||
let window = adw::ApplicationWindow::builder()
|
||||
.application(adw_app)
|
||||
.width_request(800)
|
||||
.height_request(746)
|
||||
.build();
|
||||
window.connect_destroy(|s| {
|
||||
let _ = gtk::prelude::WidgetExt::activate_action(s, "app.quit", None);
|
||||
});
|
||||
|
||||
let stylesheet = String::from_utf8(
|
||||
resources_lookup_data(
|
||||
&format!("{}style.css", resource_path),
|
||||
gio::ResourceLookupFlags::NONE,
|
||||
)
|
||||
.expect("stylesheet must be available in the resources")
|
||||
.to_vec(),
|
||||
)
|
||||
.expect("to parse stylesheet");
|
||||
|
||||
let provider = gtk::CssProvider::new();
|
||||
provider.load_from_data(&stylesheet);
|
||||
|
||||
#[allow(deprecated)]
|
||||
let context = window.style_context();
|
||||
#[allow(deprecated)]
|
||||
context.add_provider(&provider, STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
let navigation = adw::NavigationView::new();
|
||||
|
||||
let layout = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let initial_view = View::Placeholder(PlaceholderView::default().upcast());
|
||||
|
||||
let header_bar = adw::HeaderBar::new();
|
||||
|
||||
let main_menu = gio::Menu::new();
|
||||
main_menu.append(Some("About"), Some("app.about"));
|
||||
main_menu.append(Some("Quit"), Some("app.quit"));
|
||||
let main_menu_button = gtk::MenuButton::builder()
|
||||
.icon_name("open-menu")
|
||||
.direction(gtk::ArrowType::Down)
|
||||
.halign(gtk::Align::End)
|
||||
.menu_model(&main_menu)
|
||||
.build();
|
||||
header_bar.pack_end(&main_menu_button);
|
||||
|
||||
layout.append(&initial_view.widget());
|
||||
|
||||
let nav_layout = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
||||
nav_layout.append(&header_bar);
|
||||
nav_layout.append(&layout);
|
||||
navigation.push(
|
||||
&adw::NavigationPage::builder()
|
||||
.can_pop(false)
|
||||
.title("FitnessTrax")
|
||||
.child(&nav_layout)
|
||||
.build(),
|
||||
);
|
||||
|
||||
window.set_content(Some(&navigation));
|
||||
window.present();
|
||||
|
||||
let s = Self {
|
||||
app: ft_app,
|
||||
layout,
|
||||
current_view: Rc::new(RefCell::new(initial_view)),
|
||||
settings: gio::Settings::new(app_id),
|
||||
navigation,
|
||||
};
|
||||
|
||||
s.load_records();
|
||||
|
||||
s.navigation.connect_popped({
|
||||
let s = s.clone();
|
||||
move |_, _| {
|
||||
if let View::Historical(_) = *s.current_view.borrow() {
|
||||
s.load_records();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
fn show_welcome_view(&self) {
|
||||
let view = View::Welcome(WelcomeView::new({
|
||||
let s = self.clone();
|
||||
move |path| s.on_apply_config(path)
|
||||
}));
|
||||
self.swap_main(view);
|
||||
}
|
||||
|
||||
fn show_historical_view(&self, interval: DayInterval) {
|
||||
let on_select_day = {
|
||||
let s = self.clone();
|
||||
move |date| {
|
||||
let s = s.clone();
|
||||
glib::spawn_future_local(async move {
|
||||
let view_model = DayDetailViewModel::new(date, s.app.clone()).await.unwrap();
|
||||
let layout = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
||||
layout.append(&adw::HeaderBar::new());
|
||||
// layout.append(&DayDetailView::new(date, records, s.app.clone()));
|
||||
layout.append(&DayDetailView::new(view_model));
|
||||
let page = &adw::NavigationPage::builder()
|
||||
.title(date.format("%Y-%m-%d").to_string())
|
||||
.child(&layout)
|
||||
.build();
|
||||
s.navigation.push(page);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let view = View::Historical(HistoricalView::new(
|
||||
self.app.clone(),
|
||||
interval,
|
||||
Rc::new(on_select_day),
|
||||
));
|
||||
self.swap_main(view);
|
||||
}
|
||||
|
||||
fn load_records(&self) {
|
||||
glib::spawn_future_local({
|
||||
let s = self.clone();
|
||||
async move {
|
||||
if s.app.database_is_open() {
|
||||
let end = Local::now().date_naive();
|
||||
let start = end - Duration::days(7);
|
||||
s.show_historical_view(DayInterval { start, end });
|
||||
} else {
|
||||
s.show_welcome_view();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Switch views.
|
||||
//
|
||||
// This function only replaces the old view with the one which matches the current view state.
|
||||
// It is responsible for ensuring that the new view goes into the layout in the correct
|
||||
// position.
|
||||
fn swap_main(&self, view: View) {
|
||||
let mut current_widget = self.current_view.borrow_mut();
|
||||
self.layout.remove(¤t_widget.widget());
|
||||
*current_widget = view;
|
||||
self.layout.append(¤t_widget.widget());
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn on_apply_config(&self, path: PathBuf) {
|
||||
glib::spawn_future_local({
|
||||
let s = self.clone();
|
||||
async move {
|
||||
if s.app.open_db(path.clone()).await.is_ok() {
|
||||
let _ = s.settings.set("series-path", path.to_str().unwrap());
|
||||
s.load_records();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
Copyright 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//! ActionGroup and related structures
|
||||
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ActionGroupPrivate;
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for ActionGroupPrivate {
|
||||
const NAME: &'static str = "ActionGroup";
|
||||
type Type = ActionGroup;
|
||||
type ParentType = gtk::Box;
|
||||
}
|
||||
|
||||
impl ObjectImpl for ActionGroupPrivate {}
|
||||
impl WidgetImpl for ActionGroupPrivate {}
|
||||
impl BoxImpl for ActionGroupPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct ActionGroup(ObjectSubclass<ActionGroupPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||
}
|
||||
|
||||
impl ActionGroup {
|
||||
fn new(builder: ActionGroupBuilder) -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_orientation(builder.orientation);
|
||||
|
||||
let primary_button = builder.primary_action.button();
|
||||
let secondary_button = builder.secondary_action.map(|action| action.button());
|
||||
let tertiary_button = builder.tertiary_action.map(|action| action.button());
|
||||
|
||||
if let Some(button) = tertiary_button {
|
||||
s.append(&button);
|
||||
}
|
||||
|
||||
s.set_halign(gtk::Align::End);
|
||||
if let Some(button) = secondary_button {
|
||||
s.append(&button);
|
||||
}
|
||||
s.append(&primary_button);
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
pub fn builder() -> ActionGroupBuilder {
|
||||
ActionGroupBuilder {
|
||||
orientation: gtk::Orientation::Horizontal,
|
||||
primary_action: Action {
|
||||
label: "Ok".to_owned(),
|
||||
action: Box::new(|| {}),
|
||||
},
|
||||
secondary_action: None,
|
||||
tertiary_action: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Action {
|
||||
label: String,
|
||||
action: Box<dyn Fn()>,
|
||||
}
|
||||
|
||||
impl Action {
|
||||
fn button(self) -> gtk::Button {
|
||||
let button = gtk::Button::builder().label(self.label).build();
|
||||
button.connect_clicked(move |_| (self.action)());
|
||||
button
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ActionGroupBuilder {
|
||||
orientation: gtk::Orientation,
|
||||
primary_action: Action,
|
||||
secondary_action: Option<Action>,
|
||||
tertiary_action: Option<Action>,
|
||||
}
|
||||
|
||||
impl ActionGroupBuilder {
|
||||
pub fn orientation(mut self, orientation: gtk::Orientation) -> Self {
|
||||
self.orientation = orientation;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn primary_action<A>(mut self, label: &str, action: A) -> Self
|
||||
where
|
||||
A: Fn() + 'static,
|
||||
{
|
||||
self.primary_action = Action {
|
||||
label: label.to_owned(),
|
||||
action: Box::new(action),
|
||||
};
|
||||
self
|
||||
}
|
||||
|
||||
pub fn secondary_action<A>(mut self, label: &str, action: A) -> Self
|
||||
where
|
||||
A: Fn() + 'static,
|
||||
{
|
||||
self.secondary_action = Some(Action {
|
||||
label: label.to_owned(),
|
||||
action: Box::new(action),
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
pub fn tertiary_action<A>(mut self, label: &str, action: A) -> Self
|
||||
where
|
||||
A: Fn() + 'static,
|
||||
{
|
||||
self.tertiary_action = Some(Action {
|
||||
label: label.to_owned(),
|
||||
action: Box::new(action),
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> ActionGroup {
|
||||
ActionGroup::new(self)
|
||||
}
|
||||
}
|
|
@ -1,175 +0,0 @@
|
|||
/*
|
||||
Copyright 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::{components::{i32_field_builder, TextEntry, month_field_builder}, types::ParseError};
|
||||
use chrono::{Datelike, Local};
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
pub struct DateFieldPrivate {
|
||||
date: Rc<RefCell<chrono::NaiveDate>>,
|
||||
year: TextEntry<i32>,
|
||||
month: TextEntry<u32>,
|
||||
day: TextEntry<u32>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for DateFieldPrivate {
|
||||
const NAME: &'static str = "DateField";
|
||||
type Type = DateField;
|
||||
type ParentType = gtk::Box;
|
||||
|
||||
fn new() -> Self {
|
||||
let date = Rc::new(RefCell::new(Local::now().date_naive()));
|
||||
|
||||
let year = i32_field_builder()
|
||||
.with_value(date.borrow().year())
|
||||
.with_on_update(
|
||||
{
|
||||
let date = date.clone();
|
||||
move |value| {
|
||||
if let Some(year) = value {
|
||||
let mut date = date.borrow_mut();
|
||||
if let Some(new_date) = date.with_year(year) {
|
||||
*date = new_date;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.with_length(4)
|
||||
.with_css_classes(vec!["date-field__year".to_owned()]).build();
|
||||
|
||||
let month = month_field_builder()
|
||||
.with_value(date.borrow().month())
|
||||
.with_on_update(
|
||||
{
|
||||
let date = date.clone();
|
||||
move |value| {
|
||||
if let Some(month) = value {
|
||||
let mut date = date.borrow_mut();
|
||||
if let Some(new_date) = date.with_month(month) {
|
||||
*date = new_date;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.with_css_classes(vec!["date-field__month".to_owned()])
|
||||
.build();
|
||||
|
||||
/* Modify this so that it enforces the number of days per month */
|
||||
let day = TextEntry::builder()
|
||||
.with_placeholder("day".to_owned())
|
||||
.with_value(date.borrow().day())
|
||||
.with_renderer(|v| format!("{}", v))
|
||||
.with_parser(|v| v.parse::<u32>().map_err(|_| ParseError))
|
||||
.with_on_update({
|
||||
let date = date.clone();
|
||||
move |value| {
|
||||
if let Some(day) = value {
|
||||
let mut date = date.borrow_mut();
|
||||
if let Some(new_date) = date.with_day(day) {
|
||||
*date = new_date;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.with_css_classes(vec!["date-field__day".to_owned()])
|
||||
.build();
|
||||
|
||||
Self {
|
||||
date,
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl ObjectImpl for DateFieldPrivate {}
|
||||
impl WidgetImpl for DateFieldPrivate {}
|
||||
impl BoxImpl for DateFieldPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct DateField(ObjectSubclass<DateFieldPrivate>) @extends gtk::Box, gtk::Widget;
|
||||
}
|
||||
|
||||
/* Render a date in the format 2006 Jan 01. The entire date is editable. When the user moves to one part of the date, it will be erased and replaced with a grey placeholder.
|
||||
*/
|
||||
impl DateField {
|
||||
pub fn new(date: chrono::NaiveDate) -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
s.add_css_class("date-field");
|
||||
|
||||
s.append(&s.imp().year.widget());
|
||||
s.append(>k::Label::new(Some("-")));
|
||||
s.append(&s.imp().month.widget());
|
||||
s.append(>k::Label::new(Some("-")));
|
||||
s.append(&s.imp().day.widget());
|
||||
|
||||
s.set_date(date);
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
pub fn set_date(&self, date: chrono::NaiveDate) {
|
||||
self.imp().year.set_value(Some(date.year()));
|
||||
self.imp().month.set_value(Some(date.month()));
|
||||
self.imp().day.set_value(Some(date.day()));
|
||||
|
||||
*self.imp().date.borrow_mut() = date;
|
||||
}
|
||||
|
||||
pub fn date(&self) -> chrono::NaiveDate {
|
||||
*self.imp().date.borrow()
|
||||
}
|
||||
/*
|
||||
pub fn is_valid(&self) -> bool {
|
||||
false
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
// use crate::gtk_init::gtk_init;
|
||||
|
||||
// Enabling this test pushes tests on the TextField into an infinite loop. That likely indicates a bad interaction within the TextField itself, and that is going to need to be fixed.
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn it_allows_valid_dates() {
|
||||
let reference = chrono::NaiveDate::from_ymd_opt(2006, 01, 02).unwrap();
|
||||
let field = DateField::new(reference);
|
||||
field.imp().year.set_value(Some(2023));
|
||||
field.imp().month.set_value(Some(10));
|
||||
field.imp().day.set_value(Some(13));
|
||||
// assert!(field.is_valid());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn it_disallows_out_of_range_months() {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn it_allows_days_within_range_for_month() {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
|
@ -1,189 +0,0 @@
|
|||
/*
|
||||
Copyright 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::{components::DateField, types::DayInterval};
|
||||
use chrono::{Duration, Local, Months};
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use std::cell::RefCell;
|
||||
|
||||
type OnSearch = dyn Fn(DayInterval) + 'static;
|
||||
|
||||
pub struct DateRangePickerPrivate {
|
||||
start: DateField,
|
||||
end: DateField,
|
||||
|
||||
on_search: RefCell<Box<OnSearch>>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for DateRangePickerPrivate {
|
||||
const NAME: &'static str = "DateRangePicker";
|
||||
type Type = DateRangePicker;
|
||||
type ParentType = gtk::Box;
|
||||
|
||||
fn new() -> Self {
|
||||
let default_date = Local::now().date_naive();
|
||||
let start = DateField::new(default_date);
|
||||
start.add_css_class("date-range-picker__date-field");
|
||||
let end = DateField::new(default_date);
|
||||
end.add_css_class("date-range-picker__date-field");
|
||||
|
||||
Self {
|
||||
start,
|
||||
end,
|
||||
on_search: RefCell::new(Box::new(|_| {})),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for DateRangePickerPrivate {}
|
||||
impl WidgetImpl for DateRangePickerPrivate {}
|
||||
impl BoxImpl for DateRangePickerPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct DateRangePicker(ObjectSubclass<DateRangePickerPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||
}
|
||||
|
||||
impl DateRangePicker {
|
||||
pub fn connect_on_search<OnSearch>(&self, f: OnSearch)
|
||||
where
|
||||
OnSearch: Fn(DayInterval) + 'static,
|
||||
{
|
||||
*self.imp().on_search.borrow_mut() = Box::new(f);
|
||||
}
|
||||
|
||||
pub fn set_interval(&self, start: chrono::NaiveDate, end: chrono::NaiveDate) {
|
||||
self.imp().start.set_date(start);
|
||||
self.imp().end.set_date(end);
|
||||
}
|
||||
|
||||
pub fn interval(&self) -> DayInterval {
|
||||
DayInterval {
|
||||
start: self.imp().start.date(),
|
||||
end: self.imp().end.date(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for DateRangePicker {
|
||||
fn default() -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_orientation(gtk::Orientation::Vertical);
|
||||
s.add_css_class("date-range-picker");
|
||||
|
||||
let search_button = gtk::Button::builder()
|
||||
.css_classes(["date-range-picker__search-button"])
|
||||
.label("Search")
|
||||
.build();
|
||||
search_button.connect_clicked({
|
||||
let s = s.clone();
|
||||
move |_| (s.imp().on_search.borrow())(s.interval())
|
||||
});
|
||||
|
||||
let last_week_button = gtk::Button::builder()
|
||||
.css_classes(["date-range-picker__range-button"])
|
||||
.label("week")
|
||||
.build();
|
||||
last_week_button.connect_clicked({
|
||||
let s = s.clone();
|
||||
move |_| {
|
||||
let end = Local::now().date_naive();
|
||||
let start = end - Duration::days(7);
|
||||
s.set_interval(start, end);
|
||||
(s.imp().on_search.borrow())(s.interval());
|
||||
}
|
||||
});
|
||||
|
||||
let two_weeks_button = gtk::Button::builder()
|
||||
.css_classes(["date-range-picker__range-button"])
|
||||
.label("two weeks")
|
||||
.build();
|
||||
two_weeks_button.connect_clicked({
|
||||
let s = s.clone();
|
||||
move |_| {
|
||||
let end = Local::now().date_naive();
|
||||
let start = end - Duration::days(14);
|
||||
s.set_interval(start, end);
|
||||
(s.imp().on_search.borrow())(s.interval());
|
||||
}
|
||||
});
|
||||
|
||||
let last_month_button = gtk::Button::builder()
|
||||
.css_classes(["date-range-picker__range-button"])
|
||||
.label("month")
|
||||
.build();
|
||||
last_month_button.connect_clicked({
|
||||
let s = s.clone();
|
||||
move |_| {
|
||||
let end = Local::now().date_naive();
|
||||
let start = end - Months::new(1);
|
||||
s.set_interval(start, end);
|
||||
(s.imp().on_search.borrow())(s.interval());
|
||||
}
|
||||
});
|
||||
|
||||
let six_months_button = gtk::Button::builder()
|
||||
.css_classes(["date-range-picker__range-button"])
|
||||
.label("six months")
|
||||
.build();
|
||||
six_months_button.connect_clicked({
|
||||
let s = s.clone();
|
||||
move |_| {
|
||||
let end = Local::now().date_naive();
|
||||
let start = end - Months::new(6);
|
||||
s.set_interval(start, end);
|
||||
(s.imp().on_search.borrow())(s.interval());
|
||||
}
|
||||
});
|
||||
|
||||
let last_year_button = gtk::Button::builder()
|
||||
.css_classes(["date-range-picker__range-button"])
|
||||
.label("year")
|
||||
.build();
|
||||
last_year_button.connect_clicked({
|
||||
let s = s.clone();
|
||||
move |_| {
|
||||
let end = Local::now().date_naive();
|
||||
let start = end - Months::new(12);
|
||||
s.set_interval(start, end);
|
||||
(s.imp().on_search.borrow())(s.interval());
|
||||
}
|
||||
});
|
||||
|
||||
let date_row = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.build();
|
||||
date_row.append(&s.imp().start);
|
||||
date_row.append(>k::Label::new(Some("to")));
|
||||
date_row.append(&s.imp().end);
|
||||
date_row.append(&search_button);
|
||||
|
||||
let quick_picker = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.build();
|
||||
quick_picker.append(&last_week_button);
|
||||
quick_picker.append(&two_weeks_button);
|
||||
quick_picker.append(&last_month_button);
|
||||
quick_picker.append(&six_months_button);
|
||||
quick_picker.append(&last_year_button);
|
||||
|
||||
s.append(&date_row);
|
||||
s.append(&quick_picker);
|
||||
|
||||
s
|
||||
}
|
||||
}
|
|
@ -1,400 +0,0 @@
|
|||
/*
|
||||
Copyright 2023-2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// use chrono::NaiveDate;
|
||||
// use ft_core::TraxRecord;
|
||||
use crate::{
|
||||
components::{
|
||||
steps_editor, time_distance_summary, weight_field, ActionGroup, Steps, WeightLabel,
|
||||
},
|
||||
types::{DistanceFormatter, DurationFormatter, WeightFormatter},
|
||||
view_models::DayDetailViewModel,
|
||||
};
|
||||
use emseries::{Record, RecordId};
|
||||
use ft_core::{TimeDistanceActivity, TraxRecord, TIME_DISTANCE_ACTIVITIES};
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use super::{time_distance::TimeDistanceEdit, time_distance_detail};
|
||||
|
||||
pub struct DaySummaryPrivate {
|
||||
date: gtk::Label,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for DaySummaryPrivate {
|
||||
const NAME: &'static str = "DaySummary";
|
||||
type Type = DaySummary;
|
||||
type ParentType = gtk::Box;
|
||||
|
||||
fn new() -> Self {
|
||||
let date = gtk::Label::builder()
|
||||
.css_classes(["day-summary__date"])
|
||||
.halign(gtk::Align::Start)
|
||||
.build();
|
||||
Self { date }
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for DaySummaryPrivate {}
|
||||
impl WidgetImpl for DaySummaryPrivate {}
|
||||
impl BoxImpl for DaySummaryPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
/// The DaySummary displays one day's activities in a narrative style. This is meant to give
|
||||
/// an overall feel of everything that happened during the day without going into details.
|
||||
pub struct DaySummary(ObjectSubclass<DaySummaryPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||
}
|
||||
|
||||
impl Default for DaySummary {
|
||||
fn default() -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_orientation(gtk::Orientation::Vertical);
|
||||
s.set_css_classes(&["day-summary"]);
|
||||
|
||||
s.append(&s.imp().date);
|
||||
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
impl DaySummary {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn set_data(&self, view_model: DayDetailViewModel) {
|
||||
self.imp()
|
||||
.date
|
||||
.set_text(&view_model.date.format("%Y-%m-%d").to_string());
|
||||
|
||||
let row = gtk::Box::builder().build();
|
||||
|
||||
let weight_label = gtk::Label::builder()
|
||||
.halign(gtk::Align::Start)
|
||||
.css_classes(["day-summary__weight"])
|
||||
.build();
|
||||
if let Some(w) = view_model.weight() {
|
||||
weight_label.set_label(&w.to_string())
|
||||
}
|
||||
|
||||
let steps_label = gtk::Label::builder()
|
||||
.halign(gtk::Align::Start)
|
||||
.css_classes(["day-summary__steps"])
|
||||
.build();
|
||||
if let Some(s) = view_model.steps() {
|
||||
steps_label.set_label(&format!("{} steps", s));
|
||||
}
|
||||
|
||||
row.append(&weight_label);
|
||||
row.append(&steps_label);
|
||||
self.append(&row);
|
||||
|
||||
for activity in TIME_DISTANCE_ACTIVITIES {
|
||||
let summary = view_model.time_distance_summary(activity);
|
||||
if let Some(label) = time_distance_summary(
|
||||
activity,
|
||||
DistanceFormatter::from(summary.0),
|
||||
DurationFormatter::from(summary.1),
|
||||
) {
|
||||
self.append(&label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct DayDetailPrivate {}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for DayDetailPrivate {
|
||||
const NAME: &'static str = "DayDetail";
|
||||
type Type = DayDetail;
|
||||
type ParentType = gtk::Box;
|
||||
}
|
||||
|
||||
impl ObjectImpl for DayDetailPrivate {}
|
||||
impl WidgetImpl for DayDetailPrivate {}
|
||||
impl BoxImpl for DayDetailPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct DayDetail(ObjectSubclass<DayDetailPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||
}
|
||||
|
||||
impl DayDetail {
|
||||
pub fn new<OnEdit>(view_model: DayDetailViewModel, on_edit: OnEdit) -> Self
|
||||
where
|
||||
OnEdit: Fn() + 'static,
|
||||
{
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_orientation(gtk::Orientation::Vertical);
|
||||
s.set_hexpand(true);
|
||||
|
||||
s.append(
|
||||
&ActionGroup::builder()
|
||||
.primary_action("Edit", Box::new(on_edit))
|
||||
.build(),
|
||||
);
|
||||
|
||||
let top_row = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.build();
|
||||
let weight_view = WeightLabel::new(view_model.weight().map(WeightFormatter::from));
|
||||
top_row.append(&weight_view.widget());
|
||||
|
||||
let steps_view = Steps::new(view_model.steps());
|
||||
top_row.append(&steps_view.widget());
|
||||
|
||||
s.append(&top_row);
|
||||
|
||||
let records = view_model.time_distance_records();
|
||||
for emseries::Record { data, .. } in records {
|
||||
s.append(&time_distance_detail(data));
|
||||
}
|
||||
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DayEditPrivate {
|
||||
on_finished: RefCell<Box<dyn Fn()>>,
|
||||
#[allow(unused)]
|
||||
workout_rows: RefCell<gtk::Box>,
|
||||
view_model: RefCell<Option<DayDetailViewModel>>,
|
||||
}
|
||||
|
||||
impl Default for DayEditPrivate {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
on_finished: RefCell::new(Box::new(|| {})),
|
||||
workout_rows: RefCell::new(
|
||||
gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.hexpand(true)
|
||||
.build(),
|
||||
),
|
||||
view_model: RefCell::new(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for DayEditPrivate {
|
||||
const NAME: &'static str = "DayEdit";
|
||||
type Type = DayEdit;
|
||||
type ParentType = gtk::Box;
|
||||
}
|
||||
|
||||
impl ObjectImpl for DayEditPrivate {}
|
||||
impl WidgetImpl for DayEditPrivate {}
|
||||
impl BoxImpl for DayEditPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct DayEdit(ObjectSubclass<DayEditPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||
}
|
||||
|
||||
impl DayEdit {
|
||||
pub fn new<OnFinished>(view_model: DayDetailViewModel, on_finished: OnFinished) -> Self
|
||||
where
|
||||
OnFinished: Fn() + 'static,
|
||||
{
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_orientation(gtk::Orientation::Vertical);
|
||||
s.set_hexpand(true);
|
||||
*s.imp().on_finished.borrow_mut() = Box::new(on_finished);
|
||||
*s.imp().view_model.borrow_mut() = Some(view_model.clone());
|
||||
|
||||
let workout_buttons = workout_buttons(view_model.clone(), {
|
||||
let s = s.clone();
|
||||
move |workout| s.add_row(workout)
|
||||
});
|
||||
|
||||
view_model
|
||||
.records()
|
||||
.into_iter()
|
||||
.filter_map({
|
||||
let s = s.clone();
|
||||
move |record| match record.data {
|
||||
TraxRecord::TimeDistance(workout) => Some(TimeDistanceEdit::new(workout, {
|
||||
let s = s.clone();
|
||||
move |data| {
|
||||
s.update_workout(record.id, data);
|
||||
}
|
||||
})),
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
.for_each(|row| s.imp().workout_rows.borrow().append(&row));
|
||||
|
||||
s.append(&control_buttons(&s, &view_model));
|
||||
s.append(&weight_and_steps_row(&view_model));
|
||||
s.append(&*s.imp().workout_rows.borrow());
|
||||
s.append(&workout_buttons);
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
fn finish(&self) {
|
||||
glib::spawn_future_local({
|
||||
let s = self.clone();
|
||||
async move {
|
||||
let view_model = {
|
||||
let view_model = s.imp().view_model.borrow();
|
||||
view_model
|
||||
.as_ref()
|
||||
.expect("DayEdit has not been initialized with the view model")
|
||||
.clone()
|
||||
};
|
||||
let _ = view_model.async_save().await;
|
||||
(s.imp().on_finished.borrow())()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn add_row(&self, workout: Record<TraxRecord>) {
|
||||
let workout_rows = self.imp().workout_rows.borrow();
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
match workout.data {
|
||||
TraxRecord::TimeDistance(r) => workout_rows.append(&TimeDistanceEdit::new(r, {
|
||||
let s = self.clone();
|
||||
move |data| {
|
||||
println!("update workout callback on workout: {:?}", workout.id);
|
||||
s.update_workout(workout.id, data)
|
||||
}
|
||||
})),
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn update_workout(&self, id: RecordId, data: ft_core::TimeDistance) {
|
||||
if let Some(ref view_model) = *self.imp().view_model.borrow() {
|
||||
let record = Record {
|
||||
id,
|
||||
data: TraxRecord::TimeDistance(data),
|
||||
};
|
||||
view_model.update_record(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn control_buttons(s: &DayEdit, view_model: &DayDetailViewModel) -> ActionGroup {
|
||||
ActionGroup::builder()
|
||||
.primary_action("Save", {
|
||||
let s = s.clone();
|
||||
move || s.finish()
|
||||
})
|
||||
.secondary_action("Cancel", {
|
||||
let s = s.clone();
|
||||
let view_model = view_model.clone();
|
||||
move || {
|
||||
let s = s.clone();
|
||||
let view_model = view_model.clone();
|
||||
glib::spawn_future_local(async move {
|
||||
view_model.revert().await;
|
||||
s.finish();
|
||||
});
|
||||
}
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
fn weight_and_steps_row(view_model: &DayDetailViewModel) -> gtk::Box {
|
||||
let row = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.build();
|
||||
row.append(
|
||||
&weight_field(view_model.weight().map(WeightFormatter::from), {
|
||||
let view_model = view_model.clone();
|
||||
move |w| match w {
|
||||
Some(w) => view_model.set_weight(*w),
|
||||
None => eprintln!("have not implemented record delete"),
|
||||
}
|
||||
})
|
||||
.widget(),
|
||||
);
|
||||
|
||||
row.append(
|
||||
&steps_editor(view_model.steps(), {
|
||||
let view_model = view_model.clone();
|
||||
move |s| match s {
|
||||
Some(s) => view_model.set_steps(s),
|
||||
None => eprintln!("have not implemented record delete"),
|
||||
}
|
||||
})
|
||||
.widget(),
|
||||
);
|
||||
|
||||
row
|
||||
}
|
||||
|
||||
fn workout_buttons<AddRow>(view_model: DayDetailViewModel, add_row: AddRow) -> gtk::Box
|
||||
where
|
||||
AddRow: Fn(Record<TraxRecord>) + 'static,
|
||||
{
|
||||
let add_row = Rc::new(add_row);
|
||||
|
||||
let layout = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.build();
|
||||
|
||||
for (activity, icon, label) in [
|
||||
(
|
||||
TimeDistanceActivity::Biking,
|
||||
"cycling-symbolic",
|
||||
"Bike Ride",
|
||||
),
|
||||
(TimeDistanceActivity::Rowing, "rowing-symbolic", "Rowing"),
|
||||
(TimeDistanceActivity::Running, "running-symbolic", "Run"),
|
||||
(TimeDistanceActivity::Swimming, "swimming-symbolic", "Swim"),
|
||||
(TimeDistanceActivity::Walking, "walking-symbolic", "Walk"),
|
||||
] {
|
||||
let button = workout_button(activity, icon, label, view_model.clone(), {
|
||||
let add_row = add_row.clone();
|
||||
move |record| add_row(record)
|
||||
});
|
||||
layout.append(&button);
|
||||
}
|
||||
|
||||
layout
|
||||
}
|
||||
|
||||
fn workout_button<AddRow>(
|
||||
activity: TimeDistanceActivity,
|
||||
_icon: &str,
|
||||
label: &str,
|
||||
view_model: DayDetailViewModel,
|
||||
add_row: AddRow,
|
||||
) -> gtk::Button
|
||||
where
|
||||
AddRow: Fn(Record<TraxRecord>) + 'static,
|
||||
{
|
||||
let button = gtk::Button::builder()
|
||||
.label(label)
|
||||
.width_request(64)
|
||||
.height_request(64)
|
||||
.build();
|
||||
button.connect_clicked({
|
||||
let view_model = view_model.clone();
|
||||
move |_| {
|
||||
let workout = view_model.new_time_distance(activity);
|
||||
add_row(workout.map(TraxRecord::TimeDistance));
|
||||
}
|
||||
});
|
||||
button
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
Copyright 2023-2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not,
|
||||
see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
mod action_group;
|
||||
pub use action_group::ActionGroup;
|
||||
|
||||
mod day;
|
||||
pub use day::{DayDetail, DayEdit, DaySummary};
|
||||
|
||||
mod date_field;
|
||||
pub use date_field::DateField;
|
||||
|
||||
mod date_range;
|
||||
pub use date_range::DateRangePicker;
|
||||
|
||||
mod singleton;
|
||||
pub use singleton::{Singleton, SingletonImpl};
|
||||
|
||||
mod steps;
|
||||
pub use steps::{steps_editor, Steps};
|
||||
|
||||
mod text_entry;
|
||||
pub use text_entry::{distance_field, duration_field, time_field, weight_field, i32_field_builder, month_field_builder, TextEntry};
|
||||
|
||||
mod time_distance;
|
||||
pub use time_distance::{time_distance_detail, time_distance_summary};
|
||||
|
||||
mod weight;
|
||||
pub use weight::WeightLabel;
|
||||
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use std::{cell::RefCell, path::PathBuf, rc::Rc};
|
||||
|
||||
pub struct FileChooserRowPrivate {
|
||||
path: RefCell<Option<PathBuf>>,
|
||||
label: gtk::Label,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for FileChooserRowPrivate {
|
||||
const NAME: &'static str = "FileChooser";
|
||||
type Type = FileChooserRow;
|
||||
type ParentType = gtk::Box;
|
||||
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
path: RefCell::new(None),
|
||||
label: gtk::Label::builder().hexpand(true).build(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for FileChooserRowPrivate {}
|
||||
impl WidgetImpl for FileChooserRowPrivate {}
|
||||
impl BoxImpl for FileChooserRowPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct FileChooserRow(ObjectSubclass<FileChooserRowPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||
}
|
||||
|
||||
impl FileChooserRow {
|
||||
pub fn new<F>(on_selected: F) -> Self
|
||||
where
|
||||
F: Fn(PathBuf) + 'static,
|
||||
{
|
||||
let s: Self = Object::builder().build();
|
||||
|
||||
s.set_css_classes(&["dialog-row", "card"]);
|
||||
s.set_orientation(gtk::Orientation::Horizontal);
|
||||
s.set_spacing(8);
|
||||
|
||||
// The database selection row should be a box that shows a default database path, along with a
|
||||
// button that triggers a file chooser dialog. Once the dialog returns, the box should be
|
||||
// updated to reflect the chosen path.
|
||||
s.imp().label.set_text("No database selected");
|
||||
|
||||
let on_selected = Rc::new(Box::new(on_selected));
|
||||
|
||||
let import_button = gtk::Button::builder().label("Import a Database").build();
|
||||
|
||||
let handle_file_selection = Rc::new(Box::new({
|
||||
let s = s.clone();
|
||||
let on_selected = on_selected.clone();
|
||||
move |file_id: Result<gio::File, glib::Error>| match file_id {
|
||||
Ok(file_id) => match file_id.path() {
|
||||
Some(path) => {
|
||||
s.imp().label.set_text(path.to_str().unwrap());
|
||||
on_selected(path.clone());
|
||||
*s.imp().path.borrow_mut() = Some(path);
|
||||
}
|
||||
None => {
|
||||
*s.imp().path.borrow_mut() = None;
|
||||
s.imp().label.set_text("No database selected");
|
||||
}
|
||||
},
|
||||
Err(err) => println!("file opening failed: {}", err),
|
||||
}
|
||||
}));
|
||||
|
||||
import_button.connect_clicked({
|
||||
let handle_file_selection = handle_file_selection.clone();
|
||||
move |_| {
|
||||
let no_window: Option<>k::Window> = None;
|
||||
let not_cancellable: Option<&gio::Cancellable> = None;
|
||||
let handle_file_selection = handle_file_selection.clone();
|
||||
gtk::FileDialog::builder().build().open(
|
||||
no_window,
|
||||
not_cancellable,
|
||||
move |file_id| handle_file_selection(file_id),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
let new_button = gtk::Button::builder().label("Create Database").build();
|
||||
new_button.connect_clicked({
|
||||
let handle_file_selection = handle_file_selection.clone();
|
||||
move |_| {
|
||||
let no_window: Option<>k::Window> = None;
|
||||
let not_cancellable: Option<&gio::Cancellable> = None;
|
||||
let handle_file_selection = handle_file_selection.clone();
|
||||
gtk::FileDialog::builder().build().save(
|
||||
no_window,
|
||||
not_cancellable,
|
||||
move |file_id| handle_file_selection(file_id),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
s.imp().label.set_halign(gtk::Align::Start);
|
||||
s.append(&s.imp().label);
|
||||
s.append(&import_button);
|
||||
s.append(&new_button);
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
pub fn path(&self) -> Option<PathBuf> {
|
||||
self.imp().path.borrow().clone()
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
Copyright 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//! A Widget container for a single components
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use std::cell::RefCell;
|
||||
|
||||
pub struct SingletonPrivate {
|
||||
widget: RefCell<gtk::Widget>,
|
||||
}
|
||||
|
||||
impl Default for SingletonPrivate {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
widget: RefCell::new(gtk::Label::new(None).upcast()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for SingletonPrivate {
|
||||
const NAME: &'static str = "Singleton";
|
||||
type Type = Singleton;
|
||||
type ParentType = gtk::Box;
|
||||
}
|
||||
|
||||
impl ObjectImpl for SingletonPrivate {}
|
||||
impl WidgetImpl for SingletonPrivate {}
|
||||
impl BoxImpl for SingletonPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
/// The Singleton component contains exactly one child widget. The swap function makes it easy
|
||||
/// to handle the job of swapping that child out for a different one.
|
||||
pub struct Singleton(ObjectSubclass<SingletonPrivate>) @extends gtk::Box, gtk::Widget;
|
||||
}
|
||||
|
||||
impl Default for Singleton {
|
||||
fn default() -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
|
||||
s.append(&*s.imp().widget.borrow());
|
||||
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
impl Singleton {
|
||||
pub fn swap(&self, new_widget: &impl IsA<gtk::Widget>) {
|
||||
let new_widget = new_widget.clone().upcast();
|
||||
self.remove(&*self.imp().widget.borrow());
|
||||
self.append(&new_widget);
|
||||
*self.imp().widget.borrow_mut() = new_widget;
|
||||
}
|
||||
}
|
||||
|
||||
pub trait SingletonImpl: WidgetImpl + BoxImpl {}
|
||||
unsafe impl<T: SingletonImpl> IsSubclassable<T> for Singleton {}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
Copyright 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::{components::TextEntry, types::ParseError};
|
||||
use gtk::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Steps {
|
||||
label: gtk::Label,
|
||||
}
|
||||
|
||||
impl Steps {
|
||||
pub fn new(steps: Option<u32>) -> Self {
|
||||
let label = gtk::Label::builder()
|
||||
.css_classes(["card", "step-view"])
|
||||
.can_focus(true)
|
||||
.build();
|
||||
|
||||
match steps {
|
||||
Some(s) => label.set_text(&format!("{}", s)),
|
||||
None => label.set_text("No steps recorded"),
|
||||
}
|
||||
|
||||
Self { label }
|
||||
}
|
||||
|
||||
pub fn widget(&self) -> gtk::Widget {
|
||||
self.label.clone().upcast()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn steps_editor<OnUpdate>(value: Option<u32>, on_update: OnUpdate) -> TextEntry<u32>
|
||||
where
|
||||
OnUpdate: Fn(Option<u32>) + 'static,
|
||||
{
|
||||
let text_entry = TextEntry::builder()
|
||||
.with_placeholder( "0".to_owned())
|
||||
.with_renderer(|v| format!("{}", v))
|
||||
.with_parser(|v| v.parse::<u32>().map_err(|_| ParseError))
|
||||
.with_on_update(on_update);
|
||||
|
||||
if let Some(time) = value {
|
||||
text_entry.with_value(time)
|
||||
} else {
|
||||
text_entry
|
||||
}.build()
|
||||
}
|
|
@ -1,373 +0,0 @@
|
|||
/*
|
||||
Copyright 2023-2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::types::{
|
||||
DistanceFormatter, DurationFormatter, FormatOption, ParseError, TimeFormatter, WeightFormatter,
|
||||
};
|
||||
use gtk::prelude::*;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
pub type Parser<T> = dyn Fn(&str) -> Result<T, ParseError>;
|
||||
pub type OnUpdate<T> = dyn Fn(Option<T>);
|
||||
|
||||
// TextEntry is not a proper widget because I was never able to figure out how to do a type parameterization on a GTK widget.
|
||||
#[derive(Clone)]
|
||||
pub struct TextEntry<T: Clone + std::fmt::Debug> {
|
||||
value: Rc<RefCell<Option<T>>>,
|
||||
|
||||
widget: gtk::Entry,
|
||||
renderer: Rc<dyn Fn(&T) -> String>,
|
||||
parser: Rc<Parser<T>>,
|
||||
on_update: Rc<OnUpdate<T>>,
|
||||
}
|
||||
|
||||
impl<T: Clone + std::fmt::Debug> std::fmt::Debug for TextEntry<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||
write!(
|
||||
f,
|
||||
"{{ value: {:?}, widget: {:?} }}",
|
||||
self.value, self.widget
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// I do not understand why the data should be 'static.
|
||||
impl<T: Clone + std::fmt::Debug + 'static> TextEntry<T> {
|
||||
fn from_builder(builder: TextEntryBuilder<T>) -> TextEntry<T> {
|
||||
let widget = gtk::Entry::builder()
|
||||
.placeholder_text(builder.placeholder)
|
||||
.build();
|
||||
if let Some(ref v) = builder.value {
|
||||
widget.set_text(&(builder.renderer)(v))
|
||||
}
|
||||
|
||||
let s = Self {
|
||||
value: Rc::new(RefCell::new(builder.value)),
|
||||
widget,
|
||||
renderer: Rc::new(builder.renderer),
|
||||
parser: Rc::new(builder.parser),
|
||||
on_update: Rc::new(builder.on_update),
|
||||
};
|
||||
|
||||
s.widget.buffer().connect_text_notify({
|
||||
let s = s.clone();
|
||||
move |buffer| s.handle_text_change(buffer)
|
||||
});
|
||||
|
||||
if let Some(length) = builder.length {
|
||||
s.widget.set_max_length(length.try_into().unwrap());
|
||||
}
|
||||
|
||||
// let classes: Vec<&str> = builder.css_classes.iter(|v| v.as_ref()).collect();
|
||||
let classes: Vec<&str> = builder.css_classes.iter().map(AsRef::as_ref).collect();
|
||||
s.widget.set_css_classes(&classes);
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
pub fn builder() -> TextEntryBuilder<T> {
|
||||
TextEntryBuilder::default()
|
||||
}
|
||||
|
||||
pub fn set_value(&self, val: Option<T>) {
|
||||
if let Some(ref v) = val {
|
||||
self.widget.set_text(&(self.renderer)(v));
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_text_change(&self, buffer: >k::EntryBuffer) {
|
||||
if buffer.text().is_empty() {
|
||||
*self.value.borrow_mut() = None;
|
||||
self.widget.remove_css_class("error");
|
||||
(self.on_update)(None);
|
||||
return;
|
||||
}
|
||||
match (self.parser)(buffer.text().as_str()) {
|
||||
Ok(v) => {
|
||||
*self.value.borrow_mut() = Some(v.clone());
|
||||
self.widget.remove_css_class("error");
|
||||
(self.on_update)(Some(v));
|
||||
}
|
||||
// need to change the border to provide a visual indicator of an error
|
||||
Err(_) => {
|
||||
self.widget.add_css_class("error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn widget(&self) -> gtk::Widget {
|
||||
self.widget.clone().upcast::<gtk::Widget>()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn has_parse_error(&self) -> bool {
|
||||
self.widget.has_css_class("error")
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TextEntryBuilder<T: Clone + std::fmt::Debug + 'static> {
|
||||
placeholder: String,
|
||||
value: Option<T>,
|
||||
length: Option<usize>,
|
||||
css_classes: Vec<String>,
|
||||
renderer: Box<dyn Fn(&T) -> String>,
|
||||
parser: Box<Parser<T>>,
|
||||
on_update: Box<OnUpdate<T>>,
|
||||
}
|
||||
|
||||
impl<T: Clone + std::fmt::Debug + 'static> Default for TextEntryBuilder<T> {
|
||||
fn default() -> TextEntryBuilder<T> {
|
||||
TextEntryBuilder {
|
||||
placeholder: "".to_owned(),
|
||||
value: None,
|
||||
length: None,
|
||||
css_classes: vec![],
|
||||
renderer: Box::new(|_| "".to_owned()),
|
||||
parser: Box::new(|_| Err(ParseError)),
|
||||
on_update: Box::new(|_| {}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone + std::fmt::Debug + 'static> TextEntryBuilder<T> {
|
||||
pub fn build(self) -> TextEntry<T> {
|
||||
TextEntry::from_builder(self)
|
||||
}
|
||||
|
||||
pub fn with_placeholder(self, placeholder: String) -> Self {
|
||||
Self {
|
||||
placeholder,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_value(self, value: T) -> Self {
|
||||
Self {
|
||||
value: Some(value),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_length(self, length: usize) -> Self {
|
||||
Self {
|
||||
length: Some(length),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_css_classes(self, classes: Vec<String>) -> Self {
|
||||
Self {
|
||||
css_classes: classes,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_renderer(self, renderer: impl Fn(&T) -> String + 'static) -> Self {
|
||||
Self {
|
||||
renderer: Box::new(renderer),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_parser(self, parser: impl Fn(&str) -> Result<T, ParseError> + 'static) -> Self {
|
||||
Self {
|
||||
parser: Box::new(parser),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_on_update(self, on_update: impl Fn(Option<T>) + 'static) -> Self {
|
||||
Self {
|
||||
on_update: Box::new(on_update),
|
||||
..self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn time_field<OnUpdate>(
|
||||
value: Option<TimeFormatter>,
|
||||
on_update: OnUpdate,
|
||||
) -> TextEntry<TimeFormatter>
|
||||
where
|
||||
OnUpdate: Fn(Option<TimeFormatter>) + 'static,
|
||||
{
|
||||
let text_entry = TextEntry::builder()
|
||||
.with_placeholder("HH:MM".to_owned())
|
||||
.with_renderer(|val: &TimeFormatter| val.format(FormatOption::Abbreviated))
|
||||
.with_parser(TimeFormatter::parse)
|
||||
.with_on_update(on_update);
|
||||
|
||||
if let Some(time) = value {
|
||||
text_entry.with_value(time)
|
||||
} else {
|
||||
text_entry
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
pub fn distance_field<OnUpdate>(
|
||||
value: Option<DistanceFormatter>,
|
||||
on_update: OnUpdate,
|
||||
) -> TextEntry<DistanceFormatter>
|
||||
where
|
||||
OnUpdate: Fn(Option<DistanceFormatter>) + 'static,
|
||||
{
|
||||
let text_entry = TextEntry::builder()
|
||||
.with_placeholder("0 km".to_owned())
|
||||
.with_renderer(|val: &DistanceFormatter| val.format(FormatOption::Abbreviated))
|
||||
.with_parser(DistanceFormatter::parse)
|
||||
.with_on_update(on_update);
|
||||
|
||||
if let Some(distance) = value {
|
||||
text_entry.with_value(distance)
|
||||
} else {
|
||||
text_entry
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
pub fn duration_field<OnUpdate>(
|
||||
value: Option<DurationFormatter>,
|
||||
on_update: OnUpdate,
|
||||
) -> TextEntry<DurationFormatter>
|
||||
where
|
||||
OnUpdate: Fn(Option<DurationFormatter>) + 'static,
|
||||
{
|
||||
let text_entry = TextEntry::builder()
|
||||
.with_placeholder("0 m".to_owned())
|
||||
.with_renderer(|val: &DurationFormatter| val.format(FormatOption::Abbreviated))
|
||||
.with_parser(DurationFormatter::parse)
|
||||
.with_on_update(on_update);
|
||||
|
||||
if let Some(duration) = value {
|
||||
text_entry.with_value(duration)
|
||||
} else {
|
||||
text_entry
|
||||
}
|
||||
.build()
|
||||
}
|
||||
pub fn weight_field<OnUpdate>(
|
||||
weight: Option<WeightFormatter>,
|
||||
on_update: OnUpdate,
|
||||
) -> TextEntry<WeightFormatter>
|
||||
where
|
||||
OnUpdate: Fn(Option<WeightFormatter>) + 'static,
|
||||
{
|
||||
let text_entry = TextEntry::builder()
|
||||
.with_placeholder("0 kg".to_owned())
|
||||
.with_renderer(|val: &WeightFormatter| val.format(FormatOption::Abbreviated))
|
||||
.with_parser(WeightFormatter::parse)
|
||||
.with_on_update(on_update);
|
||||
if let Some(weight) = weight {
|
||||
text_entry.with_value(weight)
|
||||
} else {
|
||||
text_entry
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
pub fn i32_field_builder() -> TextEntryBuilder<i32>
|
||||
{
|
||||
TextEntry::builder()
|
||||
.with_placeholder("0".to_owned())
|
||||
.with_renderer(|val| format!("{}", val))
|
||||
.with_parser(|v| v.parse::<i32>().map_err(|_| ParseError))
|
||||
}
|
||||
|
||||
pub fn month_field_builder() -> TextEntryBuilder<u32>
|
||||
{
|
||||
TextEntry::builder()
|
||||
.with_placeholder("0".to_owned())
|
||||
.with_renderer(|val| format!("{}", val))
|
||||
.with_parser(|v| {
|
||||
let val = v.parse::<u32>().map_err(|_| ParseError)?;
|
||||
if val == 0 || val > 12 {
|
||||
return Err(ParseError);
|
||||
}
|
||||
Ok(val)
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::gtk_init::gtk_init;
|
||||
|
||||
fn setup_u32_entry() -> (Rc<RefCell<Option<u32>>>, TextEntry<u32>) {
|
||||
let current_value = Rc::new(RefCell::new(None));
|
||||
|
||||
let entry = TextEntry::builder()
|
||||
.with_placeholder("step count".to_owned())
|
||||
.with_renderer(|steps| format!("{}", steps))
|
||||
.with_parser(|v| v.parse::<u32>().map_err(|_| ParseError))
|
||||
.with_on_update({
|
||||
let current_value = current_value.clone();
|
||||
move |v| *current_value.borrow_mut() = v
|
||||
})
|
||||
.build();
|
||||
|
||||
(current_value, entry)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_responds_to_field_changes() {
|
||||
gtk_init();
|
||||
let (current_value, entry) = setup_u32_entry();
|
||||
let buffer = entry.widget.buffer();
|
||||
|
||||
buffer.set_text("1");
|
||||
assert_eq!(*current_value.borrow(), Some(1));
|
||||
|
||||
buffer.set_text("15");
|
||||
assert_eq!(*current_value.borrow(), Some(15));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_preserves_last_value_in_parse_error() {
|
||||
crate::gtk_init::gtk_init();
|
||||
let (current_value, entry) = setup_u32_entry();
|
||||
let buffer = entry.widget.buffer();
|
||||
|
||||
buffer.set_text("1");
|
||||
assert_eq!(*current_value.borrow(), Some(1));
|
||||
|
||||
buffer.set_text("a5");
|
||||
assert_eq!(*current_value.borrow(), Some(1));
|
||||
assert!(entry.has_parse_error());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_update_on_empty_strings() {
|
||||
gtk_init();
|
||||
let (current_value, entry) = setup_u32_entry();
|
||||
let buffer = entry.widget.buffer();
|
||||
|
||||
buffer.set_text("1");
|
||||
assert_eq!(*current_value.borrow(), Some(1));
|
||||
buffer.set_text("");
|
||||
assert_eq!(*current_value.borrow(), None);
|
||||
|
||||
buffer.set_text("1");
|
||||
assert_eq!(*current_value.borrow(), Some(1));
|
||||
buffer.set_text("1a");
|
||||
assert_eq!(*current_value.borrow(), Some(1));
|
||||
assert!(entry.has_parse_error());
|
||||
|
||||
buffer.set_text("");
|
||||
assert_eq!(*current_value.borrow(), None);
|
||||
assert!(!entry.has_parse_error());
|
||||
}
|
||||
}
|
|
@ -1,271 +0,0 @@
|
|||
/*
|
||||
Copyright 2023-2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
components::{distance_field, duration_field, time_field},
|
||||
types::{DistanceFormatter, DurationFormatter, FormatOption, TimeFormatter},
|
||||
};
|
||||
use dimensioned::si;
|
||||
use ft_core::{TimeDistance, TimeDistanceActivity, TIME_DISTANCE_ACTIVITIES};
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
pub fn time_distance_summary(
|
||||
activity: TimeDistanceActivity,
|
||||
distance: DistanceFormatter,
|
||||
duration: DurationFormatter,
|
||||
) -> Option<gtk::Label> {
|
||||
let text = match (*distance > si::M, *duration > si::S) {
|
||||
(true, true) => Some(format!(
|
||||
"{} of {:?} in {}",
|
||||
distance.format(FormatOption::Full),
|
||||
activity,
|
||||
duration.format(FormatOption::Full)
|
||||
)),
|
||||
(true, false) => Some(format!(
|
||||
"{} of {:?}",
|
||||
distance.format(FormatOption::Full),
|
||||
activity
|
||||
)),
|
||||
(false, true) => Some(format!(
|
||||
"{} of {:?}",
|
||||
duration.format(FormatOption::Full),
|
||||
activity
|
||||
)),
|
||||
(false, false) => None,
|
||||
};
|
||||
|
||||
text.map(|text| gtk::Label::builder().halign(gtk::Align::Start).label(&text).build())
|
||||
}
|
||||
|
||||
pub fn time_distance_detail(record: ft_core::TimeDistance) -> gtk::Box {
|
||||
let layout = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.hexpand(true)
|
||||
.build();
|
||||
let first_row = gtk::Box::builder().homogeneous(true).build();
|
||||
|
||||
first_row.append(
|
||||
>k::Label::builder()
|
||||
.halign(gtk::Align::Start)
|
||||
.label(record.datetime.format("%H:%M").to_string())
|
||||
.build(),
|
||||
);
|
||||
|
||||
first_row.append(
|
||||
>k::Label::builder()
|
||||
.halign(gtk::Align::Start)
|
||||
.label(format!("{:?}", record.activity))
|
||||
.build(),
|
||||
);
|
||||
|
||||
first_row.append(
|
||||
>k::Label::builder()
|
||||
.halign(gtk::Align::Start)
|
||||
.label(
|
||||
record
|
||||
.distance
|
||||
.map(|dist| DistanceFormatter::from(dist).format(FormatOption::Abbreviated))
|
||||
.unwrap_or("".to_owned()),
|
||||
)
|
||||
.build(),
|
||||
);
|
||||
|
||||
first_row.append(
|
||||
>k::Label::builder()
|
||||
.halign(gtk::Align::Start)
|
||||
.label(
|
||||
record
|
||||
.duration
|
||||
.map(|duration| {
|
||||
DurationFormatter::from(duration).format(FormatOption::Abbreviated)
|
||||
})
|
||||
.unwrap_or("".to_owned()),
|
||||
)
|
||||
.build(),
|
||||
);
|
||||
|
||||
layout.append(&first_row);
|
||||
|
||||
layout.append(
|
||||
>k::Label::builder()
|
||||
.halign(gtk::Align::Start)
|
||||
.label(
|
||||
record
|
||||
.comments
|
||||
.map(|comments| comments.to_string())
|
||||
.unwrap_or("".to_owned()),
|
||||
)
|
||||
.build(),
|
||||
);
|
||||
|
||||
layout
|
||||
}
|
||||
|
||||
type OnUpdate = Rc<RefCell<Box<dyn Fn(TimeDistance)>>>;
|
||||
|
||||
pub struct TimeDistanceEditPrivate {
|
||||
#[allow(unused)]
|
||||
workout: RefCell<ft_core::TimeDistance>,
|
||||
on_update: OnUpdate,
|
||||
}
|
||||
|
||||
impl Default for TimeDistanceEditPrivate {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
workout: RefCell::new(TimeDistance {
|
||||
datetime: chrono::Utc::now().into(),
|
||||
activity: TimeDistanceActivity::Biking,
|
||||
duration: None,
|
||||
distance: None,
|
||||
comments: None,
|
||||
}),
|
||||
on_update: Rc::new(RefCell::new(Box::new(|_| {}))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for TimeDistanceEditPrivate {
|
||||
const NAME: &'static str = "TimeDistanceEdit";
|
||||
type Type = TimeDistanceEdit;
|
||||
type ParentType = gtk::Box;
|
||||
}
|
||||
|
||||
impl ObjectImpl for TimeDistanceEditPrivate {}
|
||||
impl WidgetImpl for TimeDistanceEditPrivate {}
|
||||
impl BoxImpl for TimeDistanceEditPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct TimeDistanceEdit(ObjectSubclass<TimeDistanceEditPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||
}
|
||||
|
||||
impl Default for TimeDistanceEdit {
|
||||
fn default() -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_orientation(gtk::Orientation::Vertical);
|
||||
s.set_hexpand(true);
|
||||
s.set_css_classes(&["time-distance-edit"]);
|
||||
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
impl TimeDistanceEdit {
|
||||
pub fn new<OnUpdate>(workout: TimeDistance, on_update: OnUpdate) -> Self
|
||||
where
|
||||
OnUpdate: Fn(TimeDistance) + 'static,
|
||||
{
|
||||
let s = Self::default();
|
||||
|
||||
*s.imp().workout.borrow_mut() = workout.clone();
|
||||
*s.imp().on_update.borrow_mut() = Box::new(on_update);
|
||||
|
||||
let details_row = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.build();
|
||||
|
||||
details_row.append(
|
||||
&time_field(
|
||||
Some(TimeFormatter::from(workout.datetime.naive_local().time())),
|
||||
{
|
||||
let s = s.clone();
|
||||
move |t| s.update_time(t)
|
||||
},
|
||||
)
|
||||
.widget(),
|
||||
);
|
||||
details_row.append(&s.activity_menu(workout.activity));
|
||||
details_row.append(
|
||||
&distance_field(workout.distance.map(DistanceFormatter::from), {
|
||||
let s = s.clone();
|
||||
move |d| s.update_distance(d)
|
||||
})
|
||||
.widget(),
|
||||
);
|
||||
details_row.append(
|
||||
&duration_field(workout.duration.map(DurationFormatter::from), {
|
||||
let s = s.clone();
|
||||
move |d| s.update_duration(d)
|
||||
})
|
||||
.widget(),
|
||||
);
|
||||
s.append(&details_row);
|
||||
s.append(>k::Entry::new());
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
fn update_time(&self, time: Option<TimeFormatter>) {
|
||||
if let Some(time_formatter) = time {
|
||||
let mut workout = self.imp().workout.borrow_mut();
|
||||
let tz = workout.datetime.timezone();
|
||||
let new_time = workout
|
||||
.datetime
|
||||
.date_naive()
|
||||
.and_time(*time_formatter)
|
||||
.and_local_timezone(tz)
|
||||
.unwrap()
|
||||
.fixed_offset();
|
||||
workout.datetime = new_time;
|
||||
(self.imp().on_update.borrow())(workout.clone());
|
||||
}
|
||||
}
|
||||
|
||||
fn update_workout_type(&self, type_: TimeDistanceActivity) {
|
||||
let mut workout = self.imp().workout.borrow_mut();
|
||||
workout.activity = type_;
|
||||
(self.imp().on_update.borrow())(workout.clone())
|
||||
}
|
||||
|
||||
fn update_distance(&self, distance: Option<DistanceFormatter>) {
|
||||
let mut workout = self.imp().workout.borrow_mut();
|
||||
workout.distance = distance.map(|d| *d);
|
||||
(self.imp().on_update.borrow())(workout.clone());
|
||||
}
|
||||
|
||||
fn update_duration(&self, duration: Option<DurationFormatter>) {
|
||||
let mut workout = self.imp().workout.borrow_mut();
|
||||
workout.duration = duration.map(|d| *d);
|
||||
(self.imp().on_update.borrow())(workout.clone());
|
||||
}
|
||||
|
||||
fn activity_menu(&self, selected: TimeDistanceActivity) -> gtk::DropDown {
|
||||
let options = TIME_DISTANCE_ACTIVITIES
|
||||
.iter()
|
||||
.map(|item| format!("{:?}", item))
|
||||
.collect::<Vec<String>>();
|
||||
|
||||
let options = options.iter().map(|o| o.as_ref()).collect::<Vec<&str>>();
|
||||
|
||||
let selected_idx = TIME_DISTANCE_ACTIVITIES
|
||||
.iter()
|
||||
.position(|&v| v == selected)
|
||||
.unwrap_or(0);
|
||||
|
||||
let menu = gtk::DropDown::from_strings(&options);
|
||||
menu.set_selected(selected_idx as u32);
|
||||
menu.connect_selected_item_notify({
|
||||
let s = self.clone();
|
||||
move |menu| {
|
||||
let new_item = TIME_DISTANCE_ACTIVITIES[menu.selected() as usize];
|
||||
s.update_workout_type(new_item);
|
||||
}
|
||||
});
|
||||
menu
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
Copyright 2023-2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::types::{FormatOption, WeightFormatter};
|
||||
use gtk::prelude::*;
|
||||
|
||||
pub struct WeightLabel {
|
||||
label: gtk::Label,
|
||||
}
|
||||
|
||||
impl WeightLabel {
|
||||
pub fn new(weight: Option<WeightFormatter>) -> Self {
|
||||
let label = gtk::Label::builder()
|
||||
.css_classes(["card", "weight-view"])
|
||||
.can_focus(true)
|
||||
.build();
|
||||
|
||||
match weight {
|
||||
Some(w) => label.set_text(&w.format(FormatOption::Abbreviated)),
|
||||
None => label.set_text("No weight recorded"),
|
||||
}
|
||||
|
||||
Self { label }
|
||||
}
|
||||
|
||||
pub fn widget(&self) -> gtk::Widget {
|
||||
self.label.clone().upcast()
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
use std::sync::Once;
|
||||
|
||||
static INITIALIZED: Once = Once::new();
|
||||
|
||||
pub fn gtk_init() {
|
||||
INITIALIZED.call_once(|| {
|
||||
eprintln!("initializing GTK");
|
||||
let _ = gtk::init();
|
||||
});
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
Copyright 2023 - 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
mod about;
|
||||
mod app;
|
||||
mod app_window;
|
||||
mod components;
|
||||
#[cfg(test)]
|
||||
mod gtk_init;
|
||||
mod types;
|
||||
mod view_models;
|
||||
mod views;
|
||||
|
||||
use adw::prelude::*;
|
||||
use app_window::AppWindow;
|
||||
use gio::ActionEntry;
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
const APP_ID_DEV: &str = "com.luminescent-dreams.fitnesstrax.dev";
|
||||
const APP_ID_PROD: &str = "com.luminescent-dreams.fitnesstrax";
|
||||
|
||||
const RESOURCE_BASE_PATH: &str = "/com/luminescent-dreams/fitnesstrax/";
|
||||
|
||||
fn setup_app_about_action(app: &adw::Application) {
|
||||
let action = ActionEntry::builder("about")
|
||||
.activate(|_app: &adw::Application, _, _| {
|
||||
let window = about::AboutWindow::default();
|
||||
window.present();
|
||||
}).build();
|
||||
app.add_action_entries([action]);
|
||||
}
|
||||
|
||||
/// Sets up an application-global action, `app.quit`, which will terminate the application.
|
||||
fn setup_app_close_action(app: &adw::Application) {
|
||||
let action = ActionEntry::builder("quit")
|
||||
.activate(|app: &adw::Application, _, _| {
|
||||
// right now, stopping the application is dirt simple. But we could use this
|
||||
// block to add extra code that does additional shutdown steps if we ever want
|
||||
// some states that shouldn't be discarded.
|
||||
app.quit();
|
||||
})
|
||||
.build();
|
||||
app.add_action_entries([action]);
|
||||
app.set_accels_for_action("app.quit", &["<Ctrl>Q"]);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// I still don't fully understand gio resources. resources_register_include! is convenient
|
||||
// because I don't have to deal with filesystem locations at runtime. However, I think other
|
||||
// GTK applications do that rather than compiling the resources directly into the app. So, I'm
|
||||
// unclear as to how I want to handle this.
|
||||
gio::resources_register_include!("com.luminescent-dreams.fitnesstrax.gresource")
|
||||
.expect("to register resources");
|
||||
|
||||
let app_id = if std::env::var_os("ENV") == Some("dev".into()) {
|
||||
APP_ID_DEV
|
||||
} else {
|
||||
APP_ID_PROD
|
||||
};
|
||||
|
||||
let settings = gio::Settings::new(app_id);
|
||||
let ft_app = app::App::new({
|
||||
let path = settings.string("series-path");
|
||||
if path.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(PathBuf::from(path))
|
||||
}
|
||||
});
|
||||
|
||||
let adw_app = adw::Application::builder()
|
||||
.application_id(app_id)
|
||||
.resource_base_path(RESOURCE_BASE_PATH)
|
||||
.build();
|
||||
|
||||
adw_app.connect_activate(move |adw_app| {
|
||||
let icon_theme = gtk::IconTheme::for_display(&gdk::Display::default().unwrap());
|
||||
icon_theme.add_resource_path(&(RESOURCE_BASE_PATH.to_owned() + "/icons/scalable/actions"));
|
||||
|
||||
setup_app_about_action(adw_app);
|
||||
setup_app_close_action(adw_app);
|
||||
|
||||
AppWindow::new(app_id, RESOURCE_BASE_PATH, adw_app, ft_app.clone());
|
||||
});
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
ApplicationExtManual::run_with_args(&adw_app, &args);
|
||||
}
|
|
@ -1,349 +0,0 @@
|
|||
use chrono::{Local, NaiveDate};
|
||||
use dimensioned::si;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct ParseError;
|
||||
|
||||
// This interval doesn't feel right, either. The idea that I have a specific interval type for just
|
||||
// NaiveDate is odd. This should be genericized, as should the iterator. Also, it shouldn't live
|
||||
// here, but in utilities.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct DayInterval {
|
||||
pub start: NaiveDate,
|
||||
pub end: NaiveDate,
|
||||
}
|
||||
|
||||
impl Default for DayInterval {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
start: (Local::now() - chrono::Duration::days(7)).date_naive(),
|
||||
end: Local::now().date_naive(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DayInterval {
|
||||
pub fn days(&self) -> impl Iterator<Item = NaiveDate> {
|
||||
DayIterator {
|
||||
current: self.start,
|
||||
end: self.end,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct DayIterator {
|
||||
current: NaiveDate,
|
||||
end: NaiveDate,
|
||||
}
|
||||
|
||||
impl Iterator for DayIterator {
|
||||
type Item = NaiveDate;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if self.current <= self.end {
|
||||
let val = self.current;
|
||||
self.current += chrono::Duration::days(1);
|
||||
Some(val)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum FormatOption {
|
||||
Abbreviated,
|
||||
#[allow(unused)]
|
||||
Full,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct TimeFormatter(chrono::NaiveTime);
|
||||
|
||||
impl TimeFormatter {
|
||||
#[allow(unused)]
|
||||
pub fn format(&self, option: FormatOption) -> String {
|
||||
match option {
|
||||
FormatOption::Abbreviated => self.0.format("%H:%M"),
|
||||
FormatOption::Full => self.0.format("%H:%M:%S"),
|
||||
}
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn parse(s: &str) -> Result<TimeFormatter, ParseError> {
|
||||
let parts = s
|
||||
.split(':')
|
||||
.map(|part| part.parse::<u32>().map_err(|_| ParseError))
|
||||
.collect::<Result<Vec<u32>, ParseError>>()?;
|
||||
match parts.len() {
|
||||
0 => Err(ParseError),
|
||||
1 => Err(ParseError),
|
||||
2 => chrono::NaiveTime::from_hms_opt(parts[0], parts[1], 0)
|
||||
.map(|v| TimeFormatter(v))
|
||||
.ok_or(ParseError),
|
||||
3 => chrono::NaiveTime::from_hms_opt(parts[0], parts[1], parts[2])
|
||||
.map(|v| TimeFormatter(v))
|
||||
.ok_or(ParseError),
|
||||
_ => Err(ParseError),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for TimeFormatter {
|
||||
type Target = chrono::NaiveTime;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<chrono::NaiveTime> for TimeFormatter {
|
||||
fn from(value: chrono::NaiveTime) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd)]
|
||||
pub struct WeightFormatter(si::Kilogram<f64>);
|
||||
|
||||
impl WeightFormatter {
|
||||
#[allow(unused)]
|
||||
pub fn format(&self, option: FormatOption) -> String {
|
||||
match option {
|
||||
FormatOption::Abbreviated => format!("{} kg", self.0.value_unsafe),
|
||||
FormatOption::Full => format!("{} kilograms", self.0.value_unsafe),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn parse(s: &str) -> Result<WeightFormatter, ParseError> {
|
||||
s.parse::<f64>()
|
||||
.map(|w| WeightFormatter(w * si::KG))
|
||||
.map_err(|_| ParseError)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Add for WeightFormatter {
|
||||
type Output = WeightFormatter;
|
||||
fn add(self, rside: Self) -> Self::Output {
|
||||
Self::Output::from(self.0 + rside.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Sub for WeightFormatter {
|
||||
type Output = WeightFormatter;
|
||||
fn sub(self, rside: Self) -> Self::Output {
|
||||
Self::Output::from(self.0 - rside.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for WeightFormatter {
|
||||
type Target = si::Kilogram<f64>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<si::Kilogram<f64>> for WeightFormatter {
|
||||
fn from(value: si::Kilogram<f64>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd)]
|
||||
pub struct DistanceFormatter(si::Meter<f64>);
|
||||
|
||||
impl DistanceFormatter {
|
||||
#[allow(unused)]
|
||||
pub fn format(&self, option: FormatOption) -> String {
|
||||
match option {
|
||||
FormatOption::Abbreviated => format!("{} km", self.0.value_unsafe / 1000.),
|
||||
FormatOption::Full => format!("{} kilometers", self.0.value_unsafe / 1000.),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn parse(s: &str) -> Result<DistanceFormatter, ParseError> {
|
||||
let value = s.parse::<f64>().map_err(|_| ParseError)?;
|
||||
Ok(DistanceFormatter(value * 1000. * si::M))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Add for DistanceFormatter {
|
||||
type Output = DistanceFormatter;
|
||||
fn add(self, rside: Self) -> Self::Output {
|
||||
Self::Output::from(self.0 + rside.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Sub for DistanceFormatter {
|
||||
type Output = DistanceFormatter;
|
||||
fn sub(self, rside: Self) -> Self::Output {
|
||||
Self::Output::from(self.0 - rside.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for DistanceFormatter {
|
||||
type Target = si::Meter<f64>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<si::Meter<f64>> for DistanceFormatter {
|
||||
fn from(value: si::Meter<f64>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd)]
|
||||
pub struct DurationFormatter(si::Second<f64>);
|
||||
|
||||
impl DurationFormatter {
|
||||
#[allow(unused)]
|
||||
pub fn format(&self, option: FormatOption) -> String {
|
||||
let (hours, minutes) = self.hours_and_minutes();
|
||||
let (h, m) = match option {
|
||||
FormatOption::Abbreviated => ("h", "m"),
|
||||
FormatOption::Full => (" hours", " minutes"),
|
||||
};
|
||||
if hours > 0 {
|
||||
format!("{}{} {}{}", hours, h, minutes, m)
|
||||
} else {
|
||||
format!("{}{}", minutes, m)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn parse(s: &str) -> Result<DurationFormatter, ParseError> {
|
||||
let value = s.parse::<f64>().map_err(|_| ParseError)?;
|
||||
Ok(DurationFormatter(value * 60. * si::S))
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn hours_and_minutes(&self) -> (i64, i64) {
|
||||
let minutes: i64 = (self.0.value_unsafe / 60.).round() as i64;
|
||||
let hours: i64 = minutes / 60;
|
||||
let minutes = minutes - (hours * 60);
|
||||
(hours, minutes)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Add for DurationFormatter {
|
||||
type Output = DurationFormatter;
|
||||
fn add(self, rside: Self) -> Self::Output {
|
||||
Self::Output::from(self.0 + rside.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Sub for DurationFormatter {
|
||||
type Output = DurationFormatter;
|
||||
fn sub(self, rside: Self) -> Self::Output {
|
||||
Self::Output::from(self.0 - rside.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for DurationFormatter {
|
||||
type Target = si::Second<f64>;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<si::Second<f64>> for DurationFormatter {
|
||||
fn from(value: si::Second<f64>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use dimensioned::si;
|
||||
|
||||
#[test]
|
||||
fn it_parses_weight_values() {
|
||||
assert_eq!(
|
||||
WeightFormatter::parse("15.3"),
|
||||
Ok(WeightFormatter(15.3 * si::KG))
|
||||
);
|
||||
assert_eq!(WeightFormatter::parse("15.ab"), Err(ParseError));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_formats_weight_values() {
|
||||
assert_eq!(
|
||||
WeightFormatter::from(15.3 * si::KG).format(FormatOption::Abbreviated),
|
||||
"15.3 kg"
|
||||
);
|
||||
assert_eq!(
|
||||
WeightFormatter::from(15.3 * si::KG).format(FormatOption::Full),
|
||||
"15.3 kilograms"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_parses_distance_values() {
|
||||
assert_eq!(
|
||||
DistanceFormatter::parse("70"),
|
||||
Ok(DistanceFormatter(70000. * si::M))
|
||||
);
|
||||
assert_eq!(DistanceFormatter::parse("15.ab"), Err(ParseError));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_formats_distance_values() {
|
||||
assert_eq!(
|
||||
DistanceFormatter::from(70000. * si::M).format(FormatOption::Abbreviated),
|
||||
"70 km"
|
||||
);
|
||||
assert_eq!(
|
||||
DistanceFormatter::from(70000. * si::M).format(FormatOption::Full),
|
||||
"70 kilometers"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_parses_duration_values() {
|
||||
assert_eq!(
|
||||
DurationFormatter::parse("70"),
|
||||
Ok(DurationFormatter(4200. * si::S))
|
||||
);
|
||||
assert_eq!(DurationFormatter::parse("15.ab"), Err(ParseError));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_formats_duration_values() {
|
||||
assert_eq!(
|
||||
DurationFormatter::from(4200. * si::S).format(FormatOption::Abbreviated),
|
||||
"1h 10m"
|
||||
);
|
||||
assert_eq!(
|
||||
DurationFormatter::from(4200. * si::S).format(FormatOption::Full),
|
||||
"1 hours 10 minutes"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_parses_time_values() {
|
||||
assert_eq!(
|
||||
TimeFormatter::parse("13:25"),
|
||||
Ok(TimeFormatter::from(
|
||||
chrono::NaiveTime::from_hms_opt(13, 25, 0).unwrap()
|
||||
)),
|
||||
);
|
||||
assert_eq!(
|
||||
TimeFormatter::parse("13:25:50"),
|
||||
Ok(TimeFormatter::from(
|
||||
chrono::NaiveTime::from_hms_opt(13, 25, 50).unwrap()
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_formats_time_values() {
|
||||
let time = TimeFormatter::from(chrono::NaiveTime::from_hms_opt(13, 25, 50).unwrap());
|
||||
assert_eq!(time.format(FormatOption::Abbreviated), "13:25".to_owned());
|
||||
assert_eq!(time.format(FormatOption::Full), "13:25:50".to_owned());
|
||||
}
|
||||
}
|
|
@ -1,657 +0,0 @@
|
|||
/*
|
||||
Copyright 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::app::{ReadError, RecordProvider};
|
||||
use dimensioned::si;
|
||||
use emseries::{Record, RecordId, Recordable};
|
||||
use ft_core::{TimeDistance, TimeDistanceActivity, TraxRecord};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ops::Deref,
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
// These are actually a used imports. Clippy isn't detecting their use, probably because of complexity around the async trait macros.
|
||||
#[allow(unused_imports)]
|
||||
use crate::app::WriteError;
|
||||
#[allow(unused_imports)]
|
||||
use chrono::NaiveDate;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
enum RecordState<T: Clone + Recordable> {
|
||||
Original(Record<T>),
|
||||
New(Record<T>),
|
||||
Updated(Record<T>),
|
||||
Deleted(Record<T>),
|
||||
}
|
||||
|
||||
impl<T: Clone + emseries::Recordable> RecordState<T> {
|
||||
fn exists(&self) -> bool {
|
||||
match self {
|
||||
RecordState::Original(_) => true,
|
||||
RecordState::New(_) => true,
|
||||
RecordState::Updated(_) => true,
|
||||
RecordState::Deleted(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn data(&self) -> Option<&Record<T>> {
|
||||
match self {
|
||||
RecordState::Original(ref r) => Some(r),
|
||||
RecordState::New(ref r) => None,
|
||||
RecordState::Updated(ref r) => Some(r),
|
||||
RecordState::Deleted(ref r) => Some(r),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_value(&mut self, value: T) {
|
||||
*self = match self {
|
||||
RecordState::Original(r) => RecordState::Updated(Record { data: value, ..*r }),
|
||||
RecordState::New(r) => RecordState::New(Record { data: value, ..*r }),
|
||||
RecordState::Updated(r) => RecordState::Updated(Record { data: value, ..*r }),
|
||||
RecordState::Deleted(r) => RecordState::Updated(Record { data: value, ..*r }),
|
||||
};
|
||||
}
|
||||
|
||||
fn with_value(mut self, value: T) -> RecordState<T> {
|
||||
self.set_value(value);
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn with_delete(self) -> Option<RecordState<T>> {
|
||||
match self {
|
||||
RecordState::Original(r) => Some(RecordState::Deleted(r)),
|
||||
RecordState::New(r) => None,
|
||||
RecordState::Updated(r) => Some(RecordState::Deleted(r)),
|
||||
RecordState::Deleted(r) => Some(RecordState::Deleted(r)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone + emseries::Recordable> Deref for RecordState<T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
match self {
|
||||
RecordState::Original(ref r) => &r.data,
|
||||
RecordState::New(ref r) => &r.data,
|
||||
RecordState::Updated(ref r) => &r.data,
|
||||
RecordState::Deleted(ref r) => &r.data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone + emseries::Recordable> std::ops::DerefMut for RecordState<T> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
match self {
|
||||
RecordState::Original(ref mut r) => &mut r.data,
|
||||
RecordState::New(ref mut r) => &mut r.data,
|
||||
RecordState::Updated(ref mut r) => &mut r.data,
|
||||
RecordState::Deleted(ref mut r) => &mut r.data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DayDetailViewModel {
|
||||
provider: Arc<dyn RecordProvider>,
|
||||
pub date: chrono::NaiveDate,
|
||||
weight: Arc<RwLock<Option<RecordState<ft_core::Weight>>>>,
|
||||
steps: Arc<RwLock<Option<RecordState<ft_core::Steps>>>>,
|
||||
records: Arc<RwLock<HashMap<RecordId, RecordState<TraxRecord>>>>,
|
||||
}
|
||||
|
||||
impl DayDetailViewModel {
|
||||
pub async fn new(
|
||||
date: chrono::NaiveDate,
|
||||
provider: impl RecordProvider + 'static,
|
||||
) -> Result<Self, ReadError> {
|
||||
let s = Self {
|
||||
provider: Arc::new(provider),
|
||||
date,
|
||||
weight: Arc::new(RwLock::new(None)),
|
||||
steps: Arc::new(RwLock::new(None)),
|
||||
records: Arc::new(RwLock::new(HashMap::new())),
|
||||
};
|
||||
s.populate_records().await;
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
pub fn weight(&self) -> Option<si::Kilogram<f64>> {
|
||||
(*self.weight.read().unwrap()).as_ref().map(|w| w.weight)
|
||||
}
|
||||
|
||||
pub fn set_weight(&self, new_weight: si::Kilogram<f64>) {
|
||||
let mut record = self.weight.write().unwrap();
|
||||
let new_record = match *record {
|
||||
Some(ref rstate) => rstate.clone().with_value(ft_core::Weight {
|
||||
date: self.date,
|
||||
weight: new_weight,
|
||||
}),
|
||||
None => RecordState::New(Record {
|
||||
id: RecordId::default(),
|
||||
data: ft_core::Weight {
|
||||
date: self.date,
|
||||
weight: new_weight,
|
||||
},
|
||||
}),
|
||||
};
|
||||
*record = Some(new_record);
|
||||
}
|
||||
|
||||
pub fn steps(&self) -> Option<u32> {
|
||||
(*self.steps.read().unwrap()).as_ref().map(|w| w.count)
|
||||
}
|
||||
|
||||
pub fn set_steps(&self, new_count: u32) {
|
||||
let mut record = self.steps.write().unwrap();
|
||||
let new_record = match *record {
|
||||
Some(ref rstate) => rstate.clone().with_value(ft_core::Steps {
|
||||
date: self.date,
|
||||
count: new_count,
|
||||
}),
|
||||
None => RecordState::New(Record {
|
||||
id: RecordId::default(),
|
||||
data: ft_core::Steps {
|
||||
date: self.date,
|
||||
count: new_count,
|
||||
},
|
||||
}),
|
||||
};
|
||||
*record = Some(new_record);
|
||||
}
|
||||
|
||||
pub fn new_time_distance(&self, activity: TimeDistanceActivity) -> Record<TimeDistance> {
|
||||
let now = chrono::Local::now();
|
||||
let base_time = now.time();
|
||||
let tz = now.timezone();
|
||||
let datetime = self
|
||||
.date
|
||||
.clone()
|
||||
.and_time(base_time)
|
||||
.and_local_timezone(tz)
|
||||
.unwrap()
|
||||
.into();
|
||||
|
||||
let id = RecordId::default();
|
||||
let workout = TimeDistance {
|
||||
datetime,
|
||||
activity,
|
||||
distance: None,
|
||||
duration: None,
|
||||
comments: None,
|
||||
};
|
||||
let tr = TraxRecord::from(workout.clone());
|
||||
self.records
|
||||
.write()
|
||||
.unwrap()
|
||||
.insert(id, RecordState::New(Record { id, data: tr }));
|
||||
Record { id, data: workout }
|
||||
}
|
||||
|
||||
pub fn time_distance_records(&self) -> Vec<Record<TimeDistance>> {
|
||||
self.records
|
||||
.read()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|(_, record)| record.exists())
|
||||
.filter_map(|(id, record_state)| match **record_state {
|
||||
TraxRecord::TimeDistance(ref workout) => Some(Record {
|
||||
id: *id,
|
||||
data: workout.clone(),
|
||||
}),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn time_distance_summary(
|
||||
&self,
|
||||
activity: TimeDistanceActivity,
|
||||
) -> (si::Meter<f64>, si::Second<f64>) {
|
||||
self.time_distance_records()
|
||||
.into_iter()
|
||||
.filter(|rec| rec.data.activity == activity)
|
||||
.fold(
|
||||
(0. * si::M, 0. * si::S),
|
||||
|(distance, duration), workout| match (workout.data.distance, workout.data.duration)
|
||||
{
|
||||
(Some(distance_), Some(duration_)) => {
|
||||
(distance + distance_, duration + duration_)
|
||||
}
|
||||
(Some(distance_), None) => (distance + distance_, duration),
|
||||
(None, Some(duration_)) => (distance, duration + duration_),
|
||||
(None, None) => (distance, duration),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn update_record(&self, update: Record<TraxRecord>) {
|
||||
let mut records = self.records.write().unwrap();
|
||||
records
|
||||
.entry(update.id)
|
||||
.and_modify(|record| record.set_value(update.data));
|
||||
}
|
||||
|
||||
pub fn records(&self) -> Vec<Record<TraxRecord>> {
|
||||
let read_lock = self.records.read().unwrap();
|
||||
read_lock
|
||||
.iter()
|
||||
.filter_map(|(_, record_state)| record_state.data())
|
||||
.cloned()
|
||||
.collect::<Vec<Record<TraxRecord>>>()
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn get_record(&self, id: &RecordId) -> Option<Record<TraxRecord>> {
|
||||
let record_set = self.records.read().unwrap();
|
||||
record_set.get(id).map(|record| Record {
|
||||
id: *id,
|
||||
data: (**record).clone(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn remove_record(&self, id: RecordId) {
|
||||
let mut record_set = self.records.write().unwrap();
|
||||
let updated_record = match record_set.remove(&id) {
|
||||
Some(RecordState::Original(r)) => Some(RecordState::Deleted(r)),
|
||||
Some(RecordState::New(_)) => None,
|
||||
Some(RecordState::Updated(r)) => Some(RecordState::Deleted(r)),
|
||||
Some(RecordState::Deleted(r)) => Some(RecordState::Deleted(r)),
|
||||
None => None,
|
||||
};
|
||||
if let Some(updated_record) = updated_record {
|
||||
record_set.insert(id, updated_record);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn save(&self) {
|
||||
let s = self.clone();
|
||||
|
||||
glib::spawn_future(async move { s.async_save().await });
|
||||
}
|
||||
|
||||
pub async fn async_save(&self) {
|
||||
let weight_record = self.weight.read().unwrap().clone();
|
||||
match weight_record {
|
||||
Some(RecordState::New(data)) => {
|
||||
let _ = self
|
||||
.provider
|
||||
.put_record(TraxRecord::Weight(data.data))
|
||||
.await;
|
||||
}
|
||||
Some(RecordState::Original(_)) => {}
|
||||
Some(RecordState::Updated(weight)) => {
|
||||
let _ = self
|
||||
.provider
|
||||
.update_record(Record {
|
||||
id: weight.id,
|
||||
data: TraxRecord::Weight(weight.data),
|
||||
})
|
||||
.await;
|
||||
}
|
||||
Some(RecordState::Deleted(_)) => {}
|
||||
None => {}
|
||||
}
|
||||
|
||||
let steps_record = self.steps.read().unwrap().clone();
|
||||
match steps_record {
|
||||
Some(RecordState::New(data)) => {
|
||||
let _ = self.provider.put_record(TraxRecord::Steps(data.data)).await;
|
||||
}
|
||||
Some(RecordState::Original(_)) => {}
|
||||
Some(RecordState::Updated(steps)) => {
|
||||
let _ = self
|
||||
.provider
|
||||
.update_record(Record {
|
||||
id: steps.id,
|
||||
data: TraxRecord::Steps(steps.data),
|
||||
})
|
||||
.await;
|
||||
}
|
||||
Some(RecordState::Deleted(_)) => {}
|
||||
None => {}
|
||||
}
|
||||
|
||||
let records = self
|
||||
.records
|
||||
.write()
|
||||
.unwrap()
|
||||
.drain()
|
||||
.map(|(_, record)| record)
|
||||
.collect::<Vec<RecordState<TraxRecord>>>();
|
||||
|
||||
for record in records {
|
||||
println!("saving record: {:?}", record);
|
||||
match record {
|
||||
RecordState::New(data) => {
|
||||
let _ = self.provider.put_record(data.data).await;
|
||||
}
|
||||
RecordState::Original(_) => {}
|
||||
RecordState::Updated(r) => {
|
||||
let _ = self.provider.update_record(r.clone()).await;
|
||||
}
|
||||
RecordState::Deleted(r) => {
|
||||
let _ = self.provider.delete_record(r.id).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
self.populate_records().await;
|
||||
}
|
||||
|
||||
pub async fn revert(&self) {
|
||||
self.populate_records().await;
|
||||
}
|
||||
|
||||
async fn populate_records(&self) {
|
||||
let records = self.provider.records(self.date, self.date).await.unwrap();
|
||||
|
||||
let (weight_records, records): (Vec<Record<TraxRecord>>, Vec<Record<TraxRecord>>) =
|
||||
records.into_iter().partition(|r| r.data.is_weight());
|
||||
let (step_records, records): (Vec<Record<TraxRecord>>, Vec<Record<TraxRecord>>) =
|
||||
records.into_iter().partition(|r| r.data.is_steps());
|
||||
|
||||
*self.weight.write().unwrap() = weight_records
|
||||
.first()
|
||||
.and_then(|r| match r.data {
|
||||
TraxRecord::Weight(ref w) => Some((r.id, w.clone())),
|
||||
_ => None,
|
||||
})
|
||||
.map(|(id, w)| RecordState::Original(Record { id, data: w }));
|
||||
|
||||
*self.steps.write().unwrap() = step_records
|
||||
.first()
|
||||
.and_then(|r| match r.data {
|
||||
TraxRecord::Steps(ref w) => Some((r.id, w.clone())),
|
||||
_ => None,
|
||||
})
|
||||
.map(|(id, w)| RecordState::Original(Record { id, data: w }));
|
||||
|
||||
*self.records.write().unwrap() = records
|
||||
.into_iter()
|
||||
.map(|r| (r.id, RecordState::Original(r)))
|
||||
.collect::<HashMap<RecordId, RecordState<TraxRecord>>>();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use dimensioned::si;
|
||||
use emseries::Record;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct MockProvider {
|
||||
records: Arc<RwLock<HashMap<RecordId, Record<TraxRecord>>>>,
|
||||
|
||||
put_records: Arc<RwLock<Vec<Record<TraxRecord>>>>,
|
||||
updated_records: Arc<RwLock<Vec<Record<TraxRecord>>>>,
|
||||
deleted_records: Arc<RwLock<Vec<RecordId>>>,
|
||||
}
|
||||
|
||||
impl MockProvider {
|
||||
fn new(records: Vec<Record<TraxRecord>>) -> Self {
|
||||
let record_map = records
|
||||
.into_iter()
|
||||
.map(|r| (r.id, r))
|
||||
.collect::<HashMap<RecordId, Record<TraxRecord>>>();
|
||||
Self {
|
||||
records: Arc::new(RwLock::new(record_map)),
|
||||
put_records: Arc::new(RwLock::new(vec![])),
|
||||
updated_records: Arc::new(RwLock::new(vec![])),
|
||||
deleted_records: Arc::new(RwLock::new(vec![])),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl RecordProvider for MockProvider {
|
||||
async fn records(
|
||||
&self,
|
||||
start: NaiveDate,
|
||||
end: NaiveDate,
|
||||
) -> Result<Vec<Record<TraxRecord>>, ReadError> {
|
||||
let start = emseries::Timestamp::Date(start);
|
||||
let end = emseries::Timestamp::Date(end);
|
||||
Ok(self
|
||||
.records
|
||||
.read()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|(_, r)| r)
|
||||
.filter(|r| r.timestamp() >= start && r.timestamp() <= end)
|
||||
.cloned()
|
||||
.collect::<Vec<Record<TraxRecord>>>())
|
||||
}
|
||||
|
||||
async fn put_record(&self, record: TraxRecord) -> Result<RecordId, WriteError> {
|
||||
let id = RecordId::default();
|
||||
let record = Record {
|
||||
id: id,
|
||||
data: record,
|
||||
};
|
||||
self.put_records.write().unwrap().push(record.clone());
|
||||
self.records.write().unwrap().insert(id, record);
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
async fn update_record(&self, record: Record<TraxRecord>) -> Result<(), WriteError> {
|
||||
println!("updated record: {:?}", record);
|
||||
self.updated_records.write().unwrap().push(record.clone());
|
||||
self.records.write().unwrap().insert(record.id, record);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn delete_record(&self, id: RecordId) -> Result<(), WriteError> {
|
||||
self.deleted_records.write().unwrap().push(id);
|
||||
let _ = self.records.write().unwrap().remove(&id);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
async fn create_empty_view_model() -> (DayDetailViewModel, MockProvider) {
|
||||
let provider = MockProvider::new(vec![]);
|
||||
|
||||
let oct_13 = chrono::NaiveDate::from_ymd_opt(2023, 10, 13).unwrap();
|
||||
let model = DayDetailViewModel::new(oct_13, provider.clone())
|
||||
.await
|
||||
.unwrap();
|
||||
(model, provider)
|
||||
}
|
||||
|
||||
async fn create_view_model() -> (DayDetailViewModel, MockProvider) {
|
||||
let oct_12 = chrono::NaiveDate::from_ymd_opt(2023, 10, 12).unwrap();
|
||||
let oct_13 = chrono::NaiveDate::from_ymd_opt(2023, 10, 13).unwrap();
|
||||
let oct_13_am: DateTime<FixedOffset> = oct_13
|
||||
.clone()
|
||||
.and_hms_opt(3, 28, 0)
|
||||
.unwrap()
|
||||
.and_utc()
|
||||
.with_timezone(&FixedOffset::east_opt(5 * 3600).unwrap());
|
||||
let provider = MockProvider::new(vec![
|
||||
Record {
|
||||
id: RecordId::default(),
|
||||
data: TraxRecord::Weight(ft_core::Weight {
|
||||
date: oct_12,
|
||||
weight: 93. * si::KG,
|
||||
}),
|
||||
},
|
||||
Record {
|
||||
id: RecordId::default(),
|
||||
data: TraxRecord::Weight(ft_core::Weight {
|
||||
date: oct_13,
|
||||
weight: 95. * si::KG,
|
||||
}),
|
||||
},
|
||||
Record {
|
||||
id: RecordId::default(),
|
||||
data: TraxRecord::Steps(ft_core::Steps {
|
||||
date: oct_13,
|
||||
count: 2500,
|
||||
}),
|
||||
},
|
||||
Record {
|
||||
id: RecordId::default(),
|
||||
data: TraxRecord::TimeDistance(ft_core::TimeDistance {
|
||||
datetime: oct_13_am.clone(),
|
||||
activity: TimeDistanceActivity::Biking,
|
||||
distance: Some(15000. * si::M),
|
||||
duration: Some(3600. * si::S),
|
||||
comments: Some("somecomments present".to_owned()),
|
||||
}),
|
||||
},
|
||||
]);
|
||||
let model = DayDetailViewModel::new(oct_13, provider.clone())
|
||||
.await
|
||||
.unwrap();
|
||||
(model, provider)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_honors_only_the_first_weight_and_step_record() {
|
||||
let (view_model, _provider) = create_view_model().await;
|
||||
assert_eq!(view_model.weight(), Some(95. * si::KG));
|
||||
assert_eq!(view_model.steps(), Some(2500));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_can_create_a_weight_and_stepcount() {
|
||||
let (view_model, provider) = create_empty_view_model().await;
|
||||
assert_eq!(view_model.weight(), None);
|
||||
assert_eq!(view_model.steps(), None);
|
||||
|
||||
view_model.set_weight(95. * si::KG);
|
||||
view_model.set_steps(250);
|
||||
|
||||
assert_eq!(view_model.weight(), Some(95. * si::KG));
|
||||
assert_eq!(view_model.steps(), Some(250));
|
||||
|
||||
view_model.set_weight(93. * si::KG);
|
||||
view_model.set_steps(255);
|
||||
|
||||
assert_eq!(view_model.weight(), Some(93. * si::KG));
|
||||
assert_eq!(view_model.steps(), Some(255));
|
||||
|
||||
view_model.async_save().await;
|
||||
|
||||
println!("provider: {:?}", provider);
|
||||
assert_eq!(provider.put_records.read().unwrap().len(), 2);
|
||||
assert_eq!(provider.updated_records.read().unwrap().len(), 0);
|
||||
assert_eq!(provider.deleted_records.read().unwrap().len(), 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_can_construct_new_records() {
|
||||
let (view_model, provider) = create_empty_view_model().await;
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(0. * si::M, 0. * si::S)
|
||||
);
|
||||
|
||||
let mut record = view_model.new_time_distance(TimeDistanceActivity::Biking);
|
||||
record.data.duration = Some(60. * si::S);
|
||||
view_model.async_save().await;
|
||||
|
||||
assert_eq!(provider.put_records.read().unwrap().len(), 1);
|
||||
assert_eq!(provider.updated_records.read().unwrap().len(), 0);
|
||||
assert_eq!(provider.deleted_records.read().unwrap().len(), 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_can_update_a_new_record_before_saving() {
|
||||
let (view_model, provider) = create_empty_view_model().await;
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(0. * si::M, 0. * si::S)
|
||||
);
|
||||
|
||||
let mut record = view_model.new_time_distance(TimeDistanceActivity::Biking);
|
||||
record.data.duration = Some(60. * si::S);
|
||||
let record = record.map(TraxRecord::TimeDistance);
|
||||
view_model.update_record(record.clone());
|
||||
assert_eq!(view_model.get_record(&record.id), Some(record));
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(0. * si::M, 60. * si::S)
|
||||
);
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Running),
|
||||
(0. * si::M, 0. * si::S)
|
||||
);
|
||||
view_model.async_save().await;
|
||||
|
||||
assert_eq!(provider.put_records.read().unwrap().len(), 1);
|
||||
assert_eq!(provider.updated_records.read().unwrap().len(), 0);
|
||||
assert_eq!(provider.deleted_records.read().unwrap().len(), 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_can_update_an_existing_record() {
|
||||
let (view_model, provider) = create_view_model().await;
|
||||
let mut workout = view_model.time_distance_records().first().cloned().unwrap();
|
||||
|
||||
workout.data.duration = Some(1800. * si::S);
|
||||
view_model.update_record(workout.map(TraxRecord::TimeDistance));
|
||||
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(15000. * si::M, 1800. * si::S)
|
||||
);
|
||||
|
||||
view_model.async_save().await;
|
||||
|
||||
assert_eq!(provider.put_records.read().unwrap().len(), 0);
|
||||
assert_eq!(provider.updated_records.read().unwrap().len(), 1);
|
||||
assert_eq!(provider.deleted_records.read().unwrap().len(), 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_can_remove_a_new_record() {
|
||||
let (view_model, provider) = create_empty_view_model().await;
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(0. * si::M, 0. * si::S)
|
||||
);
|
||||
|
||||
let record = view_model.new_time_distance(TimeDistanceActivity::Biking);
|
||||
view_model.remove_record(record.id);
|
||||
view_model.save();
|
||||
|
||||
assert_eq!(provider.put_records.read().unwrap().len(), 0);
|
||||
assert_eq!(provider.updated_records.read().unwrap().len(), 0);
|
||||
assert_eq!(provider.deleted_records.read().unwrap().len(), 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_can_delete_an_existing_record() {
|
||||
let (view_model, provider) = create_view_model().await;
|
||||
let workout = view_model.time_distance_records().first().cloned().unwrap();
|
||||
|
||||
view_model.remove_record(workout.id);
|
||||
assert_eq!(
|
||||
view_model.time_distance_summary(TimeDistanceActivity::Biking),
|
||||
(0. * si::M, 0. * si::S)
|
||||
);
|
||||
view_model.async_save().await;
|
||||
|
||||
assert_eq!(provider.put_records.read().unwrap().len(), 0);
|
||||
assert_eq!(provider.updated_records.read().unwrap().len(), 0);
|
||||
assert_eq!(provider.deleted_records.read().unwrap().len(), 1);
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
Copyright 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
mod day_detail;
|
||||
pub use day_detail::DayDetailViewModel;
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
Copyright 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
components::{DayDetail, DayEdit, Singleton, SingletonImpl},
|
||||
view_models::DayDetailViewModel,
|
||||
};
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use std::cell::RefCell;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct DayDetailViewPrivate {
|
||||
container: Singleton,
|
||||
view_model: RefCell<Option<DayDetailViewModel>>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for DayDetailViewPrivate {
|
||||
const NAME: &'static str = "DayDetailView";
|
||||
type Type = DayDetailView;
|
||||
type ParentType = gtk::Box;
|
||||
}
|
||||
|
||||
impl ObjectImpl for DayDetailViewPrivate {}
|
||||
impl WidgetImpl for DayDetailViewPrivate {}
|
||||
impl BoxImpl for DayDetailViewPrivate {}
|
||||
impl SingletonImpl for DayDetailViewPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct DayDetailView(ObjectSubclass<DayDetailViewPrivate>) @extends gtk::Box, gtk::Widget;
|
||||
}
|
||||
|
||||
impl DayDetailView {
|
||||
pub fn new(view_model: DayDetailViewModel) -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
*s.imp().view_model.borrow_mut() = Some(view_model);
|
||||
|
||||
s.append(&s.imp().container);
|
||||
|
||||
s.view();
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
fn view(&self) {
|
||||
let view_model = self.imp().view_model.borrow();
|
||||
let view_model = view_model
|
||||
.as_ref()
|
||||
.expect("DayDetailView has not been initialized with a view_model")
|
||||
.clone();
|
||||
|
||||
self.imp().container.swap(&DayDetail::new(view_model, {
|
||||
let s = self.clone();
|
||||
move || s.edit()
|
||||
}));
|
||||
}
|
||||
|
||||
fn edit(&self) {
|
||||
let view_model = self.imp().view_model.borrow();
|
||||
let view_model = view_model
|
||||
.as_ref()
|
||||
.expect("DayDetailView has not been initialized with a view_model")
|
||||
.clone();
|
||||
|
||||
self.imp().container.swap(&DayEdit::new(view_model, {
|
||||
let s = self.clone();
|
||||
move || s.view()
|
||||
}));
|
||||
}
|
||||
}
|
|
@ -1,182 +0,0 @@
|
|||
/*
|
||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
app::App,
|
||||
components::{DateRangePicker, DaySummary},
|
||||
types::DayInterval,
|
||||
view_models::DayDetailViewModel,
|
||||
};
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
/// The historical view will show a window into the main database. It will show some version of
|
||||
/// daily summaries, daily details, and will provide all functions the user may need for editing
|
||||
/// records.
|
||||
pub struct HistoricalViewPrivate {
|
||||
app: Rc<RefCell<Option<App>>>,
|
||||
list_view: gtk::ListView,
|
||||
date_range_picker: DateRangePicker,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for HistoricalViewPrivate {
|
||||
const NAME: &'static str = "HistoricalView";
|
||||
type Type = HistoricalView;
|
||||
type ParentType = gtk::Box;
|
||||
|
||||
fn new() -> Self {
|
||||
let factory = gtk::SignalListItemFactory::new();
|
||||
factory.connect_setup(move |_, list_item| {
|
||||
list_item
|
||||
.downcast_ref::<gtk::ListItem>()
|
||||
.expect("should be a ListItem")
|
||||
.set_child(Some(&DaySummary::new()));
|
||||
});
|
||||
|
||||
let date_range_picker = DateRangePicker::default();
|
||||
|
||||
let s = Self {
|
||||
app: Rc::new(RefCell::new(None)),
|
||||
list_view: gtk::ListView::builder()
|
||||
.factory(&factory)
|
||||
.single_click_activate(true)
|
||||
.show_separators(true)
|
||||
.build(),
|
||||
date_range_picker,
|
||||
};
|
||||
|
||||
factory.connect_bind({
|
||||
let app = s.app.clone();
|
||||
move |_, list_item| {
|
||||
let date = list_item
|
||||
.downcast_ref::<gtk::ListItem>()
|
||||
.expect("should be a ListItem")
|
||||
.item()
|
||||
.and_downcast::<Date>()
|
||||
.expect("should be a Date");
|
||||
|
||||
let summary = list_item
|
||||
.downcast_ref::<gtk::ListItem>()
|
||||
.expect("should be a ListItem")
|
||||
.child()
|
||||
.and_downcast::<DaySummary>()
|
||||
.expect("should be a DaySummary");
|
||||
|
||||
if let Some(app) = app.borrow().clone() {
|
||||
glib::spawn_future_local(async move {
|
||||
let view_model = DayDetailViewModel::new(date.date(), app.clone())
|
||||
.await
|
||||
.unwrap();
|
||||
summary.set_data(view_model);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for HistoricalViewPrivate {}
|
||||
impl WidgetImpl for HistoricalViewPrivate {}
|
||||
impl BoxImpl for HistoricalViewPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct HistoricalView(ObjectSubclass<HistoricalViewPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||
}
|
||||
|
||||
impl HistoricalView {
|
||||
pub fn new<SelectFn>(app: App, interval: DayInterval, on_select_day: Rc<SelectFn>) -> Self
|
||||
where
|
||||
SelectFn: Fn(chrono::NaiveDate) + 'static,
|
||||
{
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_orientation(gtk::Orientation::Vertical);
|
||||
s.set_css_classes(&["historical"]);
|
||||
|
||||
*s.imp().app.borrow_mut() = Some(app);
|
||||
|
||||
s.imp().date_range_picker.connect_on_search({
|
||||
let s = s.clone();
|
||||
move |interval| s.set_interval(interval)
|
||||
});
|
||||
s.set_interval(interval);
|
||||
|
||||
s.imp().list_view.connect_activate({
|
||||
let on_select_day = on_select_day.clone();
|
||||
move |s, idx| {
|
||||
// This gets triggered whenever the user clicks on an item on the list.
|
||||
let item = s.model().unwrap().item(idx).unwrap();
|
||||
let date = item.downcast_ref::<Date>().unwrap();
|
||||
on_select_day(date.date());
|
||||
}
|
||||
});
|
||||
|
||||
let scroller = gtk::ScrolledWindow::builder()
|
||||
.child(&s.imp().list_view)
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.hscrollbar_policy(gtk::PolicyType::Never)
|
||||
.build();
|
||||
|
||||
s.append(&s.imp().date_range_picker);
|
||||
s.append(&scroller);
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
pub fn set_interval(&self, interval: DayInterval) {
|
||||
let mut model = gio::ListStore::new::<Date>();
|
||||
let mut days = interval.days().map(Date::new).collect::<Vec<Date>>();
|
||||
days.reverse();
|
||||
model.extend(days.into_iter());
|
||||
self.imp()
|
||||
.list_view
|
||||
.set_model(Some(>k::NoSelection::new(Some(model))));
|
||||
self.imp().date_range_picker.set_interval(interval.start, interval.end);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct DatePrivate {
|
||||
date: RefCell<chrono::NaiveDate>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for DatePrivate {
|
||||
const NAME: &'static str = "Date";
|
||||
type Type = Date;
|
||||
}
|
||||
|
||||
impl ObjectImpl for DatePrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct Date(ObjectSubclass<DatePrivate>);
|
||||
}
|
||||
|
||||
impl Date {
|
||||
pub fn new(date: chrono::NaiveDate) -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
*s.imp().date.borrow_mut() = date;
|
||||
s
|
||||
}
|
||||
|
||||
pub fn date(&self) -> chrono::NaiveDate {
|
||||
*self.imp().date.borrow()
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use gtk::prelude::*;
|
||||
|
||||
mod day_detail_view;
|
||||
pub use day_detail_view::DayDetailView;
|
||||
|
||||
mod historical_view;
|
||||
pub use historical_view::HistoricalView;
|
||||
|
||||
mod placeholder_view;
|
||||
pub use placeholder_view::PlaceholderView;
|
||||
|
||||
mod welcome_view;
|
||||
pub use welcome_view::WelcomeView;
|
||||
|
||||
pub enum View {
|
||||
Placeholder(PlaceholderView),
|
||||
Welcome(WelcomeView),
|
||||
Historical(HistoricalView),
|
||||
}
|
||||
|
||||
impl View {
|
||||
pub fn widget(&self) -> gtk::Widget {
|
||||
match self {
|
||||
View::Placeholder(widget) => widget.clone().upcast::<gtk::Widget>(),
|
||||
View::Welcome(widget) => widget.clone().upcast::<gtk::Widget>(),
|
||||
View::Historical(widget) => widget.clone().upcast::<gtk::Widget>(),
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use glib::Object;
|
||||
use gtk::subclass::prelude::*;
|
||||
|
||||
pub struct PlaceholderViewPrivate {}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for PlaceholderViewPrivate {
|
||||
const NAME: &'static str = "PlaceholderView";
|
||||
type Type = PlaceholderView;
|
||||
type ParentType = gtk::Box;
|
||||
|
||||
fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for PlaceholderViewPrivate {}
|
||||
impl WidgetImpl for PlaceholderViewPrivate {}
|
||||
impl BoxImpl for PlaceholderViewPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct PlaceholderView(ObjectSubclass<PlaceholderViewPrivate>) @extends gtk::Box, gtk::Widget;
|
||||
}
|
||||
|
||||
impl Default for PlaceholderView {
|
||||
fn default() -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
s
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::components::FileChooserRow;
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// This is the view to show if the application has not yet been configured. It will walk the user
|
||||
/// through the most critical setup steps so that we can move on to the other views in the app.
|
||||
pub struct WelcomeViewPrivate {}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for WelcomeViewPrivate {
|
||||
const NAME: &'static str = "WelcomeView";
|
||||
type Type = WelcomeView;
|
||||
type ParentType = gtk::Box;
|
||||
|
||||
fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for WelcomeViewPrivate {}
|
||||
impl WidgetImpl for WelcomeViewPrivate {}
|
||||
impl BoxImpl for WelcomeViewPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct WelcomeView(ObjectSubclass<WelcomeViewPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||
}
|
||||
|
||||
impl WelcomeView {
|
||||
pub fn new<OnSave>(on_save: OnSave) -> Self
|
||||
where
|
||||
OnSave: Fn(PathBuf) + 'static,
|
||||
{
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_orientation(gtk::Orientation::Vertical);
|
||||
s.set_css_classes(&["welcome"]);
|
||||
|
||||
// Replace this with the welcome screen that we set up in the fitnesstrax/unconfigured-page
|
||||
// branch.
|
||||
let title = gtk::Label::builder()
|
||||
.label("Welcome to FitnessTrax")
|
||||
.css_classes(["welcome__title"])
|
||||
.build();
|
||||
|
||||
let content = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.vexpand(true)
|
||||
.build();
|
||||
|
||||
let save_button = gtk::Button::builder()
|
||||
.label("Save Settings")
|
||||
.sensitive(false)
|
||||
.build();
|
||||
|
||||
// The database selection row should be a box that shows a default database path, along with a
|
||||
// button that triggers a file chooser dialog. Once the dialog returns, the box should be
|
||||
// updated to reflect the chosen path.
|
||||
let db_row = FileChooserRow::new({
|
||||
let save_button = save_button.clone();
|
||||
move |_| save_button.set_sensitive(true)
|
||||
});
|
||||
|
||||
content.append(>k::Label::new(Some("Welcome to FitnessTrax. The application has not yet been configured, so I will walk you through that. Let's start out by selecting your database.")));
|
||||
content.append(&db_row);
|
||||
|
||||
save_button.connect_clicked({
|
||||
let db_row = db_row.clone();
|
||||
move |_| {
|
||||
if let Some(path) = db_row.path() {
|
||||
on_save(path);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
s.append(&title);
|
||||
s.append(&content);
|
||||
s.append(&save_button);
|
||||
|
||||
s
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
[package]
|
||||
name = "ft-core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
chrono = { version = "0.4" }
|
||||
chrono-tz = { version = "0.8" }
|
||||
dimensioned = { version = "0.8", features = [ "serde" ] }
|
||||
emseries = { path = "../../emseries" }
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
serde_json = { version = "1" }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "*"
|
||||
|
||||
|
|
@ -1,328 +0,0 @@
|
|||
/*
|
||||
Copyright 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use chrono::SecondsFormat;
|
||||
use chrono_tz::Etc::UTC;
|
||||
use dimensioned::si;
|
||||
use emseries::{Record, RecordId, Series, Timestamp};
|
||||
use ft_core::{self, DurationWorkout, DurationWorkoutActivity, SetRepActivity, TraxRecord};
|
||||
use serde::{
|
||||
de::{self, Visitor},
|
||||
Deserialize, Deserializer, Serialize, Serializer,
|
||||
};
|
||||
use std::{
|
||||
fmt,
|
||||
fs::File,
|
||||
io::{BufRead, BufReader, Read},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
/// This is a wrapper around date time objects, using timezones from the chroon-tz database and
|
||||
/// providing string representation and parsing of the form "<RFC3339> <Timezone Name>", i.e.,
|
||||
/// "2019-05-15T14:30:00Z US/Central". The to_string method, and serde serialization will
|
||||
/// produce a string of this format. The parser will accept an RFC3339-only string of the forms
|
||||
/// "2019-05-15T14:30:00Z", "2019-05-15T14:30:00+00:00", and also an "RFC3339 Timezone Name"
|
||||
/// string.
|
||||
///
|
||||
/// The function here is to generate as close to unambiguous time/date strings, (for earth's
|
||||
/// gravitational frame of reference), as possible. Clumping together the time, offset from UTC,
|
||||
/// and the named time zone allows future parsers to know the exact interpretation of the time in
|
||||
/// the frame of reference of the original recording.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct DateTimeTz(pub chrono::DateTime<chrono_tz::Tz>);
|
||||
|
||||
impl fmt::Display for DateTimeTz {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
if self.0.timezone() == UTC {
|
||||
write!(f, "{}", self.0.to_rfc3339_opts(SecondsFormat::Secs, true))
|
||||
} else {
|
||||
write!(
|
||||
f,
|
||||
"{} {}",
|
||||
self.0
|
||||
.with_timezone(&chrono_tz::Etc::UTC)
|
||||
.to_rfc3339_opts(SecondsFormat::Secs, true,),
|
||||
self.0.timezone().name()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DateTimeTz {
|
||||
pub fn map<F>(&self, f: F) -> DateTimeTz
|
||||
where
|
||||
F: FnOnce(chrono::DateTime<chrono_tz::Tz>) -> chrono::DateTime<chrono_tz::Tz>,
|
||||
{
|
||||
DateTimeTz(f(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for DateTimeTz {
|
||||
type Err = chrono::ParseError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let v: Vec<&str> = s.split_terminator(' ').collect();
|
||||
if v.len() == 2 {
|
||||
let tz = v[1].parse::<chrono_tz::Tz>().unwrap();
|
||||
chrono::DateTime::parse_from_rfc3339(v[0]).map(|ts| DateTimeTz(ts.with_timezone(&tz)))
|
||||
} else {
|
||||
chrono::DateTime::parse_from_rfc3339(v[0]).map(|ts| DateTimeTz(ts.with_timezone(&UTC)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<chrono::DateTime<chrono_tz::Tz>> for DateTimeTz {
|
||||
fn from(dt: chrono::DateTime<chrono_tz::Tz>) -> DateTimeTz {
|
||||
DateTimeTz(dt)
|
||||
}
|
||||
}
|
||||
|
||||
struct DateTimeTzVisitor;
|
||||
|
||||
impl<'de> Visitor<'de> for DateTimeTzVisitor {
|
||||
type Value = DateTimeTz;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("a string date time representation that can be parsed")
|
||||
}
|
||||
|
||||
fn visit_str<E: de::Error>(self, s: &str) -> Result<Self::Value, E> {
|
||||
DateTimeTz::from_str(s).or(Err(E::custom(
|
||||
"string is not a parsable datetime representation".to_owned(),
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for DateTimeTz {
|
||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
serializer.serialize_str(&self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for DateTimeTz {
|
||||
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
||||
deserializer.deserialize_str(DateTimeTzVisitor)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
struct Steps {
|
||||
date: DateTimeTz,
|
||||
steps: u32,
|
||||
}
|
||||
|
||||
impl From<Steps> for ft_core::Steps {
|
||||
fn from(s: Steps) -> Self {
|
||||
Self {
|
||||
date: s.date.0.naive_utc().date(),
|
||||
count: s.steps,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
struct Weight {
|
||||
date: DateTimeTz,
|
||||
weight: f64,
|
||||
}
|
||||
|
||||
impl From<Weight> for ft_core::Weight {
|
||||
fn from(w: Weight) -> Self {
|
||||
Self {
|
||||
date: w.date.0.naive_utc().date(),
|
||||
weight: w.weight * si::KG,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
enum TDActivity {
|
||||
Cycling,
|
||||
Rowing,
|
||||
Running,
|
||||
Swimming,
|
||||
Walking,
|
||||
}
|
||||
|
||||
impl From<TDActivity> for ft_core::TimeDistanceActivity {
|
||||
fn from(activity: TDActivity) -> Self {
|
||||
match activity {
|
||||
TDActivity::Cycling => ft_core::TimeDistanceActivity::Biking,
|
||||
TDActivity::Rowing => ft_core::TimeDistanceActivity::Rowing,
|
||||
TDActivity::Running => ft_core::TimeDistanceActivity::Running,
|
||||
TDActivity::Swimming => ft_core::TimeDistanceActivity::Swimming,
|
||||
TDActivity::Walking => ft_core::TimeDistanceActivity::Walking,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
struct TimeDistance {
|
||||
date: DateTimeTz,
|
||||
activity: TDActivity,
|
||||
comments: Option<String>,
|
||||
distance: Option<f64>,
|
||||
duration: Option<f64>,
|
||||
}
|
||||
|
||||
impl From<TimeDistance> for ft_core::TimeDistance {
|
||||
fn from(td: TimeDistance) -> Self {
|
||||
Self {
|
||||
datetime: td.date.0.fixed_offset(),
|
||||
activity: td.activity.into(),
|
||||
comments: td.comments,
|
||||
distance: td.distance.map(|d| d * si::M),
|
||||
duration: td.duration.map(|d| d * si::S),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
enum SRActivity {
|
||||
Pushups,
|
||||
Situps,
|
||||
}
|
||||
|
||||
impl From<SRActivity> for SetRepActivity {
|
||||
fn from(activity: SRActivity) -> Self {
|
||||
match activity {
|
||||
SRActivity::Pushups => Self::Pushups,
|
||||
SRActivity::Situps => Self::Situps,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
struct SetRep {
|
||||
date: DateTimeTz,
|
||||
activity: SRActivity,
|
||||
sets: Vec<u32>,
|
||||
comments: Option<String>,
|
||||
}
|
||||
|
||||
impl From<SetRep> for ft_core::SetRep {
|
||||
fn from(sr: SetRep) -> Self {
|
||||
Self {
|
||||
date: sr.date.0.naive_utc().date(),
|
||||
activity: sr.activity.into(),
|
||||
sets: sr.sets,
|
||||
comments: sr.comments,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
enum RDActivity {
|
||||
MartialArts,
|
||||
}
|
||||
|
||||
impl From<RDActivity> for DurationWorkoutActivity {
|
||||
fn from(_: RDActivity) -> Self {
|
||||
Self::MartialArts
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
struct RepDuration {
|
||||
date: DateTimeTz,
|
||||
activity: RDActivity,
|
||||
sets: Vec<f64>,
|
||||
}
|
||||
|
||||
impl From<RepDuration> for DurationWorkout {
|
||||
fn from(rd: RepDuration) -> Self {
|
||||
Self {
|
||||
datetime: rd.date.0.fixed_offset(),
|
||||
activity: rd.activity.into(),
|
||||
duration: rd.sets.into_iter().map(|d| d * si::S).next(),
|
||||
comments: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
enum LegacyData {
|
||||
RepDuration(RepDuration),
|
||||
SetRep(SetRep),
|
||||
Steps(Steps),
|
||||
TimeDistance(TimeDistance),
|
||||
Weight(Weight),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
struct LegacyRecord {
|
||||
id: RecordId,
|
||||
data: LegacyData,
|
||||
}
|
||||
|
||||
impl From<LegacyRecord> for Record<TraxRecord> {
|
||||
fn from(record: LegacyRecord) -> Self {
|
||||
match record.data {
|
||||
LegacyData::RepDuration(rd) => Record {
|
||||
id: record.id,
|
||||
data: TraxRecord::DurationWorkout(rd.into()),
|
||||
},
|
||||
LegacyData::SetRep(sr) => Record {
|
||||
id: record.id,
|
||||
data: TraxRecord::SetRep(sr.into()),
|
||||
},
|
||||
LegacyData::Steps(s) => Record {
|
||||
id: record.id,
|
||||
data: TraxRecord::Steps(s.into()),
|
||||
},
|
||||
LegacyData::TimeDistance(td) => Record {
|
||||
id: record.id,
|
||||
data: TraxRecord::TimeDistance(td.into()),
|
||||
},
|
||||
LegacyData::Weight(weight) => Record {
|
||||
id: record.id,
|
||||
data: TraxRecord::Weight(weight.into()),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut args = std::env::args();
|
||||
let _ = args.next().unwrap();
|
||||
let input_filename = args.next().unwrap();
|
||||
println!("input filename: {}", input_filename);
|
||||
// let output: Series<ft_core::TraxRecord> = Series::open_file("import.fitnesstrax").unwrap();
|
||||
|
||||
let input_file = File::open(input_filename).unwrap();
|
||||
let mut buf_reader = BufReader::new(input_file);
|
||||
// let mut contents = String::new();
|
||||
// buf_reader.read_(&mut contents).unwrap();
|
||||
|
||||
let mut count = 0;
|
||||
|
||||
loop {
|
||||
let mut line = String::new();
|
||||
let res = buf_reader.read_line(&mut line);
|
||||
match res {
|
||||
Err(err) => {
|
||||
panic!("failed after {} lines: {:?}", count, err);
|
||||
}
|
||||
Ok(0) => std::process::exit(0),
|
||||
Ok(_) => {
|
||||
let record = serde_json::from_str::<LegacyRecord>(&line).unwrap();
|
||||
let record: Record<TraxRecord> = record.into();
|
||||
println!("{}", serde_json::to_string(&record).unwrap());
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn read_a_legacy_set_rep_record() {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn read_a_legacy_steps_record() {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn read_a_legacy_time_distance_record() {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn read_a_legacy_weight_record() {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
mod legacy;
|
||||
|
||||
mod types;
|
||||
pub use types::{
|
||||
DurationWorkout, DurationWorkoutActivity, SetRep, SetRepActivity, Steps, TimeDistance,
|
||||
TimeDistanceActivity, TraxRecord, Weight, DURATION_WORKOUT_ACTIVITIES, SET_REP_ACTIVITIES,
|
||||
TIME_DISTANCE_ACTIVITIES,
|
||||
};
|
|
@ -1,261 +0,0 @@
|
|||
/*
|
||||
Copyright 2023-2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of FitnessTrax.
|
||||
|
||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use chrono::{DateTime, FixedOffset, NaiveDate};
|
||||
use dimensioned::si;
|
||||
use emseries::{Recordable, Timestamp};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub enum SetRepActivity {
|
||||
Pushups,
|
||||
Situps,
|
||||
}
|
||||
|
||||
pub const SET_REP_ACTIVITIES: [SetRepActivity; 2] =
|
||||
[SetRepActivity::Pushups, SetRepActivity::Situps];
|
||||
|
||||
/// SetRep represents workouts like pushups or situps, which involve doing a "set" of a number of
|
||||
/// actions, resting, and then doing another set.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SetRep {
|
||||
/// I assume that a set/rep workout is only done once in a day.
|
||||
pub date: NaiveDate,
|
||||
/// The activity involved
|
||||
pub activity: SetRepActivity,
|
||||
/// Each set entry represents the number of times that the action was performed in a set. So, a
|
||||
/// pushup workout that involved five sets would have five entries. Each entry would be x
|
||||
/// number of pushups. A viable workout would be something like [6, 6, 4, 4, 5].
|
||||
pub sets: Vec<u32>,
|
||||
pub comments: Option<String>,
|
||||
}
|
||||
|
||||
impl Recordable for SetRep {
|
||||
fn timestamp(&self) -> Timestamp {
|
||||
Timestamp::Date(self.date)
|
||||
}
|
||||
|
||||
fn tags(&self) -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
/// The number of steps one takes in a single day.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Steps {
|
||||
pub date: NaiveDate,
|
||||
pub count: u32,
|
||||
}
|
||||
|
||||
impl Recordable for Steps {
|
||||
fn timestamp(&self) -> Timestamp {
|
||||
Timestamp::Date(self.date)
|
||||
}
|
||||
|
||||
fn tags(&self) -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub enum TimeDistanceActivity {
|
||||
Biking,
|
||||
Running,
|
||||
Rowing,
|
||||
Swimming,
|
||||
Walking,
|
||||
}
|
||||
|
||||
pub const TIME_DISTANCE_ACTIVITIES: [TimeDistanceActivity; 5] = [
|
||||
TimeDistanceActivity::Biking,
|
||||
TimeDistanceActivity::Rowing,
|
||||
TimeDistanceActivity::Running,
|
||||
TimeDistanceActivity::Swimming,
|
||||
TimeDistanceActivity::Walking,
|
||||
];
|
||||
|
||||
/// TimeDistance represents workouts characterized by a duration and a distance travelled. These
|
||||
/// sorts of workouts can occur many times a day, depending on how one records things. I might
|
||||
/// record a single 30-km workout if I go on a long-distanec ride. Or I might record multiple 5km
|
||||
/// workouts if I am out running errands. Distance and Duration are both optional because different
|
||||
/// people have different priorities and may choose to measure different things.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct TimeDistance {
|
||||
/// The precise time (and the relevant timezone) of the workout. One of the edge cases that I
|
||||
/// account for is that a ride which occurred at 11pm on one day in one timezone would then
|
||||
/// count as 1am on the next day if the user moves two timezones to the east. While technically
|
||||
/// correct, for most users this would throw off many years of metrics in ways that can be very
|
||||
/// hard to understand. Keeping the fixed offset means that we can have the most precise time
|
||||
/// in the database, but we can still get a Naive Date from the DateTime, which will still read
|
||||
/// as the original day.
|
||||
pub datetime: DateTime<FixedOffset>,
|
||||
/// The activity
|
||||
pub activity: TimeDistanceActivity,
|
||||
/// The distance travelled. This is optional because such a workout makes sense even without
|
||||
/// the distance.
|
||||
pub distance: Option<si::Meter<f64>>,
|
||||
/// The duration of the workout, which is also optional. Some people may keep track of the
|
||||
/// amount of distance travelled without tracking the duration.
|
||||
pub duration: Option<si::Second<f64>>,
|
||||
pub comments: Option<String>,
|
||||
}
|
||||
|
||||
impl Recordable for TimeDistance {
|
||||
fn timestamp(&self) -> Timestamp {
|
||||
Timestamp::DateTime(self.datetime)
|
||||
}
|
||||
|
||||
fn tags(&self) -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
/// A singular daily weight measurement. Weight changes slowly enough that it seems unlikely to
|
||||
/// need to track more than a single weight in a day.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Weight {
|
||||
pub date: NaiveDate,
|
||||
pub weight: si::Kilogram<f64>,
|
||||
}
|
||||
|
||||
impl Recordable for Weight {
|
||||
fn timestamp(&self) -> Timestamp {
|
||||
Timestamp::Date(self.date)
|
||||
}
|
||||
|
||||
fn tags(&self) -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub enum DurationWorkoutActivity {
|
||||
MartialArts,
|
||||
Yoga,
|
||||
}
|
||||
|
||||
pub const DURATION_WORKOUT_ACTIVITIES: [DurationWorkoutActivity; 2] = [
|
||||
DurationWorkoutActivity::MartialArts,
|
||||
DurationWorkoutActivity::Yoga,
|
||||
];
|
||||
|
||||
/// Generic workouts for which only duration really matters. This is for things
|
||||
/// such as Martial Arts or Yoga, which are activities done for an amount of
|
||||
/// time, but with no other details.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct DurationWorkout {
|
||||
pub datetime: DateTime<FixedOffset>,
|
||||
pub activity: DurationWorkoutActivity,
|
||||
pub duration: Option<si::Second<f64>>,
|
||||
pub comments: Option<String>,
|
||||
}
|
||||
|
||||
impl Recordable for DurationWorkout {
|
||||
fn timestamp(&self) -> Timestamp {
|
||||
Timestamp::DateTime(self.datetime)
|
||||
}
|
||||
|
||||
fn tags(&self) -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
/// The unified data structure for all records that are part of the app.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub enum TraxRecord {
|
||||
DurationWorkout(DurationWorkout),
|
||||
SetRep(SetRep),
|
||||
Steps(Steps),
|
||||
TimeDistance(TimeDistance),
|
||||
Weight(Weight),
|
||||
}
|
||||
|
||||
impl TraxRecord {
|
||||
pub fn is_weight(&self) -> bool {
|
||||
matches!(self, TraxRecord::Weight(_))
|
||||
}
|
||||
|
||||
pub fn is_steps(&self) -> bool {
|
||||
matches!(self, TraxRecord::Steps(_))
|
||||
}
|
||||
|
||||
pub fn is_time_distance(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
TraxRecord::TimeDistance(TimeDistance {
|
||||
activity: TimeDistanceActivity::Biking,
|
||||
..
|
||||
}) | TraxRecord::TimeDistance(TimeDistance {
|
||||
activity: TimeDistanceActivity::Running,
|
||||
..
|
||||
}) | TraxRecord::TimeDistance(TimeDistance {
|
||||
activity: TimeDistanceActivity::Rowing,
|
||||
..
|
||||
}) | TraxRecord::TimeDistance(TimeDistance {
|
||||
activity: TimeDistanceActivity::Swimming,
|
||||
..
|
||||
}) | TraxRecord::TimeDistance(TimeDistance {
|
||||
activity: TimeDistanceActivity::Walking,
|
||||
..
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Recordable for TraxRecord {
|
||||
fn timestamp(&self) -> Timestamp {
|
||||
match self {
|
||||
TraxRecord::TimeDistance(rec) => Timestamp::DateTime(rec.datetime),
|
||||
TraxRecord::SetRep(rec) => rec.timestamp(),
|
||||
TraxRecord::Steps(rec) => rec.timestamp(),
|
||||
TraxRecord::Weight(rec) => rec.timestamp(),
|
||||
TraxRecord::DurationWorkout(rec) => rec.timestamp(),
|
||||
}
|
||||
}
|
||||
|
||||
fn tags(&self) -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TimeDistance> for TraxRecord {
|
||||
fn from(td: TimeDistance) -> Self {
|
||||
Self::TimeDistance(td)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use emseries::Series;
|
||||
|
||||
#[test]
|
||||
fn can_record_records() {
|
||||
let file = tempfile::NamedTempFile::new().expect("a temporary file");
|
||||
let path = file.into_temp_path();
|
||||
let mut series: Series<TraxRecord> = Series::open(&path).unwrap();
|
||||
|
||||
let record = TraxRecord::Steps(Steps {
|
||||
date: NaiveDate::from_ymd_opt(2023, 1, 1).unwrap(),
|
||||
count: 1000,
|
||||
});
|
||||
|
||||
let id = series.put(record.clone()).unwrap();
|
||||
|
||||
let record_ = series.get(&id).unwrap();
|
||||
assert_eq!(record_.data, record);
|
||||
}
|
||||
}
|
118
flake.lock
118
flake.lock
|
@ -1,6 +1,37 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1650374568,
|
||||
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
|
@ -20,20 +51,36 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1704732714,
|
||||
"narHash": "sha256-ABqK/HggMYA/jMUXgYyqVAcQ8QjeMyr1jcXfTpSHmps=",
|
||||
"lastModified": 1691421349,
|
||||
"narHash": "sha256-RRJyX0CUrs4uW4gMhd/X4rcDG8PTgaaCQM5rXEJOx6g=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "6723fa4e4f1a30d42a633bef5eb01caeb281adc3",
|
||||
"rev": "011567f35433879aae5024fc6ec53f2a0568a6c4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-23.11",
|
||||
"ref": "nixos-23.05",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1654275867,
|
||||
"narHash": "sha256-pt14ZE4jVPGvfB2NynGsl34pgXfOqum5YJNpDK4+b9E=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "7a20c208aacf4964c19186dcad51f89165dc7ed0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "release-22.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1681303793,
|
||||
"narHash": "sha256-JEdQHsYuCfRL2PICHlOiH/2ue3DwoxUX7DJ6zZxZXFk=",
|
||||
|
@ -48,13 +95,60 @@
|
|||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"pkgs-cargo2nix": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1682891040,
|
||||
"narHash": "sha256-hjajsi7lq24uYitUh4o04UJi1g0Qe6ruPL0s5DgPQMY=",
|
||||
"owner": "cargo2nix",
|
||||
"repo": "cargo2nix",
|
||||
"rev": "0167b39f198d72acdf009265634504fd6f5ace15",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cargo2nix",
|
||||
"repo": "cargo2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"pkgs-cargo2nix": "pkgs-cargo2nix",
|
||||
"typeshare": "typeshare",
|
||||
"unstable": "unstable"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"pkgs-cargo2nix",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"pkgs-cargo2nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1653878966,
|
||||
"narHash": "sha256-T51Gck/vrJZi1m+uTbhEFTRgZmE59sydVONadADv358=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "8526d618af012a923ca116be9603e818b502a8db",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
|
@ -72,15 +166,15 @@
|
|||
},
|
||||
"typeshare": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1698205128,
|
||||
"narHash": "sha256-jP+81TkldLtda8bzmsBWahETGsyFkoDOCT244YkA+S4=",
|
||||
"lastModified": 1690502632,
|
||||
"narHash": "sha256-+k81RrxfphDUD5kekWbQ4xuZIHBEAQf67uivaQ34Afs=",
|
||||
"owner": "1Password",
|
||||
"repo": "typeshare",
|
||||
"rev": "c3ee2ad8f27774c45db7af4f2ba746c4ae11de21",
|
||||
"rev": "9f74772af53759aee2f53e64478523e53083719e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -91,11 +185,11 @@
|
|||
},
|
||||
"unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1704722960,
|
||||
"narHash": "sha256-mKGJ3sPsT6//s+Knglai5YflJUF2DGj7Ai6Ynopz0kI=",
|
||||
"lastModified": 1690367991,
|
||||
"narHash": "sha256-2VwOn1l8y6+cu7zjNE8MgeGJNNz1eat1HwHrINeogFA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "317484b1ead87b9c1b8ac5261a8d2dd748a0492d",
|
||||
"rev": "c9cf0708f00fbe553319258e48ca89ff9a413703",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
62
flake.nix
62
flake.nix
|
@ -2,12 +2,13 @@
|
|||
description = "Lumenescent Dreams Tools";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-23.11";
|
||||
nixpkgs.url = "nixpkgs/nixos-23.05";
|
||||
unstable.url = "nixpkgs/nixos-unstable";
|
||||
pkgs-cargo2nix.url = "github:cargo2nix/cargo2nix";
|
||||
typeshare.url = "github:1Password/typeshare";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, unstable, typeshare, ... }:
|
||||
outputs = { self, nixpkgs, unstable, pkgs-cargo2nix, typeshare, ... }:
|
||||
let
|
||||
version = builtins.string 0 8 self.lastModifiedDate;
|
||||
supportedSystems = [ "x86_64-linux" ];
|
||||
|
@ -17,6 +18,7 @@
|
|||
let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
pkgs-unstable = import unstable { system = "x86_64-linux"; };
|
||||
cargo2nix = pkgs-cargo2nix.packages."x86_64-linux";
|
||||
in
|
||||
pkgs.mkShell {
|
||||
name = "ld-tools-devshell";
|
||||
|
@ -24,6 +26,8 @@
|
|||
pkgs.cargo-nextest
|
||||
pkgs.clang
|
||||
pkgs.crate2nix
|
||||
pkgs.entr
|
||||
pkgs.glade
|
||||
pkgs.glib
|
||||
pkgs.gst_all_1.gst-plugins-bad
|
||||
pkgs.gst_all_1.gst-plugins-base
|
||||
|
@ -32,72 +36,18 @@
|
|||
pkgs.gst_all_1.gstreamer
|
||||
pkgs.gtk4
|
||||
pkgs.libadwaita
|
||||
pkgs.librsvg
|
||||
pkgs.nodejs
|
||||
pkgs.openssl
|
||||
pkgs.pipewire
|
||||
pkgs.pkg-config
|
||||
pkgs.rustup
|
||||
pkgs.sqlite
|
||||
pkgs.cargo-nextest
|
||||
pkgs.wasm-pack
|
||||
pkgs.sqlx-cli
|
||||
pkgs.udev
|
||||
pkgs.wasm-pack
|
||||
typeshare.packages."x86_64-linux".default
|
||||
];
|
||||
LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
ENV = "dev";
|
||||
};
|
||||
|
||||
packages."x86_64-linux" =
|
||||
let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
|
||||
gtkNativeInputs = [
|
||||
pkgs.pkg-config
|
||||
pkgs.gtk4
|
||||
pkgs.libadwaita
|
||||
pkgs.wrapGAppsHook4
|
||||
];
|
||||
|
||||
cargoOverrides = pkgs: pkgs.buildRustCrate.override {
|
||||
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
|
||||
gobject-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
gio-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
gdk-pixbuf-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
libadwaita-sys = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
|
||||
dashboard = attrs: { nativeBuildInputs = gtkNativeInputs; };
|
||||
fitnesstrax = import ./fitnesstrax/app/override.nix { gtkNativeInputs = gtkNativeInputs; };
|
||||
otg-gtk = import ./otg/gtk/override.nix { gtkNativeInputs = gtkNativeInputs; };
|
||||
};
|
||||
};
|
||||
|
||||
cargo_nix = pkgs.callPackage ./Cargo.nix {
|
||||
nixpkgs = nixpkgs;
|
||||
buildRustCrateForPkgs = cargoOverrides;
|
||||
};
|
||||
|
||||
in rec {
|
||||
cyberpunk-splash = cargo_nix.workspaceMembers.cyberpunk-splash.build;
|
||||
dashboard = cargo_nix.workspaceMembers.dashboard.build;
|
||||
file-service = cargo_nix.workspaceMembers.file-service.build;
|
||||
fitnesstrax = cargo_nix.workspaceMembers.fitnesstrax.build;
|
||||
otg-gtk = cargo_nix.workspaceMembers.otg-gtk.build;
|
||||
|
||||
all = pkgs.symlinkJoin {
|
||||
name = "all";
|
||||
paths = [
|
||||
cyberpunk-splash
|
||||
dashboard
|
||||
file-service
|
||||
fitnesstrax
|
||||
otg-gtk
|
||||
];
|
||||
};
|
||||
|
||||
default = all;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
[package]
|
||||
name = "icon-test"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
adw = { version = "0.5", package = "libadwaita", features = [ "v1_4" ] }
|
||||
gio = { version = "0.18" }
|
||||
glib = { version = "0.18" }
|
||||
gtk = { version = "0.7", package = "gtk4", features = [ "v4_10" ] }
|
|
@ -1,38 +0,0 @@
|
|||
use adw::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let adw_app = adw::Application::builder().build();
|
||||
|
||||
adw_app.connect_activate(move |adw_app| {
|
||||
let window = gtk::ApplicationWindow::builder()
|
||||
.application(adw_app)
|
||||
.width_request(400)
|
||||
.height_request(400)
|
||||
.build();
|
||||
|
||||
let sunrise_button = gtk::Button::builder()
|
||||
.icon_name("daytime-sunrise-symbolic")
|
||||
.width_request(64)
|
||||
.height_request(64)
|
||||
.build();
|
||||
|
||||
let walking_button = gtk::Button::builder()
|
||||
.icon_name("walking2-symbolic")
|
||||
.width_request(64)
|
||||
.height_request(64)
|
||||
.build();
|
||||
|
||||
let layout = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.valign(gtk::Align::Start)
|
||||
.build();
|
||||
layout.append(&sunrise_button);
|
||||
layout.append(&walking_button);
|
||||
|
||||
window.set_child(Some(&layout));
|
||||
window.present();
|
||||
});
|
||||
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
ApplicationExtManual::run_with_args(&adw_app, &args);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
SOURCES = $(shell find ../core -name "*.rs")
|
||||
dist/index.ts: $(SOURCES)
|
||||
mkdir -p dist
|
||||
typeshare ../core --lang=typescript --output-file=dist/index.ts
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "core-types",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"types": "dist/index.ts",
|
||||
"main": "dist/index.ts",
|
||||
"scripts": {
|
||||
"build": "make",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Savanni D'Gerinel <savanni@luminescent-dreams.com>",
|
||||
"license": "GPL-3.0-or-later"
|
||||
}
|
|
@ -0,0 +1,591 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[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 = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
||||
|
||||
[[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.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"time",
|
||||
"wasm-bindgen",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "codespan-reporting"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
|
||||
dependencies = [
|
||||
"termcolor",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cool_asserts"
|
||||
version = "2.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee9f254e53f61e2688d3677fa2cbe4e9b950afd56f48819c98817417cf6b28ec"
|
||||
dependencies = [
|
||||
"indent_write",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
|
||||
|
||||
[[package]]
|
||||
name = "cxx"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cxxbridge-flags",
|
||||
"cxxbridge-macro",
|
||||
"link-cplusplus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxx-build"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"codespan-reporting",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"scratch",
|
||||
"syn 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-flags"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb"
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-macro"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "grid"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0634107a3a005070dd73e27e74ecb691a94e9e5ba7829f434db7fbf73a6b5c47"
|
||||
dependencies = [
|
||||
"no-std-compat",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"windows",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
|
||||
dependencies = [
|
||||
"cxx",
|
||||
"cxx-build",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indent_write"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0cfe9645a18782869361d9c8732246be7b410ad4e919d3609ebabdac00ba12c3"
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.61"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kifu-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"cool_asserts",
|
||||
"grid",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sgf",
|
||||
"thiserror",
|
||||
"typeshare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
|
||||
|
||||
[[package]]
|
||||
name = "link-cplusplus"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "no-std-compat"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"
|
||||
|
||||
[[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 = "num-integer"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.52"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
|
||||
|
||||
[[package]]
|
||||
name = "scratch"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.162"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.162"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.96"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sgf"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"nom",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"typeshare",
|
||||
]
|
||||
|
||||
[[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.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typeshare"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f44d1a2f454cb35fbe05b218c410792697e76bd868f48d3a418f2cd1a7d527d6"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"typeshare-annotation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typeshare-annotation"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc670d0e358428857cc3b4bf504c691e572fccaec9542ff09212d3f13d74b7a9"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
|
@ -1,12 +1,11 @@
|
|||
[package]
|
||||
name = "otg-core"
|
||||
name = "kifu-core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
async-std = { version = "1" }
|
||||
chrono = { version = "0.4" }
|
||||
config = { path = "../../config" }
|
||||
config-derive = { path = "../../config-derive" }
|
||||
|
@ -14,9 +13,8 @@ sgf = { path = "../../sgf" }
|
|||
grid = { version = "0.9" }
|
||||
serde_json = { version = "1" }
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
nary_tree = { version = "0.4" }
|
||||
thiserror = { version = "1" }
|
||||
uuid = { version = "0.8", features = ["v4", "serde"] }
|
||||
typeshare = { version = "1" }
|
||||
|
||||
[dev-dependencies]
|
||||
cool_asserts = { version = "2" }
|
|
@ -0,0 +1,153 @@
|
|||
use crate::{
|
||||
types::{AppState, Config, ConfigOption, DatabasePath, GameState, Player, Rank},
|
||||
ui::{configuration, home, playing_field, ConfigurationView, HomeView, PlayingFieldView},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
use typeshare::typeshare;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
#[serde(tag = "type", content = "content")]
|
||||
pub enum CoreRequest {
|
||||
ChangeSetting(ChangeSettingRequest),
|
||||
CreateGame(CreateGameRequest),
|
||||
Home,
|
||||
OpenConfiguration,
|
||||
PlayingField,
|
||||
PlayStone(PlayStoneRequest),
|
||||
StartGame,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
#[serde(tag = "type", content = "content")]
|
||||
pub enum ChangeSettingRequest {
|
||||
LibraryPath(String),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct PlayStoneRequest {
|
||||
pub column: u8,
|
||||
pub row: u8,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct CreateGameRequest {
|
||||
pub black_player: PlayerInfoRequest,
|
||||
pub white_player: PlayerInfoRequest,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub enum PlayerInfoRequest {
|
||||
Hotseat(HotseatPlayerRequest),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct HotseatPlayerRequest {
|
||||
pub name: String,
|
||||
pub rank: Option<String>,
|
||||
}
|
||||
|
||||
impl From<HotseatPlayerRequest> for Player {
|
||||
fn from(p: HotseatPlayerRequest) -> Self {
|
||||
Self {
|
||||
name: p.name,
|
||||
rank: p.rank.and_then(|r| Rank::try_from(r.as_ref()).ok()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
#[serde(tag = "type", content = "content")]
|
||||
pub enum CoreResponse {
|
||||
ConfigurationView(ConfigurationView),
|
||||
HomeView(HomeView),
|
||||
PlayingFieldView(PlayingFieldView),
|
||||
UpdatedConfigurationView(ConfigurationView),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CoreApp {
|
||||
config: Arc<RwLock<Config>>,
|
||||
state: Arc<RwLock<AppState>>,
|
||||
}
|
||||
|
||||
impl CoreApp {
|
||||
pub fn new(config_path: std::path::PathBuf) -> Self {
|
||||
let config = Config::from_path(config_path).expect("configuration to open");
|
||||
|
||||
let db_path: DatabasePath = config.get().unwrap();
|
||||
let state = Arc::new(RwLock::new(AppState::new(db_path)));
|
||||
|
||||
Self {
|
||||
config: Arc::new(RwLock::new(config)),
|
||||
state,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn dispatch(&self, request: CoreRequest) -> CoreResponse {
|
||||
match request {
|
||||
CoreRequest::ChangeSetting(request) => match request {
|
||||
ChangeSettingRequest::LibraryPath(path) => {
|
||||
let mut config = self.config.write().unwrap();
|
||||
config.set(ConfigOption::DatabasePath(DatabasePath(PathBuf::from(
|
||||
path,
|
||||
))));
|
||||
CoreResponse::UpdatedConfigurationView(configuration(&config))
|
||||
}
|
||||
},
|
||||
CoreRequest::CreateGame(create_request) => {
|
||||
let mut app_state = self.state.write().unwrap();
|
||||
let white_player = {
|
||||
match create_request.white_player {
|
||||
PlayerInfoRequest::Hotseat(request) => Player::from(request),
|
||||
}
|
||||
};
|
||||
let black_player = {
|
||||
match create_request.black_player {
|
||||
PlayerInfoRequest::Hotseat(request) => Player::from(request),
|
||||
}
|
||||
};
|
||||
app_state.game = Some(GameState {
|
||||
white_player,
|
||||
black_player,
|
||||
..GameState::default()
|
||||
});
|
||||
let game_state = app_state.game.as_ref().unwrap();
|
||||
CoreResponse::PlayingFieldView(playing_field(game_state))
|
||||
}
|
||||
CoreRequest::Home => {
|
||||
CoreResponse::HomeView(home(self.state.read().unwrap().database.all_games()))
|
||||
}
|
||||
CoreRequest::OpenConfiguration => {
|
||||
CoreResponse::ConfigurationView(configuration(&self.config.read().unwrap()))
|
||||
}
|
||||
CoreRequest::PlayingField => {
|
||||
let app_state = self.state.read().unwrap();
|
||||
let game = app_state.game.as_ref().unwrap();
|
||||
CoreResponse::PlayingFieldView(playing_field(game))
|
||||
}
|
||||
CoreRequest::PlayStone(request) => {
|
||||
let mut app_state = self.state.write().unwrap();
|
||||
app_state.place_stone(request);
|
||||
|
||||
let game = app_state.game.as_ref().unwrap();
|
||||
CoreResponse::PlayingFieldView(playing_field(game))
|
||||
}
|
||||
CoreRequest::StartGame => {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run(&self) {}
|
||||
}
|
|
@ -1,39 +1,13 @@
|
|||
/*
|
||||
Copyright 2024, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of On the Grid.
|
||||
|
||||
On the Grid is free software: you can redistribute it and/or modify it under the terms of
|
||||
the GNU General Public License as published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
On the Grid is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with On the Grid. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// TBQH, I don't recall what state this object is in, but I do know that I might have some troubles
|
||||
// integrating it with a game record. Some of the time here is going to be me reading (and
|
||||
// documenting) my code from almost a year ago.
|
||||
//
|
||||
use crate::{BoardError, Color, Size};
|
||||
use sgf::{GameNode, MoveNode};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Goban {
|
||||
/// The size of the board. Usually this is symetrical, but I have actually played a 5x25 game.
|
||||
/// These are fun for novelty, but don't lend much to understanding the game.
|
||||
pub struct Board {
|
||||
pub size: Size,
|
||||
|
||||
/// I found that it was easiest to track groups of stones than to track individual stones on the
|
||||
/// board. So, I just keep track of all of the groups.
|
||||
pub groups: Vec<Group>,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Goban {
|
||||
impl std::fmt::Display for Board {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||
write!(f, " ")?;
|
||||
// for c in 'A'..'U' {
|
||||
|
@ -57,7 +31,7 @@ impl std::fmt::Display for Goban {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Goban {
|
||||
impl PartialEq for Board {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
if self.size != other.size {
|
||||
return false;
|
||||
|
@ -77,7 +51,7 @@ impl PartialEq for Goban {
|
|||
}
|
||||
}
|
||||
|
||||
impl Goban {
|
||||
impl Board {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
size: Size {
|
||||
|
@ -88,18 +62,10 @@ impl Goban {
|
|||
}
|
||||
}
|
||||
|
||||
/// Generate a board state from an iterator of coordinates and the color of any stone present on
|
||||
/// the board. As we walk through the iterator, we play each stone as though it were being
|
||||
/// played in a game.
|
||||
///
|
||||
/// This would not work at all if we wanted to set up an impossible board state, given that
|
||||
/// groups of stones get automatically removed once surrounded.
|
||||
pub fn from_coordinates(
|
||||
coordinates: impl IntoIterator<Item = (Coordinate, Color)>,
|
||||
mut coordinates: impl Iterator<Item = (Coordinate, Color)>,
|
||||
) -> Result<Self, BoardError> {
|
||||
coordinates
|
||||
.into_iter()
|
||||
.try_fold(Self::new(), |board, (coordinate, color)| {
|
||||
coordinates.try_fold(Self::new(), |board, (coordinate, color)| {
|
||||
board.place_stone(coordinate, color)
|
||||
})
|
||||
}
|
||||
|
@ -111,78 +77,38 @@ pub struct Coordinate {
|
|||
pub row: u8,
|
||||
}
|
||||
|
||||
impl Goban {
|
||||
/// place_stone is the most fundamental function of this object. This is as though a player put
|
||||
/// a stone on the board and evaluated the consequences.
|
||||
///
|
||||
/// This function does not enforce turn order.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use otg_core::{Color, Size, Coordinate, Goban};
|
||||
/// use cool_asserts::assert_matches;
|
||||
///
|
||||
/// let goban = Goban::new();
|
||||
/// assert_eq!(goban.size, Size{ width: 19, height: 19 });
|
||||
/// let move_result = goban.place_stone(Coordinate{ column: 4, row: 4 }, Color::Black);
|
||||
/// assert_matches!(move_result, Goban);
|
||||
/// ```
|
||||
impl Board {
|
||||
pub fn place_stone(mut self, coordinate: Coordinate, color: Color) -> Result<Self, BoardError> {
|
||||
// Bail out immediately if there is already a stone at this location.
|
||||
if self.stone(&coordinate).is_some() {
|
||||
return Err(BoardError::InvalidPosition);
|
||||
}
|
||||
|
||||
// Find all friendly groups adjacent to this stone. First, calculate the adjacent
|
||||
// coordinates. Then see if there is any group which contains that coordinate. If not, this
|
||||
// stone forms a new group of its own.
|
||||
//
|
||||
// A little subtle here is that this stone will be added to *every* adjoining friendly
|
||||
// group. This normally means only that a group gets bigger, but it could also cause two
|
||||
// groups to share a stone, which means they're now a single group.
|
||||
let mut friendly_group = self
|
||||
.adjacencies(&coordinate)
|
||||
.into_iter()
|
||||
.filter(|c| self.stone(c) == Some(color))
|
||||
.filter_map(|c| self.group(&c).map(|g| g.coordinates.clone()))
|
||||
// In fact, this last step actually connects the coordinates of those friendly groups
|
||||
// into a single large group.
|
||||
.fold(HashSet::new(), |acc, set| {
|
||||
acc.union(&set).cloned().collect()
|
||||
});
|
||||
|
||||
// This is a little misnamed. This is a HashSet, not a full Group.
|
||||
friendly_group.insert(coordinate);
|
||||
|
||||
// Remove all groups which contain the stones overlapping with this friendly group.
|
||||
self.groups
|
||||
.retain(|g| g.coordinates.is_disjoint(&friendly_group));
|
||||
|
||||
// Generate a new friendly group given the coordinates.
|
||||
let friendly_group = Group {
|
||||
color,
|
||||
coordinates: friendly_group,
|
||||
};
|
||||
// Now add the group back to the board.
|
||||
self.groups.push(friendly_group.clone());
|
||||
|
||||
// Now, find all groups adjacent to this one. Those are the only groups that this move is
|
||||
// going to impact. Calculate their liberties.
|
||||
let adjacent_groups = self.adjacent_groups(&friendly_group);
|
||||
for group in adjacent_groups {
|
||||
// Any group that has been reduced to 0 liberties should now be removed from the board.
|
||||
//
|
||||
// TODO: capture rules: we're not counting captured stones yet. Okay with some scoring
|
||||
// methods, but not all.
|
||||
if self.liberties(&group) == 0 {
|
||||
self.remove_group(&group);
|
||||
}
|
||||
}
|
||||
|
||||
// Now, recalculate the liberties of this friendly group. If this group has been reduced to
|
||||
// zero liberties, after all captures have been accounted for, the move is an illegal
|
||||
// self-capture. Drop all of the work we've done and return an error.
|
||||
if self.liberties(&friendly_group) == 0 {
|
||||
return Err(BoardError::SelfCapture);
|
||||
}
|
||||
|
@ -190,53 +116,6 @@ impl Goban {
|
|||
Ok(self)
|
||||
}
|
||||
|
||||
/// Apply a list of moves to the board and return the final board. The moves will be played as
|
||||
/// though they are live moves played normally, but this function is for generating a board
|
||||
/// state from a game record. All of the moves will be played in the order given. This does not
|
||||
/// allow for the branching which is natural in a game review.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use otg_core::{Color, Size, Coordinate, Goban};
|
||||
/// use cool_asserts::assert_matches;
|
||||
/// use sgf::{GameNode, MoveNode, Move};
|
||||
///
|
||||
/// let goban = Goban::new();
|
||||
/// let moves = vec![
|
||||
/// GameNode::MoveNode(MoveNode::new(sgf::Color::Black, Move::Move("dd".to_owned()))),
|
||||
/// GameNode::MoveNode(MoveNode::new(sgf::Color::White, Move::Move("pp".to_owned()))),
|
||||
/// GameNode::MoveNode(MoveNode::new(sgf::Color::Black, Move::Move("dp".to_owned()))),
|
||||
/// ];
|
||||
/// let moves_: Vec<&GameNode> = moves.iter().collect();
|
||||
/// let goban = goban.apply_moves(moves_).expect("the test to have valid moves");
|
||||
///
|
||||
/// assert_eq!(goban.stone(&Coordinate{ row: 3, column: 3 }), Some(Color::Black));
|
||||
/// assert_eq!(goban.stone(&Coordinate{ row: 15, column: 15 }), Some(Color::White));
|
||||
/// assert_eq!(goban.stone(&Coordinate{ row: 15, column: 3 }), Some(Color::Black));
|
||||
/// ```
|
||||
pub fn apply_moves<'a>(
|
||||
self,
|
||||
moves: impl IntoIterator<Item = &'a GameNode>,
|
||||
) -> Result<Goban, BoardError> {
|
||||
let mut s = self;
|
||||
for m in moves.into_iter() {
|
||||
match m {
|
||||
GameNode::MoveNode(node) => s = s.apply_move_node(node)?,
|
||||
GameNode::SetupNode(_n) => unimplemented!("setup nodes aren't processed yet"),
|
||||
};
|
||||
}
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
fn apply_move_node(self, m: &MoveNode) -> Result<Goban, BoardError> {
|
||||
if let Some((row, column)) = m.mv.coordinate() {
|
||||
self.place_stone(Coordinate { row, column }, Color::from(&m.color))
|
||||
} else {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stone(&self, coordinate: &Coordinate) -> Option<Color> {
|
||||
self.groups
|
||||
.iter()
|
||||
|
@ -244,17 +123,17 @@ impl Goban {
|
|||
.map(|g| g.color)
|
||||
}
|
||||
|
||||
fn group(&self, coordinate: &Coordinate) -> Option<&Group> {
|
||||
pub fn group(&self, coordinate: &Coordinate) -> Option<&Group> {
|
||||
self.groups
|
||||
.iter()
|
||||
.find(|g| g.coordinates.contains(coordinate))
|
||||
}
|
||||
|
||||
fn remove_group(&mut self, group: &Group) {
|
||||
pub fn remove_group(&mut self, group: &Group) {
|
||||
self.groups.retain(|g| g != group);
|
||||
}
|
||||
|
||||
fn adjacent_groups(&self, group: &Group) -> Vec<Group> {
|
||||
pub fn adjacent_groups(&self, group: &Group) -> Vec<Group> {
|
||||
let adjacent_spaces = self.group_halo(group).into_iter();
|
||||
let mut grps: Vec<Group> = Vec::new();
|
||||
|
||||
|
@ -274,7 +153,7 @@ impl Goban {
|
|||
grps
|
||||
}
|
||||
|
||||
fn group_halo(&self, group: &Group) -> HashSet<Coordinate> {
|
||||
pub fn group_halo(&self, group: &Group) -> HashSet<Coordinate> {
|
||||
group
|
||||
.coordinates
|
||||
.iter()
|
||||
|
@ -282,14 +161,14 @@ impl Goban {
|
|||
.collect::<HashSet<Coordinate>>()
|
||||
}
|
||||
|
||||
fn liberties(&self, group: &Group) -> usize {
|
||||
pub fn liberties(&self, group: &Group) -> usize {
|
||||
self.group_halo(group)
|
||||
.into_iter()
|
||||
.filter(|c| self.stone(c).is_none())
|
||||
.count()
|
||||
}
|
||||
|
||||
fn adjacencies(&self, coordinate: &Coordinate) -> Vec<Coordinate> {
|
||||
pub fn adjacencies(&self, coordinate: &Coordinate) -> Vec<Coordinate> {
|
||||
let mut v = Vec::new();
|
||||
if coordinate.column > 0 {
|
||||
v.push(Coordinate {
|
||||
|
@ -314,7 +193,7 @@ impl Goban {
|
|||
v.into_iter().filter(|c| self.within_board(c)).collect()
|
||||
}
|
||||
|
||||
fn within_board(&self, coordinate: &Coordinate) -> bool {
|
||||
pub fn within_board(&self, coordinate: &Coordinate) -> bool {
|
||||
coordinate.column < self.size.width && coordinate.row < self.size.height
|
||||
}
|
||||
}
|
||||
|
@ -345,8 +224,8 @@ mod test {
|
|||
* A stone placed in a suicidal position is legal if it captures other stones first.
|
||||
*/
|
||||
|
||||
fn with_example_board(test: impl FnOnce(Goban)) {
|
||||
let board = Goban::from_coordinates(
|
||||
fn with_example_board(test: impl FnOnce(Board)) {
|
||||
let board = Board::from_coordinates(
|
||||
vec![
|
||||
(Coordinate { column: 3, row: 3 }, Color::White),
|
||||
(Coordinate { column: 3, row: 4 }, Color::White),
|
||||
|
@ -405,7 +284,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn it_gets_adjacencies_for_coordinate() {
|
||||
let board = Goban::new();
|
||||
let board = Board::new();
|
||||
for column in 0..19 {
|
||||
for row in 0..19 {
|
||||
for coordinate in board.adjacencies(&Coordinate { column, row }) {
|
||||
|
@ -423,7 +302,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn it_counts_individual_liberties() {
|
||||
let board = Goban::from_coordinates(
|
||||
let board = Board::from_coordinates(
|
||||
vec![
|
||||
(Coordinate { column: 3, row: 3 }, Color::White),
|
||||
(Coordinate { column: 0, row: 3 }, Color::White),
|
||||
|
@ -478,7 +357,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn stones_share_liberties() {
|
||||
with_example_board(|board: Goban| {
|
||||
with_example_board(|board: Board| {
|
||||
let test_cases = vec![
|
||||
(
|
||||
board.clone(),
|
||||
|
@ -611,6 +490,7 @@ mod test {
|
|||
),
|
||||
];
|
||||
|
||||
println!("{}", board);
|
||||
for (board, coordinate, group, liberties) in test_cases {
|
||||
assert_eq!(board.group(&coordinate), group.as_ref());
|
||||
assert_eq!(
|
||||
|
@ -687,11 +567,11 @@ mod test {
|
|||
#[test]
|
||||
fn validate_group_comparisons() {
|
||||
{
|
||||
let b1 = Goban::from_coordinates(
|
||||
let b1 = Board::from_coordinates(
|
||||
vec![(Coordinate { column: 7, row: 9 }, Color::White)].into_iter(),
|
||||
)
|
||||
.unwrap();
|
||||
let b2 = Goban::from_coordinates(
|
||||
let b2 = Board::from_coordinates(
|
||||
vec![(Coordinate { column: 7, row: 9 }, Color::White)].into_iter(),
|
||||
)
|
||||
.unwrap();
|
||||
|
@ -700,7 +580,7 @@ mod test {
|
|||
}
|
||||
|
||||
{
|
||||
let b1 = Goban::from_coordinates(
|
||||
let b1 = Board::from_coordinates(
|
||||
vec![
|
||||
(Coordinate { column: 7, row: 9 }, Color::White),
|
||||
(Coordinate { column: 8, row: 10 }, Color::White),
|
||||
|
@ -708,7 +588,7 @@ mod test {
|
|||
.into_iter(),
|
||||
)
|
||||
.unwrap();
|
||||
let b2 = Goban::from_coordinates(
|
||||
let b2 = Board::from_coordinates(
|
||||
vec![
|
||||
(Coordinate { column: 8, row: 10 }, Color::White),
|
||||
(Coordinate { column: 7, row: 9 }, Color::White),
|
||||
|
@ -723,7 +603,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn two_boards_can_be_compared() {
|
||||
let board = Goban::from_coordinates(
|
||||
let board = Board::from_coordinates(
|
||||
vec![
|
||||
(Coordinate { column: 7, row: 9 }, Color::White),
|
||||
(Coordinate { column: 8, row: 8 }, Color::White),
|
|
@ -1,6 +1,6 @@
|
|||
use std::{io::Read, path::PathBuf};
|
||||
|
||||
use sgf::{parse_sgf, GameRecord};
|
||||
use sgf::{parse_sgf, Game};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
@ -21,12 +21,12 @@ impl From<std::io::Error> for Error {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct Database {
|
||||
games: Vec<GameRecord>,
|
||||
games: Vec<Game>,
|
||||
}
|
||||
|
||||
impl Database {
|
||||
pub fn open_path(path: PathBuf) -> Result<Database, Error> {
|
||||
let mut games: Vec<GameRecord> = Vec::new();
|
||||
let mut games: Vec<Game> = Vec::new();
|
||||
|
||||
let extension = PathBuf::from("sgf").into_os_string();
|
||||
|
||||
|
@ -42,9 +42,9 @@ impl Database {
|
|||
.unwrap();
|
||||
match parse_sgf(&buffer) {
|
||||
Ok(sgfs) => {
|
||||
let mut sgfs =
|
||||
sgfs.into_iter().flatten().collect::<Vec<sgf::GameRecord>>();
|
||||
games.append(&mut sgfs);
|
||||
for sgf in sgfs {
|
||||
games.push(sgf);
|
||||
}
|
||||
}
|
||||
Err(err) => println!("Error parsing {:?}: {:?}", entry.path(), err),
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ impl Database {
|
|||
Ok(Database { games })
|
||||
}
|
||||
|
||||
pub fn all_games(&self) -> impl Iterator<Item = &GameRecord> {
|
||||
pub fn all_games(&self) -> impl Iterator<Item = &Game> {
|
||||
self.games.iter()
|
||||
}
|
||||
}
|
||||
|
@ -82,11 +82,11 @@ mod test {
|
|||
Database::open_path(PathBuf::from("fixtures/five_games/")).expect("database to open");
|
||||
assert_eq!(db.all_games().count(), 5);
|
||||
|
||||
assert_matches!(db.all_games().find(|g| g.black_player.name == Some("Steve".to_owned())),
|
||||
assert_matches!(db.all_games().find(|g| g.info.black_player == Some("Steve".to_owned())),
|
||||
Some(game) => {
|
||||
assert_eq!(game.black_player.name, Some("Steve".to_owned()));
|
||||
assert_eq!(game.white_player.name, Some("Savanni".to_owned()));
|
||||
assert_eq!(game.dates, vec![Date::Date(chrono::NaiveDate::from_ymd_opt(2023, 4, 19).unwrap())]);
|
||||
assert_eq!(game.info.black_player, Some("Steve".to_owned()));
|
||||
assert_eq!(game.info.white_player, Some("Savanni".to_owned()));
|
||||
assert_eq!(game.info.date, vec![Date::Date(chrono::NaiveDate::from_ymd_opt(2023, 4, 19).unwrap())]);
|
||||
// assert_eq!(game.info.komi, Some(6.5));
|
||||
}
|
||||
);
|
|
@ -0,0 +1,17 @@
|
|||
extern crate config_derive;
|
||||
|
||||
mod api;
|
||||
pub use api::{
|
||||
ChangeSettingRequest, CoreApp, CoreRequest, CoreResponse, CreateGameRequest,
|
||||
HotseatPlayerRequest, PlayerInfoRequest,
|
||||
};
|
||||
|
||||
mod board;
|
||||
pub use board::*;
|
||||
|
||||
mod database;
|
||||
|
||||
mod types;
|
||||
pub use types::{BoardError, Color, Rank, Size};
|
||||
|
||||
pub mod ui;
|
|
@ -0,0 +1,238 @@
|
|||
use crate::{
|
||||
api::PlayStoneRequest,
|
||||
board::{Board, Coordinate},
|
||||
database::Database,
|
||||
};
|
||||
use config::define_config;
|
||||
use config_derive::ConfigOption;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{path::PathBuf, time::Duration};
|
||||
use thiserror::Error;
|
||||
use typeshare::typeshare;
|
||||
|
||||
define_config! {
|
||||
DatabasePath(DatabasePath),
|
||||
Me(Me),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ConfigOption)]
|
||||
pub struct DatabasePath(pub PathBuf);
|
||||
|
||||
impl std::ops::Deref for DatabasePath {
|
||||
type Target = PathBuf;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ConfigOption)]
|
||||
pub struct Me(Player);
|
||||
|
||||
impl std::ops::Deref for Me {
|
||||
type Target = Player;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Error)]
|
||||
pub enum BoardError {
|
||||
#[error("Position is invalid")]
|
||||
InvalidPosition,
|
||||
#[error("Self-capture is forbidden")]
|
||||
SelfCapture,
|
||||
#[error("Ko")]
|
||||
Ko,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Hash, Eq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub enum Color {
|
||||
Black,
|
||||
White,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct Size {
|
||||
pub width: u8,
|
||||
pub height: u8,
|
||||
}
|
||||
|
||||
impl Default for Size {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
width: 19,
|
||||
height: 19,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AppState {
|
||||
pub game: Option<GameState>,
|
||||
pub database: Database,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
pub fn new(database_path: DatabasePath) -> Self {
|
||||
Self {
|
||||
game: Some(GameState::default()),
|
||||
database: Database::open_path(database_path.to_path_buf()).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn place_stone(&mut self, req: PlayStoneRequest) {
|
||||
if let Some(ref mut game) = self.game {
|
||||
let _ = game.place_stone(Coordinate {
|
||||
column: req.column,
|
||||
row: req.row,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub enum Rank {
|
||||
Kyu(u8),
|
||||
Dan(u8),
|
||||
Pro(u8),
|
||||
}
|
||||
|
||||
impl TryFrom<&str> for Rank {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(_: &str) -> Result<Rank, Self::Error> {
|
||||
Ok(Rank::Kyu(15))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Rank> for String {
|
||||
fn from(r: Rank) -> String {
|
||||
match r {
|
||||
Rank::Kyu(v) => format!("{} kyu", v),
|
||||
Rank::Dan(v) => format!("{} dan", v),
|
||||
Rank::Pro(v) => format!("{} pro", v),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Player {
|
||||
pub name: String,
|
||||
pub rank: Option<Rank>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct GameState {
|
||||
pub board: Board,
|
||||
pub past_positions: Vec<Board>,
|
||||
|
||||
pub conversation: Vec<String>,
|
||||
pub current_player: Color,
|
||||
|
||||
pub white_player: Player,
|
||||
pub black_player: Player,
|
||||
|
||||
pub white_clock: Duration,
|
||||
pub black_clock: Duration,
|
||||
}
|
||||
|
||||
impl Default for GameState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
board: Board::new(),
|
||||
past_positions: vec![],
|
||||
conversation: vec![],
|
||||
current_player: Color::Black,
|
||||
white_player: Player {
|
||||
name: "".to_owned(),
|
||||
rank: None,
|
||||
},
|
||||
black_player: Player {
|
||||
name: "".to_owned(),
|
||||
rank: None,
|
||||
},
|
||||
white_clock: Duration::from_secs(600),
|
||||
black_clock: Duration::from_secs(600),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GameState {
|
||||
fn place_stone(&mut self, coordinate: Coordinate) -> Result<(), BoardError> {
|
||||
let board = self.board.clone();
|
||||
let new_board = board.place_stone(coordinate, self.current_player)?;
|
||||
|
||||
if self.past_positions.contains(&new_board) {
|
||||
return Err(BoardError::Ko);
|
||||
}
|
||||
|
||||
self.past_positions.push(self.board.clone());
|
||||
self.board = new_board;
|
||||
match self.current_player {
|
||||
Color::White => self.current_player = Color::Black,
|
||||
Color::Black => self.current_player = Color::White,
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn current_player_changes_after_move() {
|
||||
let mut state = GameState::default();
|
||||
assert_eq!(state.current_player, Color::Black);
|
||||
state.place_stone(Coordinate { column: 9, row: 9 }).unwrap();
|
||||
assert_eq!(state.current_player, Color::White);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn current_player_remains_the_same_after_self_capture() {
|
||||
let mut state = GameState::default();
|
||||
state.board = Board::from_coordinates(
|
||||
vec![
|
||||
(Coordinate { column: 17, row: 0 }, Color::White),
|
||||
(Coordinate { column: 17, row: 1 }, Color::White),
|
||||
(Coordinate { column: 18, row: 1 }, Color::White),
|
||||
]
|
||||
.into_iter(),
|
||||
)
|
||||
.unwrap();
|
||||
state.current_player = Color::Black;
|
||||
|
||||
assert_eq!(
|
||||
state.place_stone(Coordinate { column: 18, row: 0 }),
|
||||
Err(BoardError::SelfCapture)
|
||||
);
|
||||
assert_eq!(state.current_player, Color::Black);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ko_rules_are_enforced() {
|
||||
let mut state = GameState::default();
|
||||
state.board = Board::from_coordinates(
|
||||
vec![
|
||||
(Coordinate { column: 7, row: 9 }, Color::White),
|
||||
(Coordinate { column: 8, row: 8 }, Color::White),
|
||||
(Coordinate { column: 8, row: 10 }, Color::White),
|
||||
(Coordinate { column: 9, row: 9 }, Color::White),
|
||||
(Coordinate { column: 10, row: 9 }, Color::Black),
|
||||
(Coordinate { column: 9, row: 8 }, Color::Black),
|
||||
(Coordinate { column: 9, row: 10 }, Color::Black),
|
||||
]
|
||||
.into_iter(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
state.place_stone(Coordinate { column: 8, row: 9 }).unwrap();
|
||||
assert_eq!(
|
||||
state.place_stone(Coordinate { column: 9, row: 9 }),
|
||||
Err(BoardError::Ko)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
use crate::{
|
||||
types::{Config, DatabasePath},
|
||||
ui::Field,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct ConfigurationView {
|
||||
pub library: Field<()>,
|
||||
}
|
||||
|
||||
pub fn configuration(config: &Config) -> ConfigurationView {
|
||||
let path: Option<DatabasePath> = config.get();
|
||||
ConfigurationView {
|
||||
library: Field {
|
||||
id: "library-path-field".to_owned(),
|
||||
label: "Library".to_owned(),
|
||||
value: path.map(|path| path.to_string_lossy().into_owned()),
|
||||
action: (),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use sgf::{Game, GameResult, Win};
|
||||
use typeshare::typeshare;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[typeshare]
|
||||
pub struct GamePreviewElement {
|
||||
pub date: String,
|
||||
pub name: String,
|
|
@ -1,6 +1,8 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct Menu<T: PartialEq + Eq> {
|
||||
current: Option<T>,
|
||||
options: Vec<T>,
|
|
@ -1,9 +1,11 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
pub mod game_preview;
|
||||
pub mod menu;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct Action<A> {
|
||||
pub id: String,
|
||||
pub label: String,
|
||||
|
@ -11,6 +13,7 @@ pub struct Action<A> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct Toggle<A> {
|
||||
pub id: String,
|
||||
pub label: String,
|
||||
|
@ -19,6 +22,7 @@ pub struct Toggle<A> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct Field<A> {
|
||||
pub id: String,
|
||||
pub label: String,
|
|
@ -1,6 +1,7 @@
|
|||
use crate::ui::{Action, GamePreviewElement};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sgf::Game;
|
||||
use typeshare::typeshare;
|
||||
|
||||
fn rank_strings() -> Vec<String> {
|
||||
vec![
|
||||
|
@ -17,6 +18,7 @@ fn rank_strings() -> Vec<String> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub enum PlayerElement {
|
||||
Hotseat(HotseatPlayerElement),
|
||||
// Remote(RemotePlayerElement),
|
||||
|
@ -30,6 +32,7 @@ impl Default for PlayerElement {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
|
||||
#[typeshare]
|
||||
pub struct HotseatPlayerElement {
|
||||
pub placeholder: Option<String>,
|
||||
pub default_rank: Option<String>,
|
||||
|
@ -37,12 +40,15 @@ pub struct HotseatPlayerElement {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct RemotePlayerElement {}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct BotPlayerElement {}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct HomeView {
|
||||
pub black_player: PlayerElement,
|
||||
pub white_player: PlayerElement,
|
|
@ -3,8 +3,10 @@ use crate::{
|
|||
ui::types,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct PlayingFieldView {
|
||||
pub board: types::BoardElement,
|
||||
pub player_card_black: types::PlayerCardElement,
|
|
@ -1,17 +1,20 @@
|
|||
use crate::types::{Color, Size};
|
||||
use crate::{
|
||||
api::{CoreRequest, PlayStoneRequest},
|
||||
Coordinate, Goban,
|
||||
Board, Coordinate,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct Jitter {
|
||||
pub x: i8,
|
||||
pub y: i8,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct StoneElement {
|
||||
pub color: Color,
|
||||
pub jitter: Jitter,
|
||||
|
@ -29,6 +32,8 @@ impl StoneElement {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
#[serde(tag = "type", content = "content")]
|
||||
pub enum IntersectionElement {
|
||||
Unplayable,
|
||||
Empty(CoreRequest),
|
||||
|
@ -36,6 +41,7 @@ pub enum IntersectionElement {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct BoardElement {
|
||||
pub size: Size,
|
||||
pub spaces: Vec<IntersectionElement>,
|
||||
|
@ -74,8 +80,8 @@ impl BoardElement {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<&Goban> for BoardElement {
|
||||
fn from(board: &Goban) -> Self {
|
||||
impl From<&Board> for BoardElement {
|
||||
fn from(board: &Board) -> Self {
|
||||
let spaces: Vec<IntersectionElement> =
|
||||
(0..board.size.height)
|
||||
.map(|row| {
|
||||
|
@ -108,6 +114,7 @@ impl Default for BoardElement {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct PlayerCardElement {
|
||||
pub color: Color,
|
||||
pub name: String,
|
||||
|
@ -116,9 +123,11 @@ pub struct PlayerCardElement {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct ChatElement {
|
||||
pub messages: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[typeshare]
|
||||
pub struct TextFieldElement {}
|
|
@ -0,0 +1,47 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="styles.css" />
|
||||
|
||||
<body>
|
||||
<div class="menu">
|
||||
<ul>
|
||||
<li> <a href="index.html">Index</a> </li>
|
||||
<li> <a href="playing.html">Game Board for playing</a> </li>
|
||||
<li> <a href="database.html">Game database</a> </li>
|
||||
<li> <a href="analysis.html">Game board for analysis</a> </li>
|
||||
<li> Connection management </li>
|
||||
<li> Challenge list </li>
|
||||
<li> Friends list </li>
|
||||
<li> Open challenges </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="widget">
|
||||
<div> US Go Congress 2023, DDK Tournament, Round 1, Board 25 </div>
|
||||
<div class="game-analysis">
|
||||
<div class="game-analysis__board">
|
||||
<img src="game-screen.jpg" />
|
||||
</div>
|
||||
|
||||
<div class="game-analysis__tree">
|
||||
<div>
|
||||
<img src="game-tree.jpg" />
|
||||
</div>
|
||||
<p> Shoring up the wall. Any chance to capture that group was lost a couple of moves back and Savanni knows it. </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="game-info">
|
||||
<div class="player-info">
|
||||
<div> Savanni (10k) </div>
|
||||
</div>
|
||||
<div class="player-info">
|
||||
<div> Opal (10k) </div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="styles.css" />
|
||||
|
||||
<body>
|
||||
<div class="menu">
|
||||
<ul>
|
||||
<li> <a href="index.html">Index</a> </li>
|
||||
<li> <a href="playing.html">Game Board for playing</a> </li>
|
||||
<li> <a href="database.html">Game database</a> </li>
|
||||
<li> Game board for analysis </li>
|
||||
<li> Connection management </li>
|
||||
<li> Challenge list </li>
|
||||
<li> Friends list </li>
|
||||
<li> Open challenges </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="widget">
|
||||
<div class="game-filter">
|
||||
<input class="game-filter__term" placeholder="date" />
|
||||
<input class="game-filter__term" placeholder="player name" />
|
||||
<input class="game-filter__term" placeholder="minimum strength" />
|
||||
<input class="game-filter__term" placeholder="maximum strength" />
|
||||
</div>
|
||||
|
||||
<div class="game-database">
|
||||
<div class="game-entry">
|
||||
<a href="analysis.html"><img class="game-entry__icon" src="game-thumbnail.jpg" /></a>
|
||||
<div class="game-entry__info-card">
|
||||
<div class="game-entry__info-row">
|
||||
2016-06-15
|
||||
</div>
|
||||
|
||||
<div class="game-entry__info-row">
|
||||
(B) Alpha Go (w)
|
||||
</div>
|
||||
|
||||
<div class="game-entry__info-row">
|
||||
(W) Lee Sedol
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="game-entry">
|
||||
<img class="game-entry__icon" src="game-thumbnail.jpg" />
|
||||
<div class="game-entry__info-card">
|
||||
<div class="game-entry__info-row">
|
||||
2016-06-15
|
||||
</div>
|
||||
|
||||
<div class="game-entry__info-row">
|
||||
(B) Alpha Go (w)
|
||||
</div>
|
||||
|
||||
<div class="game-entry__info-row">
|
||||
(W) Lee Sedol
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="game-entry">
|
||||
<img class="game-entry__icon" src="game-thumbnail.jpg" />
|
||||
<div class="game-entry__info-card">
|
||||
<div class="game-entry__info-row">
|
||||
2016-06-15
|
||||
</div>
|
||||
|
||||
<div class="game-entry__info-row">
|
||||
(B) Alpha Go (w)
|
||||
</div>
|
||||
|
||||
<div class="game-entry__info-row">
|
||||
(W) Lee Sedol
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="game-entry">
|
||||
<img class="game-entry__icon" src="game-thumbnail.jpg" />
|
||||
<div class="game-entry__info-card">
|
||||
<div class="game-entry__info-row">
|
||||
2016-06-15
|
||||
</div>
|
||||
|
||||
<div class="game-entry__info-row">
|
||||
(B) Alpha Go (w)
|
||||
</div>
|
||||
|
||||
<div class="game-entry__info-row">
|
||||
(W) Lee Sedol
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="game-entry">
|
||||
<img class="game-entry__icon" src="game-thumbnail.jpg" />
|
||||
<div class="game-entry__info-card">
|
||||
<div class="game-entry__info-row">
|
||||
2016-06-15
|
||||
</div>
|
||||
|
||||
<div class="game-entry__info-row">
|
||||
(B) Alpha Go (w)
|
||||
</div>
|
||||
|
||||
<div class="game-entry__info-row">
|
||||
(W) Lee Sedol
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 151 KiB |
Binary file not shown.
After Width: | Height: | Size: 81 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
|
@ -0,0 +1,24 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="styles.css" />
|
||||
|
||||
<body>
|
||||
<div class="menu">
|
||||
<ul>
|
||||
<li> <a href="playing.html">Game Board for playing</a> </li>
|
||||
<li> <a href="database.html">Game database</a> </li>
|
||||
<li> <a href="analysis.html">Game board for analysis</a> </li>
|
||||
<li> Connection management </li>
|
||||
<li> Challenge list </li>
|
||||
<li> Friends list </li>
|
||||
<li> Open challenges </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="widget">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,49 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="styles.css" />
|
||||
|
||||
<body>
|
||||
<div class="menu">
|
||||
<ul>
|
||||
<li> <a href="index.html">Index</a> </li>
|
||||
<li> <a href="playing.html">Game Board for playing</a> </li>
|
||||
<li> Game database </li>
|
||||
<li> Game board for analysis </li>
|
||||
<li> Connection management </li>
|
||||
<li> Challenge list </li>
|
||||
<li> Friends list </li>
|
||||
<li> Open challenges </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="widget">
|
||||
|
||||
<img src="game-screen.jpg" />
|
||||
|
||||
<div class="game-info">
|
||||
<div class="player-info">
|
||||
<div> Savanni (10k) </div> <div> 24:53 </div>
|
||||
</div>
|
||||
<div class="player-info">
|
||||
<div> Opal (10k) </div> <div> 25:00 </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="chat">
|
||||
<div>
|
||||
<textarea cols="80" rows="25">
|
||||
[22:05] Savanni: oops
|
||||
[22:06] Opal: you know I'll take advantage of that, right?
|
||||
</textarea>
|
||||
</div>
|
||||
<div>
|
||||
<input size="60"></input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,270 @@
|
|||
(;FF[4]
|
||||
CA[UTF-8]
|
||||
GM[1]
|
||||
DT[2022-02-17]
|
||||
GN[Amika Matĉo]
|
||||
PC[https://online-go.com/review/823151]
|
||||
PB[mearss25]
|
||||
PW[savanni.dgerinel]
|
||||
BR[16k]
|
||||
WR[10k]
|
||||
TM[1500]OT[15 fischer]
|
||||
RE[W+46.5]
|
||||
SZ[19]
|
||||
KM[7.5]
|
||||
RU[AGA]
|
||||
|
||||
;B[pd]SQ[ph]SQ[oi]LB[pi:B]LB[qi:A]SQ[pj]LB[qj:C]
|
||||
;W[dp]
|
||||
;B[dd]
|
||||
;W[qp]
|
||||
;B[ch]
|
||||
;W[np]
|
||||
;B[cl]
|
||||
;W[qf]
|
||||
;B[qh]
|
||||
(;W[of]
|
||||
(;B[nc]
|
||||
;W[oi]
|
||||
;B[pj]
|
||||
;W[md]
|
||||
;B[nk]
|
||||
;W[jd]
|
||||
;B[gc]
|
||||
(;W[jj]
|
||||
;B[mi]
|
||||
;W[mj]
|
||||
;B[lj]
|
||||
;W[nj]
|
||||
;B[ok]
|
||||
;W[li]
|
||||
;B[ki]
|
||||
;W[lh]
|
||||
;B[kj]
|
||||
;W[kh]
|
||||
;B[mk]
|
||||
(;W[pi]
|
||||
;B[qi]
|
||||
;W[ji]
|
||||
;B[ni]
|
||||
;W[oj]
|
||||
;B[nh]
|
||||
;W[mh]
|
||||
;B[oh]
|
||||
;W[ng]
|
||||
;B[ig]
|
||||
;W[qc]
|
||||
;B[pf]
|
||||
;W[pg]
|
||||
;B[ph]
|
||||
;W[pe]
|
||||
;B[qd]
|
||||
;W[od]
|
||||
;B[oc]
|
||||
;W[pc]
|
||||
;B[nd]
|
||||
;W[oe]
|
||||
;B[og]
|
||||
;W[rd]
|
||||
;B[mc]
|
||||
;W[mf]
|
||||
;B[ld]
|
||||
;W[me]
|
||||
;B[jh]
|
||||
;W[cc]
|
||||
;B[cd]
|
||||
;W[dc]
|
||||
;B[ec]
|
||||
;W[eb]
|
||||
;B[fd]
|
||||
;W[fb]
|
||||
;B[gb]
|
||||
;W[bd]
|
||||
;B[be]
|
||||
;W[bc]
|
||||
;B[ad]
|
||||
;W[ce]
|
||||
;B[de]
|
||||
;W[ac]
|
||||
;B[cf]
|
||||
;W[ae]
|
||||
;B[fa]
|
||||
;W[ea]
|
||||
;B[ga]
|
||||
;W[ca]
|
||||
;B[cq]
|
||||
;W[dq]
|
||||
;B[cp]
|
||||
;W[cn]
|
||||
;B[bn]
|
||||
;W[do]
|
||||
;B[cm]
|
||||
;W[cr]
|
||||
;B[co]
|
||||
;W[dn]
|
||||
;B[dm]
|
||||
;W[fn]
|
||||
;B[fm]
|
||||
;W[hn]
|
||||
;B[il]
|
||||
;W[jp]
|
||||
;B[hq]
|
||||
;W[jq]
|
||||
;B[er]
|
||||
;W[dr]
|
||||
;B[fq]
|
||||
;W[ir]
|
||||
;B[io]
|
||||
;W[jm]
|
||||
;B[kn]
|
||||
;W[jn]
|
||||
;B[ho]
|
||||
;W[gn]
|
||||
;B[hr]
|
||||
;W[gp]
|
||||
;B[gr]
|
||||
;W[es]
|
||||
;B[fs]
|
||||
;W[ds]
|
||||
;B[eq]
|
||||
;W[hs]
|
||||
;B[go]
|
||||
;W[fp]
|
||||
;B[en]
|
||||
;W[eo]
|
||||
;B[br]
|
||||
;W[fo]
|
||||
;B[mo]
|
||||
;W[mp]
|
||||
;B[lp]
|
||||
;W[lq]
|
||||
;B[ko]
|
||||
;W[jo]
|
||||
;B[km]
|
||||
;W[ql]
|
||||
;B[pl]
|
||||
;W[pm]
|
||||
;B[om]
|
||||
;W[pn]
|
||||
;B[on]
|
||||
;W[oo]
|
||||
;B[no]
|
||||
;W[op]
|
||||
;B[qk]
|
||||
;W[rl]
|
||||
;B[rk]
|
||||
;W[rn]
|
||||
;B[qg]
|
||||
;W[rf]
|
||||
;B[rg]
|
||||
;W[kf]
|
||||
;B[if]
|
||||
;W[kc]
|
||||
;B[lb]
|
||||
;W[lc]
|
||||
;B[kb]
|
||||
;W[jb]
|
||||
;B[ma]
|
||||
;W[ob]
|
||||
;B[nb]
|
||||
;W[pa]
|
||||
;B[ka]
|
||||
;W[je]
|
||||
;B[ie]
|
||||
;W[id]
|
||||
;B[hd]
|
||||
;W[jl]
|
||||
;B[ii]
|
||||
;W[ik]
|
||||
;B[hk]
|
||||
;W[hl]
|
||||
;B[gl]
|
||||
;W[hm]
|
||||
;B[ij]
|
||||
;W[jk]
|
||||
;B[gm]
|
||||
;W[bf]
|
||||
;B[bg]
|
||||
;W[ce]
|
||||
;B[cg]
|
||||
;W[be]
|
||||
;B[fh]
|
||||
;W[jg]
|
||||
;B[ih]
|
||||
;W[em]
|
||||
;B[el]
|
||||
;W[gk]
|
||||
;B[hj]
|
||||
;W[fl]
|
||||
;B[gj]
|
||||
;W[fk]
|
||||
;B[ek]
|
||||
;W[kp]
|
||||
;B[fj]
|
||||
;W[sl]
|
||||
;B[sk]
|
||||
;W[kk]
|
||||
;B[lk]
|
||||
;W[lo]
|
||||
;B[ln]
|
||||
;W[lp]
|
||||
;B[ll]
|
||||
;W[sf]
|
||||
;B[sg]
|
||||
;W[ib]
|
||||
;B[ic]
|
||||
;W[jc]
|
||||
;B[hc]
|
||||
;W[is]
|
||||
;B[bs]
|
||||
;W[fc]
|
||||
;B[ed]
|
||||
;W[ne]
|
||||
;B[na]
|
||||
;W[oa]
|
||||
;B[qa]
|
||||
;W[pb]
|
||||
;B[rc]
|
||||
;W[qe]
|
||||
;B[ag]
|
||||
;W[jf]
|
||||
;B[pf]
|
||||
;W[kl]
|
||||
;B[mm]
|
||||
;W[pg]
|
||||
;B[]
|
||||
;W[pf]
|
||||
;B[]
|
||||
;W[]
|
||||
)(;W[lk]
|
||||
;B[kk]
|
||||
;W[ll]
|
||||
;B[kl]
|
||||
;W[km]
|
||||
;B[jm]
|
||||
;W[kn]
|
||||
))(;W[mj]
|
||||
))(;B[nd]
|
||||
;W[oh]
|
||||
;B[qk]
|
||||
))(;W[qc]
|
||||
(;B[qd]
|
||||
;W[pc]
|
||||
;B[od]
|
||||
;W[rd]
|
||||
;B[re]
|
||||
;W[rc]
|
||||
;B[rf]
|
||||
;W[nc]
|
||||
;B[me]
|
||||
)(;B[pc]TR[jc]
|
||||
;W[qd]
|
||||
;B[pe]
|
||||
(;W[rf]
|
||||
;B[og]
|
||||
)(;W[pf]
|
||||
;B[of]
|
||||
;W[oe]
|
||||
(;B[ne]
|
||||
)(;B[nf]
|
||||
)))))
|
|
@ -0,0 +1,44 @@
|
|||
body {
|
||||
background: hsl(0 0% 85%);
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.menu {
|
||||
border-right: 1px solid black;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.game-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.widget {
|
||||
}
|
||||
|
||||
.game-database {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.game-entry {
|
||||
display: flex;
|
||||
width: 500px;
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.game-entry__icon {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.game-analysis {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.game-analysis__board {
|
||||
flex-shrink: 1;
|
||||
}
|
||||
|
||||
.game-analysis__tree {
|
||||
flex-shrink: 0;
|
||||
}
|
|
@ -0,0 +1,564 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[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 = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
||||
|
||||
[[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.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "codespan-reporting"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
|
||||
dependencies = [
|
||||
"termcolor",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
|
||||
|
||||
[[package]]
|
||||
name = "cxx"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cxxbridge-flags",
|
||||
"cxxbridge-macro",
|
||||
"link-cplusplus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxx-build"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"codespan-reporting",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"scratch",
|
||||
"syn 2.0.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-flags"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb"
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-macro"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "grid"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0634107a3a005070dd73e27e74ecb691a94e9e5ba7829f434db7fbf73a6b5c47"
|
||||
dependencies = [
|
||||
"no-std-compat",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"windows",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
|
||||
dependencies = [
|
||||
"cxx",
|
||||
"cxx-build",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.61"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kifu-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"grid",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"typeshare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kifu-wasm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kifu-core",
|
||||
"serde",
|
||||
"serde-wasm-bindgen",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.142"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317"
|
||||
|
||||
[[package]]
|
||||
name = "link-cplusplus"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "no-std-compat"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
|
||||
|
||||
[[package]]
|
||||
name = "scratch"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.160"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-wasm-bindgen"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.160"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.96"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[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.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typeshare"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f44d1a2f454cb35fbe05b218c410792697e76bd868f48d3a418f2cd1a7d527d6"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"typeshare-annotation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typeshare-annotation"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc670d0e358428857cc3b4bf504c691e572fccaec9542ff09212d3f13d74b7a9"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.61"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue