libobs_wrapper\data/
lib_support.rs

1//! Use the `libobs-source` crate to create sources like `window_capture` for obs
2
3use crate::{
4    data::ObsData,
5    runtime::ObsRuntime,
6    utils::{traits::ObsUpdatable, ObjectInfo, ObsError, ObsString},
7};
8
9use super::updater::ObsDataUpdater;
10
11pub trait StringEnum {
12    fn to_str(&self) -> &str;
13}
14
15//TODO Use generics to make the build function return a trait rather than a struct
16/// Trait for building OBS sources.
17pub trait ObsObjectBuilder {
18    fn new<T: Into<ObsString> + Send + Sync>(
19        name: T,
20        runtime: ObsRuntime,
21    ) -> Result<Self, ObsError>
22    where
23        Self: Sized;
24
25    /// Returns the name of the source.
26    fn get_name(&self) -> ObsString;
27
28    fn build(self) -> Result<ObjectInfo, ObsError>
29    where
30        Self: Sized;
31
32    fn get_settings(&self) -> &ObsData;
33    fn get_settings_updater(&mut self) -> &mut ObsDataUpdater;
34
35    fn get_hotkeys(&self) -> &ObsData;
36    fn get_hotkeys_updater(&mut self) -> &mut ObsDataUpdater;
37
38    /// Returns the ID of the source.
39    fn get_id() -> ObsString;
40}
41
42pub trait ObsObjectUpdater<'a> {
43    type ToUpdate: ObsUpdatable;
44    fn create_update(
45        runtime: ObsRuntime,
46        updatable: &'a mut Self::ToUpdate,
47    ) -> Result<Self, ObsError>
48    where
49        Self: Sized;
50
51    fn get_settings(&self) -> &ObsData;
52    fn get_settings_updater(&mut self) -> &mut ObsDataUpdater;
53
54    fn update(self) -> Result<(), ObsError>;
55
56    /// Returns the ID of the object
57    fn get_id() -> ObsString;
58}