pub fn plugin<D: Any + Send>(
        #[cfg_attr(target_arch = "wasm32", allow(unused_mut))] mut self,
        // This is a function so that it never gets called if we're compiling for Wasm, which means Rust eliminates it as dead code!
        #[cfg_attr(target_arch = "wasm32", allow(unused_variables))] plugin: impl Fn() -> Plugin<G, D>
            + Send,
        #[cfg_attr(target_arch = "wasm32", allow(unused_variables))] plugin_data: D,
    ) -> Self {
        // If we're compiling for Wasm, plugins that don't run on the client side shouldn't be added (they'll then be eliminated as dead code)
        #[cfg(not(target_arch = "wasm32"))]
        {
            let plugin = plugin();
            // If the plugin can run on the client-side, it should use `.client_plugin()` for verbosity
            // We don;t have access to the actual plugin data until now, so we can;t do this at the root of the function
            if plugin.env != PluginEnv::Server {
                panic!("attempted to register plugin that can run on the client with `.plugin()`, this plugin should be registered with `.plugin_with_client_privilege()` (this will increase your final bundle size)")
            }
            // Insert the plugin data
            let plugin_data: Box<dyn Any + Send> = Box::new(plugin_data);
            let res = self.plugin_data.insert(plugin.name.clone(), plugin_data);
            // If there was an old value, there are two plugins with the same name, which is very bad (arbitrarily inconsistent behavior overriding)
            if res.is_some() {
                panic!("two plugins have the same name '{}', which could lead to arbitrary and inconsistent behavior modification (please file an issue with the plugin that doesn't have the same name as its crate)", &plugin.name);
            }
            // Register functional and control actions using the plugin's provided registrar
            self.functional_actions =
                (plugin.functional_actions_registrar)(self.functional_actions);
            self.control_actions = (plugin.control_actions_registrar)(self.control_actions);
        }

        self
    }
/// Registers a new plugin, consuming `self`. For control actions, this will check if a plugin has already registered on an action,
/// and throw an error if one has, noting the conflict explicitly in the error message. This can only register plugins that run
/// exclusively on the server-side (including tinker-time and the build process).
// We allow unusued variables and the like for linting because otherwise any errors in Wasm compilation will show these up, which is annoying
Registers a new plugin, consuming `self`. For control actions, this will check if a plugin has already registered on an action,
and throw an error if one has, noting the conflict explicitly in the error message. This can only register plugins that run
exclusively on the server-side (including tinker-time and the build process).
We allow unusued variables and the like for linting because otherwise any errors in Wasm compilation will show these up, which is annoying
Registers a new plugin consuming ` self ` . For control actions this will check if a plugin has already registered on an action and throw an error if one has noting the conflict explicitly in the error message . This can only register plugins that run exclusively on the server - side ( including tinker - time and the build process ) . We allow unusued variables and the like for linting because otherwise any errors in Wasm compilation will show these up which is annoying
pub fn plugin<D: Any + Send>(
        #[cfg_attr(target_arch = "wasm32", allow(unused_mut))] mut self,
        // This is a function so that it never gets called if we're compiling for Wasm, which means Rust eliminates it as dead code!
        #[cfg_attr(target_arch = "wasm32", allow(unused_variables))] plugin: impl Fn() -> Plugin<G, D>
            + Send,
        #[cfg_attr(target_arch = "wasm32", allow(unused_variables))] plugin_data: D,
    ) -> Self {
        // If we're compiling for Wasm, plugins that don't run on the client side shouldn't be added (they'll then be eliminated as dead code)
        #[cfg(not(target_arch = "wasm32"))]
        {
            let plugin = plugin();
            // If the plugin can run on the client-side, it should use `.client_plugin()` for verbosity
            // We don;t have access to the actual plugin data until now, so we can;t do this at the root of the function
            if plugin.env != PluginEnv::Server {
                panic!("attempted to register plugin that can run on the client with `.plugin()`, this plugin should be registered with `.plugin_with_client_privilege()` (this will increase your final bundle size)")
            }
            // Insert the plugin data
            let plugin_data: Box<dyn Any + Send> = Box::new(plugin_data);
            let res = self.plugin_data.insert(plugin.name.clone(), plugin_data);
            // If there was an old value, there are two plugins with the same name, which is very bad (arbitrarily inconsistent behavior overriding)
            if res.is_some() {
                panic!("two plugins have the same name '{}', which could lead to arbitrary and inconsistent behavior modification (please file an issue with the plugin that doesn't have the same name as its crate)", &plugin.name);
            }
            // Register functional and control actions using the plugin's provided registrar
            self.functional_actions =
                (plugin.functional_actions_registrar)(self.functional_actions);
            self.control_actions = (plugin.control_actions_registrar)(self.control_actions);
        }
        self
    }
pub fn plugin < D : Any + Send > ( # [ cfg_attr ( target_arch " " allow ( unused_mut ) ) ] mut self , // This is a function so that it never gets called if we're compiling for Wasm, which means Rust eliminates it as dead code! # [ cfg_attr ( target_arch " " allow ( unused_variables ) ) ] plugin : impl Fn ( ) -> Plugin < G , D > + Send , # [ cfg_attr ( target_arch " " allow ( unused_variables ) ) ] plugin_data : D , ) -> Self { // If we're compiling for Wasm, plugins that don't run on the client side shouldn't be added (they'll then be eliminated as dead code) # [ cfg ( not ( target_arch " " ) ) ] { let plugin = plugin ( ) ; // If the plugin can run on the client-side, it should use `.client_plugin()` for verbosity // We don;t have access to the actual plugin data until now, so we can;t do this at the root of the function if plugin . env != PluginEnv :: Server { panic ! ( " " ) } // Insert the plugin data let plugin_data : Box < dyn Any + Send > = Box :: new ( plugin_data ) ; let res = self . plugin_data . insert ( plugin . name . clone ( ) , plugin_data ) ; // If there was an old value, there are two plugins with the same name, which is very bad (arbitrarily inconsistent behavior overriding) if res . is_some ( ) { panic ! ( " " plugin name ) ; } // Register functional and control actions using the plugin's provided registrar self . functional_actions = ( plugin . functional_actions_registrar ) ( self . functional_actions ) ; self . control_actions = ( plugin . control_actions_registrar ) ( self . control_actions ) ; } self }
Registers a new plugin, consuming `self`.
Registers a new plugin consuming ` self ` .
mut self
plugin
impl Fn() -> Plugin<G, D>
            + Send
plugin_data
D
mut self
plugin
impl Fn() -> Plugin<G, D>
            + Send
plugin_data
D