Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Re-export bson lib #290

Merged
merged 5 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "Apache-2.0"
name = "mongodb"
readme = "README.md"
repository = "https://github.com/mongodb-labs/mongo-rust-driver-prototype"
version = "0.3.10"
version = "0.3.11"

[dependencies]
bitflags = "1.0.0"
Expand Down
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,38 @@ The driver is available on crates.io. To use the MongoDB driver in your code, ad

```toml
[dependencies]
bson = "0.12.2"
mongodb = "0.3.10"
mongodb = "0.3.11"
```

Alternately, you can use the MongoDB driver with SSL support. To do this, you must have OpenSSL installed on your system. Then, enable the `ssl` feature for MongoDB in your Cargo.toml:

```toml
[dependencies]
# ...
mongodb = { version = "0.3.10", features = ["ssl"] }
mongodb = { version = "0.3.11", features = ["ssl"] }
```

Then, import the bson and driver libraries within your code.

```rust
#[macro_use(bson, doc)]
extern crate bson;
extern crate mongodb;
```

or with Rust 2018:

```rust
extern crate mongodb;
use mongodb::{bson, doc};
```

Examples
--------

Here's a basic example of driver usage:

```rust
use bson::Bson;
use mongodb::{Bson, bson, doc};
use mongodb::{Client, ThreadedClient};
use mongodb::db::ThreadedDatabase;

Expand All @@ -58,7 +63,7 @@ fn main() {

let coll = client.db("test").collection("movies");

let doc = doc! {
let doc = doc! {
"title": "Jaws",
"array": [ 1, 2, 3 ],
};
Expand Down Expand Up @@ -88,7 +93,7 @@ fn main() {
To connect with SSL, use either `ClientOptions::with_ssl` or `ClientOptions::with_unauthenticated_ssl` and then `Client::connect_with_options`. Afterwards, the client can be used as above (note that the server will have to be configured to accept SSL connections and that you'll have to generate your own keys and certificates):

```rust
use bson::Bson;
use mongodb::{Bson, bson, doc};
use mongodb::{Client, ClientOptions, ThreadedClient};
use mongodb::db::ThreadedDatabase;

Expand All @@ -107,6 +112,13 @@ fn main() {
let client = Client::connect_with_options("localhost", 27017, options)
.expect("Failed to initialize standalone client.");

let coll = client.db("test").collection("movies");

let doc = doc! {
"title": "Jaws",
"array": [ 1, 2, 3 ],
};

// Insert document into 'test.movies' collection
coll.insert_one(doc.clone(), None)
.ok().expect("Failed to insert document.");
Expand Down
2 changes: 1 addition & 1 deletion src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Authentication schemes.
use bson::Bson::{self, Binary};
use bson::Document;
use bson::{Document, bson, doc};
use bson::spec::BinarySubtype::Generic;
use CommandType::Suppressed;
use hmac::{Hmac, Mac};
Expand Down
2 changes: 1 addition & 1 deletion src/coll/batch.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Models for collection-level batch operations.
use super::options::WriteModel;

use bson::{Bson, Document};
use bson::{Bson, Document, bson, doc};
use std::convert::From;

#[derive(Debug, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion src/coll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod error;
pub mod options;
pub mod results;

use bson::{self, Bson, oid};
use bson::{self, Bson, bson, doc, oid};
use command_type::CommandType;

use self::batch::{Batch, DeleteModel, UpdateModel};
Expand Down
2 changes: 1 addition & 1 deletion src/coll/options.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Options for collection-level operations.
use bson::{self, Bson};
use bson::{self, Bson, bson, doc};
use common::{ReadPreference, WriteConcern};
use Error::ArgumentError;
use Result;
Expand Down
2 changes: 1 addition & 1 deletion src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use Error::{self, ArgumentError};
use Result;

use bson::{self, Bson};
use bson::{self, Bson, bson, doc};
use std::collections::BTreeMap;
use std::str::FromStr;

Expand Down
2 changes: 1 addition & 1 deletion src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use {Client, CommandType, Error, ErrorCode, Result, ThreadedClient};
use apm::{CommandStarted, CommandResult, EventRunner};

use bson::{self, Bson};
use bson::{self, bson, doc, Bson};
use common::{merge_options, ReadMode, ReadPreference};
use coll::options::FindOptions;
use pool::PooledStream;
Expand Down
3 changes: 1 addition & 2 deletions src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ pub mod options;
pub mod roles;

use auth::Authenticator;
use bson;
use bson::Bson;
use bson::{self, bson, doc, Bson};
use {Client, CommandType, ThreadedClient, Result};
use Error::{CursorNotFoundError, OperationError, ResponseError};
use coll::Collection;
Expand Down
2 changes: 1 addition & 1 deletion src/db/roles.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Role-based database and command authorization.
use std::string::ToString;

use bson::Bson;
use bson::{Bson, bson, doc};

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum SingleDatabaseRole {
Expand Down
2 changes: 1 addition & 1 deletion src/gridfs/file.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Lower-level file and chunk representations in GridFS.
use bson::{self, Bson, oid};
use bson::{self, Bson, bson, doc, oid};
use bson::spec::BinarySubtype;

use chrono::{DateTime, Utc};
Expand Down
2 changes: 1 addition & 1 deletion src/gridfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//! ```
pub mod file;

use bson::{self, oid};
use bson::{self, bson, doc, oid};

use db::{Database, ThreadedDatabase};
use coll::Collection;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
#[doc(html_root_url = "https://docs.rs/mongodb")]
#[macro_use]
extern crate bitflags;
#[macro_use(bson, doc)]
extern crate bson;
extern crate bufstream;
extern crate byteorder;
Expand Down Expand Up @@ -163,6 +162,8 @@ mod apm;
mod auth;
mod command_type;

pub use bson::*;

pub use apm::{CommandStarted, CommandResult};
pub use command_type::CommandType;
pub use error::{Error, ErrorCode, Result};
Expand All @@ -175,7 +176,6 @@ use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicIsize, Ordering, ATOMIC_ISIZE_INIT};

use apm::Listener;
use bson::Bson;
use common::{ReadPreference, ReadMode, WriteConcern};
use connstring::ConnectionString;
use db::{Database, ThreadedDatabase};
Expand Down
1 change: 1 addition & 0 deletions src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use cursor::Cursor;
use stream::{Stream, StreamConnector};
use wire_protocol::flags::OpQueryFlags;

use bson::{bson, doc};
use bufstream::BufStream;

use std::fmt;
Expand Down
2 changes: 1 addition & 1 deletion src/topology/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use {Client, Result};
use Error::{self, ArgumentError, OperationError};

use bson::{self, Bson, oid};
use bson::{self, Bson, bson, doc, oid};
use chrono::{DateTime, Utc};

use coll::options::FindOptions;
Expand Down