Crate for fixed randomness buffer?

Asking on here because I'm not too familiar with the rand ecosystem and searching around didn't find me anything.

I am trying to build a system that uses a seedable RNG that is stable in the face of omitting/replacing some random operations. The plan is to make each operation consume a fixed amount of 'randomness', perhaps by filling a buffer with random bytes, and then generating random values out of it. (If the bytes are exhausted, I will stop then making random decisions.) If I want to skip the operation, I would just fill the buffer and then move on, so that the next operation continues from the same random state.

The engineering problem is that I want this buffer to have a generic RNG API so I can produce data of whatever type I need. So I'm curious if anybody has already done this, or knows of a good way to go about it?


EDIT: Perhaps this was a premature question... It looks like all I have to do is implement rand::RngCore around a buffer, and everything else should fall out naturally...

I feel like all you need to do is to generate a new seed value for each thing that you consider a single operation. This way every operation, even a "skip" operation, needs the same number of bytes, that is, the bytes that constitute one seed for your random number generator of choice. I don't see the need to pre-fill these bytes into any buffer. The single operation can then use the random seed to create a new Rng and this way it can effectively get as many bytes out of this as it needs. Swapping one operation out for another will not affect succeeding operations in this way, because the "root Rng" so to speak, the one that generates the seeds, always advances by the same amount.

Oh yeah, that will probably work better. Then I don't even have to worry about what to do when the buffer runs out.