use crate::filters::prelude::*;
use serde::{Deserialize, Serialize};
use crate::generated::quilkin::filters::drop::v1alpha1 as proto;
pub const NAME: &str = Drop::NAME;
pub struct Drop;
impl Drop {
fn new() -> Self {
Self
}
}
impl Filter for Drop {
#[cfg_attr(feature = "instrument", tracing::instrument(skip_all))]
fn read<P: PacketMut>(&self, _: &mut ReadContext<'_, P>) -> Result<(), FilterError> {
Err(FilterError::Dropped)
}
#[cfg_attr(feature = "instrument", tracing::instrument(skip_all))]
fn write<P: PacketMut>(&self, _: &mut WriteContext<P>) -> Result<(), FilterError> {
Err(FilterError::Dropped)
}
}
impl StaticFilter for Drop {
const NAME: &'static str = "quilkin.filters.drop.v1alpha1.Drop";
type Configuration = Config;
type BinaryConfiguration = proto::Drop;
fn try_from_config(_: Option<Self::Configuration>) -> Result<Self, CreationError> {
Ok(Drop::new())
}
}
#[derive(Serialize, Deserialize, Debug, schemars::JsonSchema)]
pub struct Config;
impl From<Config> for proto::Drop {
fn from(_config: Config) -> Self {
Self {}
}
}
impl TryFrom<proto::Drop> for Config {
type Error = ConvertProtoConfigError;
fn try_from(_: proto::Drop) -> Result<Self, Self::Error> {
Ok(Config)
}
}