freedom_api/extensions/
user.rs1use std::future::Future;
2
3use crate::{api::Api, error::Error};
4use freedom_models::{account::Account, user::User};
5
6pub trait UserExt {
7 fn get_id(&self) -> Result<i32, Error>;
8
9 fn get_account<C>(&self, client: &C) -> impl Future<Output = Result<Account, Error>> + Send
10 where
11 C: Api + Send;
12}
13
14impl UserExt for User {
15 fn get_id(&self) -> Result<i32, Error> {
16 super::get_id("self", &self.links)
17 }
18
19 async fn get_account<C>(&self, client: &C) -> Result<Account, Error>
20 where
21 C: Api + Send,
22 {
23 super::get_content("account", &self.links, client).await
24 }
25}