Low-level wrapper to easily support sync, async, and generator functions.