Skip to content

Commit a1ebc6d

Browse files
committed
(add-start-tls) updated example code in the readme, removed references
to try!
1 parent 263a5c2 commit a1ebc6d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ use openldap::*;
1515
use openldap::errors::*;
1616

1717
fn some_ldap_function(ldap_uri: &str, ldap_user: &str, ldap_pass: &str) -> Result<(), LDAPError> {
18-
19-
let ldap = try!(RustLDAP::new(ldap_uri));
18+
let ldap = RustLDAP::new(ldap_uri).unwrap();
2019

2120
ldap.set_option(codes::options::LDAP_OPT_PROTOCOL_VERSION,
2221
&codes::versions::LDAP_VERSION3);
2322

2423
ldap.set_option(codes::options::LDAP_OPT_X_TLS_REQUIRE_CERT,
2524
&codes::options::LDAP_OPT_X_TLS_DEMAND);
2625

27-
try!(ldap.simple_bind(ldap_user, ldap_pass));
26+
ldap.simple_bind(ldap_user, ldap_pass).unwrap();
2827

2928
// Returns a LDAPResponse, a.k.a. Vec<HashMap<String,Vec<String>>>.
3029
let _ = ldap.simple_search("CN=Stephen,OU=People,DC=Earth",
@@ -49,22 +48,24 @@ network. See https://linux.die.net/man/3/ldap_start_tls_s for more information
4948

5049
```rust
5150
fn some_ldap_function(ldap_uri: &str, ldap_user: &str, ldap_pass: &str) -> Result<(), LDAPError> {
52-
let ldap = try!(RustLDAP::new(ldap_uri));
51+
let ldap = RustLDAP::new(ldap_uri).unwrap();
5352

5453
ldap.set_option(codes::options::LDAP_OPT_PROTOCOL_VERSION,
5554
&codes::versions::LDAP_VERSION3);
5655

5756
ldap.set_option(codes::options::LDAP_OPT_X_TLS_REQUIRE_CERT,
5857
&codes::options::LDAP_OPT_X_TLS_DEMAND);
5958
ldap.set_option(openldap::codes::options::LDAP_OPT_X_TLS_NEWCTX, &0);
59+
6060
ldap.start_tls(None, None);
6161

62-
try!(ldap.simple_bind(ldap_user, ldap_pass));
62+
ldap.simple_bind(ldap_user, ldap_pass).unwrap();
63+
64+
Ok(())
6365
}
6466

6567
```
66-
When performing an operation that can fail, use the `try!` macro. On failure,
67-
an `openldap::errors::LDAPError` will be returned that includes a detailed
68+
On failure, an `openldap::errors::LDAPError` will be returned that includes a detailed
6869
message from the native OpenLDAP library.
6970

7071
## contributing

0 commit comments

Comments
 (0)