Module falco_plugin::base
source · Expand description
§The common foundation for all Falco plugins
All plugins must implement the base::Plugin
trait which specifies some basic metadata
about the plugin. For example, a plugin that doesn’t support any capabilities (which is
useless and would fail to load, but is a necessary step to building an actually useful plugin)
might look like:
use std::ffi::CStr;
use falco_plugin::base::{InitInput, Plugin};
use falco_plugin::plugin;
use falco_plugin::FailureReason;
// define the type holding the plugin state
struct NoOpPlugin;
// implement the base::Plugin trait
impl Plugin for NoOpPlugin {
const NAME: &'static CStr = c"sample-plugin-rs";
const PLUGIN_VERSION: &'static CStr = c"0.0.1";
const DESCRIPTION: &'static CStr = c"A sample Falco plugin that does nothing";
const CONTACT: &'static CStr = c"you@example.com";
type ConfigType = ();
fn new(input: &InitInput, config: Self::ConfigType)
-> Result<Self, FailureReason> {
Ok(NoOpPlugin)
}
fn set_config(&mut self, config: Self::ConfigType) -> Result<(), anyhow::Error> {
Ok(())
}
}
// generate the actual plugin wrapper code
plugin!(NoOpPlugin);
See the base::Plugin
trait documentation for details.
Structs§
- The plugin init input from the Falco plugin framework
- A wrapper to mark a configuration schema as JSON-encoded
- Automatically generate the Falco plugin API structure (overriding the API version)
Traits§
- A base trait for implementing Falco plugins
- Trait for creating and accessing tables
Type Aliases§
- Automatically generate the Falco plugin API structure