use serde::Serialize;
use time::Duration;
use super::Client;
use crate::{error::Result, requests::transitions::Request, responses::transitions as responses};
pub struct Transitions<'a> {
pub(super) client: &'a Client,
}
impl Transitions<'_> {
#[doc(alias = "GetTransitionKindList")]
pub async fn list_kinds(&self) -> Result<Vec<String>> {
self.client
.send_message::<_, responses::TransitionKinds>(Request::GetTransitionKindList)
.await
.map(|tk| tk.transition_kinds)
}
#[doc(alias = "GetSceneTransitionList")]
pub async fn list(&self) -> Result<responses::SceneTransitionList> {
self.client
.send_message(Request::GetSceneTransitionList)
.await
}
#[doc(alias = "GetCurrentSceneTransition")]
pub async fn current(&self) -> Result<responses::CurrentSceneTransition> {
self.client
.send_message(Request::GetCurrentSceneTransition)
.await
}
#[doc(alias = "SetCurrentSceneTransition")]
pub async fn set_current(&self, name: &str) -> Result<()> {
self.client
.send_message(Request::SetCurrentSceneTransition { name })
.await
}
#[doc(alias = "SetCurrentSceneTransitionDuration")]
pub async fn set_current_duration(&self, duration: Duration) -> Result<()> {
self.client
.send_message(Request::SetCurrentSceneTransitionDuration { duration })
.await
}
#[doc(alias = "SetCurrentSceneTransitionSettings")]
pub async fn set_current_settings<T>(&self, settings: T, overlay: Option<bool>) -> Result<()>
where
T: Serialize,
{
self.client
.send_message(Request::SetCurrentSceneTransitionSettings {
settings: serde_json::to_value(&settings)
.map_err(crate::error::SerializeCustomDataError)?,
overlay,
})
.await
}
#[doc(alias = "GetCurrentSceneTransitionCursor")]
pub async fn current_cursor(&self) -> Result<f32> {
self.client
.send_message::<_, responses::TransitionCursor>(
Request::GetCurrentSceneTransitionCursor,
)
.await
.map(|tc| tc.transition_cursor)
}
#[doc(alias = "TriggerStudioModeTransition")]
pub async fn trigger(&self) -> Result<()> {
self.client
.send_message(Request::TriggerStudioModeTransition)
.await
}
#[doc(alias = "SetTBarPosition")]
pub async fn set_tbar_position(&self, position: f32, release: Option<bool>) -> Result<()> {
self.client
.send_message(Request::SetTbarPosition { position, release })
.await
}
}