use async_trait::async_trait;
use futures::Stream;
use serde::{Deserialize, Serialize};
use std::pin::Pin;
use crate::protocol::{Notification, Request, Response};
use crate::Error;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum Message {
#[serde(rename = "request")]
Request(Request),
#[serde(rename = "response")]
Response(Response),
#[serde(rename = "notification")]
Notification(Notification),
}
#[async_trait]
pub trait Transport: Send + Sync + 'static {
async fn send(&self, message: Message) -> Result<(), Error>;
fn receive(&self) -> Pin<Box<dyn Stream<Item = Result<Message, Error>> + Send>>;
async fn close(&self) -> Result<(), Error>;
}
pub mod stdio;
pub mod websocket;