Best way to mock-up a lower-level API?

Hi Rustaceans,

I'm currently working on a high-level API based on a lower-level API. For unit testing, I would like to replace the lower-level API with a mock implementation.

I guess I could turn the entire APIs into objects instead of modules, and pass an instance of the lower-level API to the higher-level API, but this doesn't look very readable or rustdoc-friendly.

Is there a better design?


What do you mean by "objects"? You can use traits for everything if you want to, and if you don't use trait objects, that indirection will not be noticeable at runtime.

Ah, right, for some reason, I was assuming that I needed to use trait objects, but you are right that I can use just the raw trait, and it's not that invasive, in terms of signature. I'll see how that goes.