Not too different from C++'s iterator interface for generators, I guess.