Trait plugger_types::Pluggable [] [src]

pub trait Pluggable: PluggableFields + PluggableMethods {
    fn name(&self) -> &'static str;

    fn fields(&self) -> Vec<Field> { ... }
fn methods(&self) -> Vec<Method> { ... }
fn class(&self) -> Class { ... } }

An object that can be plugged into a scripting language.

Can be automatically derived by placing #[pluggable] on a struct.

When implementing Pluggable, it is necessary to have both a struct and an impl, with both having the #[pluggable] attribute.

This has been split up into two other traits

  • PluggableFields
  • `PluggableMethods

This is because the syntax extender can not see all of the code - it can only see the thing it's operating on. This is why we need an attribute on the struct and the impl. We can't implement a trait twice, each time overriding a specific method.

Because of this, it is necessary to mark both the struct and the impl with the pluggable attribute. It's not the prettiest, but it does work.

Required Methods

Provided Methods

Implementors