I am writing some async code, but I also have sync code and they both do file system calls.
I am using tokio.
I want to "make sure" (at least in debug mode) that file system calls are either done in an async fashion (using tokio's APIs), or in spawn_blocking
if they are in an async context, but most importantly that if they are not called in an async context, they should not be in an non-blocking (spawn
) task.
EDIT That last sentence may need some explaining: so if someone calls that function, I want it to assert that it is not called in async mode, or at least that it is called from spawn_blocking
.
Are there APIs in tokio to inspect / assert on these things?