turnloop_mongodb/lib.rs
1//! Sans-IO MongoDB components. The host owns sockets, TLS, DNS, entropy and time.
2//! Call `Connection::connected`, complete explicit TLS requests, then drive bytes
3//! through `transmit` / `consume_transmit` and `receive` / `poll_event`.
4//! One operation per connection follows MongoDB's request/response turn-taking.
5//! Raw BSON replies borrow the receive buffer until `release_reply`.
6//!
7//! # Getting started on turnloop
8//! Enable the `turnloop` feature for the `asynchronous` module. The embedding
9//! host owns `LocalExecutor` and calls `turn`; adapters await its streams and
10//! deadline futures. See the crate README and turnloop-io for ownership, streaming
11//! and cancellation examples. Default features retain the sans-I/O API.
12//!
13//! # Host entropy
14//! Every random or unique value comes from the host; nothing here reads OS
15//! entropy or a clock. The obligations, all described in one place in the
16//! [README's Host entropy section](https://github.com/PerryTS/turnloop/blob/main/protocols/turnloop-mongodb/README.md#host-entropy):
17//! - a CSPRNG SCRAM nonce for [`Connection::connected`] when credentials are set;
18//! - an `_id` on every inserted document, from [`command::ObjectIdGenerator`]
19//! (the server otherwise assigns one the host never learns);
20//! - random session UUIDs for [`session::Session::new`] and
21//! [`operation::RetrySession`];
22//! - selection entropy for [`topology::Topology::choose`].
23//!
24//! The `turnloop` feature's client supplies all but the `_id`.
25#![deny(unsafe_op_in_unsafe_fn)]
26#![forbid(unsafe_code)]
27
28#[cfg(all(target_os = "wasi", target_env = "p3"))]
29use turnloop_wasi_random as _;
30
31pub use bson;
32pub mod auth;
33pub mod command;
34pub mod connection;
35pub mod error;
36pub mod operation;
37pub mod pool;
38pub mod retry;
39pub mod session;
40pub mod time;
41pub mod topology;
42pub use time::Instant;
43pub mod uri;
44pub mod wire;
45mod zlib;
46pub use connection::{Connection, ConnectionEvent};
47pub use error::{Error, ErrorKind, Result};
48
49#[cfg(feature = "turnloop")]
50pub mod asynchronous;