Struct perseus::plugins::Plugin

source ·
pub struct Plugin<D: Any + Send + Sync> {
    pub name: String,
    pub functional_actions_registrar: Box<dyn Fn(FunctionalPluginActions) -> FunctionalPluginActions>,
    pub control_actions_registrar: Box<dyn Fn(ControlPluginActions) -> ControlPluginActions>,
    pub env: PluginEnv,
    /* private fields */
}
Expand description

A Perseus plugin. This must be exported by all plugin crates so the user can register the plugin easily.

Fields§

§name: String

The machine name of the plugin, which will be used as a key in a HashMap with many other plugins. This should be the public crate name in all cases.

§functional_actions_registrar: Box<dyn Fn(FunctionalPluginActions) -> FunctionalPluginActions>

A function that will be provided functional actions. It should then register runners from the plugin for every action that it takes.

§control_actions_registrar: Box<dyn Fn(ControlPluginActions) -> ControlPluginActions>

A function that will be provided control actions. It should then register runners from the plugin for every action that it takes.

§env: PluginEnv

The environment that the plugin should run in.

Implementations§

source§

impl<D: Any + Send + Sync> Plugin<D>

source

pub fn new( name: &str, functional_actions_registrar: impl Fn(FunctionalPluginActions) -> FunctionalPluginActions + 'static, control_actions_registrar: impl Fn(ControlPluginActions) -> ControlPluginActions + 'static, env: PluginEnv ) -> Self

Creates a new plugin with a name, functional actions, control actions, and whether or not the plugin is tinker-only.

Trait Implementations§

source§

impl<D: Any + Send + Sync> Debug for Plugin<D>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D> !RefUnwindSafe for Plugin<D>

§

impl<D> !Send for Plugin<D>

§

impl<D> !Sync for Plugin<D>

§

impl<D> Unpin for Plugin<D>where D: Unpin,

§

impl<D> !UnwindSafe for Plugin<D>

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.