Expand description
Sans-IO MongoDB components. The host owns sockets, TLS, DNS, entropy and time.
Call Connection::connected, complete explicit TLS requests, then drive bytes
through transmit / consume_transmit and receive / poll_event.
One operation per connection follows MongoDB’s request/response turn-taking.
Raw BSON replies borrow the receive buffer until release_reply.
§Getting started on turnloop
Enable the turnloop feature for the asynchronous module. The embedding
host owns LocalExecutor and calls turn; adapters await its streams and
deadline futures. See the crate README and turnloop-io for ownership, streaming
and cancellation examples. Default features retain the sans-I/O API.
§Host entropy
Every random or unique value comes from the host; nothing here reads OS entropy or a clock. The obligations, all described in one place in the README’s Host entropy section:
- a CSPRNG SCRAM nonce for
Connection::connectedwhen credentials are set; - an
_idon every inserted document, fromcommand::ObjectIdGenerator(the server otherwise assigns one the host never learns); - random session UUIDs for
session::Session::newandoperation::RetrySession; - selection entropy for
topology::Topology::choose.
The turnloop feature’s client supplies all but the _id.
Re-exports§
pub use connection::Connection;pub use connection::ConnectionEvent;pub use error::Error;pub use error::ErrorKind;pub use error::Result;pub use bson;
Modules§
- auth
- auth/auth.md §§ SCRAM-SHA-1, SCRAM-SHA-256 and mongodb-handshake/handshake.md § Speculative Authentication. Entropy is provided by the host, never acquired here; see the crate’s host entropy obligations.
- command
- crud/crud.md §§ Read/Write Operations, Write Models and Results.
Builders retain capacity. Inputs and options are borrowed raw BSON; IDs and
wall-clock ObjectId timestamps are supplied by the host (no ObjectId::new()).
Inserted documents need an
_idbefore sending; seeObjectIdGeneratorand the crate’s host entropy obligations. - connection
- mongodb-handshake/handshake.md §§ Connection Handshake, Speculative Authentication.
Events are pull-based. A token is accepted only on successful
command, and is settled exactly once before reuse: by a Failed or Unacknowledged event, or byrelease_reply()after its Reply event.fail()before that release revokes the reply and settles the token with Failed instead;close()keeps a received reply readable until it is released. - error
- operation
- Retry orchestration for an operation across server selection and pool checkout.
retryable-reads/retryable-reads.md § Executing Retryable Read Commands;
retryable-writes/retryable-writes.md § Executing Retryable Write Commands.
The adapter performs the action returned by
actionand reports its outcome. Input BSON and wire templates are copied into retained buffers once per command. - pool
- connection-monitoring-and-pooling/connection-monitoring-and-pooling.md §§ Connection Pool, Connection Pool Clearing, Wait Queue, Connection Checkout. Host performs Connect/Close actions and reports authentication-ready connections.
- retry
- retryable-reads/retryable-reads.md §§ Supported Read Operations, Retryable Error; retryable-writes/retryable-writes.md §§ Supported Write Operations, RetryableWriteError Labels.
- session
- sessions/driver-sessions.md §§ Server Session, Command Decoration; transactions/transactions.md §§ State Machine, commitTransaction, abortTransaction; change-streams/change-streams.md §§ Resume Process, Resume Tokens.
- time
- Native/WASI use std::time::Instant, supplied by the host. Browser Wasm uses explicit monotonic ticks because std::time::Instant cannot be constructed there. Mirrors the core lane’s host-clock representation without depending on the loop.
- topology
- server-discovery-and-monitoring/server-discovery-and-monitoring.md §§ Parsing hello, TopologyType table, updateRSFromPrimary, Error Handling; server-selection/ server-selection.md §§ Read Preference, Latency Window, max-staleness.
- uri
- connection-string/connection-string-spec.md; initial-dns-seedlist-discovery/ initial-dns-seedlist-discovery.md §§ Seedlist Discovery, DNS Record Validation.
- wire
- MongoDB specifications: message/OP_MSG.md §§ OP_MSG, flagBits, sections; compression/OP_COMPRESSED.md. Integer arithmetic is checked before slicing.