PubSub Trait
The PubSub
/AsyncPubSub
traits contain functions for using PubSub in BonsaiDb. The traits are implemented by the Database
types in each crate:
- For bonsaidb-local:
Database
/AsyncDatabase
- For bonsaidb-server:
ServerDatabase
, andDatabase
viaServerDatabase::as_blocking()
- For bonsaidb-client:
BlockingRemoteDatabase
/AsyncRemoteDatabase
Using these traits, you can write code that generically can work regardless of whether BonsaiDb is operationg locally with no network connection or across the globe.
The only differences between PubSub
and AsyncPubSub
is that
AsyncPubSub
is able to be used in async code and the PubSub
trait is
designed to block the current thread. BonsaiDb is designed to try to make it
hard to accidentally call a blocking function from async code accidentally,
while still supporting both async and blocking access patterns.