freedom_api/extensions/
user.rs

1use 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>(
10        &self,
11        client: &C,
12    ) -> impl Future<Output = Result<Account, Error>> + Send + Sync
13    where
14        C: Api;
15}
16
17impl UserExt for User {
18    fn get_id(&self) -> Result<i32, Error> {
19        super::get_id("self", &self.links)
20    }
21
22    async fn get_account<C>(&self, client: &C) -> Result<Account, Error>
23    where
24        C: Api,
25    {
26        super::get_content("account", &self.links, client).await
27    }
28}