add docs, add instance.get_user()
This commit is contained in:
parent
3cd19ed15e
commit
7904b3d9f8
|
@ -4,9 +4,20 @@ use crate::{
|
||||||
types::{User, UserObject},
|
types::{User, UserObject},
|
||||||
},
|
},
|
||||||
errors::InstanceServerError,
|
errors::InstanceServerError,
|
||||||
|
instance::Instance,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<'a> User<'a> {
|
impl<'a> User<'a> {
|
||||||
|
/**
|
||||||
|
Get a user object by id, or get the current user.
|
||||||
|
# Arguments
|
||||||
|
* `token` - A valid access token for the API.
|
||||||
|
* `url_api` - The URL to the API.
|
||||||
|
* `id` - The id of the user that will be retrieved. If this is None, the current user will be retrieved.
|
||||||
|
* `instance_limits` - The [`Limits`] of the instance.
|
||||||
|
# Errors
|
||||||
|
* [`InstanceServerError`] - If the request fails.
|
||||||
|
*/
|
||||||
pub async fn get(
|
pub async fn get(
|
||||||
token: &String,
|
token: &String,
|
||||||
url_api: &String,
|
url_api: &String,
|
||||||
|
@ -35,3 +46,29 @@ impl<'a> User<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Instance<'a> {
|
||||||
|
/**
|
||||||
|
Get a user object by id, or get the current user.
|
||||||
|
# Arguments
|
||||||
|
* `token` - A valid access token for the API.
|
||||||
|
* `id` - The id of the user that will be retrieved. If this is None, the current user will be retrieved.
|
||||||
|
# Errors
|
||||||
|
* [`InstanceServerError`] - If the request fails.
|
||||||
|
# Notes
|
||||||
|
This function is a wrapper around [`User::get`].
|
||||||
|
*/
|
||||||
|
pub async fn get_user(
|
||||||
|
&mut self,
|
||||||
|
token: String,
|
||||||
|
id: Option<&String>,
|
||||||
|
) -> Result<UserObject, InstanceServerError> {
|
||||||
|
User::get(
|
||||||
|
&token,
|
||||||
|
&self.urls.get_api().to_string(),
|
||||||
|
id,
|
||||||
|
&mut self.limits,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue