konnektoren_core/controller/plugins/
controller_plugin.rs

1use crate::controller::GameControllerTrait;
2use std::sync::Arc;
3use thiserror::Error;
4
5#[derive(Error, Debug, PartialEq)]
6pub enum ControllerPluginError {
7    #[error("Plugin initialization error: {0}")]
8    InitError(String),
9
10    #[error("Plugin loading error: {0}")]
11    LoadError(String),
12
13    #[error("Plugin unloading error: {0}")]
14    UnloadError(String),
15
16    #[error("General plugin error: {0}")]
17    PluginError(String),
18}
19
20#[cfg(test)]
21use mockall::{automock, predicate::*};
22
23#[cfg_attr(test, automock)]
24pub trait ControllerPlugin: Send + Sync {
25    fn name(&self) -> &str;
26    fn init(&self) -> Result<(), ControllerPluginError>;
27    fn load(
28        &self,
29        game_controller: Arc<dyn GameControllerTrait>,
30    ) -> Result<(), ControllerPluginError>;
31    fn unload(
32        &self,
33        game_controller: Arc<dyn GameControllerTrait>,
34    ) -> Result<(), ControllerPluginError>;
35}