Code Review - First Attempt At Lib

I'm not sure if this is the right place or not, but I've seen some of these requests on the forum and figured I'd give it a try. I've been playing around with Rust for a while and decided to try and make a small, real world example lib for measuring download speed as practice. The repo is located here if anyone has time to take a look.

I'm trying to keep things as idiomatic as possible and try to learn best practices early on. I'd love to get feedback from people more experienced then I am on things I'm doing wrong, anti patterns I might be implementing and any other improvements you might think of.

Again, I'm not really sure if this is the correct place for this, but I figured it couldn't hurt to ask. I'd greatly appreciate any amount of time and feedback one might be able to offer.

The only issue I can find after a quick skim is that you embedded an api token in the code. While this is more convenient than manually passing it every time you run the program, this can cause the token to be revoked. Either to revoke this api token after they find it, or people will start to abuse it and it will be revoked.

Other than that, you seem to follow best practices. I saw you used clippy, and I assume you use rustfmt. Keep going!

This is a good place to ask. You are not the first person to ask for a review of their code.

Thanks for taking the time to look at my code. The api token in the bin was mainly just for quick testing. I'll make sure to store the api token in a config, or environment variable when I start using the code for real.

I was also curious about my SpeedTestEvents trait. Does that seem like a proper use of a trait to act as a callback code can hook into to get data about the download?

Yes. You could also create a Stream which produces a message every time one of the on_* methods is currently called. This may be more ergonomic for the user, but is a bit more complex to implement.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.