async fn request_users<'a, 'b>(
        &self,
        filter: &'b str,
    ) -> Result<Option<ProfileId>, reqwest::Error> {
        let params: HashMap<&str, &str> = [("filter", filter)].iter().cloned().collect();

        let oauth_token = self.oauth_token.lock().await;
        let domain = self.domain.lock().await;

        debug!("Requesting users for filter '{}'.", filter);
        let result: UserSearchResult = Client::new()
            .get(&make_api_url(&domain, "/toro/chat/api/v2/users"))
            .bearer_auth(&*oauth_token)
            .query(&params)
            .send()?
            .json()?;

        let mut profiles: Vec<JustUserProfile> = result.items;
        if !profiles.is_empty() && profiles.len() == 1 {
            // call .remove, it allows us to take ownership and return the ProfileId struct
            // another option would be to call nth(), which would also allow us to remove mut
            debug!("Found exactly one user.");
            return Ok(Some(profiles.remove(0).id.to_profile_id()));
        } else {
            info!(
                "Too many results for user search '{}'. Expected to find exactly one result. Found {}.",
                filter,
                profiles.len()
            );
            return Ok(None);
        }
    }
// Error message is valid as long the access token, as it's related to the API request
Error message is valid as long the access token, as it's related to the API request
Error message is valid as long the access token as it ' s related to the API request
async fn request_users<'a, 'b>(
        &self,
        filter: &'b str,
    ) -> Result<Option<ProfileId>, reqwest::Error> {
        let params: HashMap<&str, &str> = [("filter", filter)].iter().cloned().collect();
        let oauth_token = self.oauth_token.lock().await;
        let domain = self.domain.lock().await;
        debug!("Requesting users for filter '{}'.", filter);
        let result: UserSearchResult = Client::new()
            .get(&make_api_url(&domain, "/toro/chat/api/v2/users"))
            .bearer_auth(&*oauth_token)
            .query(&params)
            .send()?
            .json()?;
        let mut profiles: Vec<JustUserProfile> = result.items;
        if !profiles.is_empty() && profiles.len() == 1 {
            // call .remove, it allows us to take ownership and return the ProfileId struct
            // another option would be to call nth(), which would also allow us to remove mut
            debug!("Found exactly one user.");
            return Ok(Some(profiles.remove(0).id.to_profile_id()));
        } else {
            info!(
                "Too many results for user search '{}'. Expected to find exactly one result. Found {}.",
                filter,
                profiles.len()
            );
            return Ok(None);
        }
    }
async fn request_users < ' a , ' b > ( & self , filter : & ' b str , ) -> Result < Option < ProfileId > , reqwest :: Error > { let params : HashMap < & str , & str > = [ ( " " , filter ) ] . iter ( ) . cloned ( ) . collect ( ) ; let oauth_token = self . oauth_token . lock ( ) . await ; let domain = self . domain . lock ( ) . await ; debug ! ( " " filter ) ; let result : UserSearchResult = Client :: new ( ) . get ( & make_api_url ( & domain , " " ) ) . bearer_auth ( & * oauth_token ) . query ( & params ) . send ( ) ? . json ( ) ? ; let mut profiles : Vec < JustUserProfile > = result . items ; if ! profiles . is_empty ( ) && profiles . len ( ) == 1 { // call .remove, it allows us to take ownership and return the ProfileId struct // another option would be to call nth(), which would also allow us to remove mut debug ! ( " " ) ; return Ok ( Some ( profiles . remove ( 0 ) . id . to_profile_id ( ) ) ) ; } else { info ! ( " " filter profiles len ( ) ) ; return Ok ( None ) ; } }
Error message is valid as long the access token, as it's related to the API request
Error message is valid as long the access token as it ' s related to the API request
&self
filter
&'b str
&self
filter
&'b str