workflow_rpc/server/protocol/
mod.rs1pub mod borsh;
8pub mod serde_json;
9
10use crate::imports::*;
11use crate::server::Interface;
12pub use crate::server::result::Result;
13use workflow_websocket::server::{Message, Result as WebSocketResult, WebSocketSink};
14
15pub use self::borsh::BorshProtocol;
16pub use self::serde_json::JsonProtocol;
17
18#[async_trait]
20pub trait ProtocolHandler<ServerContext, ConnectionContext, Ops>:
21 DowncastSync + Sized + Send + Sync
22where
23 Ops: OpsT,
24 ServerContext: Clone + Send + Sync + 'static,
25 ConnectionContext: Clone + Send + Sync + 'static,
26{
27 fn new(methods: Arc<Interface<ServerContext, ConnectionContext, Ops>>) -> Self
29 where
30 Self: Sized;
31
32 fn encoding(&self) -> Encoding;
34
35 async fn handle_message(
38 &self,
39 connection_ctx: ConnectionContext,
40 message: Message,
41 sink: &WebSocketSink,
42 ) -> WebSocketResult<()>;
43
44 fn serialize_notification_message<Msg>(
47 &self,
48 op: Ops,
49 msg: Msg,
50 ) -> Result<tungstenite::Message>
51 where
52 Msg: BorshSerialize + Serialize + Send + Sync + 'static;
53}