pub trait Plugin:
Send
+ Sync
+ 'static {
const PUBLISHER: &'static str;
const NAME: &'static str;
// Required methods
fn set_config(&self, config: JsonValue) -> StdResult<(), ConfigError>;
fn default_policy_expr(&self) -> Result<String>;
fn explain_default_query(&self) -> Result<Option<String>>;
fn queries(&self) -> impl Iterator<Item = NamedQuery>;
// Provided methods
fn default_query(&self) -> Option<DynQuery> { ... }
fn schemas(&self) -> impl Iterator<Item = QuerySchema> { ... }
}
Expand description
The core trait that a plugin author must implement using the Hipcheck SDK.
Declares basic information about the plugin and its query endpoints, and accepts a configuration map from Hipcheck core.
Required Associated Constants§
Required Methods§
Sourcefn set_config(&self, config: JsonValue) -> StdResult<(), ConfigError>
fn set_config(&self, config: JsonValue) -> StdResult<(), ConfigError>
Handle setting configuration. The config
parameter is a JSON object of String, String
pairs.
Sourcefn default_policy_expr(&self) -> Result<String>
fn default_policy_expr(&self) -> Result<String>
Get the plugin’s default policy expression. This will only ever be called after
Plugin::set_config()
. For more information on policy expression syntax, see the Hipcheck
website.
Sourcefn explain_default_query(&self) -> Result<Option<String>>
fn explain_default_query(&self) -> Result<Option<String>>
Get an unstructured description of what is returned by the plugin’s default query.
Sourcefn queries(&self) -> impl Iterator<Item = NamedQuery>
fn queries(&self) -> impl Iterator<Item = NamedQuery>
Get all the queries supported by the plugin. Each query endpoint in a plugin will have its
own trait Query
implementation. This function should return an iterator containing one
NamedQuery
instance for each trait Query
implementation defined by the plugin author.
Provided Methods§
Sourcefn default_query(&self) -> Option<DynQuery>
fn default_query(&self) -> Option<DynQuery>
Get the plugin’s default query, if it has one. The default query is a NamedQuery
with an
empty name
string. In most cases users should not need to override the default
implementation.
Sourcefn schemas(&self) -> impl Iterator<Item = QuerySchema>
fn schemas(&self) -> impl Iterator<Item = QuerySchema>
Get all schemas for queries provided by the plugin. In most cases users should not need to override the default implementation.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.