BSON is sent to and from the server.
Each message starts with a header:
Acquire socket lock, Use socket, Release socket lock.
Two options: Mutable or immutable pool.
A mutable connection pool requires a mutex to guarantee thread safety.
An immutable connection pool requires explicit lock and socket initialization on creation.
Acquire lock, extract socket, lock socket, use socket.
but...
Doubles the number of locks per socket
Poisoned locks still hinder pool functionality!
The Good:
Variable number of lazily-connected sockets
Almost lock-free
One master lock on the connection pool
The Bad:
The number of open sockets is uncapped.
Recycling vulnerability: Old sockets can be dropped as new ones are constantly made to take their place.
Rust makes it easy to auto-convert types.
Encoding traits allow arbitrary structs to be converted.
BSON can be decoded into structs and vice versa without any matching involved.
All errors in rust are handled by Result<T, Err>.
Defining your own Error type is easy!
Unobtrusive error handling and control paths.
To provide concurrency and safety, Rust relies on a number of wrapping structs: Arc, Box, MutexGuard, Ref, etc.
An auto-dereferencing system makes this as transparent and user-friendly as possible.
Iterate with control.
Read and write anything.
bson library
OID generation
stable macro
connection strings
wire protocol
CRUD, commands, and cursors
bulk writes
connection pooling
error handling
automated testing suites
replica set failover
server discovery and monitoring (SDAM)
SCRAM-SHA-1 auth
shard tagging, indexes, and other server commands