Skip to content

Commit ab1183c

Browse files
committed
minor: fix sync tests
1 parent 4a71a26 commit ab1183c

File tree

7 files changed

+36
-39
lines changed

7 files changed

+36
-39
lines changed

src/client/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ const DEFAULT_SERVER_SELECTION_TIMEOUT: Duration = Duration::from_secs(30);
3737
/// so it can safely be shared across threads. For example:
3838
///
3939
/// ```rust
40+
/// # #[cfg(not(feature = "sync"))]
4041
/// # use mongodb::{Client, error::Result};
4142
/// #
43+
/// # #[cfg(not(feature = "sync"))]
4244
/// # async fn start_workers() -> Result<()> {
4345
/// let client = Client::with_uri_str("mongodb://example.com").await?;
4446
///

src/coll/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ const MAX_INSERT_DOCS_BYTES: usize = 16 * 1000 * 1000;
4646
///
4747
/// ```rust
4848
/// # use bson::{bson, doc};
49-
/// # use mongodb::{Client, error::Result};
49+
/// # use mongodb::error::Result;
5050
/// #
51+
/// # #[cfg(not(feature = "sync"))]
5152
/// # async fn start_workers() -> Result<()> {
53+
/// # use mongodb::Client;
54+
/// #
5255
/// # let client = Client::with_uri_str("mongodb://example.com").await?;
5356
/// let coll = client.database("items").collection("in_stock");
5457
///

src/db/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ use crate::{
3535
///
3636
/// ```rust
3737
///
38+
/// # #[cfg(not(feature = "sync"))]
3839
/// # use mongodb::{Client, error::Result};
39-
///
40+
/// #
41+
/// # #[cfg(not(feature = "sync"))]
4042
/// # async fn start_workers() -> Result<()> {
4143
/// # let client = Client::with_uri_str("mongodb://example.com").await?;
4244
/// let db = client.database("items");

src/event/cmap.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,11 @@ pub struct ConnectionCheckedInEvent {
190190
/// # ConnectionCheckoutFailedEvent
191191
/// # },
192192
/// # options::ClientOptions,
193-
/// # Client,
194193
/// # };
194+
/// # #[cfg(feature = "sync")]
195+
/// # use mongodb::sync::Client;
196+
/// # #[cfg(not(feature = "sync"))]
197+
/// # use mongodb::Client;
195198
/// #
196199
/// struct FailedCheckoutLogger;
197200
///

src/event/command.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@ pub struct CommandFailedEvent {
8484
/// # CommandFailedEvent
8585
/// # },
8686
/// # options::ClientOptions,
87-
/// # Client,
8887
/// # };
88+
/// # #[cfg(feature = "sync")]
89+
/// # use mongodb::sync::Client;
90+
/// # #[cfg(not(feature = "sync"))]
91+
/// # use mongodb::Client;
8992
/// #
9093
/// struct FailedCommandLogger;
9194
///

src/lib.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
//! [`Client::with_uri_str`](struct.Client.html#method.with_uri_str):
66
//!
77
//! ```rust
8+
//! # #[cfg(not(feature = "sync"))]
89
//! # use mongodb::{Client, error::Result};
910
//! #
11+
//! # #[cfg(not(feature = "sync"))]
1012
//! # async fn make_client() -> Result<Client> {
1113
//! let client = Client::with_uri_str("mongodb://localhost:27017/").await?;
1214
//! # Ok(client)
@@ -19,8 +21,11 @@
1921
//! # use mongodb::{
2022
//! # error::Result,
2123
//! # options::{StreamAddress, ClientOptions},
22-
//! # Client,
2324
//! # };
25+
//! # #[cfg(feature = "sync")]
26+
//! # use mongodb::sync::Client;
27+
//! # #[cfg(not(feature = "sync"))]
28+
//! # use mongodb::Client;
2429
//! #
2530
//! # fn make_client() -> Result<Client> {
2631
//! let options = ClientOptions::builder()
@@ -42,10 +47,13 @@
4247
//!
4348
//! ```rust
4449
//! # use bson::{bson, doc};
45-
//! # use mongodb::{Client, error::Result};
50+
//! # use mongodb::error::Result;
51+
//! # #[cfg(not(feature = "sync"))]
52+
//! # use mongodb::Client;
4653
//! #
54+
//! # #[cfg(not(feature = "sync"))]
4755
//! # async fn do_stuff() -> Result<()> {
48-
//! # let client = Client::with_uri_str("mongodb://localhost:27017").await?;
56+
//! # let client = Client::with_uri_str("mongodb://example.com").await?;
4957
//! #
5058
//! let db = client.database("some_db");
5159
//! for coll_name in db.list_collection_names(None).await? {
@@ -133,16 +141,20 @@ define_if_single_runtime_enabled! {
133141
pub use coll::Namespace;
134142
}
135143

136-
#[cfg(all(feature = "tokio-runtime", feature = "async-std-runtime", not(feature = "sync")))]
144+
#[cfg(all(
145+
feature = "tokio-runtime",
146+
feature = "async-std-runtime",
147+
not(feature = "sync")
148+
))]
137149
compile_error!(
138150
"`tokio-runtime` and `async-runtime` can't both be enabled; either disable \
139151
`async-std-runtime` or set `default-features = false` in your Cargo.toml"
140152
);
141153

142154
#[cfg(all(feature = "tokio-runtime", feature = "sync"))]
143155
compile_error!(
144-
"`tokio-runtime` and `sync` can't both be enabled; either disable \
145-
`sync` or set `default-features = false` in your Cargo.toml"
156+
"`tokio-runtime` and `sync` can't both be enabled; either disable `sync` or set \
157+
`default-features = false` in your Cargo.toml"
146158
);
147159

148160
#[cfg(all(not(feature = "tokio-runtime"), not(feature = "async-std-runtime")))]

src/sync/cursor.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
use bson::Document;
22
use futures::StreamExt;
33

4-
use crate::{
5-
cursor::ImpatientCursor as AsyncImpatientCursor,
6-
error::Result,
7-
Cursor as AsyncCursor,
8-
RUNTIME,
9-
};
4+
use crate::{error::Result, Cursor as AsyncCursor, RUNTIME};
105

116
/// A `Cursor` streams the result of a query. When a query is made, a `Cursor` will be returned with
127
/// the first batch of results from the server; the documents will be returned as the `Cursor` is
@@ -71,10 +66,6 @@ impl Cursor {
7166
pub(crate) fn new(async_cursor: AsyncCursor) -> Self {
7267
Self { async_cursor }
7368
}
74-
75-
pub fn into_impatient(self) -> ImpatientCursor {
76-
ImpatientCursor::new(self.async_cursor.into_impatent())
77-
}
7869
}
7970

8071
impl Iterator for Cursor {
@@ -84,22 +75,3 @@ impl Iterator for Cursor {
8475
RUNTIME.block_on(self.async_cursor.next())
8576
}
8677
}
87-
88-
#[derive(Debug)]
89-
pub struct ImpatientCursor {
90-
async_cursor: AsyncImpatientCursor,
91-
}
92-
93-
impl ImpatientCursor {
94-
pub(crate) fn new(async_cursor: AsyncImpatientCursor) -> Self {
95-
Self { async_cursor }
96-
}
97-
}
98-
99-
impl Iterator for ImpatientCursor {
100-
type Item = Result<Document>;
101-
102-
fn next(&mut self) -> Option<Self::Item> {
103-
RUNTIME.block_on(self.async_cursor.next())
104-
}
105-
}

0 commit comments

Comments
 (0)