Closed SergioGasquez closed 6 months ago
Thanks for taking care of this! I took a quick look and I think it looks pretty good overall, but I have a couple features I'd like to continue developing to see how they affect this.
Will try to get this taken care of sooner than later and update here when able.
Rebased on top of #516! But now Clippy is back at screaming that a function has too many args (8/7) :(
Rebased on top of https://github.com/esp-rs/espflash/pull/525! Clippy is now screaming louder that a function has too many args (9/7)
I've spent a few minuted touching the related code in probe-rs, here are my initial impressions:
I find #[non_exhaustive]
structs with all-public fields somewhat weird if I don't have a shorthand to create them. If I have to basically list all fields while calling new, it's just a worse version of non-#[non_exhaustive]
. That FlashData
does some actual login in its new somewhat mitigates this point, but:
I think a builder for FlashData
would help greatly in its usability. Many optional parameters in new
doesn't really help usability compared to the previous state. If the API looked like Builder::new(required_params).with_optional_x(x).with_optional_y(y).build()
there would be no question of what the individual None-s mean and which order they come in.
Also I find it somewhat weird that I have to specify a chip revision for FlashData
, then I need a minimum revision (a pair, which is... unclear from the signature) in get_flash_image
.
FlashData::new()
also does not return espflash::error::Error
. I'm not yet sure if espflash::error::Error
was split up or changed further, but if not, then this fact complicates error handling a bit. miette
also does not recommend Report
:
It’s a best practice to wrap any “external” error types in your error enum instead of using something like Report in a library.
non_exhaustinve
FlashData
andFlashSettings
structs to reduce number of input arguments in the following functions:save_elf_as_image
flash_elf_image
load_elf_to_flash
get_flash_image
for all targetsFlashData
avoids duplicating code of parsing the bootloader and partition table file that was present in several places.Not completely convinced on the
FlashData
name.