At this point it's really plausible to put _almost_ all this logic in rust, with the exception of the extern global access.