From 7419090ac8f70352f47d668143281280169cb2fa Mon Sep 17 00:00:00 2001 From: Kevin Yeh Date: Mon, 12 Nov 2018 16:34:55 -0500 Subject: [PATCH 1/5] pub export bson macros --- src/auth.rs | 2 +- src/coll/batch.rs | 2 +- src/coll/mod.rs | 2 +- src/coll/options.rs | 2 +- src/common.rs | 2 +- src/cursor.rs | 2 +- src/db/mod.rs | 3 +-- src/db/roles.rs | 2 +- src/gridfs/file.rs | 2 +- src/gridfs/mod.rs | 2 +- src/lib.rs | 2 +- src/pool.rs | 1 + src/topology/monitor.rs | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index cb899736..6e4b6f0d 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -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}; diff --git a/src/coll/batch.rs b/src/coll/batch.rs index d9457661..43ffe4cb 100644 --- a/src/coll/batch.rs +++ b/src/coll/batch.rs @@ -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)] diff --git a/src/coll/mod.rs b/src/coll/mod.rs index 20c69f9d..91a2a8ee 100644 --- a/src/coll/mod.rs +++ b/src/coll/mod.rs @@ -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}; diff --git a/src/coll/options.rs b/src/coll/options.rs index 236e8317..badc5596 100644 --- a/src/coll/options.rs +++ b/src/coll/options.rs @@ -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; diff --git a/src/common.rs b/src/common.rs index bc8c5cb1..8f2b2064 100644 --- a/src/common.rs +++ b/src/common.rs @@ -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; diff --git a/src/cursor.rs b/src/cursor.rs index 39697f43..0aebb048 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -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; diff --git a/src/db/mod.rs b/src/db/mod.rs index 366bd9ed..c635097a 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -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; diff --git a/src/db/roles.rs b/src/db/roles.rs index a7b9f214..93f786bf 100644 --- a/src/db/roles.rs +++ b/src/db/roles.rs @@ -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 { diff --git a/src/gridfs/file.rs b/src/gridfs/file.rs index afb2da3c..a2007e34 100644 --- a/src/gridfs/file.rs +++ b/src/gridfs/file.rs @@ -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}; diff --git a/src/gridfs/mod.rs b/src/gridfs/mod.rs index 8cf27e8f..aa304a9c 100644 --- a/src/gridfs/mod.rs +++ b/src/gridfs/mod.rs @@ -30,7 +30,7 @@ //! ``` pub mod file; -use bson::{self, oid}; +use bson::{self, bson, doc, oid}; use db::{Database, ThreadedDatabase}; use coll::Collection; diff --git a/src/lib.rs b/src/lib.rs index 8593166f..efe9fd46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -126,8 +126,8 @@ #[doc(html_root_url = "https://docs.rs/mongodb")] #[macro_use] extern crate bitflags; -#[macro_use(bson, doc)] extern crate bson; +pub use bson::{bson, doc}; extern crate bufstream; extern crate byteorder; extern crate chrono; diff --git a/src/pool.rs b/src/pool.rs index 59fab399..e916a5e0 100644 --- a/src/pool.rs +++ b/src/pool.rs @@ -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; diff --git a/src/topology/monitor.rs b/src/topology/monitor.rs index df5975a9..47561f6c 100644 --- a/src/topology/monitor.rs +++ b/src/topology/monitor.rs @@ -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; From 0b158bd44d15140d9085535e994d8a29e8122612 Mon Sep 17 00:00:00 2001 From: Kevin Yeh Date: Mon, 12 Nov 2018 17:35:19 -0500 Subject: [PATCH 2/5] re-export bson --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index efe9fd46..063fde62 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -127,7 +127,6 @@ #[macro_use] extern crate bitflags; extern crate bson; -pub use bson::{bson, doc}; extern crate bufstream; extern crate byteorder; extern crate chrono; @@ -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}; @@ -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}; From ac17386a17c7973777fb667fd0a9c6ce605e1c05 Mon Sep 17 00:00:00 2001 From: Kevin Yeh Date: Mon, 12 Nov 2018 17:38:50 -0500 Subject: [PATCH 3/5] Update documentation --- Cargo.toml | 2 +- README.md | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ae4e3197..17fb0562 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/README.md b/README.md index c2da20b7..98af59bb 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,7 @@ 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: @@ -31,24 +30,30 @@ Alternately, you can use the MongoDB driver with SSL support. To do this, you mu ```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 3.10+: + +```rust +extern crate mongodb; +use mongodb::{bson, doc}; +``` + Examples -------- Here's a basic example of driver usage: ```rust -use bson::Bson; +use mongodb::Bson; use mongodb::{Client, ThreadedClient}; use mongodb::db::ThreadedDatabase; @@ -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; use mongodb::{Client, ClientOptions, ThreadedClient}; use mongodb::db::ThreadedDatabase; From 240668128450ad338a69b2f7d3463ea8eecf6872 Mon Sep 17 00:00:00 2001 From: Kevin Yeh Date: Tue, 13 Nov 2018 06:48:30 -0500 Subject: [PATCH 4/5] Fix README examples --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 98af59bb..4a29a788 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Examples Here's a basic example of driver usage: ```rust -use mongodb::Bson; +use mongodb::{Bson, bson, doc}; use mongodb::{Client, ThreadedClient}; use mongodb::db::ThreadedDatabase; @@ -63,7 +63,7 @@ fn main() { let coll = client.db("test").collection("movies"); - let doc = doc! { + let doc = doc! { "title": "Jaws", "array": [ 1, 2, 3 ], }; @@ -93,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 mongodb::Bson; +use mongodb::{Bson, bson, doc}; use mongodb::{Client, ClientOptions, ThreadedClient}; use mongodb::db::ThreadedDatabase; @@ -112,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."); From e42e494cf21893c302247ea90c4fb9eb6b60cf16 Mon Sep 17 00:00:00 2001 From: Anthony Dodd Date: Tue, 13 Nov 2018 22:06:25 -0500 Subject: [PATCH 5/5] Update README.md Co-Authored-By: kyeah --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a29a788..704bdb9c 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Then, import the bson and driver libraries within your code. extern crate mongodb; ``` -or with Rust 3.10+: +or with Rust 2018: ```rust extern crate mongodb;