use async_trait::async_trait;
use crate::core::context::Context;
use serde_json::Value;
#[async_trait]
pub trait Link<Input = Value, Output = Value>: Send + Sync {
async fn call(&self, ctx: Context<Input>) -> Result<Context<Output>, Box<dyn std::error::Error + Send + Sync>>;
}
#[async_trait]
pub trait LegacyLink: Send + Sync {
async fn call(&self, ctx: Context) -> Result<Context, Box<dyn std::error::Error + Send + Sync>>;
}
#[async_trait]
impl<T> Link for T
where
T: LegacyLink,
{
async fn call(&self, ctx: Context) -> Result<Context, Box<dyn std::error::Error + Send + Sync>> {
self.call(ctx).await
}
}