burn_lm_inference/
plugin.rs

1use std::fmt::Debug;
2
3use crate::{InferenceJob, InferenceResult, Stats};
4
5pub type CreateCliFlagsFn = fn() -> clap::Command;
6
7pub trait InferencePlugin: Send + Sync + Debug {
8    fn clone_box(&self) -> Box<dyn InferencePlugin>;
9    fn model_name(&self) -> &'static str;
10    fn model_cli_param_name(&self) -> &'static str;
11    fn model_creation_date(&self) -> &'static str;
12    fn owned_by(&self) -> &'static str;
13    fn create_cli_flags_fn(&self) -> CreateCliFlagsFn;
14    fn downloader(&self) -> Option<fn() -> InferenceResult<Option<Stats>>>;
15    fn is_downloaded(&self) -> bool;
16    fn deleter(&self) -> Option<fn() -> InferenceResult<Option<Stats>>>;
17    fn parse_cli_config(&self, args: &clap::ArgMatches);
18    fn parse_json_config(&self, json: &str);
19    fn load(&self) -> InferenceResult<Option<Stats>>;
20    fn is_loaded(&self) -> bool;
21    fn unload(&self) -> InferenceResult<Option<Stats>>;
22    fn run_job(&self, job: InferenceJob) -> InferenceResult<Stats>;
23    fn clear_state(&self) -> InferenceResult<()>;
24}
25
26impl Clone for Box<dyn InferencePlugin> {
27    fn clone(&self) -> Box<dyn InferencePlugin> {
28        self.clone_box()
29    }
30}