Skip to content

Conversation

@StrikeForceZero
Copy link
Owner

@StrikeForceZero StrikeForceZero commented Jan 17, 2026

Summary

This gives users the ability to hook the auto plugin build function by implementing AutoPluginBuildHook for their own hooks

Examples:

Unit

#[derive(AutoPlugin)]
#[auto_plugin(impl_plugin_trait)]
struct TestPlugin;

struct MyCustomHookUnit;

impl<T: Component + 'static> AutoPluginBuildHook<T> for MyCustomHookUnit {
    fn on_build(&self, app: &mut App) {
        // access to T for any type-related plumbing e.g. registering types
       app.register_type::<T>();
    }
}


#[derive(Component, Debug)]
#[auto_plugin_build_hook(plugin = TestPlugin, hook = MyCustomHookUnit)]
struct TestComponent;

Instance

#[derive(AutoPlugin)]
#[auto_plugin(impl_plugin_trait)]
struct TestPlugin;

struct MyCustomHookInstance(&'static str);

impl<T: Component + 'static> AutoPluginBuildHook<T> for MyCustomHookInstance {
    fn on_build(&self, app: &mut App) {
        // access to T for any type-related plumbing e.g. registering types
       app.register_type::<T>();
       // or access the hooks instance
       println!("{}", self.0);
    }
}


#[derive(Component, Debug)]
#[auto_plugin_build_hook(plugin = TestPlugin, hook = MyCustomHookInstance("bar"))]
struct TestComponent;

TODO:

  • add documentation

@StrikeForceZero StrikeForceZero added this to the v0.10.0 milestone Jan 17, 2026
@StrikeForceZero StrikeForceZero modified the milestones: v0.10.0, v0.9.1 Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants