1use std::future::Future;
4use std::pin::Pin;
5use std::sync::Arc;
6
7use futures_core::Stream;
8
9use crate::errors::SeamError;
10
11pub type BoxFuture<T> = Pin<Box<dyn Future<Output = T> + Send>>;
12
13pub type BoxStream<T> = Pin<Box<dyn Stream<Item = T> + Send>>;
14
15pub type HandlerFn =
16 Arc<dyn Fn(serde_json::Value) -> BoxFuture<Result<serde_json::Value, SeamError>> + Send + Sync>;
17
18pub type SubscriptionHandlerFn = Arc<
19 dyn Fn(
20 serde_json::Value,
21 ) -> BoxFuture<Result<BoxStream<Result<serde_json::Value, SeamError>>, SeamError>>
22 + Send
23 + Sync,
24>;
25
26pub struct ProcedureDef {
27 pub name: String,
28 pub input_schema: serde_json::Value,
29 pub output_schema: serde_json::Value,
30 pub handler: HandlerFn,
31}
32
33pub struct SubscriptionDef {
34 pub name: String,
35 pub input_schema: serde_json::Value,
36 pub output_schema: serde_json::Value,
37 pub handler: SubscriptionHandlerFn,
38}