diff options
Diffstat (limited to 'src/filters/error.rs')
-rw-r--r-- | src/filters/error.rs | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/src/filters/error.rs b/src/filters/error.rs deleted file mode 100644 index 504802f..0000000 --- a/src/filters/error.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::error::ServiceError; - -use super::{Node, NodeContext, NodeKind, NodeRequest, NodeResponse}; -use futures::Future; -use serde::Deserialize; -use serde_yaml::Value; -use std::{pin::Pin, sync::Arc}; - -pub struct ErrorKind; - -#[derive(Deserialize)] -#[serde(transparent)] -struct Error(String); - -impl NodeKind for ErrorKind { - fn name(&self) -> &'static str { - "error" - } - fn instanciate(&self, config: Value) -> anyhow::Result<Arc<dyn Node>> { - Ok(Arc::new(serde_yaml::from_value::<Error>(config)?)) - } -} - -impl Node for Error { - fn handle<'a>( - &'a self, - _context: &'a mut NodeContext, - _request: NodeRequest, - ) -> Pin<Box<dyn Future<Output = Result<NodeResponse, ServiceError>> + Send + Sync + 'a>> { - Box::pin(async move { Err(ServiceError::Custom(self.0.clone())) }) - } -} |