Fix a few compile warnings

This commit is contained in:
ViViDboarder 2020-03-05 13:07:14 -08:00
parent 76e803a472
commit 42489d39e1
2 changed files with 11 additions and 7 deletions

View File

@ -150,7 +150,7 @@ impl Client {
} }
/// Get all existing users /// Get all existing users
pub fn users(&mut self) -> Result<Vec<User>, Box<Error>> { pub fn users(&mut self) -> Result<Vec<User>, Box<dyn Error>> {
let all_users: Vec<User> = self.get("/users").json()?; let all_users: Vec<User> = self.get("/users").json()?;
Ok(all_users) Ok(all_users)
} }

View File

@ -27,7 +27,7 @@ fn invite_users(
config: &config::Config, config: &config::Config,
client: &mut bw_admin::Client, client: &mut bw_admin::Client,
start_loop: bool, start_loop: bool,
) -> Result<(), Box<Error>> { ) -> Result<(), Box<dyn Error>> {
if start_loop { if start_loop {
start_sync_loop(config, client)?; start_sync_loop(config, client)?;
} else { } else {
@ -38,7 +38,7 @@ fn invite_users(
} }
/// Creates set of email addresses for users that already exist in Bitwarden /// Creates set of email addresses for users that already exist in Bitwarden
fn get_existing_users(client: &mut bw_admin::Client) -> Result<HashSet<String>, Box<Error>> { fn get_existing_users(client: &mut bw_admin::Client) -> Result<HashSet<String>, Box<dyn Error>> {
let all_users = client.users()?; let all_users = client.users()?;
let mut user_emails = HashSet::with_capacity(all_users.len()); let mut user_emails = HashSet::with_capacity(all_users.len());
for user in all_users { for user in all_users {
@ -60,7 +60,11 @@ fn get_existing_users(client: &mut bw_admin::Client) -> Result<HashSet<String>,
} }
/// Creates an LDAP connection, authenticating if necessary /// Creates an LDAP connection, authenticating if necessary
fn ldap_client(ldap_url: String, bind_dn: String, bind_pw: String) -> Result<LdapConn, Box<Error>> { fn ldap_client(
ldap_url: String,
bind_dn: String,
bind_pw: String,
) -> Result<LdapConn, Box<dyn Error>> {
let ldap = LdapConn::new(ldap_url.as_str())?; let ldap = LdapConn::new(ldap_url.as_str())?;
match ldap.simple_bind(bind_dn.as_str(), bind_pw.as_str()) { match ldap.simple_bind(bind_dn.as_str(), bind_pw.as_str()) {
_ => {} _ => {}
@ -70,7 +74,7 @@ fn ldap_client(ldap_url: String, bind_dn: String, bind_pw: String) -> Result<Lda
} }
/// Retrieves search results from ldap /// Retrieves search results from ldap
fn search_entries(config: &config::Config) -> Result<Vec<SearchEntry>, Box<Error>> { fn search_entries(config: &config::Config) -> Result<Vec<SearchEntry>, Box<dyn Error>> {
let ldap = ldap_client( let ldap = ldap_client(
config.get_ldap_url(), config.get_ldap_url(),
config.get_ldap_bind_dn(), config.get_ldap_bind_dn(),
@ -108,7 +112,7 @@ fn search_entries(config: &config::Config) -> Result<Vec<SearchEntry>, Box<Error
fn invite_from_ldap( fn invite_from_ldap(
config: &config::Config, config: &config::Config,
client: &mut bw_admin::Client, client: &mut bw_admin::Client,
) -> Result<(), Box<Error>> { ) -> Result<(), Box<dyn Error>> {
match get_existing_users(client) { match get_existing_users(client) {
Ok(existing_users) => { Ok(existing_users) => {
let mail_field = config.get_ldap_mail_field(); let mail_field = config.get_ldap_mail_field();
@ -150,7 +154,7 @@ fn invite_from_ldap(
fn start_sync_loop( fn start_sync_loop(
config: &config::Config, config: &config::Config,
client: &mut bw_admin::Client, client: &mut bw_admin::Client,
) -> Result<(), Box<Error>> { ) -> Result<(), Box<dyn Error>> {
let interval = Duration::from_secs(config.get_ldap_sync_interval_seconds()); let interval = Duration::from_secs(config.get_ldap_sync_interval_seconds());
loop { loop {
invite_from_ldap(config, client)?; invite_from_ldap(config, client)?;