I do something similar. I have all my esp/idf code in one crate and all my business logic in a separate crate. The business crate has no dependencies that won’t compile/run on the host. This is where all my tests live.
This is good advice however it should be noted that many of espressif's other purely software components depend on esp-hal, so you still want it to compile if you use any of espressif's provided components.
Re:The Rust on ESP Book
by waterTanuki on Wednesday July 29, 2026 @09:45PM
(#49105259)
Interesting pattern but it sounds like it's fundamentally incompatible with setups using embassy
Re:The Rust on ESP Book
by bigfishrunning on Thursday July 30, 2026 @08:39AM
(#49109198)
Why would that be? one of the nice features of the sans-io pattern is that it seperates your HAL from the program itself; if your state machine says "send a network packet", send it using embassy (or tokio or bsd-sockets or whatever). The underlying libraries have little or no bearing on "write your program as a big synchronous state-machine"
same goes for "wait 10 ms" or "change this gpio pin".
https://sans-io.readthedocs.io/how-to-sans-io.html
Keeping all of the actual hardware/network/io interface code separate really makes writing unit tests and porting to different computers much simpler