osquery_rust/plugin/_enums/
plugin.rs

1use crate::_osquery as osquery;
2use crate::plugin::Table;
3use crate::plugin::{OsqueryPlugin, Registry};
4
5#[derive(Clone, Debug)]
6pub enum Plugin {
7    Config,
8    Logger,
9    Table(Table),
10}
11
12impl OsqueryPlugin for Plugin {
13    // Name is the name used to refer to the plugin (e.g. the name of the
14    // table the plugin implements).
15    fn name(&self) -> String {
16        match self {
17            Plugin::Config => todo!(),
18            Plugin::Logger => todo!(),
19            Plugin::Table(t) => t.name(),
20        }
21    }
22
23    // Registry is which "registry" the plugin should be added to.
24    fn registry(&self) -> Registry {
25        match self {
26            Plugin::Config => Registry::Config,
27            Plugin::Logger => Registry::Logger,
28            Plugin::Table(_) => Registry::Table,
29        }
30    }
31
32    // Routes returns detailed information about the interface exposed
33    // by the plugin. See the example plugins for implementation details.
34    //pub(crate) fn routes(&self) -> osquery::ExtensionPluginResponse {
35    fn routes(&self) -> osquery::ExtensionPluginResponse {
36        match self {
37            Plugin::Config => {
38                todo!()
39            }
40            Plugin::Logger => {
41                todo!()
42            }
43            Plugin::Table(t) => t.routes(),
44        }
45    }
46
47    // Ping implements the plugin's health check. If the plugin is in a
48    // healthy state, Status OK should be returned.
49    fn ping(&self) -> osquery::ExtensionStatus {
50        todo!()
51    }
52
53    // Call requests the plugin to perform its defined behavior, returning
54    // a response containing the result.
55    fn call(&self, req: osquery::ExtensionPluginRequest) -> osquery::ExtensionResponse {
56        match self {
57            Plugin::Config => {
58                todo!()
59            }
60            Plugin::Logger => {
61                todo!()
62            }
63            Plugin::Table(t) => t.call(req),
64        }
65    }
66
67    // Shutdown notifies the plugin to stop.
68    fn shutdown(&self) {
69        todo!()
70    }
71}