Carl Worth [Tue, 10 Mar 2026 02:36:37 +0000 (19:36 -0700)]
Parse the json file and deserialize it into a struct
Where the struct only has a 'name' field so far.
This commit shows a few new things in rust that we haven't seen
previously:
* The "mod config" to depend on a module contained in config.rs
* The ? operator ("try operator") which unwraps a Result if it is_ok,
and insteadd returns an error if it is not.
* Dependencies on rust packages, (serde_json, and serde with the
"derive" feature") used for the JSON parsing and deserializing.
* The derive attribute (spelled "#[derive(...)]" used to automatically
create implementations of the Debug and Deserialize traits for our
struct. Debug isn't used here, but could be used by passing a
ConfigFile value to println! or format! macros using a "{:?}" format
specifier.
* A closure accepting a single parameter: |e| { ... }
Carl Worth [Tue, 10 Mar 2026 01:52:58 +0000 (18:52 -0700)]
Return an actual value from main
This is a more idiomatic behavior from main, using a Result to return
either the unit type (which will cause a return of 0) or else an Error
(coerced from a string by using .into()). In that case, the program
will print "Error: " and our error string before exiting with a value
of 1.
Carl Worth [Tue, 10 Mar 2026 00:04:39 +0000 (17:04 -0700)]
Switch from hello world to a program that prints a usage string
OK, so it's not much more than "hello, world", but it just show how to
use std::env as well as Vec<String> and even has an actual condition
in it! It's almost like real programming now.
Oh, and of course there's the collect() call which showcases both an
iterator and the magic of rust's type inference here (telling
collect() to return a Vec<string>). So, there's quite a bit of rust
here, even for just a tiny block of code.
Carl Worth [Tue, 10 Mar 2026 00:02:57 +0000 (17:02 -0700)]
Rename package from "server" to "chip-timing-server"
The "server" name was appropriate for the directory we are in,
(underneath the chip-timing directory), but it's excessively vague for
an actual compiled binary name. So use chip-timing-server instead.