pub fn plugin_register_add_hook_command<T: HookCommand>(&mut self) -> ReaperFunctionResult<()> {
        unsafe {
            self.plugin_register_add(RegistrationObject::HookCommand(
                delegating_hook_command::<T>,
            ))?;
        }
        Ok(())
    }
/// Registers a hook command.
///
/// REAPER calls hook commands whenever an action is requested to be run.
///
/// This method doesn't take a closure because REAPER expects a plain function pointer here.
/// Unlike [`audio_reg_hardware_hook_add`](#method.audio_reg_hardware_hook_add), REAPER
/// doesn't offer the possibiity to pass a context to the function. So we can't access any
/// context data in the hook command. You will probably have to use a kind of static
/// variable which contains command IDs in order to make proper use of this method. The
/// high-level API makes that much easier (it just takes an arbitrary closure). For the
/// medium-level API this is out of scope.
///
/// # Errors
///
/// Returns an error if the registration failed.
///
/// # Example
///
/// ```no_run
/// # let mut session = reaper_medium::ReaperSession::default();
/// use reaper_medium::{HookCommand, CommandId};
///
/// // Usually you would use a dynamic command ID that you have obtained via
/// // `plugin_register_add_command_id()`. Unfortunately that command ID must be exposed as
/// // a static variable. The high-level API provides a solution for that.
/// const MY_COMMAND_ID: CommandId = unsafe { CommandId::new_unchecked(42000) };
///
/// struct MyHookCommand;
///
/// impl HookCommand for MyHookCommand {
///     fn call(command_id: CommandId, _flag: i32) -> bool {
///         if command_id != MY_COMMAND_ID {
///             return false;
///         }           
///         println!("Executing my command!");
///         true
///     }
/// }
/// session.plugin_register_add_hook_command::<MyHookCommand>();
/// # Ok::<_, Box<dyn std::error::Error>>(())
/// ```
///
/// # Design
///
/// You will note that this method has a somewhat strange signature: It expects a type parameter
/// only, not a function pointer. That allows us to lift the API to medium-level style.
/// The alternative would have been to expect a function pointer, but then consumers would have
/// to deal with raw types.
Registers a hook command.
REAPER calls hook commands whenever an action is requested to be run.

This method doesn't take a closure because REAPER expects a plain function pointer here.
Unlike [`audio_reg_hardware_hook_add`](#method.audio_reg_hardware_hook_add), REAPER
doesn't offer the possibiity to pass a context to the function. So we can't access any
context data in the hook command. You will probably have to use a kind of static
variable which contains command IDs in order to make proper use of this method. The
high-level API makes that much easier (it just takes an arbitrary closure). For the
medium-level API this is out of scope.
Registers a hook command . REAPER calls hook commands whenever an action is requested to be run . This method doesn ' t take a closure because REAPER expects a plain function pointer here . Unlike [ ` audio_reg_hardware_hook_add ` ] ( #method . audio_reg_hardware_hook_add ) REAPER doesn ' t offer the possibiity to pass a context to the function . So we can ' t access any context data in the hook command . You will probably have to use a kind of static variable which contains command IDs in order to make proper use of this method . The high - level API makes that much easier ( it just takes an arbitrary closure ) . For the medium - level API this is out of scope .
pub fn plugin_register_add_hook_command<T: HookCommand>(&mut self) -> ReaperFunctionResult<()> {
        unsafe {
            self.plugin_register_add(RegistrationObject::HookCommand(
                delegating_hook_command::<T>,
            ))?;
        }
        Ok(())
    }
pub fn plugin_register_add_hook_command < T : HookCommand > ( & mut self ) -> ReaperFunctionResult < ( ) > { unsafe { self . plugin_register_add ( RegistrationObject :: HookCommand ( delegating_hook_command :: < T > , ) ) ? ; } Ok ( ( ) ) }
Registers a hook command.
Registers a hook command .
&mut self
&mut self
errors
Returns an error if the registration failed.
Returns an error if the registration failed .
example
None
let mut session = reaper_medium::reapersession::default();
use reaper_medium::{HookCommand, CommandId}.

Usually you would use a dynamic command ID that you have obtained via
`plugin_register_add_command_id()`. Unfortunately that command ID must be exposed as
a static variable. The high-level API provides a solution for that.
const MY_COMMAND_ID: CommandId = unsafe { CommandId::new_unchecked(42000) }.

struct MyHookCommand.

impl HookCommand for MyHookCommand {
fn call(command_id: CommandId, _flag: i32) -> bool {
if command_id != MY_COMMAND_ID {
return false;
}
println!("Executing my command!");
true
}
}
session.plugin_register_add_hook_command::().
use reaper_medium :: { HookCommand CommandId } . Usually you would use a dynamic command ID that you have obtained via ` plugin_register_add_command_id () ` . Unfortunately that command ID must be exposed as a static variable . The high - level API provides a solution for that . const MY_COMMAND_ID : CommandId = unsafe { CommandId :: new_unchecked ( 42000 ) } . struct MyHookCommand . impl HookCommand for MyHookCommand { fn call ( command_id : CommandId _flag : i32 ) - > bool { if command_id ! = MY_COMMAND_ID { return false ; } println! ( " Executing my command! " ) ; true } } session . plugin_register_add_hook_command :: () .
ok::<_, box<dyn std::error::error>>(())
None
design
You will note that this method has a somewhat strange signature: It expects a type parameter
only, not a function pointer. That allows us to lift the API to medium-level style.
The alternative would have been to expect a function pointer, but then consumers would have
to deal with raw types.
You will note that this method has a somewhat strange signature : It expects a type parameter only not a function pointer . That allows us to lift the API to medium - level style . The alternative would have been to expect a function pointer but then consumers would have to deal with raw types .