Trait quilkin::filters::FilterFactory
source · pub trait FilterFactory: Sync + Send {
// Required methods
fn name(&self) -> &'static str;
fn config_schema(&self) -> RootSchema;
fn create_filter(
&self,
args: CreateFilterArgs
) -> Result<FilterInstance, CreationError>;
fn encode_config_to_protobuf(
&self,
args: Value
) -> Result<Any, CreationError>;
fn encode_config_to_json(&self, args: Any) -> Result<Value, CreationError>;
// Provided method
fn require_config(
&self,
config: Option<ConfigType>
) -> Result<ConfigType, CreationError> { ... }
}
Expand description
Provides the name and creation function for a given Filter
.
Required Methods§
sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
name returns the configuration name for the Filter
The returned string identifies the filter item’s path with the following format:
quilkin.filters.<module>.<version>.<item-name>
where:
module
: The rust module name containing the filter itemversion
: The filter’s version.item-name
: The name of the rust item (e.g enum, struct) implementing the filter. For example thev1alpha1
version of the debug filter has the name:quilkin.filters.debug_filter.v1alpha1.Debug
sourcefn config_schema(&self) -> RootSchema
fn config_schema(&self) -> RootSchema
Returns the schema for the configuration of the Filter
.
sourcefn create_filter(
&self,
args: CreateFilterArgs
) -> Result<FilterInstance, CreationError>
fn create_filter( &self, args: CreateFilterArgs ) -> Result<FilterInstance, CreationError>
Returns a filter based on the provided arguments.
sourcefn encode_config_to_protobuf(&self, args: Value) -> Result<Any, CreationError>
fn encode_config_to_protobuf(&self, args: Value) -> Result<Any, CreationError>
Converts YAML configuration into its Protobuf equivalvent.
sourcefn encode_config_to_json(&self, args: Any) -> Result<Value, CreationError>
fn encode_config_to_json(&self, args: Any) -> Result<Value, CreationError>
Converts YAML configuration into its Protobuf equivalvent.
Provided Methods§
sourcefn require_config(
&self,
config: Option<ConfigType>
) -> Result<ConfigType, CreationError>
fn require_config( &self, config: Option<ConfigType> ) -> Result<ConfigType, CreationError>
Returns the ConfigType
from the provided Option, otherwise it returns
Error::MissingConfig if the Option is None.
Implementations on Foreign Types§
source§impl<F> FilterFactory for PhantomData<fn() -> F>where
F: StaticFilter + 'static,
CreationError: From<<F::Configuration as TryFrom<F::BinaryConfiguration>>::Error> + From<<F::BinaryConfiguration as TryFrom<F::Configuration>>::Error>,
impl<F> FilterFactory for PhantomData<fn() -> F>where
F: StaticFilter + 'static,
CreationError: From<<F::Configuration as TryFrom<F::BinaryConfiguration>>::Error> + From<<F::BinaryConfiguration as TryFrom<F::Configuration>>::Error>,
source§fn create_filter(
&self,
args: CreateFilterArgs
) -> Result<FilterInstance, CreationError>
fn create_filter( &self, args: CreateFilterArgs ) -> Result<FilterInstance, CreationError>
Returns a filter based on the provided arguments.