pub fn plugin_register_add_csurf_inst<T>(
        &mut self,
        control_surface: Box<T>,
    ) -> ReaperFunctionResult<RegistrationHandle<T>>
    where
        T: ControlSurface + 'static,
    {
        // Create thin pointer of control_surface before making it a trait object (for being able to
        // restore the original control_surface later).
        let control_surface_thin_ptr: NonNull<T> = control_surface.as_ref().into();
        // Create low-level Rust control surface which delegates to the medium-level one.
        let low_cs = ControlSurfaceAdapter::new(control_surface, &self.reaper.get_app_version());
        // Create the C++ counterpart surface (we need to box the Rust side twice in order to obtain
        // a thin pointer for passing it to C++ as callback target).
        let double_boxed_low_cs: Box<Box<dyn IReaperControlSurface>> = Box::new(Box::new(low_cs));
        let cpp_cs =
            unsafe { create_cpp_to_rust_control_surface(double_boxed_low_cs.as_ref().into()) };
        // Store the low-level Rust control surface in memory. Although we keep it here,
        // conceptually it's owned by REAPER, so we should not access it while being registered.
        let handle = RegistrationHandle::new(control_surface_thin_ptr, cpp_cs.cast());
        self.csurf_insts
            .insert(handle.reaper_ptr(), double_boxed_low_cs);
        // Register the C++ control surface at REAPER
        unsafe { self.plugin_register_add(RegistrationObject::CsurfInst(cpp_cs))? };
        // Return a handle which the consumer can use to unregister
        Ok(handle)
    }
/// Registers a hidden control surface.
///
/// This is very useful for being notified by REAPER about all kinds of events in the main
/// thread.
///
/// This function returns a handle which you can use to unregister the control surface at any
/// time via [`plugin_register_remove_csurf_inst()`].
///
/// # Errors
///
/// Returns an error if the registration failed.
///
/// # Example
///
/// ```no_run
/// # let mut session = reaper_medium::ReaperSession::default();
/// use reaper_medium::ControlSurface;
///
/// #[derive(Debug)]
/// struct MyControlSurface;
///
/// impl ControlSurface for MyControlSurface {
///     fn set_track_list_change(&self) {
///         println!("Tracks changed");
///     }
/// }
/// session.plugin_register_add_csurf_inst(Box::new(MyControlSurface));
/// # Ok::<_, Box<dyn std::error::Error>>(())
/// ```
///
/// [`plugin_register_remove_csurf_inst()`]: #method.plugin_register_remove_csurf_inst
Registers a hidden control surface.
This is very useful for being notified by REAPER about all kinds of events in the main
thread.

This function returns a handle which you can use to unregister the control surface at any
time via [`plugin_register_remove_csurf_inst()`].
Registers a hidden control surface . This is very useful for being notified by REAPER about all kinds of events in the main thread . This function returns a handle which you can use to unregister the control surface at any time via [ ` plugin_register_remove_csurf_inst () ` ] .
pub fn plugin_register_add_csurf_inst<T>(
        &mut self,
        control_surface: Box<T>,
    ) -> ReaperFunctionResult<RegistrationHandle<T>>
    where
        T: ControlSurface + 'static,
    {
        // Create thin pointer of control_surface before making it a trait object (for being able to
        // restore the original control_surface later).
        let control_surface_thin_ptr: NonNull<T> = control_surface.as_ref().into();
        // Create low-level Rust control surface which delegates to the medium-level one.
        let low_cs = ControlSurfaceAdapter::new(control_surface, &self.reaper.get_app_version());
        // Create the C++ counterpart surface (we need to box the Rust side twice in order to obtain
        // a thin pointer for passing it to C++ as callback target).
        let double_boxed_low_cs: Box<Box<dyn IReaperControlSurface>> = Box::new(Box::new(low_cs));
        let cpp_cs =
            unsafe { create_cpp_to_rust_control_surface(double_boxed_low_cs.as_ref().into()) };
        // Store the low-level Rust control surface in memory. Although we keep it here,
        // conceptually it's owned by REAPER, so we should not access it while being registered.
        let handle = RegistrationHandle::new(control_surface_thin_ptr, cpp_cs.cast());
        self.csurf_insts
            .insert(handle.reaper_ptr(), double_boxed_low_cs);
        // Register the C++ control surface at REAPER
        unsafe { self.plugin_register_add(RegistrationObject::CsurfInst(cpp_cs))? };
        // Return a handle which the consumer can use to unregister
        Ok(handle)
    }
pub fn plugin_register_add_csurf_inst < T > ( & mut self , control_surface : Box < T > , ) -> ReaperFunctionResult < RegistrationHandle < T > > where T : ControlSurface + ' static , { // Create thin pointer of control_surface before making it a trait object (for being able to // restore the original control_surface later). let control_surface_thin_ptr : NonNull < T > = control_surface . as_ref ( ) . into ( ) ; // Create low-level Rust control surface which delegates to the medium-level one. let low_cs = ControlSurfaceAdapter :: new ( control_surface , & self . reaper . get_app_version ( ) ) ; // Create the C++ counterpart surface (we need to box the Rust side twice in order to obtain // a thin pointer for passing it to C++ as callback target). let double_boxed_low_cs : Box < Box < dyn IReaperControlSurface > > = Box :: new ( Box :: new ( low_cs ) ) ; let cpp_cs = unsafe { create_cpp_to_rust_control_surface ( double_boxed_low_cs . as_ref ( ) . into ( ) ) } ; // Store the low-level Rust control surface in memory. Although we keep it here, // conceptually it's owned by REAPER, so we should not access it while being registered. let handle = RegistrationHandle :: new ( control_surface_thin_ptr , cpp_cs . cast ( ) ) ; self . csurf_insts . insert ( handle . reaper_ptr ( ) , double_boxed_low_cs ) ; // Register the C++ control surface at REAPER unsafe { self . plugin_register_add ( RegistrationObject :: CsurfInst ( cpp_cs ) ) ? } ; // Return a handle which the consumer can use to unregister Ok ( handle ) }
Registers a hidden control surface.
Registers a hidden control surface .
&mut self
control_surface
Box<T>
&mut self
control_surface
Box<T>
errors
Returns an error if the registration failed.
Returns an error if the registration failed .
example
None
let mut session = reaper_medium::reapersession::default();
None
[derive(debug)]
struct MyControlSurface.

impl ControlSurface for MyControlSurface {
fn set_track_list_change(&self) {
println!("Tracks changed");
}
}
session.plugin_register_add_csurf_inst(Box::new(MyControlSurface)).
struct MyControlSurface . impl ControlSurface for MyControlSurface { fn set_track_list_change ( &self ) { println! ( " Tracks changed " ) ; } } session . plugin_register_add_csurf_inst ( Box :: new ( MyControlSurface )) .
ok::<_, box<dyn std::error::error>>(())
None