Struct perseus::plugins::Plugins

source ·
pub struct Plugins {
    pub functional_actions: FunctionalPluginActions,
    pub control_actions: ControlPluginActions,
    /* private fields */
}
Expand description

A representation of all the plugins used by an app.

Due to the sheer number and complexity of nested fields, this is best transferred in an Rc, which unfortunately results in double indirection for runner functions.

Fields§

§functional_actions: FunctionalPluginActions

The functional actions that this plugin takes. This is defined by default such that all actions are assigned to a default, and so they can all be run without long chains of matching Option<T>s.

§control_actions: ControlPluginActions

The control actions that this plugin takes. This is defined by default such that all actions are assigned to a default, and so they can all be run without long chains of matching Option<T>s.

Implementations§

source§

impl Plugins

source

pub fn new() -> Self

Creates a new instance of Plugins, with no actions taken by any plugins, and the data map empty.

source

pub fn plugin<D: Any + Send + Sync>( self, plugin: impl Fn() -> Plugin<D> + Send + Sync, plugin_data: D ) -> 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).

source

pub fn plugin_with_client_privilege<D: Any + Send + Sync>( self, plugin: impl Fn() -> Plugin<D> + Send + Sync, plugin_data: D ) -> Self

The same as .plugin(), but registers a plugin that can run on the client-side. This is deliberately separated out to make conditional compilation feasible and to emphasize to users what’s increasing their bundle sizes. Note that this should also be used for plugins that run on both the client and server.

source

pub fn get_plugin_data(&self) -> &HashMap<String, Box<dyn Any + Send + Sync>>

Gets a reference to the map of plugin data. Note that each element of plugin data is additionally Boxed.

Trait Implementations§

source§

impl Debug for Plugins

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Plugins

source§

fn default() -> Plugins

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.