You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 18, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+41-3Lines changed: 41 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,14 +18,22 @@ Installation
18
18
19
19
#### Importing
20
20
21
-
The 1.0 driver is available on crates.io. To use the MongoDB driver in your code, add the bson and mongodb packages to your `Cargo.toml`:
21
+
The driver is available on crates.io. To use the MongoDB driver in your code, add the bson and mongodb packages to your `Cargo.toml`:
22
22
23
23
```
24
24
[dependencies]
25
-
bson = "0.3.1"
25
+
bson = "0.3.2"
26
26
mongodb = "0.1.8"
27
27
```
28
28
29
+
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:
30
+
31
+
```
32
+
[dependencies]
33
+
...
34
+
mongodb = { version = "0.1.8", features = ["ssl"] }
35
+
```
36
+
29
37
Then, import the bson and driver libraries within your code.
30
38
31
39
```rust
@@ -46,7 +54,7 @@ use mongodb::db::ThreadedDatabase;
46
54
47
55
fnmain() {
48
56
letclient=Client::connect("localhost", 27017)
49
-
.ok().expect("Failed to initialize standalone client.");
57
+
.expect("Failed to initialize standalone client.");
50
58
51
59
letcoll=client.db("test").collection("movies");
52
60
@@ -74,3 +82,33 @@ fn main() {
74
82
}
75
83
}
76
84
```
85
+
86
+
To connect with SSL, use `ClientOptions::with_ssl` and `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):
0 commit comments