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 parameter types: change some String parameters to traits and… #61

Merged
merged 2 commits into from
Oct 31, 2024
Merged
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
4 changes: 3 additions & 1 deletion cli/src/ldap_opt.rs
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@ impl Default for SyncRequestMode {
}
*/

use url::Url;

#[derive(Debug, clap::Subcommand)]
enum LdapAction {
/// Search a directory server
@@ -58,7 +60,7 @@ struct LdapOpt {
verbose: bool,

#[clap(short = 'H', long = "url")]
url: url::Url,
url: Url,

#[clap(short = 'j', long = "json")]
json: bool,
6 changes: 3 additions & 3 deletions client/src/addirsync.rs
Original file line number Diff line number Diff line change
@@ -18,17 +18,17 @@ pub struct LdapSyncRepl {

impl LdapClient {
#[tracing::instrument(level = "debug", skip_all)]
pub async fn ad_dirsync(
pub async fn ad_dirsync<S: Into<String>>(
&mut self,
basedn: String,
basedn: S,
cookie: Option<Vec<u8>>,
) -> crate::LdapResult<LdapSyncRepl> {
let msgid = self.get_next_msgid();

let msg = LdapMsg {
msgid,
op: LdapOp::SearchRequest(LdapSearchRequest {
base: basedn,
base: basedn.into(),
scope: LdapSearchScope::Subtree,
aliases: LdapDerefAliases::Never,
sizelimit: 0,
5 changes: 3 additions & 2 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -487,15 +487,16 @@ impl LdapClient {
}

#[tracing::instrument(level = "debug", skip_all)]
pub async fn bind(&mut self, dn: String, pw: String) -> LdapResult<()> {
pub async fn bind<S: Into<String>>(&mut self, dn: S, pw: S) -> LdapResult<()> {
let dn = dn.into();
info!(%dn);
let msgid = self.get_next_msgid();

let msg = LdapMsg {
msgid,
op: LdapOp::BindRequest(LdapBindRequest {
dn,
cred: LdapBindCred::Simple(pw),
cred: LdapBindCred::Simple(pw.into()),
}),
ctrl: vec![],
};
6 changes: 3 additions & 3 deletions client/src/search.rs
Original file line number Diff line number Diff line change
@@ -8,17 +8,17 @@ pub struct LdapSearchResult {

impl LdapClient {
#[tracing::instrument(level = "debug", skip_all)]
pub async fn search(
pub async fn search<S: Into<String>>(
&mut self,
basedn: String,
basedn: S,
filter: LdapFilter,
) -> crate::LdapResult<LdapSearchResult> {
let msgid = self.get_next_msgid();

let msg = LdapMsg {
msgid,
op: LdapOp::SearchRequest(LdapSearchRequest {
base: basedn,
base: basedn.into(),
scope: LdapSearchScope::Subtree,
aliases: LdapDerefAliases::Never,
sizelimit: 0,
6 changes: 3 additions & 3 deletions client/src/syncrepl.rs
Original file line number Diff line number Diff line change
@@ -46,9 +46,9 @@ pub enum LdapSyncRepl {

impl LdapClient {
#[tracing::instrument(level = "debug", skip_all)]
pub async fn syncrepl(
pub async fn syncrepl<S: Into<String>>(
&mut self,
basedn: String,
basedn: S,
filter: LdapFilter,
cookie: Option<Vec<u8>>,
mode: SyncRequestMode,
@@ -58,7 +58,7 @@ impl LdapClient {
let msg = LdapMsg {
msgid,
op: LdapOp::SearchRequest(LdapSearchRequest {
base: basedn,
base: basedn.into(),
scope: LdapSearchScope::Subtree,
aliases: LdapDerefAliases::Never,
sizelimit: 0,