aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/plugin/plugin_interface.rs
blob: 852c69b7f307aa5d76bbfafa77073042c8b9beb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! ref: composer/src/Composer/Plugin/PluginInterface.php

use crate::composer::FullComposerHandle;
use crate::io::IOInterface;
use crate::plugin::Capable;

pub const PLUGIN_API_VERSION: &'static str = "2.9.0";

pub trait PluginInterface: std::fmt::Debug {
    fn activate(&mut self, composer: &FullComposerHandle, io: &dyn IOInterface);

    fn deactivate(&mut self, composer: &FullComposerHandle, io: &dyn IOInterface);

    fn uninstall(&mut self, composer: &FullComposerHandle, io: &dyn IOInterface);

    fn clone_box(&self) -> Box<dyn PluginInterface> {
        todo!()
    }

    // TODO(plugin): PHP-side `instanceof` checks for EventSubscriberInterface / Capable.
    // EventSubscriberInterface is not dyn-compatible (its only method is associated, not
    // a `&self` method), so we expose a boolean predicate instead.
    fn is_event_subscriber_interface(&self) -> bool {
        false
    }

    fn as_capable(&self) -> Option<&dyn Capable> {
        None
    }
}