Skip to content
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

Refactor streaming_search_inner to return a Stream object #15

Merged
merged 13 commits into from
Oct 29, 2024
2 changes: 1 addition & 1 deletion Cargo.toml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the return type of a function warrants a major version bump.

PS. cargo-semver-checks is a pretty neat semver linter.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumped major version

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ readme = "README.md"
repository = "https://github.com/keaz/simple-ldap"
keywords = ["ldap", "ldap3", "async", "high-level"]
name = "simple-ldap"
version = "1.6.1"
version = "1.7.0"
edition = "2021"


Expand Down
42 changes: 27 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,33 @@ async fn main() -> Result<()> {
};

let pool = pool::build_connection_pool(&ldap_config).await;
let mut ldap = pool.pool.get_connection().await.unwrap();

let name_filter = EqFilter::from("cn".to_string(), "James".to_string());
let result = ldap
.streaming_search::<User>(
"ou=people,dc=example,dc=com",
self::ldap3::Scope::OneLevel,
&name_filter,
2,
vec!["cn", "sn", "uid"],
)
.await;
assert!(result.is_ok());
let result = result.unwrap();
assert!(result.len() == 2);
let ldap = pool.get_connection().await.unwrap();

let name_filter = EqFilter::from("cn".to_string(), "James".to_string());
let attra = vec!["cn", "sn", "uid"];
let result = ldap
.streaming_search(
"ou=people,dc=example,dc=com",
self::ldap3::Scope::OneLevel,
&name_filter,
2,
&attra,
)
.await;

let mut result = result.unwrap();
let mut count = 0;
loop {
match result.next::<User>().await {
Ok(StreamResult::Record(_)) => {
count += 1;
}
_ => {
break;
}
}
}
assert!(count == 2);
Ok(ldap.unbind().await?)
}
```
Expand Down
Loading
Loading