Am I thinking about this problem correctly?
I have a crate, that does some complex computation, and in the middle of its work it does some very slow OCR and it wants to offer you the ability to bring your own cache for the this part, so that next time if you ask it to do the work again, and you bring your own cache, it can skip that part.
I could break up the pipeline into tiny little pieces and expose them all, then everyone is free to borrow the various functions of the library and assemble their dream pipeline and add whatever caching they want. Problem solved!
The problem is, there is only one way to assemble the pipeline so it makes no sense to expose (leak) the various internal components as a composable thing.
So I was thinking, I make you give me two closures, one closure that passes you the three parameters that when combined make up the unique key for this cache, and you use it to call your cache and ask if you have it cached already, and a second closure for when you return None; I will pass you the data that you now need to store.
Does this sound reasonable?
I've not really seen this pattern used elsewhere, so I'm wondering if there's a reason for that!