feat: with full support for rust services
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -5,7 +5,7 @@ use std::{future::Future, pin::Pin};
|
||||
#[async_trait]
|
||||
pub trait DaggerMiddleware {
|
||||
async fn handle(
|
||||
&mut self,
|
||||
&self,
|
||||
container: dagger_sdk::Container,
|
||||
) -> eyre::Result<dagger_sdk::Container> {
|
||||
Ok(container)
|
||||
@@ -14,14 +14,14 @@ pub trait DaggerMiddleware {
|
||||
|
||||
pub struct DaggerMiddlewareFn<F>
|
||||
where
|
||||
F: FnMut(Container) -> Pin<Box<dyn Future<Output = eyre::Result<Container>> + Send>>,
|
||||
F: Fn(Container) -> Pin<Box<dyn Future<Output = eyre::Result<Container>> + Send>>,
|
||||
{
|
||||
pub func: F,
|
||||
}
|
||||
|
||||
pub fn middleware<F>(func: F) -> Box<DaggerMiddlewareFn<F>>
|
||||
where
|
||||
F: FnMut(Container) -> Pin<Box<dyn Future<Output = eyre::Result<Container>> + Send>>,
|
||||
F: Fn(Container) -> Pin<Box<dyn Future<Output = eyre::Result<Container>> + Send>>,
|
||||
{
|
||||
Box::new(DaggerMiddlewareFn { func })
|
||||
}
|
||||
@@ -29,11 +29,9 @@ where
|
||||
#[async_trait]
|
||||
impl<F> DaggerMiddleware for DaggerMiddlewareFn<F>
|
||||
where
|
||||
F: FnMut(Container) -> Pin<Box<dyn Future<Output = eyre::Result<Container>> + Send>>
|
||||
+ Send
|
||||
+ Sync,
|
||||
F: Fn(Container) -> Pin<Box<dyn Future<Output = eyre::Result<Container>> + Send>> + Send + Sync,
|
||||
{
|
||||
async fn handle(&mut self, container: Container) -> eyre::Result<Container> {
|
||||
async fn handle(&self, container: Container) -> eyre::Result<Container> {
|
||||
// Call the closure stored in the struct
|
||||
(self.func)(container).await
|
||||
}
|
||||
|
Reference in New Issue
Block a user