mirror of https://github.com/dnaka91/obws
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
use anyhow::Result;
|
|
|
|
use super::Client;
|
|
use crate::requests::RequestType;
|
|
use crate::responses;
|
|
|
|
/// API functions related to profiles.
|
|
pub struct Profiles<'a> {
|
|
pub(super) client: &'a Client,
|
|
}
|
|
|
|
impl<'a> Profiles<'a> {
|
|
/// Set the currently active profile.
|
|
///
|
|
/// - `profile_name`: Name of the desired profile.
|
|
pub async fn set_current_profile(&self, profile_name: String) -> Result<()> {
|
|
self.client
|
|
.send_message(RequestType::SetCurrentProfile { profile_name })
|
|
.await
|
|
}
|
|
|
|
/// Get the name of the current profile.
|
|
pub async fn get_current_profile(&self) -> Result<String> {
|
|
self.client
|
|
.send_message::<responses::CurrentProfile>(RequestType::GetCurrentProfile)
|
|
.await
|
|
.map(|cp| cp.profile_name)
|
|
}
|
|
|
|
/// Get a list of available profiles.
|
|
pub async fn list_profiles(&self) -> Result<Vec<responses::Profile>> {
|
|
self.client
|
|
.send_message::<responses::Profiles>(RequestType::ListProfiles)
|
|
.await
|
|
.map(|cp| cp.profiles)
|
|
}
|
|
}
|