-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUST-765 Conform API to the Rust API guidelines #337
Changes from all commits
26dd227
b112b31
dab55f2
ec8995b
46a6a4b
2602c71
b0a0378
d860375
c9a6d3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
authors = ["Saghm Rossi <[email protected]>", "Patrick Freed <[email protected]>", "Isabel Atkinson <[email protected]>"] | ||
description = "The official MongoDB driver for Rust" | ||
edition = "2018" | ||
documentation = "https://docs.rs/mongodb" | ||
keywords = ["mongo", "mongodb", "database", "bson", "nosql"] | ||
categories = ["asynchronous", "database", "web-programming"] | ||
repository = "https://github.com/mongodb/mongo-rust-driver" | ||
license = "Apache-2.0" | ||
readme = "README.md" | ||
|
@@ -37,7 +37,10 @@ bitflags = "1.1.0" | |
bson = { git = "https://github.com/mongodb/bson-rust" } | ||
chrono = "0.4.7" | ||
derivative = "2.1.1" | ||
futures = "0.3.5" | ||
futures-core = "0.3.14" | ||
futures-io = "0.3.14" | ||
futures-util = { version = "0.3.14", features = ["io"] } | ||
futures-executor = "0.3.14" | ||
hex = "0.4.0" | ||
hmac = "0.10.1" | ||
lazy_static = "1.4.0" | ||
|
@@ -110,6 +113,7 @@ features = ["v4"] | |
approx = "0.4.0" | ||
derive_more = "0.99.13" | ||
function_name = "0.2.0" | ||
futures = "0.3" | ||
pretty_assertions = "0.7.1" | ||
serde_json = "1.0.64" | ||
semver = "0.11.0" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,8 +98,8 @@ impl Client { | |
/// | ||
/// See the documentation on | ||
/// [`ClientOptions::parse`](options/struct.ClientOptions.html#method.parse) for more details. | ||
pub async fn with_uri_str(uri: &str) -> Result<Self> { | ||
let options = ClientOptions::parse_uri(uri, None).await?; | ||
pub async fn with_uri_str(uri: impl AsRef<str>) -> Result<Self> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also update the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for bringing this up, I meant to open a thread discussing this in my original review. Those two methods are a little tricky because they have generic parameters, so if we include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh right, I forgot about that restriction. I agree with your reasoning; I don't think the small benefit of having There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sgtm |
||
let options = ClientOptions::parse_uri(uri.as_ref(), None).await?; | ||
|
||
Client::with_options(options) | ||
} | ||
|
@@ -184,7 +184,7 @@ impl Client { | |
.into_iter() | ||
.map(|doc| { | ||
let name = doc.get("name").and_then(Bson::as_str).ok_or_else(|| { | ||
ErrorKind::ResponseError { | ||
ErrorKind::InvalidResponse { | ||
message: "Expected \"name\" field in server response, but it was not \ | ||
found" | ||
.to_string(), | ||
|
@@ -309,7 +309,7 @@ impl Client { | |
.await; | ||
|
||
if !change_occurred { | ||
return Err(ErrorKind::ServerSelectionError { | ||
return Err(ErrorKind::ServerSelection { | ||
message: self | ||
.inner | ||
.topology | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
futures
crate contains a number of async-related APIs that are widely used in the community, the most important one (for us) being theStream
trait, which our various cursor types conform to (it's basically the async iterator trait). Because we publicly conform to it, we'll need to do so for each major version offutures
to ensure full compatibility. Thefutures
crate is really just a collection of rexports from "sub" crates though (many of which are listed here now), each of which has differing stability exceptions. Thefutures-core
one, which containsStream
, is purposefully much more stable than the others, and it will likely go straight from0.3
to1.0
without any more breaking versions, whereasfutures-util
andfutures
itself will have potentially many major versions. For that reason, I updated this to depend directly onfutures-core
instead offutures
to reduce the number of separateStream
implementations we'll need to provide for the lifetime of 2.0. This page gives a nice overview of the situation and why we need to do this.