Skip to main content

define_object_manager

Macro define_object_manager 

Source
macro_rules! define_object_manager {
    ($(#[$parent_meta:meta])* struct $struct_name:ident($obs_id:literal, $underlying_ptr_type: ty) for $updatable_name:ident {
        $(
            $(#[$meta:meta])*
            $field:ident: $ty:ty,
        )*
    }) => { ... };
}
Expand description

Generates builder and updater structs for OBS objects.

This macro creates two structures for managing OBS objects:

  • A {StructName}Builder struct for constructing new OBS objects
  • A {StructName}Updater struct for updating existing OBS objects

§Arguments

  • struct $struct_name: The base name for the generated builder and updater structs
  • $obs_id: A string literal representing the OBS object type ID
  • $underlying_ptr_type: The underlying pointer type (e.g., *mut libobs::obs_source)
  • $updatable_name: The name of the updatable trait/type to implement
  • Field definitions: Custom fields with their types and optional doc attributes

§Example

define_object_manager!(
    struct MySource("underlying_obs_source_id", *mut libobs::obs_source) for MySourceUpdatable {
        /// ALSA device ID (e.g., "default", "hw:0,0", or custom PCM device)
       #[obs_property(type_t = "string")]
       device_id: String,

       /// Custom PCM device name (used when device_id is "__custom__")
       #[obs_property(type_t = "string")]
       custom_pcm: String,
    }
);