Skip to content
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 source/fundamentals/connections/tls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Select from the following :guilabel:`Connection String` and
:emphasize-lines: 4-5

let uri = "<connection string>"
let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;

let tls_opts = TlsOptions::builder().build();
client_options.tls = Some(Tls::Enabled(tls_opts));
Expand Down
6 changes: 3 additions & 3 deletions source/fundamentals/performance.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ option. The following code demonstrates how to specify a value for

.. code-block:: rust

let mut client_options = ClientOptions::parse_async("<connection string>").await?;
let mut client_options = ClientOptions::parse("<connection string>").await?;
client_options.max_pool_size = Some(20);

let client = Client::with_options(client_options)?;
Expand Down Expand Up @@ -156,7 +156,7 @@ instantiating a ``Client``:

.. code-block:: rust

let mut client_options = ClientOptions::parse_async("<connection string>").await?;
let mut client_options = ClientOptions::parse("<connection string>").await?;
client_options.max_connecting = Some(3);
client_options.min_pool_size = Some(1);

Expand Down Expand Up @@ -185,7 +185,7 @@ The following code sets the value of the ``max_idle_time`` option to

.. code-block:: rust

let mut client_options = ClientOptions::parse_async("<connection string>").await?;
let mut client_options = ClientOptions::parse("<connection string>").await?;
client_options.max_idle_time = Some(Duration::new(90, 0));

let client = Client::with_options(client_options)?;
Expand Down
12 changes: 6 additions & 6 deletions source/includes/fundamentals/code-snippets/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use mongodb::{ bson::doc, options::{ ClientOptions, Credential, AuthMechanism },
async fn main() -> mongodb::error::Result<()> {
// start-default
let uri = "<connection string>";
let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;

let default_cred = Credential::builder()
.username("<db_username>".to_string())
Expand All @@ -18,7 +18,7 @@ async fn main() -> mongodb::error::Result<()> {

// start-scramsha256
let uri = "<connection string>";
let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;

let scram_sha_256_cred = Credential::builder()
.username("<db_username>".to_string())
Expand All @@ -33,7 +33,7 @@ async fn main() -> mongodb::error::Result<()> {

// start-scramsha1
let uri = "<connection string>";
let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;

let scram_sha_1_cred = Credential::builder()
.username("<db_username>".to_string())
Expand All @@ -48,7 +48,7 @@ async fn main() -> mongodb::error::Result<()> {

// start-aws
let uri = "<connection string>";
let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;

let aws_cred = Credential::builder()
.username("<access key ID>".to_string())
Expand All @@ -64,7 +64,7 @@ async fn main() -> mongodb::error::Result<()> {

// start-aws-env-var
let uri = "<connection string>";
let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;

let aws_cred = Credential::builder().mechanism(AuthMechanism::MongoDbAws).build();

Expand All @@ -78,7 +78,7 @@ async fn main() -> mongodb::error::Result<()> {
tlsCAFile = "<path to CA certificate>",
tlsCertificateKeyFile = "<path to private client key>"
);
let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;
let x509_cred = Credential::builder().mechanism(AuthMechanism::MongoDbAws).build();

client_options.credential = Some(x509_cred);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use mongodb::{ bson::doc, options::{ ClientOptions, ServerApi, ServerApiVersion
async fn main() -> mongodb::error::Result<()> {
// Replace the placeholder with your Atlas connection string
let uri = "<connection string>";
let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;

// Set the server_api field of the client_options object to Stable API version 1
let server_api = ServerApi::builder().version(ServerApiVersion::V1).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use mongodb::{ bson::doc, options::{ ClientOptions, Credential, AuthMechanism },
#[tokio::main]
async fn main() -> mongodb::error::Result<()> {
let uri = "<connection string>";
let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;

// start-ldap
let plain_cred = Credential::builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use mongodb::{
async fn main() -> mongodb::error::Result<()> {
// begin-clientoptions
let uri = "<connection string>";
let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;

let compressors = vec![
Compressor::Snappy,
Expand Down
7 changes: 2 additions & 5 deletions source/includes/fundamentals/code-snippets/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ use mongodb::{ options::{ ClientOptions, TlsOptions, Tls }, Client };
async fn main() -> mongodb::error::Result<()> {
let uri = "<connection string>";

let mut client_options = ClientOptions::parse_async(uri).await?;
let mut client_options = ClientOptions::parse(uri).await?;

let ca_file = PathBuf::from(r"<path to CA certificate>");
let key_file = PathBuf::from(r"<path to client certificate>");

let tls_opts = TlsOptions::builder()
.ca_file_path(ca_file)
.cert_key_file_path(key_file)
.build();
let tls_opts = TlsOptions::builder().ca_file_path(ca_file).cert_key_file_path(key_file).build();

client_options.tls = Some(Tls::Enabled(tls_opts));
let _client = Client::with_options(client_options)?;
Expand Down
Loading