~ntgg/bread-inc

617f1ce1dba7a91c6c4d2bb762666f31ff456960 — Noah Graff 11 months ago 4e9be0b master
very basics
6 files changed, 663 insertions(+), 1 deletions(-)

A Cargo.lock
M Cargo.toml
M src/main.rs
A src/stat_text.rs
A static/index.html
A static/style.css
A Cargo.lock => Cargo.lock +440 -0
@@ 0,0 1,440 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "anymap"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

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

[[package]]
name = "backtrace"
version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
 "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
 "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "backtrace-sys"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

[[package]]
name = "bincode"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "bread-inc"
version = "0.1.0"
dependencies = [
 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
 "web_logger 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "yew 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

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

[[package]]
name = "bytes"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

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

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

[[package]]
name = "failure"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)",
 "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "failure_derive"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
 "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
 "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

[[package]]
name = "http"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
 "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
 "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "iovec"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
 "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

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

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

[[package]]
name = "log"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

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

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

[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

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

[[package]]
name = "serde_derive"
version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
 "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "serde_json"
version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

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

[[package]]
name = "stdweb"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
 "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "stdweb-internal-macros 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
 "stdweb-internal-runtime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "stdweb-derive"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
 "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "stdweb-internal-macros"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "base-x 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
 "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

[[package]]
name = "syn"
version = "0.15.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
 "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "synstructure"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
 "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
 "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

[[package]]
name = "wasm-bindgen"
version = "0.2.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "wasm-bindgen-backend"
version = "0.2.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
 "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
 "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
 "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "wasm-bindgen-macro"
version = "0.2.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
 "wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
 "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
 "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
 "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "wasm-bindgen-shared"
version = "0.2.45"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "web_logger"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
 "stdweb 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)",
]

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

[[package]]
name = "yew"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "anymap 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
 "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
 "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "stdweb 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)",
]

[metadata]
"checksum anymap 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344"
"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf"
"checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b"
"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
"checksum base-x 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "76f4eae81729e69bb1819a26c6caac956cc429238388091f98cb6cd858f16443"
"checksum bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2fb9e29e72fd6bc12071533d5dc7664cb01480c59406f656d7ac25c7bd8ff7"
"checksum bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "84dca3afd8e01b9526818b7963e5b4916063b3cdf9f10cf6b73ef0bd0ec37aa5"
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c"
"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d"
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
"checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a"
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db"
"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "32746bf0f26eab52f06af0d0aa1984f641341d06d8d673c693871da2d188c9be"
"checksum serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "46a3223d0c9ba936b61c0d2e3e559e3217dbfb8d65d06d26e8b3c25de38bae3e"
"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d"
"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
"checksum stdweb 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c34362bb10ac1a9439674795cc0e1bdcb0c46444c8fd4874ef39a01d9a8a8f24"
"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930"
"checksum stdweb-internal-macros 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e68f7d08b76979a43e93fe043b66d2626e35d41d68b0b85519202c6dd8ac59fa"
"checksum stdweb-internal-runtime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d52317523542cc0af5b7e31017ad0f7d1e78da50455e38d5657cd17754f617da"
"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe"
"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6"
"checksum wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1953f91b1608eb1522513623c7739f047bb0fed4128ce51a93f08e12cc314645"
"checksum wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "0f69da5696545d7ca6607a2e4b1a0edf5a6b36b2c49dbb0f1df6ad1d92884047"
"checksum wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4246f3bc73223bbb846f4f2430a60725826a96c9389adf715ed1d5af46dec6"
"checksum wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "c08381e07e7a79e5e229ad7c60d15833d19033542cc5dd91d085df59d235f4a6"
"checksum web_logger 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a78db9c2146b833ba825496c1851886be8221097df558903321d304c83d161a5"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum yew 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca078a19e3459f7d73b135015477bc8cdcc92c3f4a058ae949f4d957a47dfd55"

M Cargo.toml => Cargo.toml +3 -0
@@ 5,3 5,6 @@ authors = ["noah"]
edition = "2018"

[dependencies]
yew = "0.6"
log = "0.4"
web_logger = "0.1"

M src/main.rs => src/main.rs +128 -1
@@ 1,3 1,130 @@
#![recursion_limit = "1024"]
use log::{debug, info, trace};
use std::time::Duration;
use yew::{
    html,
    services::{IntervalService, Task},
    virtual_dom::{VList, VNode},
    Callback, Component, ComponentLink, Html, Renderable, ShouldRender,
};

mod stat_text;
use stat_text::StatText;

const TICK_MILLISECONDS: u64 = 500;

#[inline]
fn empty_node<CMP: Component>() -> Html<CMP> {
    VNode::VList(VList::new())
}

#[derive(Default)]
struct GameStats {
    total_wheat: u128,
    life_wheat: u128,

