Db access in rust typically needs some sort of handle and a mutex. Limiting access to the handle makes the rest of the code pure with respect to the db. The handle plays a similar role to the IO type.
Actor-like patterns makes this nice. Message-objects can be passed to/from a module with db-access or other io.
How can you prevent code from creating a handle in a new place?
You can limit access to your db credentials. But other code can still launch missiles etc.