Skip to main content

grp_core/common/users/
orgs.rs

1use crate::animation;
2use crate::error::structs::Error;
3use crate::common::users::structs::User;
4use crate::config::Config;
5use crate::platform::Platform;
6
7impl Platform {
8    
9    /// # Return
10    /// a vector of `grp_core::structs::User`
11    /// 
12    /// # Error
13    /// a `grp_core::Error` containing the detail of the error. 
14    pub async fn get_logged_orgs(&self, config: &Config) -> Result<Vec<User>, Error> {
15        let an = Box::new(animation::None);
16        match self.list_orgs(config, &an).await {
17            (orgs, None, _) if !orgs.is_empty() => Ok(orgs),
18            (orgs, None, err) if orgs.is_empty() && !err.is_empty() => {
19                Err(Error::colection(err))
20            },
21            (_, Some(e), _) => Err(e),
22            (_, None, _) => Ok(Vec::new())
23        }
24    }
25}