For someone only on chapter 7, this is ok. I would not call it idiomatic but you have not gotten to the Error Handling in chapter 9 yet. I would probably hold on getting feedback on error handling until you have gotten to that point.
But the TLDR of it is rust has two forms of errors, unrecoverable errors in the form of panic and recoverable ones in the form of returning a Result
. In this case you have opted for panicking which IMO is the wrong choice for something that is expected to fail - and http requests and parsing external data is expected to fail (even if only some of the time). Networks fail all the time, servers go down, send back wrong responses and many other things.
Do you really want to crash your program every time that happens? Probably not - at least not at this level. Instead you likely want to return an error from this function and let the caller deal with it instead as they will likely have more context as to what to do with it rather than in the leaf functions of where the error originates.
But all that is probably for once you have read through chapter 9. For now it is good to know that when you have the pattern
match foo {
Ok(value) => value,
Err(err) => panic!("it broke! {}", err),
}
You can generally replace that with a call to expect instead:
foo.expect("it broke")
Or just unwrap it if you dont need to add more context for what ever reason.
Sounds like you just need to keep the data on your server and use samba or NFS and a network mount on the other devices.