use super::Client;
use crate::{
error::Result,
requests::profiles::{Request, SetParameter},
responses::profiles as responses,
};
pub struct Profiles<'a> {
pub(super) client: &'a Client,
}
impl Profiles<'_> {
#[doc(alias = "GetProfileList")]
pub async fn list(&self) -> Result<responses::Profiles> {
self.client.send_message(Request::List).await
}
#[doc(alias = "GetProfileList")]
pub async fn current(&self) -> Result<String> {
self.client
.send_message::<_, responses::Profiles>(Request::List)
.await
.map(|p| p.current)
}
#[doc(alias = "SetCurrentProfile")]
pub async fn set_current(&self, name: &str) -> Result<()> {
self.client.send_message(Request::SetCurrent { name }).await
}
#[doc(alias = "CreateProfile")]
pub async fn create(&self, name: &str) -> Result<()> {
self.client.send_message(Request::Create { name }).await
}
#[doc(alias = "RemoveProfile")]
pub async fn remove(&self, name: &str) -> Result<()> {
self.client.send_message(Request::Remove { name }).await
}
#[doc(alias = "GetProfileParameter")]
pub async fn parameter(
&self,
category: &str,
name: &str,
) -> Result<responses::ProfileParameter> {
self.client
.send_message(Request::Parameter { category, name })
.await
}
#[doc(alias = "SetProfileParameter")]
pub async fn set_parameter(&self, parameter: SetParameter<'_>) -> Result<()> {
self.client
.send_message(Request::SetParameter(parameter))
.await
}
}