Either add rust wrappers for C++ functions called via ffi or port some pure code from C++ to rust to provide support for the upcoming `env_dispatch` rewrite.