    total_bread: u128,
    life_bread: u128,

    total_bakers: u128,
    life_bakers: u128,
}

struct Game {
    stats: GameStats,
    wheat: u128,
    bread: u128,
    bakers: u128,
    tick_job: Box<Task>,
}

impl Game {
    fn bread_cost(&self) -> u128 {
        10 + self.bread
    }

    fn baker_cost(&self) -> u128 {
        10 + self.bakers
    }
}

#[derive(Debug)]
enum Msg {
    Tick,
    FarmWheat,
    MakeBread,
    HireBaker,
}

impl Component for Game {
    type Message = Msg;
    type Properties = ();

    fn create(_: Self::Properties, mut link: ComponentLink<Self>) -> Self {
        let callback = link.send_back(|_| Msg::Tick);
        let mut interval = IntervalService::new();
        let tick_job = interval.spawn(Duration::from_millis(TICK_MILLISECONDS), callback);
        Game {
            stats: Default::default(),
            wheat: 0,
            bread: 0,
            bakers: 0,
            tick_job: Box::new(tick_job),
        }
    }

    fn update(&mut self, msg: Self::Message) -> ShouldRender {
        trace!("Recieved message: {:?}", msg);
        match msg {
            Msg::Tick => true,
            Msg::FarmWheat => {
                self.stats.life_wheat += 1;
                self.wheat += 1;
                true
            }
            Msg::MakeBread => {
                self.stats.life_bread += 1;
                self.wheat -= self.bread_cost();
                self.bread += 1;
                true
            }
            Msg::HireBaker => {
                self.stats.life_bakers += 1;
                self.bread -= self.baker_cost();
                self.bakers += 1;
                true
            }
        }
    }
}

impl Renderable<Game> for Game {
    fn view(&self) -> Html<Self> {
        html! {
            <h1>{ "Bread Inc" }</h1>
            <div id="flexo",>
                <div id="stats",>
                    <ul>
                        <li><StatText: value=format!("Wheat: {}", self.wheat), visible=self.stats.life_wheat > 0,/></li>
                        <li><StatText: value=format!("Bread: {}", self.bread), visible=self.stats.life_bread > 0,/></li>
                        <li><StatText: value=format!("Bakers: {}", self.bakers), visible=self.stats.life_bakers > 0,/></li>
                    </ul>
                </div>
                <div id="mako",>
                    <ul>
                        <li><button onclick = |_| Msg::FarmWheat,>{ "Farm Wheat" }</button></li>
                        <li><button onclick = |_| Msg::MakeBread,
                            disabled = self.wheat < self.bread_cost(),>{ "Make Bread" }</button></li>
                        <li><button onclick = |_| Msg::HireBaker,
                            disabled = self.bread < self.baker_cost(),>{ "Hire Baker" }</button></li>
                    </ul>
                </div>
            </div>
        }
    }
}

fn main() {
    println!("Hello, world!");
    web_logger::init();
    yew::start_app::<Game>();
}

A src/stat_text.rs => src/stat_text.rs +51 -0
@@ 0,0 1,51 @@
use crate::empty_node;
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};

#[derive(PartialEq, Clone, Debug)]
pub struct Props {
    pub value: String,
    pub visible: bool,
}

impl Default for Props {
    fn default() -> Self {
        Props { value: "".into(), visible: false }
    }
}

pub struct StatText {
    value: String,
    visible: bool,
}

impl Component for StatText {
    type Message = ();
    type Properties = Props;

    fn create(props: Self::Properties, _: ComponentLink<Self>) -> Self {
        StatText {
            value: props.value,
            visible: props.visible,
        }
    }

    fn update(&mut self, _: Self::Message) -> ShouldRender {
        self.visible
    }

    fn change(&mut self, props: Self::Properties) -> ShouldRender {
        self.value = props.value;
        self.visible = props.visible;
        true
    }
}

impl Renderable<StatText> for StatText {
    fn view(&self) -> Html<Self> {
        if self.visible {
            html!(<p class="stat-text",>{ &self.value }</p>)
        } else {
            empty_node()
        }
    }
}

A static/index.html => static/index.html +11 -0
@@ 0,0 1,11 @@
<!DOCTYPE HTML>
<html>
  <head>
    <meta charset='utf-8'>
    <title>Gotta Make Bread</title>
    <link rel='stylesheet' href='style.css'>
  </head>
  <body>
    <script src='bread-inc.js'></script>
  </body>
</html>

A static/style.css => static/style.css +30 -0
@@ 0,0 1,30 @@
html,body {
	margin: 0;
	padding: 0;
	display: block;
}

ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

li {
    padding: 0;
    margin: 0;
}

#flexo {
    display: flex;
}

#stats {
    width: 200px;
    background: lightblue;
}

#mako {
    flex: 1;
    background: lightgreen;
}