recursive_lookup is async, rust creates a state machine type for it
enum RecursiveLookup {
First(RecursiveLookup)
}
the size of the enum is not known at compile time, so we need to allocate it on heap -> Box
recursive function can potentially be indefinitely also -> what happens if we makes the heap full by doing it indefinitely 🤔 . In java or python it would be a stack overflow, how about in rust?
pin
makes sure that a value won't be moved in memory after it's created. the value here is Future, it can't be moved once they've polled. -> this is needed for futures type that contain self-reference (recursive call here).
_Originally posted by @sonhmai in https://github.com/neitomic/doh-server/pull/15#discussion_r1659520046_