Module mongod::blocking[][src]

A blocking Client API.

The blocking Client will block the current thread to execute, instead of returning futures that need to be executed on a runtime.

Optional

This requires the optional blocking feature to be enabled.

Making requests

This client functions in the same way as the async Client except it blocks, here is an example to fetch users from a collection.

use mongod::Collection;

let client = mongod::blocking::Client::new();

let mut cursor = client.find::<User, _>(None).unwrap();
while let Some(res) = cursor.next() {
    if let Ok(doc) = res {
        let user: User = User::from_document(doc).unwrap();
        println!("{:?}", user);
    }
}

Structs

Client

A synchronous Client to query mongo with.

ClientBuilder

A ClientBuilder can be used to create a Client with custom configuration.

Cursor

A blocking version of the mongodb::Cursor.